OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - 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<br />
Chapter Name / Number<br />
The name of the current chapter is available through a text field of the com.sun.star.text.textfield.Chapter type.<br />
The form can be defined using two properties.<br />
ChapterFormat (const)<br />
determines whether the chapter name or the chapter number is depicted (in accordance with<br />
com.sun.star.text.ChapterFormat)<br />
Level (Integer)<br />
determines the chapter level whose name and/or chapter number is to be displayed. The value 0 stands for<br />
highest level available.<br />
Bookmarks<br />
Bookmarks (Service com.sun.star.text.Bookmark) are TextContent objects. Bookmarks are created and inserted<br />
using the concept already described previously:<br />
Dim Doc As Object<br />
Dim Bookmark As Object<br />
Dim Cursor As Object<br />
Doc = ThisComponent<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 the actual bookmark<br />
object (Bookmark). The bookmark is then assigned a name and is inserted in the document through<br />
insertTextContent at the cursor position.<br />
The bookmarks of a text are accessed through a list called Bookmarks. The bookmarks can either be accessed by<br />
their number or their name.<br />
The following example shows how a bookmark can be found within a text, and a text inserted at its position.<br />
Dim Doc As Object<br />
Dim Bookmark As Object<br />
Dim Cursor As Object<br />
Doc = ThisComponent<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 its name. The<br />
createTextCursorByRange call then creates a Cursor, which is positioned at the anchor position of the<br />
bookmark. The cursor then inserts the text required at this point.<br />
90 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010