LibreOffice
LibreOffice 24.2 SDK API Reference
Public Member Functions | List of all members
XBreakIterator Interface Referencepublished

contains the base routines for iteration in Unicode string. More...

import"XBreakIterator.idl";

Inheritance diagram for XBreakIterator:
XInterface BreakIterator

Public Member Functions

long nextCharacters ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nCharacterIteratorMode, [in] long nCount, [out] long nDone)
 Traverses specified number of characters/cells in Text from nStartPos forwards. More...
 
long previousCharacters ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nCharacterIteratorMode, [in] long nCount, [out] long nDone)
 Traverses specified number of characters/cells in Text from nStartPos backwards. More...
 
Boundary nextWord ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nWordType)
 Traverses one word in Text from nStartPos forwards. More...
 
Boundary previousWord ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nWordType)
 Traverses one word in Text from nStartPos backwards. More...
 
Boundary getWordBoundary ([in] string aText, [in] long nPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nWordType, [in] boolean bPreferForward)
 Identifies StartPos and EndPos of current word. More...
 
short getWordType ([in] string aText, [in] long nPos, [in] ::com::sun::star::lang::Locale aLocale)
 
boolean isBeginWord ([in] string aText, [in] long nPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nWordType)
 If a word starts at position nPos. More...
 
boolean isEndWord ([in] string aText, [in] long nPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nWordType)
 If a word ends at position nPos. More...
 
long beginOfSentence ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale)
 Traverses in Text from nStartPos to the start of a sentence. More...
 
long endOfSentence ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale)
 Traverses in Text from nStartPos to the end of a sentence. More...
 
LineBreakResults getLineBreak ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] long nMinBreakPos, [in] LineBreakHyphenationOptions aHyphOptions, [in] LineBreakUserOptions aUserOptions)
 Calculate the line break position in the Text from the specified nStartPos. More...
 
long beginOfScript ([in] string aText, [in] long nStartPos, [in] short nScriptType)
 Traverses in Text from nStartPos to the beginning of the specified script type. More...
 
long endOfScript ([in] string aText, [in] long nStartPos, [in] short nScriptType)
 Traverses in Text from nStartPos to the end of the specified script type. More...
 
long nextScript ([in] string aText, [in] long nStartPos, [in] short nScriptType)
 Traverses in Text from nStartPos to the next start of the specified script type. More...
 
long previousScript ([in] string aText, [in] long nStartPos, [in] short nScriptType)
 Traverses in Text from nStartPos to the previous start of the specified script type. More...
 
short getScriptType ([in] string aText, [in] long nPos)
 Get the script type of the character at position nPos. More...
 
long beginOfCharBlock ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nCharType)
 Traverses in Text from nStartPos to the beginning of the specified character type. More...
 
long endOfCharBlock ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nCharType)
 Traverses in Text from nStartPos to the end of the specified character type. More...
 
long nextCharBlock ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nCharType)
 Traverses in Text from nStartPos to the next start of the specified character type. More...
 
long previousCharBlock ([in] string aText, [in] long nStartPos, [in] ::com::sun::star::lang::Locale aLocale, [in] short nCharType)
 Traverses in Text from nStartPos to the previous start of the specified character type. More...
 
- Public Member Functions inherited from XInterface
any queryInterface ([in] type aType)
 queries for a new interface to an existing UNO object. More...
 
void acquire ()
 increases the reference counter by one. More...
 
void release ()
 decreases the reference counter by one. More...
 

Detailed Description

contains the base routines for iteration in Unicode string.

Iterates over characters, words, sentences and line breaks.

Assumption: StartPos is inclusive and EndPos is exclusive.

Developers Guide
Office Development - Implementing a New Locale - XBreakIterator
Office Development - Overview and Using the API - XBreakIterator

Member Function Documentation

◆ beginOfCharBlock()

long beginOfCharBlock ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nCharType 
)

Traverses in Text from nStartPos to the beginning of the specified character type.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nCharTypeOne of CharType
Returns
The position where the character type starts

◆ beginOfScript()

long beginOfScript ( [in] string  aText,
[in] long  nStartPos,
[in] short  nScriptType 
)

Traverses in Text from nStartPos to the beginning of the specified script type.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
nScriptTypeOne of ScriptType.
Returns
The position where the script type starts.

◆ beginOfSentence()

long beginOfSentence ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale 
)

Traverses in Text from nStartPos to the start of a sentence.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
Returns
The position where the sentence starts.

◆ endOfCharBlock()

long endOfCharBlock ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nCharType 
)

Traverses in Text from nStartPos to the end of the specified character type.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nCharTypeOne of CharType
Returns
The position where the character type ends.

◆ endOfScript()

long endOfScript ( [in] string  aText,
[in] long  nStartPos,
[in] short  nScriptType 
)

Traverses in Text from nStartPos to the end of the specified script type.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
nScriptTypeOne of ScriptType.
Returns
The position where the script type ends.

◆ endOfSentence()

long endOfSentence ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale 
)

Traverses in Text from nStartPos to the end of a sentence.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
Returns
The position where the sentence ends.

◆ getLineBreak()

LineBreakResults getLineBreak ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] long  nMinBreakPos,
[in] LineBreakHyphenationOptions  aHyphOptions,
[in] LineBreakUserOptions  aUserOptions 
)

Calculate the line break position in the Text from the specified nStartPos.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nMinBreakPosDefines a minimum break position for hyphenated line break. When the position for hyphenated line break is less than nMinBreakPos, break position in LineBreakResults is set to -1.
aHyphOptionsDefines if the hyphenator is to be used.
aUserOptionsDefines how to handle hanging punctuations and forbidden characters at the start/end of a line.
Returns
The LineBreakResults contain the break position of the line, BreakType and com::sun::star::linguistic2::XHyphenatedWord

