Hi,
Once again a problem with bookmarks : I didn't found an easy way to
write some text inside a bookmark (so that if you double click on the
bookmark in the explorer, the text is highlighted). Every method I found
on the net shows how to write text at (after) a bookmark, but as I want
to apply some styles on them, I really need the bookmark to contain the
text.
The method I built is the following :
Ancre =
thiscomponent.Bookmarks.getByName("myBookmark").getAnchor
curseur = thiscomponent.Text.createTextCursor
curseur_start = thiscomponent.Text.createTextCursor
curseur.gotoRange(Ancre, False)
curseur_start.gotoRange(Ancre, False)
Call thiscomponent.Bookmarks.getByName("myBookmark").dispose
signet =
thiscomponent.createInstance("com.sun.star.text.Bookmark")
signet.Name = "myBookmark"
curseur.setString("my Text")
curseur.gotoRange(curseur_start, True)
thiscomponent.Text.insertTextContent(curseur, signet, True)
This means that I get the anchor of the bookmark to create a cursor,
remove the bookmark, insert the text, have the cursor to select the
original bookmark position and insert the bookmark over the cursor's
selection.
This works well, although if anyone has a better/easier idea, I'd be
glad to use it.
My problem is that this method doesn't work for a bookmark that is
INSIDE a textTable Cell, because I can't use a TextCursor inside a Cell
(the gotoRange(anchor) bugs).
Cell cursors are not complex enough to handle ranges inside a cell and
if I enumerate the cell content, I don't find the bookmark anymore.
So, has anyone an idea ? Either a "insert text inside bookmark even in a
cell" or a "retrieve bookmark position in a cell string so my previous
method works" method would really help me a lot.
By the way, the cell can already have some text inside, so I can't
simply take the whole cell content.
Thx
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]