Working with text in LotusScript® classes

Text includes text paragraphs and text runs, rich text styles, rich text paragraph styles, and tabs. A text run is text until the style changes or the paragraph ends.

Text paragraphs and text runs

To find text in a rich text item, use the NotesRichTextNavigator methods in conjunction with the type RTELEM_TYPE_TEXTPARAGRAPH or RTELEM_TYPE_TEXTRUN. To get text, create a NotesRichTextRange object and delineate the text with the following methods:

  • SetBegin defines the beginning of a range.
  • SetEnd defines the end of a range.

For example, if you find an element of type RTELEM_TYPE_TEXTPARAGRAPH with NotesRichTextNavigator, then call SetBegin passing it the navigator, your range starts at that paragraph.

The NotesRichTextRange class has the following properties:

Property

Data Type

Description

Navigator

NotesRichTextNavigator

(Read-only) A navigator confined to the range. This allows you, for example, to get the text runs in a text paragraph.

Style

NotesRichTextStyle

(Read-only) The style of the first text run in the range.

TextParagraph

String

(Read-only) The text of the first paragraph in the range.

TextRun

String

(Read-only) The text of the first run in the range.

Type

String

(Read-only) The type of the first element in the range.

In addition to SetBegin and SetEnd, the NotesRichTextRange class has the following methods:

  • Clone creates another NotesRichTextRange object from the current range.
  • FindAndReplace replaces the occurrence of a string in the range.
  • Remove removes the elements of the range.
  • Reset resets the range to its default values.
  • SetStyle sets all text in the range to a specified style.

Text creation

To create text in a rich text item, use the following methods:

  • AddNewLine appends one or more new lines (carriage returns) to the end of a rich text item.
  • AddPageBreak places a hard page break at the end of a NotesRichTextItem.
  • AddTab appends one or more tabs to the end of a rich text item.
  • AppendText appends text to the end of a rich text item. The text is rendered with the current style of the item.
  • AppendRTItem appends the contents of one rich text item to the end of another rich text item.

Rich text styles

You can access rich text style properties through the AppendRTItem class. The NotesRichTextStyle class contains the following properties:

Property

Data Type

Description

Bold

Boolean or Constant

(Read-write) Bold rich text attribute.

Effects

Constant

(Read-wite) Effects (emboss, extrude, etc.).

FontSize

Integer

(Read-write) Font size in points.

IsDefault

Boolean

Indicates whether all rich text style attributes are at the default state.

Italic

Boolean or Constant

(Read-write) Italic rich text attribute.

NotesColor

Constant

(Read-write) Color rich text attribute.

NotesFont

Constant

(Read-write) Font rich text attribute.

Parent

NotesSession

The session that contains a RichTextStyle object. For COM only.

PassThruHTML

Boolean

(Read-write) HTML attribute.

StrikeThrough

Boolean or Constant

(Read-write) Strikethrough rich text attribute.

Underline

Boolean or Constant

(Read-write) Underline rich text attribute.

AppendStyle appends a style to the end of a rich text item. Text following the style is rendered using that styles's attributes until another style is appended.

Use a NotesRichTextStyle object with AppendStyle in NotesRichTextItem. At creation, all the NotesRichTextStyle attributes are in the default state STYLE_NO_CHANGE (255).

Use GetNotesFont in NotesRichTextItem to establish font identifiers for NotesFont.

Rich text paragraph styles

The NotesRichTextParagraphStyle allows you to access the following attributes of a rich text paragraph object:

Property

Data type

Description

Alignment

Constant

(Read-write) Alignment attribute of a rich text paragraph.

FirstLineLeftMargin

Long

(Read-write) First line left margin attribute of a rich text paragraph.

InterLineSpacing

Constant

(Read-write) Interline spacing attribute of a rich text paragraph.

LeftMargin

Long

(Read-write) Left margin attribute of a rich text paragraph.

RightMargin

Long

(Read-write) Right margin attribute of a rich text paragraph.

SpacingAbove

Constant

(Read-write) Spacing above attribute of a rich text paragraph.

SpacingBelow

Constant

(Read-write) Spacing below attribute of a rich text paragraph.

Tabs

Variant

(Read-only) Tabs in a rich text paragraph style.

Use the CreateRichTextParagraphStyle method of NotesSession to create a new rich text paragraph style object.

Tabs

You can manipulate the tabs in a rich text paragraph style object through the ClearAllTabs, SetTab, and SetTabs and Clear methods in the NotesRichTextParagraphStyle and RichTextTab classes.

The following table lists the properties in the RichTextTab class.

Property

Description

Position

(Read-write) Position of a tab in a rich text paragraph style

Type

(Read-write) Type of tab