◆ getScriptType()

short getScriptType ( [in] string  aText,
[in] long  nPos 
)

Get the script type of the character at position nPos.

Parameters
aTextThe input text.
nPosThe index in aText.
Returns
One of ScriptType.

◆ getWordBoundary()

Boundary getWordBoundary ( [in] string  aText,
[in] long  nPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nWordType,
[in] boolean  bPreferForward 
)

Identifies StartPos and EndPos of current word.

If nPos is the boundary of a word, it is StartPos of one word and EndPos of previous word. In this situation, the outcome of the algorithm can be indeterminate. In this situation the bPreferForward flag is used. If bPreferForward == FALSE, nPos is considered to be the end of the word and we look backwards for beginning of word, otherwise nPos is considered to be the start of the next word and we look forwards for the end of the word.

Parameters
aTextThe input text.
nPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nWordTypeOne of WordType.
bPreferForwardIf TRUE, nPos should be considered the start of the next word and search proceeds forwards. If FALSE, nPos should be considered the end of the current word, and search proceeds backwards.
Returns
The Boundary of the current word.

◆ getWordType()

short getWordType ( [in] string  aText,
[in] long  nPos,
[in] ::com::sun::star::lang::Locale  aLocale 
)
Deprecated:
Get the WordType of the word that starts at position nPos.

This method is mis-defined, since WordType is not an attribute of a word, but a way to break words, like excluding or including tail spaces for spell checker or cursor traveling. It returns 0 always.

◆ isBeginWord()

boolean isBeginWord ( [in] string  aText,
[in] long  nPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nWordType 
)

If a word starts at position nPos.

It is possible that both of this method and following method isEndWord all return TRUE, since StartPos of a word is inclusive while EndPos of a word is exclusive.

◆ isEndWord()

boolean isEndWord ( [in] string  aText,
[in] long  nPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nWordType 
)

If a word ends at position nPos.

◆ nextCharacters()

long nextCharacters ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nCharacterIteratorMode,
[in] long  nCount,
[out] long  nDone 
)

Traverses specified number of characters/cells in Text from nStartPos forwards.

CharacterIteratorMode can be cell based or character based. A cell is made of more than one character.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nCharacterIteratorModeA constant from CharacterIteratorMode
nCountNumber of characters to traverse, it should not be less than 0. If you want to traverse in the opposite direction use XBreakIterator::previousCharacters() instead.
nDoneOut parameter to receive the number of cells/Unicode characters traversed.

◆ nextCharBlock()

long nextCharBlock ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nCharType 
)

Traverses in Text from nStartPos to the next start of the specified character type.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nCharTypeOne of CharType
Returns
The position where the next character type starts.

◆ nextScript()

long nextScript ( [in] string  aText,
[in] long  nStartPos,
[in] short  nScriptType 
)

Traverses in Text from nStartPos to the next start of the specified script type.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
nScriptTypeOne of ScriptType.
Returns
The position where the next script type starts.

◆ nextWord()

Boundary nextWord ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nWordType 
)

Traverses one word in Text from nStartPos forwards.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nWordTypeOne of WordType, specifies the type of traveling.
Returns
The Boundary of the found word. Normally used for CTRL-Right.

◆ previousCharacters()

long previousCharacters ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nCharacterIteratorMode,
[in] long  nCount,
[out] long  nDone 
)

Traverses specified number of characters/cells in Text from nStartPos backwards.

CharacterIteratorMode can be cell based or character based. A cell is made of more than one character.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nCharacterIteratorModeA constant from CharacterIteratorMode
nCountNumber of characters to traverse, it should not be less than 0. If you want to traverse in the opposite direction use XBreakIterator::nextCharacters() instead.
nDoneOut parameter to receive the number of cells/Unicode characters traversed.

◆ previousCharBlock()

long previousCharBlock ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nCharType 
)

Traverses in Text from nStartPos to the previous start of the specified character type.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.
nCharTypeOne of CharType
Returns
The position where the previous character type starts.

◆ previousScript()

long previousScript ( [in] string  aText,
[in] long  nStartPos,
[in] short  nScriptType 
)

Traverses in Text from nStartPos to the previous start of the specified script type.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
nScriptTypeOne of ScriptType.
Returns
The position where the previous script type starts.

◆ previousWord()

Boundary previousWord ( [in] string  aText,
[in] long  nStartPos,
[in] ::com::sun::star::lang::Locale  aLocale,
[in] short  nWordType 
)

Traverses one word in Text from nStartPos backwards.

Parameters
aTextThe input text.
nStartPosThe start index in aText.
aLocaleThe locale of the character preceding nStartPos.

If the previous character is a space character and nWordType indicates spaces should be skipped, and if the first non-space character is an Asian character, then, since Asian word break needs language specific wordbreak dictionaries, the method will return -1 in Boundary::endPos() and the position after the Asian character (i.e. the space character) in Boundary::startPos(). The caller then has to call this method again with a correct aLocale referring to the Asian character, which is then the previous character of the space character where nStartPos points to.

Note that the OpenOffice.org 1.0 / StarOffice 6.0 / StarSuite 6.0 i18n framework doesn't behave like this and mixed Western/CJK text may lead to wrong word iteration. This is fixed in later versions.

Parameters
nWordTypeOne of WordType, specifies the type of traveling.
Returns
The Boundary of the found word. Normally used for CTRL-Left.

The documentation for this interface was generated from the following file: