no message

This commit is contained in:
Bernaldo Mihasi 2022-03-24 09:43:13 +02:00
parent 864b4bfec8
commit 78895a1df1
1 changed files with 13 additions and 8 deletions

View File

@ -16,6 +16,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.util.Units; import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*; import org.apache.poi.xwpf.usermodel.*;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
@ -378,15 +379,19 @@ public class WordBuilder {
if((format == null || format.isEmpty()) || (attribute == null || attribute.isEmpty())){ if((format == null || format.isEmpty()) || (attribute == null || attribute.isEmpty())){
return null; return null;
} }
JSONArray array = new JSONArray(JavaToJson.objectStringToJson(format)); try {
StringBuilder multipleFormats = new StringBuilder(); JSONArray array = new JSONArray(JavaToJson.objectStringToJson(format));
for (int i = 0; i < array.length(); i++) { StringBuilder multipleFormats = new StringBuilder();
multipleFormats.append(array.getJSONObject(i).getString(attribute)).append(", "); for (int i = 0; i < array.length(); i++) {
multipleFormats.append(array.getJSONObject(i).getString(attribute)).append(", ");
}
if (multipleFormats.length() > 0) {
multipleFormats.setLength(multipleFormats.length() - 2);
}
return multipleFormats.toString();
} catch (JSONException e) {
return format;
} }
if (multipleFormats.length() > 0) {
multipleFormats.setLength(multipleFormats.length() - 2);
}
return multipleFormats.toString();
} }
public XWPFParagraph addParagraphContent(Object content, XWPFDocument mainDocumentPart, ParagraphStyle style, BigInteger numId) { public XWPFParagraph addParagraphContent(Object content, XWPFDocument mainDocumentPart, ParagraphStyle style, BigInteger numId) {