Difference between revisions of "Working with Text Documents"
m |
|||
Line 48: | Line 48: | ||
=Text Ranges= | =Text Ranges= | ||
[[ TextRange]] | [[ TextRange]] | ||
+ | |||
+ | [[Category:Basic:Tutorials]] | ||
+ | [[Category:Tutorials]] |
Revision as of 17:45, 16 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!)