You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2025/01/29 09:18:10 UTC
[Bug 69554] New: Docx is invalid after reading a run attribute
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: dev@poi.apache.org
Reporter: jsaintyv@gmail.com
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69554] Docx is invalid after reading a run attribute
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69554
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
--- Comment #2 from PJ Fanning <fa...@yahoo.com> ---
seems plausible - could you try making the change locally
https://poi.apache.org has docs about how to build. POI uses a Gradle based
build.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69554] Docx is invalid after reading a run attribute
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69554
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEEDINFO |RESOLVED
--- Comment #6 from PJ Fanning <fa...@yahoo.com> ---
fixed with https://github.com/apache/poi/pull/1302
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69554] Docx is invalid after reading a run attribute
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69554
--- Comment #3 from PJ Fanning <fa...@yahoo.com> ---
`CTRPr pr = getRunProperties(create)` could return null.
so the next lines will need to change because they assume pr is not null.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69554] Docx is invalid after reading a run attribute
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69554
--- Comment #4 from PJ Fanning <fa...@yahoo.com> ---
I added r1923440. It doesn't seem to break any tests.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69554] Docx is invalid after reading a run attribute
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69554
--- Comment #5 from Jérôme SAINT-YVES <js...@gmail.com> ---
Thanks, the change fixes the test case.
But I have a more complex case that leads to an invalid document.
When I use one of these methods:
run.getEmphasisMark();
run.getTextHighlightColor()
run.getVerticalAlignment();
I haven't yet found any other way to isolate this issue
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69554] Docx is invalid after reading a run attribute
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69554
Jérôme SAINT-YVES <js...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
--- Comment #1 from Jérôme SAINT-YVES <js...@gmail.com> ---
May be the issue where generated because
private CTUnderline getCTUnderline(boolean create) {
CTRPr pr = getRunProperties(true);
return pr.sizeOfUArray() > 0 ? pr.getUArray(0) : (create ? pr.addNewU()
: null);
}
getRunProperties is call with true that i should be call with
getRunProperties(create) ?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org