:: com :: sun :: star :: i18n ::

interface XBreakIterator
Base Hierarchy
::com::sun::star::uno::XInterface
 |
 +-XBreakIterator
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
6.2.2 Office Development - Common Application Features - Internationalization - Overview and Using the API - XBreakIterator
6.2.2 Office Development - Common Application Features - Internationalization - Implementing a New Locale - XBreakIterator

Methods' Summary
nextCharacters Traverses specified number of characters in Text from nStartPos to the right. CharacterIteratorMode can be cell based or character based. A cell is made of more than one character.
previousCharacters Traverses specified number of characters in Text from nStartPos to the left. CharacterIteratorMode can be cell based or character based. A cell is made of more than one character.
nextWord Traverses one word in Text from nStartPos to the right.
previousWord Traverses one word in Text from nStartPos to the left.
getWordBoundary Identifies StartPos and EndPos of current word.
getWordType Get the WordType of the word that starts at position nPos .
isBeginWord If a word starts at position nPos .
isEndWord If a word ends at position nPos .
beginOfSentence Traverses in Text from nStartPos to the start of a sentence.
endOfSentence Traverses in Text from nStartPos to the end of a sentence.
getLineBreak Calculate the linebreak position in the Text from the specified nStartPos .
beginOfScript Get the position where the specified script starts, starting to look from nStartPos to the left.
endOfScript Get the position where the specified script starts, starting to look from nStartPos to the right.
nextScript Get the position where the next specified script starts, starting to look from nStartPos to the right.
previousScript Get the position where the next specified script starts, starting to look from nStartPos to the left.
getScriptType Get the script type of the character at position nPos .
beginOfCharBlock Traverses in Text from nStartPos to the beginning of the specified character type.
endOfCharBlock Traverses in Text from nStartPos to the end of the specified character type.
nextCharBlock Traverses in Text from nStartPos to the next start of the specified character type.
previousCharBlock Traverses in Text from nStartPos to the previous start of the specified character type.
Methods' Details
nextCharacters
long
nextCharacters(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
[in] long
[out] long
 
aText,
nStartPos,
aLocale,
nCharacterIteratorMode,
nCount,
nDone );

Description
Traverses specified number of characters in Text from nStartPos to the right. CharacterIteratorMode can be cell based or character based. A cell is made of more than one character.
Parameter nCount
Number of characters to traverse, it should not be less than 0. If you want to traverse in the opposite direction use XBreakIterator::previousCharacters() instead.
previousCharacters
long
previousCharacters(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
[in] long
[out] long
 
aText,
nStartPos,
aLocale,
nCharacterIteratorMode,
nCount,
nDone );

Description
Traverses specified number of characters in Text from nStartPos to the left. CharacterIteratorMode can be cell based or character based. A cell is made of more than one character.
Parameter nCount
Number of characters to traverse, it should not be less than 0. If you want to traverse in the opposite direction use XBreakIterator::nextCharacters() instead.
nextWord
Boundary
nextWord(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
 
aText,
nStartPos,
aLocale,
nWordType );

Description
Traverses one word in Text from nStartPos to the right.
Parameter nWordType
One of WordType , specifies the type of travelling.
Returns
The Boundary of the found word. Normally used for CTRL-Right.
previousWord
Boundary
previousWord(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
 
aText,
nStartPos,
aLocale,
nWordType );

Description
Traverses one word in Text from nStartPos to the left.
Parameter aLocale
The 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.

Parameter nWordType
One of WordType , specifies the type of travelling.
Returns
The Boundary of the found word. Normally used for CTRL-Left.
getWordBoundary
Boundary
getWordBoundary(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
[in] boolean
 
aText,
nPos,
aLocale,
nWordType,
bPreferForward );

Description
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 for beginning of word on left, otherwise nPos is considered to be the start of the next word and we look right for the end of the word.

Parameter nWordType
One of WordType .
Returns
The Boundary of the current word.
getWordType
short
getWordType(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
 
aText,
nPos,
aLocale );

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

Description
If a word starts at position nPos .
isEndWord
boolean
isEndWord(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
 
aText,
nPos,
aLocale,
nWordType );

Description
If a word ends at position nPos .
beginOfSentence
long
beginOfSentence(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
 
aText,
nStartPos,
aLocale );

Description
Traverses in Text from nStartPos to the start of a sentence.
Returns
The position where the sentence starts.
endOfSentence
long
endOfSentence(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
 
aText,
nStartPos,
aLocale );

Description
Traverses in Text from nStartPos to the end of a sentence.
Returns
The position where the sentence ends.
getLineBreak
LineBreakResults
getLineBreak(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] long
[in] LineBreakHyphenationOptions
[in] LineBreakUserOptions
 
aText,
nStartPos,
aLocale,
nMinBreakPos,
aHyphOptions,
aUserOptions );

Description
Calculate the linebreak position in the Text from the specified nStartPos .
Parameter nMinBreakPos
TODO
Parameter aHyphOptions
Defines if the hyphenator is to be used.
Parameter aUserOptions
Defines how to handle hanging punctuations, the forbidden character at the start/end of a line.
Returns
The LineBreakResults contain the break position of the word and which kind of break it is.
beginOfScript
long
beginOfScript(
 
[in] string
[in] long
[in] short
 
aText,
nStartPos,
nScriptType );

Description
Get the position where the specified script starts, starting to look from nStartPos to the left.
Parameter nScriptType
One of ScriptType .
endOfScript
long
endOfScript(
 
[in] string
[in] long
[in] short
 
aText,
nStartPos,
nScriptType );

Description
Get the position where the specified script starts, starting to look from nStartPos to the right.
Parameter nScriptType
One of ScriptType .
nextScript
long
nextScript(
 
[in] string
[in] long
[in] short
 
aText,
nStartPos,
nScriptType );

Description
Get the position where the next specified script starts, starting to look from nStartPos to the right.
Parameter nScriptType
One of ScriptType .
previousScript
long
previousScript(
 
[in] string
[in] long
[in] short
 
aText,
nStartPos,
nScriptType );

Description
Get the position where the next specified script starts, starting to look from nStartPos to the left.
Parameter nScriptType
One of ScriptType .
getScriptType
short
getScriptType(
 
[in] string
[in] long
 
aText,
nPos );

Description
Get the script type of the character at position nPos .
Returns
One of ScriptType .
beginOfCharBlock
long
beginOfCharBlock(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
 
aText,
nStartPos,
aLocale,
nCharType );

Description
Traverses in Text from nStartPos to the beginning of the specified character type.
Parameter nCharType
One of CharType
Returns
The position where the character type starts
endOfCharBlock
long
endOfCharBlock(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
 
aText,
nStartPos,
aLocale,
nCharType );

Description
Traverses in Text from nStartPos to the end of the specified character type.
Parameter nCharType
One of CharType
Returns
The position where the character type ends.
nextCharBlock
long
nextCharBlock(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
 
aText,
nStartPos,
aLocale,
nCharType );

Description
Traverses in Text from nStartPos to the next start of the specified character type.
Parameter nCharType
One of CharType
Returns
The position where the next character type starts.
previousCharBlock
long
previousCharBlock(
 
[in] string
[in] long
[in] ::com::sun::star::lang::Locale
[in] short
 
aText,
nStartPos,
aLocale,
nCharType );

Description
Traverses in Text from nStartPos to the previous start of the specified character type.
Parameter nCharType
One of CharType
Returns
The position where the previous character type starts.
Top of Page