diff --git a/src/main/java/com/example/exam/exam/service/wpsword/docx4j/paragraph/Paragraphs.java b/src/main/java/com/example/exam/exam/service/wpsword/docx4j/paragraph/Paragraphs.java index 5b271ad..18b8c8f 100644 --- a/src/main/java/com/example/exam/exam/service/wpsword/docx4j/paragraph/Paragraphs.java +++ b/src/main/java/com/example/exam/exam/service/wpsword/docx4j/paragraph/Paragraphs.java @@ -149,7 +149,8 @@ public class Paragraphs { PPr pPr = paragraph.getPPr(); if (pPr != null && pPr.getSpacing() != null) { if (pPr.getSpacing().getBeforeLines()!=null){ - return pPr.getSpacing().getBeforeLines().toString(); + double lines = pPr.getSpacing().getBeforeLines().intValue() / 100.0; + return String.format("%.1f行", lines); } } if (pPr != null && pPr.getPStyle() != null && stylePart != null) { @@ -157,7 +158,8 @@ public class Paragraphs { Style style = stylePart.getStyleById(styleId); if (style != null && style.getPPr() != null && style.getPPr().getSpacing() != null) { PPrBase.Spacing spacing = style.getPPr().getSpacing(); - return spacing.getBeforeLines().toString(); + double lines = spacing.getBeforeLines().intValue() / 100.0; + return String.format("%.1f行", lines); } } return ""; @@ -167,7 +169,7 @@ public class Paragraphs { PPr pPr = paragraph.getPPr(); if (pPr != null && pPr.getSpacing() != null) { if(pPr.getSpacing().getBefore()!=null){ - return pPr.getSpacing().getBefore().toString(); + return String.valueOf(pPr.getSpacing().getBefore().intValue() / 20)+"磅"; } } if (pPr != null && pPr.getPStyle() != null && stylePart != null) { @@ -175,7 +177,7 @@ public class Paragraphs { Style style = stylePart.getStyleById(styleId); if (style != null && style.getPPr() != null && style.getPPr().getSpacing() != null) { PPrBase.Spacing spacing = style.getPPr().getSpacing(); - return spacing.getBefore().toString(); + return String.valueOf(style.getPPr().getSpacing().getBefore().intValue() / 20)+"磅"; } } return ""; @@ -185,7 +187,7 @@ public class Paragraphs { PPr pPr = paragraph.getPPr(); if (pPr != null && pPr.getSpacing() != null) { if(pPr.getSpacing().getAfter()!=null){ - return pPr.getSpacing().getAfter().toString(); + return String.valueOf(pPr.getSpacing().getAfter().intValue() / 20)+"磅"; } } if (pPr != null && pPr.getPStyle() != null && stylePart != null) { @@ -193,7 +195,7 @@ public class Paragraphs { Style style = stylePart.getStyleById(styleId); if (style != null && style.getPPr() != null && style.getPPr().getSpacing() != null) { PPrBase.Spacing spacing = style.getPPr().getSpacing(); - return spacing.getAfter().toString(); + return String.valueOf(style.getPPr().getSpacing().getAfter().intValue() / 20)+"磅"; } } return ""; @@ -203,8 +205,9 @@ public class Paragraphs { public static String getParagraphSpacingAfterLines(P paragraph, StyleDefinitionsPart stylePart, WordprocessingMLPackage wordMLPackage, NumberingDefinitionsPart ndp) { PPr pPr = paragraph.getPPr(); if (pPr != null && pPr.getSpacing() != null) { - if (pPr.getSpacing().getAfterLines()!=null){ - return pPr.getSpacing().getAfterLines().toString(); + if (pPr.getSpacing().getAfterLines() != null) { + double lines = pPr.getSpacing().getAfterLines().intValue() / 100.0; + return String.format("%.1f行", lines); } } if (pPr != null && pPr.getPStyle() != null && stylePart != null) { @@ -212,7 +215,8 @@ public class Paragraphs { Style style = stylePart.getStyleById(styleId); if (style != null && style.getPPr() != null && style.getPPr().getSpacing() != null) { PPrBase.Spacing spacing = style.getPPr().getSpacing(); - return spacing.getAfterLines().toString(); + double lines = spacing.getAfterLines().intValue() / 100.0; + return String.format("%.1f行", lines); } } return ""; diff --git a/src/main/java/com/example/exam/exam/service/wpsword/docx4j/section/SectionPage.java b/src/main/java/com/example/exam/exam/service/wpsword/docx4j/section/SectionPage.java index 6132bed..a284bdd 100644 --- a/src/main/java/com/example/exam/exam/service/wpsword/docx4j/section/SectionPage.java +++ b/src/main/java/com/example/exam/exam/service/wpsword/docx4j/section/SectionPage.java @@ -1360,7 +1360,7 @@ public class SectionPage { Pattern pattern = Pattern.compile("fillcolor=\"#([0-9a-fA-F]{6})\""); Matcher matcher = pattern.matcher(vmlXml); if (matcher.find()) { - return "#" + matcher.group(1).toUpperCase(); + return ColorUtils.getChineseColorName(matcher.group(1).toUpperCase()) ; } return null; }