Bug 66187 - MS document is error by XWPFDocument to write when XWPFRun call method getTextHightlightColor() or getEmphasisMark
Summary: MS document is error by XWPFDocument to write when XWPFRun call method getTe...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 5.2.2-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-29 09:28 UTC by cn.luowenjie
Modified: 2022-08-15 10:36 UTC (History)
0 users



Attachments
the sample (673 bytes, text/plain)
2022-07-29 09:31 UTC, cn.luowenjie
Details
The error (10.76 KB, image/png)
2022-08-01 06:46 UTC, cn.luowenjie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cn.luowenjie 2022-07-29 09:28:20 UTC
The sample:


```Java
    public static void main(String[] args) throws Exception {
        String template = XwpfUtils.class.getResource("/template-word/template.docx").getFile();
        try (FileInputStream argIS = new FileInputStream(template)) {
            try (XWPFDocument doc = new XWPFDocument(argIS)) {
                XWPFRun run =  doc.getParagraphs().get(0).getRuns().get(0);
                //TODO bug
                run.getTextHightlightColor(); //or run.getEmphasisMark()  also causes the same error

                try (OutputStream out = new FileOutputStream("output.docx")) {
                    doc.write(out);
                }
             }
        }
    }

```
Comment 1 cn.luowenjie 2022-07-29 09:30:08 UTC
    public static void main(String[] args) throws Exception {
        String template = XwpfUtils.class.getResource("/template-word/template.docx").getFile();
        try (FileInputStream argIS = new FileInputStream(template)) {
            try (XWPFDocument doc = new XWPFDocument(argIS)) {
                XWPFRun run =  doc.getParagraphs().get(0).getRuns().get(0);
                //TODO bug
                run.getTextHightlightColor(); //or run.getEmphasisMark()  also causes the same error

                try (OutputStream out = new FileOutputStream("output.docx")) {
                    doc.write(out);
                }
             }
        }
    }
Comment 2 cn.luowenjie 2022-07-29 09:31:42 UTC
Created attachment 38354 [details]
the sample
Comment 3 PJ Fanning 2022-07-29 13:03:53 UTC
Can you provide the 'error'? Is it a stack trace - if so, provide the full trace?
Comment 4 cn.luowenjie 2022-08-01 06:46:33 UTC
Created attachment 38356 [details]
The error
Comment 5 cn.luowenjie 2022-08-01 06:47:47 UTC
(In reply to PJ Fanning from comment #3)
> Can you provide the 'error'? Is it a stack trace - if so, provide the full
> trace?

The Java program runs fine, but there is an error opening the output World document.
Comment 6 PJ Fanning 2022-08-01 11:36:46 UTC
I added r1903163 - would you be able to build POI and try the change for yourself?