https://bz.apache.org/bugzilla/show_bug.cgi?id=69554
Bug ID: 69554
Summary: Docx is invalid after reading a run attribute
Product: POI
Version: 5.2.3-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XWPF
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Hello,
I found an issue. When i'm building a simple docx. This simple Junit test will
generate 3 invalid document.
public class WordToolsTest2 {
@Test
public void unvalidDocumentBugTest()
throws IOException {
buildInvalidDocument("'read emphasis mark'", (run) ->
run.getEmphasisMark());
}
@Test
public void unvalidDocumentBugTest2()
throws IOException {
buildInvalidDocument("'read getTextHighlightColor'", (run) ->
run.getTextHighlightColor());
}
@Test
public void unvalidDocumentBugTest3()
throws IOException {
buildInvalidDocument("'read getVerticalAlignment'", (run) ->
run.getVerticalAlignment());
}
private void buildInvalidDocument(String code, Consumer<XWPFRun>
reader) throws IOException {
File targetFile = File.createTempFile("test", "_output.docx");
try (XWPFDocument doc = new XWPFDocument()) {
XWPFParagraph paragraph = doc.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText("Hello " + code);
run.getUnderline();
// Corrupt generated word
reader.accept(run);
try (FileOutputStream out = new
FileOutputStream(targetFile)) {
doc.write(out);
}
}
Desktop.getDesktop().open(targetFile);
}
}
Word can open them but we get a message that they are incorrect.
I compare document.xml before and after the word fix.
Word removes elements <w:em />, <w:highlight />, <w:u />, <w:vertAlign />
below element <w:rPr>
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]