Bug 66187

Summary: MS document is error by XWPFDocument to write when XWPFRun call method getTextHightlightColor() or getEmphasisMark
Product: POI Reporter: cn.luowenjie
Component: XWPFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 5.2.2-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: the sample
The error

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?