Bug 28627

Summary: Range.delete() does the wrong thing
Product: POI Reporter: Nick Burch <apache>
Component: HDFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: 4 paragraph simple word document, for use with code to show deletion bug

Description Nick Burch 2004-04-27 14:28:29 UTC
As mentioned on the poi-user list. If you use the following code with the attached document, neither 
delete does the correct thing. On the paragraph delete, nothing is deleted, but the bold character 
properties are lost for the third paragraph. With the range delete, paragraphs 3 and 4 are deleted, 
and the bold then applies to the middle of the 2nd paragraph

        Range r = doc.getRange();
        int numParagraphs = r.numParagraphs();
        int p_s = 0;
        int p_e = 0;
        boolean useParaDel = false;
        for(int i=0; i < numParagraphs; i++) {
            Paragraph p = r.getParagraph(i);
            String text = p.text();
            if(text.trim().length() == 0) { continue; }
            System.out.println(i + "\t" + p.text() + "\n\n");

            if(text.indexOf("{delete me}") > -1) {
                System.out.println("Found, deleting");
                if(useParaDel) { p.delete(); }
                p_s = p._start;
                p_e = p._end;
            }
        }
        Range rt = new Range(p_s,p_e,r);
        if(! useParaDel ) { rt.delete(); }
Comment 1 Nick Burch 2004-04-27 14:29:44 UTC
Created attachment 11351 [details]
4 paragraph simple word document, for use with code to show deletion bug
Comment 2 Nick Burch 2008-03-13 06:02:49 UTC
Now fixed in bug #44580