|
@@ -13,6 +13,7 @@ import org.apache.poi.xwpf.usermodel.*;
|
|
|
import org.apache.xmlbeans.XmlCursor;
|
|
|
import org.apache.xmlbeans.XmlObject;
|
|
|
import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMath;
|
|
|
+import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMathPara;
|
|
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -363,12 +364,17 @@ public class WordService {
|
|
|
|
|
|
public boolean parseFormula(XWPFParagraph p) {
|
|
|
List<CTOMath> maths = p.getCTP().getOMathList();
|
|
|
- if (CommonUtil.isEmpty(maths)) {
|
|
|
+ List<CTOMathPara> paras = p.getCTP().getOMathParaList();
|
|
|
+ if (CommonUtil.isEmpty(maths) && CommonUtil.isEmpty(paras)) {
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
|
|
|
XmlCursor c = p.getCTP().newCursor();
|
|
|
c.selectPath("./*");
|
|
|
+ if(CommonUtil.notEmpty(paras)){
|
|
|
+ c.toNextSibling();
|
|
|
+ }
|
|
|
int i = 0;
|
|
|
Map<Integer, String> insert = new HashMap<>();
|
|
|
while (c.toNextSelection()) {
|
|
@@ -386,6 +392,18 @@ public class WordService {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
logger.debug("CTOMath i = " + i + " " + o.getClass());
|
|
|
+ } else if(o instanceof CTOMathPara){
|
|
|
+
|
|
|
+ c.toLastChild();
|
|
|
+ XmlObject xmlObject = c.getObject();
|
|
|
+ CTOMath m = (CTOMath) xmlObject;
|
|
|
+ try {
|
|
|
+ String mml = formulaService.getMathML(m);
|
|
|
+ insert.put(i, mml);
|
|
|
+ i++;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|