You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Tiscali <ma...@tiscali.co.uk> on 2012/06/25 16:54:49 UTC

XWPF Bookmarks.

Over on the user list, we have managed to put together some code that 
will insert text at a bookmark and recover any bookmarked text (the 
focus was on XWPF but we also have some code working for HWPF so it 
could also be modified to keep the two APIs in step). For the most part 
it works well - the remaining problems are with oddly nested bookmarks 
and bookmarks that span more than one paragraph - and the obvious next 
step is to modify XWPF (and possibly HWPF) to include this functionality 
into the API as I feel it will suit most users as it stands now and I 
can look again at how the work is actually done to accommodate those 
specific requirements.

Therein lies the rub; how to implement this. The reason for starting 
this thread is to ask for opinions on the, as I see it, two options.

* Option one would be to add two methods to XWPFDocument, 
insertTextAtBookmark(String bookmarkName) and getTextAtBookmark(String 
bookmarkName). The names are not cast in stone by any means but I do 
think it is obvious what each would do.

* Option two is a little more complex, to create a new XWPFBookmarks 
class that acts as a container for the bookmarks in a document. Each 
bookmark would be represented by an instance of the, new,  XWPFBookmark 
class. The XWPFBookmark class would have methods allowing the user to 
insert text at the bookmark and recover any text from it. XWPFBookmarks 
would have methods allowing the user to get a specific bookmark by name 
and to get a list of the names of all of the bookmarks in a document.

Of the two, option two is obviously the more complex approach but does 
have the advantage of mirroring HWPF. Option one is easier to implement. 
Combining the two is also not impossible, to have a method on 
XWPFDocument that recovers an XWPFBookmark directly, be name.

So, opinions please.

Yours

Mark B

PS I have not looked into inserting a new bookmark or modifying an 
existing one, that can always come later.


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