1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef __com_sun_star_i18n_XBreakIterator_idl__
20 #define __com_sun_star_i18n_XBreakIterator_idl__
22 #include
<com
/sun
/star
/lang
/Locale.idl
>
23 #include
<com
/sun
/star
/i18n
/LineBreakUserOptions.idl
>
24 #include
<com
/sun
/star
/i18n
/LineBreakHyphenationOptions.idl
>
25 #include
<com
/sun
/star
/i18n
/LineBreakResults.idl
>
26 #include
<com
/sun
/star
/i18n
/Boundary.idl
>
29 module com
{ module sun
{ module star
{ module i18n
{
33 contains the base routines for iteration in Unicode string. Iterates over
34 characters, words, sentences and line breaks.
36 <p> Assumption: StartPos is inclusive and EndPos is exclusive. </p>
39 published
interface XBreakIterator
: com
::sun
::star
::uno
::XInterface
41 /** Traverses specified number of characters/cells in Text from
42 <em>nStartPos</em> forwards.
43 CharacterIteratorMode can be cell based or
44 character based. A cell is made of more than one character.
50 The start index in aText.
53 The locale of the character preceding <em>nStartPos</em>.
55 @param nCharacterIteratorMode
56 A constant from CharacterIteratorMode
59 Number of characters to traverse, it should not be less than 0.
60 If you want to traverse in the opposite direction use
61 XBreakIterator::previousCharacters() instead.
64 Out parameter to receive the number of cells/Unicode characters
67 long nextCharacters
( [in] string aText
, [in] long nStartPos
,
68 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
69 [in] short nCharacterIteratorMode
,
70 [in] long nCount
, [out] long nDone
);
72 /** Traverses specified number of characters/cells in Text from
73 <em>nStartPos</em> backwards.
74 CharacterIteratorMode can be cell based or
75 character based. A cell is made of more than one character.
81 The start index in aText.
84 The locale of the character preceding <em>nStartPos</em>.
86 @param nCharacterIteratorMode
87 A constant from CharacterIteratorMode
90 Number of characters to traverse, it should not be less than 0.
91 If you want to traverse in the opposite direction use
92 XBreakIterator::nextCharacters() instead.
95 Out parameter to receive the number of cells/Unicode characters
99 long previousCharacters
( [in] string aText
, [in] long nStartPos
,
100 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
101 [in] short nCharacterIteratorMode
,
102 [in] long nCount
, [out] long nDone
);
104 /** Traverses one word in Text from <em>nStartPos</em> forwards.
110 The start index in aText.
113 The locale of the character preceding <em>nStartPos</em>.
116 One of WordType, specifies the type of
120 The Boundary of the found word. Normally used for
123 Boundary nextWord
( [in] string aText
, [in] long nStartPos
,
124 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
125 [in] short nWordType
);
127 /** Traverses one word in Text from <em>nStartPos</em> backwards.
133 The start index in aText.
136 The locale of the character preceding <em>nStartPos</em>.
138 <p> If the previous character is a space character and
139 <em>nWordType</em> indicates spaces should be skipped, and
140 if the first non-space character is an Asian character,
141 then, since Asian word break needs language specific
142 wordbreak dictionaries, the method will return -1 in
143 Boundary::endPos() and the position after the
144 Asian character (i.e. the space character) in
145 Boundary::startPos(). The caller then has to
146 call this method again with a correct <em>aLocale</em>
147 referring to the Asian character, which is then the previous
148 character of the space character where <em>nStartPos</em>
151 <p> <b>Note</b> that the OpenOffice.org 1.0 / StarOffice 6.0
152 / StarSuite 6.0 i18n framework doesn't behave like this and
153 mixed Western/CJK text may lead to wrong word iteration.
154 This is fixed in later versions. </p>
157 One of WordType, specifies the type of
161 The Boundary of the found word. Normally used for
164 Boundary previousWord
( [in] string aText
, [in] long nStartPos
,
165 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
166 [in] short nWordType
);
168 /** Identifies StartPos and EndPos of current word.
170 <p> If <em>nPos</em> is the boundary of a word, it is StartPos
171 of one word and EndPos of previous word. In this situation, the
172 outcome of the algorithm can be indeterminate. In this situation
173 the <em>bPreferForward</em> flag is used. If bPreferForward ==
174 `FALSE`, <em>nPos</em> is considered to be the end of the word
175 and we look backwards for beginning of word, otherwise
176 <em>nPos</em> is considered to be the start of the next word and
177 we look forwards for the end of the word. </p>
183 The start index in aText.
186 The locale of the character preceding <em>nStartPos</em>.
191 @param bPreferForward
192 If `TRUE`, nPos should be considered the start of the next
193 word and search proceeds forwards.
194 If `FALSE`, nPos should be considered the end of the
195 current word, and search proceeds backwards.
198 The Boundary of the current word.
200 Boundary getWordBoundary
( [in] string aText
, [in] long nPos
,
201 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
202 [in] short nWordType
,
203 [in] boolean bPreferForward
);
206 Get the WordType of the word that starts at
207 position <em>nPos</em>.
209 <p> This method is mis-defined, since WordType
210 is not an attribute of a word, but a way to break words,
211 like excluding or including tail spaces for spell checker
212 or cursor traveling. It returns 0 always.
215 short getWordType
( [in] string aText
, [in] long nPos
,
216 [in] ::com
::sun
::star
::lang
::Locale aLocale
);
218 /** If a word starts at position <em>nPos</em>.
220 <p> It is possible that both of this method
221 and following method <em>isEndWord</em> all return
222 `TRUE`, since StartPos of a word is inclusive
223 while EndPos of a word is exclusive.
227 boolean isBeginWord
( [in] string aText
, [in] long nPos
,
228 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
229 [in] short nWordType
);
231 /** If a word ends at position <em>nPos</em>.
233 boolean isEndWord
( [in] string aText
, [in] long nPos
,
234 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
235 [in] short nWordType
);
237 /** Traverses in Text from <em>nStartPos</em> to the start of a
244 The start index in aText.
247 The locale of the character preceding <em>nStartPos</em>.
250 The position where the sentence starts.
252 long beginOfSentence
( [in] string aText
, [in] long nStartPos
,
253 [in] ::com
::sun
::star
::lang
::Locale aLocale
);
255 /** Traverses in Text from <em>nStartPos</em> to the end of a
262 The start index in aText.
265 The locale of the character preceding <em>nStartPos</em>.
268 The position where the sentence ends.
270 long endOfSentence
( [in] string aText
, [in] long nStartPos
,
271 [in] ::com
::sun
::star
::lang
::Locale aLocale
);
273 /** Calculate the line break position in the Text from the specified
280 The start index in aText.
283 The locale of the character preceding <em>nStartPos</em>.
286 Defines a minimum break position for hyphenated line break.
287 When the position for hyphenated line break is less than
288 <em>nMinBreakPos</em>, break position in
289 LineBreakResults is set to -1.
292 Defines if the hyphenator is to be used.
295 Defines how to handle hanging punctuations and forbidden
296 characters at the start/end of a line.
299 The LineBreakResults contain the break
300 position of the line, BreakType and
301 com::sun::star::linguistic2::XHyphenatedWord
303 LineBreakResults getLineBreak
( [in] string aText
, [in] long nStartPos
,
304 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
305 [in] long nMinBreakPos
,
306 [in] LineBreakHyphenationOptions aHyphOptions
,
307 [in] LineBreakUserOptions aUserOptions
);
309 /** Traverses in Text from <em>nStartPos</em> to the beginning of
310 the specified script type.
316 The start index in aText.
322 The position where the script type starts.
324 long beginOfScript
( [in] string aText
, [in] long nStartPos
,
325 [in] short nScriptType
);
327 /** Traverses in Text from <em>nStartPos</em> to the end of the
328 specified script type.
334 The start index in aText.
340 The position where the script type ends.
342 long endOfScript
( [in] string aText
, [in] long nStartPos
,
343 [in] short nScriptType
);
345 /** Traverses in Text from <em>nStartPos</em> to the next start of
346 the specified script type.
352 The start index in aText.
358 The position where the next script type starts.
360 long nextScript
( [in] string aText
, [in] long nStartPos
,
361 [in] short nScriptType
);
363 /** Traverses in Text from <em>nStartPos</em> to the previous start
364 of the specified script type.
370 The start index in aText.
376 The position where the previous script type starts.
378 long previousScript
( [in] string aText
, [in] long nStartPos
,
379 [in] short nScriptType
);
381 /** Get the script type of the character at position <em>nPos</em>.
392 short getScriptType
( [in] string aText
, [in] long nPos
);
394 /** Traverses in Text from <em>nStartPos</em> to the beginning of
395 the specified character type.
401 The start index in aText.
404 The locale of the character preceding <em>nStartPos</em>.
410 The position where the character type starts
412 long beginOfCharBlock
( [in] string aText
, [in] long nStartPos
,
413 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
414 [in] short nCharType
);
416 /** Traverses in Text from <em>nStartPos</em> to the end of the
417 specified character type.
423 The start index in aText.
426 The locale of the character preceding <em>nStartPos</em>.
432 The position where the character type ends.
434 long endOfCharBlock
( [in] string aText
, [in] long nStartPos
,
435 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
436 [in] short nCharType
);
438 /** Traverses in Text from <em>nStartPos</em> to the next start of
439 the specified character type.
445 The start index in aText.
448 The locale of the character preceding <em>nStartPos</em>.
454 The position where the next character type starts.
456 long nextCharBlock
( [in] string aText
, [in] long nStartPos
,
457 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
458 [in] short nCharType
);
460 /** Traverses in Text from <em>nStartPos</em> to the previous start
461 of the specified character type.
467 The start index in aText.
470 The locale of the character preceding <em>nStartPos</em>.
476 The position where the previous character type starts.
478 long previousCharBlock
( [in] string aText
, [in] long nStartPos
,
479 [in] ::com
::sun
::star
::lang
::Locale aLocale
,
480 [in] short nCharType
);
487 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */