OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
isEndOfSentence ()<br />
returns True if the TextCursor is at the end of a sentence.<br />
gotoStartOfParagraph (Expand)<br />
jumps to the start of the current paragraph.<br />
gotoEndOfParagraph (Expand)<br />
jumps to the end of the current paragraph.<br />
gotoNextParagraph (Expand)<br />
jumps to the start of the next paragraph.<br />
gotoPreviousParagraph (Expand)<br />
jumps to the start of the previous paragraph.<br />
isStartOfParagraph ()<br />
returns True if the TextCursor is at the start of a paragraph.<br />
isEndOfParagraph ()<br />
returns True if the TextCursor is at the end of a paragraph.<br />
Editing Text Documents<br />
The text is divided into sentences on the basis of sentence symbols. Periods are, for example, interpreted as<br />
symbols indicating the end of sentences. (In English, at least, they must be followed by a space, tab, or return for<br />
this to work.)<br />
The Expand parameter is a Boolean value which specifies whether the area passed over during navigation is to be<br />
highlighted. All navigation methods furthermore return a Boolean parameter which specifies whether the<br />
navigation was successful or whether the action was terminated for lack of text.<br />
The following is a list of several methods for editing highlighted areas using a TextCursor and which also<br />
support the com.sun.star.text.TextCursor service:<br />
collapseToStart ()<br />
resets the highlighting and positions the TextCursor at the start of the previously highlighted area.<br />
collapseToEnd ()<br />
resets the highlighting and positions the TextCursor at the end of the previously highlighted area.<br />
isCollapsed ()<br />
returns True if the TextCursor does not cover any highlighting at present.<br />
Formatting Text with TextCursor<br />
The com.sun.star.text.TextCursor service supports all the character and paragraph properties that were presented<br />
at the start of this chapter.<br />
The following example shows how these can be used in conjunction with a TextCursor. It passes through a<br />
complete document and formats the first word of every sentence in bold type.<br />
Dim Doc As Object<br />
Dim Cursor As Object<br />
Dim Proceed As Boolean<br />
Doc = ThisComponent<br />
Cursor = Doc.Text.createTextCursor<br />
Do<br />
Cursor.gotoEndOfWord(True)<br />
Cursor.CharWeight = com.sun.star.awt.FontWeight.BOLD<br />
Proceed = Cursor.gotoNextSentence(False)<br />
Cursor.gotoNextWord(False)<br />
Loop While Proceed<br />
The example first creates a document object for the text that has just been opened. Then it iterates through the<br />
entire text, sentence by sentence, and highlights each of the first words and formats this in bold.<br />
Chapter 6 · Text Documents 77