Bug 28627 - Range.delete() does the wrong thing
Summary: Range.delete() does the wrong thing
Alias: None
Product: POI
Classification: Unclassified
Component: HDF (show other bugs)
Version: 3.0-dev
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2004-04-27 14:28 UTC by Nick Burch
Modified: 2008-03-13 06:02 UTC (History)
0 users

4 paragraph simple word document, for use with code to show deletion bug (19.50 KB, application/msword)
2004-04-27 14:29 UTC, Nick Burch

Note You need to log in before you can comment on or make changes to this 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