That is wrong and right somewhat. Going along with the way you want to do
it...why you have your paragraph, you can get the character runs, now look
for the text in your character runs. delete the individual character runs.

Actually, the best way would be to get the document's range. Call text() on
that range. find the text you want to delete. create a new Range based on
the text offsets then delete this range. The problem with doing it that way
is that the Range offsets are stored as byte offsets and not character
offsets. So if you have unicode characters this will be off somewhat. May be
I need to look at fixing that.

-Ryan

----- Original Message ----- 
From: "Nick Burch" <[EMAIL PROTECTED]>
To: "POI Users List" <[EMAIL PROTECTED]>; "Ryan Ackley"
<[EMAIL PROTECTED]>
Sent: Tuesday, April 27, 2004 9:19 AM
Subject: Re: bug HWPF?


> On Tue, 27 Apr 2004, Ryan Ackley wrote:
> > I saw, thanks Nick. Does the delete method work?
>
> Well, it sort of does, and sort of doesn't....
>
>
> I was about to suggest that we add an example for
> adding/replacing/editing/deleting text to the HWPF examples (and possibly
> also a matching unit test)
>
> I would be happy to code this up, but I'll need some suggestions on how
> best to acheive this.
>
> My current (not fully working) way goes something like:
>
> Grab the main range
> Get all paragraphs
> Check paragraph text for what you're interested in
> If you find it in a paragraph, get Paragraph._start and the distance in to
>  your text. Then, create a new Range (child of main range) from start +
>  distance in to end of interesting text
> If adding, to insertBefore / insertAfter
> If deleting, just call delete on this range
> If editing, call insertAfter and add your new text, then call delete on
>  the range.
>
> For at least some of the above, you'll need to start from scratch again,
> as your current objects seem to point to the wrong places....
>
> Is that kinda the correct route, or am I barking up the wrong tree?
>
> (Note that I had to make public a few protected methods and variables to
> get that to work)
>
> Nick
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to