fix(文档拆分): un 公式转图片,附录判断优化
This commit is contained in:
+48
-6
@@ -110,6 +110,7 @@ public class FileSpiltService {
|
|||||||
* 判断附录正则
|
* 判断附录正则
|
||||||
*/
|
*/
|
||||||
private static final Pattern APPENDIX_PATTERN = Pattern.compile("^附\\s{0,3}录\\s{0,3}[A-Z]{1}");
|
private static final Pattern APPENDIX_PATTERN = Pattern.compile("^附\\s{0,3}录\\s{0,3}[A-Z]{1}");
|
||||||
|
private static final Pattern APPENDIX_PATTERN2 = Pattern.compile("^Annex\\s*\\d+.*$");
|
||||||
/**
|
/**
|
||||||
* 判断范围正则
|
* 判断范围正则
|
||||||
*/
|
*/
|
||||||
@@ -219,7 +220,6 @@ public class FileSpiltService {
|
|||||||
|
|
||||||
ParagraphChildOrderManager runOrMaths = new ParagraphChildOrderManager(p);
|
ParagraphChildOrderManager runOrMaths = new ParagraphChildOrderManager(p);
|
||||||
List<Object> childList = runOrMaths.getChildList();
|
List<Object> childList = runOrMaths.getChildList();
|
||||||
|
|
||||||
for (Object child : childList) {
|
for (Object child : childList) {
|
||||||
//if (child instanceof XWPFRun) {
|
//if (child instanceof XWPFRun) {
|
||||||
// //处理段落中的文本以及图片
|
// //处理段落中的文本以及图片
|
||||||
@@ -236,7 +236,7 @@ public class FileSpiltService {
|
|||||||
.execute().body();
|
.execute().body();
|
||||||
//String post = HttpUtil.post(mathToImgUrl, map);
|
//String post = HttpUtil.post(mathToImgUrl, map);
|
||||||
if (messageList.size() > 0) {
|
if (messageList.size() > 0) {
|
||||||
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (child instanceof CTOMathPara) {
|
else if (child instanceof CTOMathPara) {
|
||||||
@@ -255,6 +255,7 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (XWPFRun xwrun : p.getRuns()) {
|
for (XWPFRun xwrun : p.getRuns()) {
|
||||||
VerticalAlign subscript = xwrun.getSubscript();
|
VerticalAlign subscript = xwrun.getSubscript();
|
||||||
String smalltext = xwrun.getText(0);
|
String smalltext = xwrun.getText(0);
|
||||||
@@ -1178,6 +1179,45 @@ public class FileSpiltService {
|
|||||||
if (element instanceof XWPFParagraph) {
|
if (element instanceof XWPFParagraph) {
|
||||||
XWPFParagraph p = (XWPFParagraph) element;
|
XWPFParagraph p = (XWPFParagraph) element;
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
|
||||||
|
ParagraphChildOrderManager runOrMaths = new ParagraphChildOrderManager((XWPFParagraph) element);
|
||||||
|
List<Object> childList = runOrMaths.getChildList();
|
||||||
|
for (Object child : childList) {
|
||||||
|
//if (child instanceof XWPFRun) {
|
||||||
|
// //处理段落中的文本以及图片
|
||||||
|
// handleParagraphRun(content, (XWPFRun) child, imageParser);
|
||||||
|
//} else
|
||||||
|
if (child instanceof CTOMath) {
|
||||||
|
CTOMath ctoMath = (CTOMath) child;
|
||||||
|
String xmlText = ctoMath.xmlText().replaceAll("xml-fragment","m:oMath");
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("encode", xmlText);
|
||||||
|
String post = HttpRequest.post(mathToImgUrl)
|
||||||
|
.header(Header.CONTENT_TYPE, "application/json")
|
||||||
|
.body(xmlText)
|
||||||
|
.execute().body();
|
||||||
|
//String post = HttpUtil.post(mathToImgUrl, map);
|
||||||
|
if (messageList.size() > 0) {
|
||||||
|
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (child instanceof CTOMathPara) {
|
||||||
|
CTOMathPara ctoMathPara = (CTOMathPara) child;
|
||||||
|
String xmlText = ctoMathPara.xmlText().replaceAll("xml-fragment","m:oMath");;
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("encode",xmlText);
|
||||||
|
String post = HttpRequest.post(mathToImgUrl)
|
||||||
|
.header(Header.CONTENT_TYPE, "application/json")
|
||||||
|
.body(xmlText)
|
||||||
|
.execute().body();
|
||||||
|
//String post = HttpUtil.post(mathToImgUrl, map);
|
||||||
|
if (messageList.size() > 0) {
|
||||||
|
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (XWPFRun xwrun : p.getRuns()) {
|
for (XWPFRun xwrun : p.getRuns()) {
|
||||||
VerticalAlign subscript = xwrun.getSubscript();
|
VerticalAlign subscript = xwrun.getSubscript();
|
||||||
String smalltext = xwrun.getText(0);
|
String smalltext = xwrun.getText(0);
|
||||||
@@ -1326,8 +1366,10 @@ public class FileSpiltService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (!hasGoIf && menuCanAdd) {
|
if (!hasGoIf && menuCanAdd) {
|
||||||
if (paragraphString.toLowerCase().replaceAll("\t", "").startsWith("annex 1")
|
boolean b = APPENDIX_PATTERN2.matcher(paragraphString).find();
|
||||||
|| paragraphString.toLowerCase().replaceAll("\t", "").startsWith("annex 1a")
|
if (b
|
||||||
|
// if (paragraphString.toLowerCase().replaceAll("\t", "").startsWith("annex 1")
|
||||||
|
// || paragraphString.toLowerCase().replaceAll("\t", "").startsWith("annex 1a")
|
||||||
&& !messageList.get(messageList.size() - 1).getItemNum().equals("annex")){
|
&& !messageList.get(messageList.size() - 1).getItemNum().equals("annex")){
|
||||||
|
|
||||||
// }
|
// }
|
||||||
@@ -1362,8 +1404,8 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!p.getText().equals("")) {
|
if (!paragraphString.equals("")) {
|
||||||
addItermsConditionsText(messageList.get(messageList.size() - 1), itemValList, p.getText(), p.getAlignment());
|
addItermsConditionsText(messageList.get(messageList.size() - 1), itemValList, paragraphString, p.getAlignment());
|
||||||
}
|
}
|
||||||
List<String> imageBundleList = readImageInParagraph((XWPFParagraph) p);
|
List<String> imageBundleList = readImageInParagraph((XWPFParagraph) p);
|
||||||
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user