You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Viliam Ďurina <vi...@kios.sk> on 2010/09/02 15:30:07 UTC
How to find the text at specified character position (CP)
Hello,
I'm trying to parse bookmarks and cross-references from word documents. I have parsed the sttbBkmk and plcbkf tables, from which I get the starting character position, where the bookmark points at. But I fail to find the text at that position. Is there a way for a particular CharacterRun to tell, which character position it starts at?
Thanks, Viliam
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: How to find the text at specified character position (CP)
Posted by Cédric Bosdonnat <ce...@free.fr>.
Hi Viliam,
On Thu, 2010-09-02 at 14:39 +0100, Nick Burch wrote:
> Yup, if you look at:
> http://poi.apache.org/apidocs/org/apache/poi/hwpf/usermodel/CharacterRun.html
> then follow it back to the parent Range object:
> http://poi.apache.org/apidocs/org/apache/poi/hwpf/usermodel/Range.html
> you have things like getStartOffset(), getEndOffset(), and the details on
> where the section and paragraphs start
Some further links if you want some examples: I have some similar things
in the ww8dumper.
http://gitorious.org/ww8dumper/ww8dumper
Regards,
--
Cédric Bosdonnat
Go-oo hacker
http://go-oo.org
OOo Eclipse Integration developer
http://cedric.bosdonnat.free.fr
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: How to find the text at specified character position (CP)
Posted by Nick Burch <ni...@alfresco.com>.
On Thu, 2 Sep 2010, Viliam Ďurina wrote:
> I'm trying to parse bookmarks and cross-references from word documents.
> I have parsed the sttbBkmk and plcbkf tables, from which I get the
> starting character position, where the bookmark points at.
You might want to double check the word specs, and ensure you're handling
the offsets in the correct one of bytes or characters. It's quite messy
which one is used where, and you'll want to ensure you're correctly in the
character domain before finding text
> But I fail to find the text at that position. Is there a way for a
> particular CharacterRun to tell, which character position it starts at?
Yup, if you look at:
http://poi.apache.org/apidocs/org/apache/poi/hwpf/usermodel/CharacterRun.html
then follow it back to the parent Range object:
http://poi.apache.org/apidocs/org/apache/poi/hwpf/usermodel/Range.html
you have things like getStartOffset(), getEndOffset(), and the details on
where the section and paragraphs start
Nick