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(); }
Created attachment 11351 [details] 4 paragraph simple word document, for use with code to show deletion bug
Now fixed in bug #44580