[Bug 61421] New: org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 61421] New: org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61421

            Bug ID: 61421
           Summary: org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeEx
                    ception: Rule M2.4 exception
           Product: POI
           Version: 3.16-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XWPF
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

Created attachment 35230
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35230&action=edit
The file caused the exeption

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61421] org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61421

Alex <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Alex <[hidden email]> ---
Code that caused the drop

XWPFDocument docx = new XWPFDocument(new FileInputStream("D:\\curs.docx"));
            ArrayList<Segment> topic = new ArrayList<>();

            int i = 0;
            for(XWPFParagraph paragraph : docx.getParagraphs()){
                byte sid = paragraph.getStyleID() != null ? (byte)
paragraph.getStyleID().charAt(0) : 0;
                if (sid >= 49 && sid <=52 ){
                    if (paragraph.getText().length() > 0) {
                        System.out.println(paragraph.getStyleID() + ":" +
paragraph.getText());
                        Segment segment = new Segment(paragraph.getText(),
Integer.valueOf(paragraph.getStyleID().charAt(0)));
                        segment.doc = new XWPFDocument(docx.getPackage());
                        segment.from = i;
                        if(topic.size() > 0){
                            topic.get(topic.size() - 1).to = i - 1;
                        }
                        topic.add(segment);

                    }
                }
                i++;
            }

            for(Segment segment : topic){
                i = 0;
                for(XWPFParagraph paragraph : docx.getParagraphs()) {
                    if(!(i >= segment.from && i <=segment.to)){
                        int pPos = segment.doc.getPosOfParagraph(paragraph);
                        segment.doc.removeBodyElement(pPos);
                    }
                    i++;
                }
                segment.doc.write(new FileOutputStream(new File("D:\\test\\" +
segment.title + ".docx")));
                segment.doc.close();
            }

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]