poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Burch <n...@torchbox.com>
Subject Re: bug HWPF?
Date Tue, 27 Apr 2004 14:12:36 GMT
On Tue, 27 Apr 2004, Ryan Ackley wrote:
> I saw, thanks Nick. Does the delete method work?

Addressing this specifically:

I have a word document with four paragraphs. The second contains the text 
"{delete me}". The third contains some bold text.

I'm trying two different ways to trash the second paragraph, having found 
it. The first, deleting the paragraph object, doesn't remove the 
paragraph, but does remove the boldening from the third paragraph. The 
second, grabbing the paragraph start and end, creating a new range, then 
deleting this, removes paragraphs 3 and 4, and the bold them applies to 
part of the second paragraph....

Relevent code is:

        int numParagraphs = r.numParagraphs();
        int p_s = 0;
        int p_e = 0;
        boolean useParaDel = true;
        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(); }

Should either of these deleting methods work? (I can send you the starting 
word doc and/or submit it to bugzilla if that'd help)


To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org

View raw message