Difference between revisions of "Working with Text Documents"
m |
|||
Line 1: | Line 1: | ||
This section is about working with the Writer component. It builds upon the material covered in [[Extensions_development_basic]] and the generic guides in the [[CookBook]]. | This section is about working with the Writer component. It builds upon the material covered in [[Extensions_development_basic]] and the generic guides in the [[CookBook]]. | ||
− | |||
=Cursors= | =Cursors= | ||
Line 19: | Line 18: | ||
|- | |- | ||
| '''Main service ''' | | '''Main service ''' | ||
− | | | + | |TextRanges |
− | | | + | |TextViewCursor |
− | | | + | |TextCursor |
|- | |- | ||
| '''Object returned ''' | | '''Object returned ''' | ||
Line 30: | Line 29: | ||
| '''Number in frame ''' | | '''Number in frame ''' | ||
|One array | |One array | ||
− | |One only | + | |One only |
|As many as required | |As many as required | ||
|- | |- | ||
Line 40: | Line 39: | ||
| '''Cookbook page ''' | | '''Cookbook page ''' | ||
|[[Current selection]] | |[[Current selection]] | ||
− | |[[View | + | |[[ View cursor]] |
− | |[[Text | + | |[[ Text cursor]] |
|- | |- | ||
|} | |} | ||
− | + | (I have not been able to work out how to select more than one block of text using code other than using the method FindAll. Although it is possible to record a current multiple selection, move the view cursor, and reselect the original multiple selection. See [[View cursor]]. If you know how to do this please edit this page!) | |
− | (I have not been able to work out how to select more than one block of text using code other than using the method FindAll. Although it is possible to record a current multiple selection, move the view cursor, and reselect the original multiple selection. See [[View | + | |
− | + | ||
− | + | ||
− | + | ||
=Text Ranges= | =Text Ranges= | ||
− | [[ | + | [[ TextRange]] |
Revision as of 00:48, 2 May 2006
This section is about working with the Writer component. It builds upon the material covered in Extensions_development_basic and the generic guides in the CookBook.
Cursors
To work within a text document typically involves the Current selection, the View cursor or a not visible Text cursor. All of them provide access to TextRange objects, which provide methods for changing the text.
The differences between them is summarised in the following table:
Current selection | View cursor | Text cursor | |
Typical command | oCurSelection = thisComponent.getCurrentSelection | oVC = thisComponent.getCurrentController.getViewCursor | oCursor = oVC.getText.createTextCursorByRange(oVC) |
Main service | TextRanges | TextViewCursor | TextCursor |
Object returned | Array of selected text ranges | The insertion point or a single text selection | A single text selection |
Number in frame | One array | One only | As many as required |
Movement | (By view cursor) | By Characters, Lines, and Pages | By Characters, Words, Sentences, and Paragraphs |
Cookbook page | Current selection | View cursor | Text cursor |
(I have not been able to work out how to select more than one block of text using code other than using the method FindAll. Although it is possible to record a current multiple selection, move the view cursor, and reselect the original multiple selection. See View cursor. If you know how to do this please edit this page!)