Improve html type field exports
This commit is contained in:
parent
adeca327a2
commit
7820235258
|
@ -205,7 +205,14 @@ public class HtmlToWorldBuilder implements NodeVisitor {
|
|||
ctLvl.addNewNumFmt().setVal(format);
|
||||
ctLvl.addNewStart().setVal(BigInteger.ONE);
|
||||
if (format == STNumberFormat.BULLET) {
|
||||
ctLvl.addNewLvlJc().setVal(STJc.LEFT);
|
||||
ctLvl.addNewLvlText().setVal("\u2022");
|
||||
ctLvl.addNewRPr(); //Set the Symbol font
|
||||
CTFonts f = ctLvl.getRPr().addNewRFonts();
|
||||
f.setAscii("Symbol");
|
||||
f.setHAnsi("Symbol");
|
||||
f.setCs("Symbol");
|
||||
f.setHint(STHint.DEFAULT);
|
||||
} else {
|
||||
ctLvl.addNewLvlText().setVal("%1.");
|
||||
}
|
||||
|
|
|
@ -34,10 +34,12 @@ public class WordBuilder {
|
|||
private Map<ParagraphStyle, ApplierWithValue<XWPFDocument, String, XWPFParagraph>> options = new HashMap<>();
|
||||
private CTAbstractNum cTAbstractNum;
|
||||
private BigInteger numId;
|
||||
private Integer indent;
|
||||
|
||||
public WordBuilder() {
|
||||
this.cTAbstractNum = CTAbstractNum.Factory.newInstance();
|
||||
this.cTAbstractNum.setAbstractNumId(BigInteger.valueOf(1));
|
||||
this.indent = 0;
|
||||
this.buildOptions();
|
||||
}
|
||||
|
||||
|
@ -52,7 +54,7 @@ public class WordBuilder {
|
|||
});
|
||||
this.options.put(ParagraphStyle.HTML, (mainDocumentPart, item) -> {
|
||||
Document htmlDoc = Jsoup.parse(item.replaceAll("\n", "<br>"));
|
||||
HtmlToWorldBuilder htmlToWorldBuilder = HtmlToWorldBuilder.convert(mainDocumentPart, htmlDoc, 0.8F);
|
||||
HtmlToWorldBuilder htmlToWorldBuilder = HtmlToWorldBuilder.convert(mainDocumentPart, htmlDoc, indent > 0 ? (indent/2.0F) * 0.8F : 0.8F);
|
||||
return htmlToWorldBuilder.getParagraph();
|
||||
});
|
||||
this.options.put(ParagraphStyle.TITLE, (mainDocumentPart, item) -> {
|
||||
|
@ -221,7 +223,8 @@ public class WordBuilder {
|
|||
if (!createListing) {
|
||||
try {
|
||||
if (field.getValue() != null && !field.getValue().toString().isEmpty()) {
|
||||
XWPFParagraph paragraph = addParagraphContent(this.formatter(field), mainDocumentPart, ParagraphStyle.TEXT, numId);
|
||||
this.indent = indent;
|
||||
XWPFParagraph paragraph = addParagraphContent(this.formatter(field), mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId);
|
||||
if (paragraph != null) {
|
||||
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||
number.setVal(BigInteger.valueOf(indent));
|
||||
|
|
Loading…
Reference in New Issue