OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
More Than Just Text 121<br />
Bookmarks<br />
Bookmarks (Service<br />
com.sun.star.text.Bookmark<br />
) are TextContent objects. Bookmarks are created and inserted using the concept already<br />
described previously:<br />
Dim Doc As Object<br />
Dim Bookmark As Object<br />
Dim Cursor As Object<br />
Doc = StarDesktop.CurrentComponent<br />
Cursor = Doc.Text.createTextCursor()<br />
Bookmark = Doc.createInstance("com.sun.star.text.Bookmark")<br />
Bookmark.Name = "My bookmarks"<br />
Doc.Text.insertTextContent(Cursor, Bookmark, True)<br />
The example creates a Cursor, which marks the insert position of the bookmark and then<br />
the actual bookmark object (Bookmark). The bookmark is then assigned a name and is<br />
inserted in the document through insertTextContent at the cursor position.<br />
The bookmarks of a text are accessed through a list called Bookmarks. The bookmarks can<br />
either be accessed by their number or their name.<br />
The following example shows how a bookmark can be found within a text, and a text<br />
inserted at its position.<br />
Dim Doc As Object<br />
Dim Bookmark As Object<br />
Dim Cursor As Object<br />
Doc = StarDesktop.CurrentComponent<br />
Bookmark = Doc.Bookmarks.getByName("My bookmarks")<br />
Cursor = Doc.Text.createTextCursorByRange(Bookmark.Anchor)<br />
Cursor.String = "Here is the bookmark"<br />
In this example, the getByName method is used to find the bookmark required by means of<br />
its name. The createTextCursorByRange call then creates a Cursor, which is positioned at<br />
the anchor position of the bookmark. The cursor then inserts the text required at this point.