1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef __com_sun_star_lang_XTextSearch_idl__
29 #define __com_sun_star_lang_XTextSearch_idl__
32 #include
<com
/sun
/star
/lang
/Locale.idl
>
33 #include
<com
/sun
/star
/uno
/XInterface.idl
>
34 //#include <com/sun/star/lang/CascadeTransliterator.idl>
36 //=============================================================================
38 module com
{ module sun
{ module star
{ module util
{
40 //=============================================================================
43 published
enum SearchAlgorithms
{
44 ABSOLUTE
, // "normal" a kind of Boyer-Moore
45 REGEXP
, // regular expression
46 APPROXIMATE
// Leveinstein distance
49 published constants SearchFlags
51 //Flag for all search methods
54 @deprecated : the constant ALL_IGNORE_CASE is never supported -
55 it must use the transliteration flags of
57 <p>@see TransliterationModulesNew
59 const long ALL_IGNORE_CASE
= 0x00000001;
61 /// Flag for normal (Boyer-Moore) search
62 const long NORM_WORD_ONLY
= 0x00000010;
64 /// Flag for "regular expression" search / interpret as extended regular expression
65 const long REG_EXTENDED
= 0x00000100;
66 /** Flag for "regular expression" search / No replace, i.e., avoid sub regular
67 expresions, return true/false to match
69 <!-- JRH: Check this for sense of the expression. -->
71 const long REG_NOSUB
= 0x00000200;
73 /// Flag for "regular expression" search / Special new line treatment
74 const long REG_NEWLINE
= 0x00000400;
76 /** A NEWLINE character in string will not be matched by a period outside bracket
77 expression or by any form of a non matching list.
78 A circumflex (^) in pattern when used to specify expression anchoring
79 <!-- JRH: anhoring to anchoring. -->
80 will match the zero length string immediately after a newline in string,
81 regardless of the setting of REG_NOTBOL
82 A dollar-sign ($) in pattern when used to specify expression anchoring,
83 will match zero-length string immediately before a new line in string,
84 regardless of the setting of REG_NOTEOL
86 const long REG_NOT_BEGINOFLINE
= 0x00000800;
88 /** The first character in the string is not the beginning of the line therefore ^ will not
89 match with first character of the string
91 const long REG_NOT_ENDOFLINE
= 0x00001000;
94 /// Flags for "Weight Levenshtein-Distance" search
95 const long LEV_RELAXED
= 0x00010000;
99 published
struct SearchOptions
{
100 //-------------------------------------------------------------------------
101 /// search type, can be: ABSOLUTE, REGEXP, APPROXIMATE
102 SearchAlgorithms algorithmType
;
104 /** some flags - can be mixed
114 (is for optional replacing - SearchOption is only the data container for it)*/
115 string replaceString
;
117 /// this is the language for case insensitive search
118 ::com
::sun
::star
::lang
::Locale Locale
;
120 /** this many characters can be different between the found and search word
121 in a "Weight Levenshtein-Distance"*/
124 /** this many characters can be missed in the found word
125 in a "Weight Levenshtein-Distance"*/
128 /// this many characters can be additional in the found word in a "Weight Levenshtein-Distance"
131 /** asian flags for the transliteration. Same meaning as the enum of TransliteratorModule
133 @see com/sun/star/i18n/XTransliteration.idl
135 long transliterateFlags
;
139 published
struct SearchResult
{
140 //-------------------------------------------------------------------------
141 /** Number of subexpressions,
142 if it is 0, then no match found; this value is 1 for ABSOLUTE and APPROXIMATE match.
143 The start and endOffset are always dependent on the search direction.
145 if you search "X" in the text "-X-" the offset are:
146 for forward: start = 1, end = 2
147 for backward: start = 2, end = 1
148 Forward, the startOffset is inclusive, the endOffset exclusive.
149 Backward, the startOffset is exclusive, the endOffset inclusive.
151 For regular expressions it can be greater than 1.
152 If the value is 1, startoffset[0] and endoffset[0] points to the matching sub string
153 if value is > 1, still startoffset[0] and endoffset[0] points to the matching substring for whole regular expression
154 startoffset[i] and endoffset[i] points to the matching substring of i th matching substring.
156 long subRegExpressions
;
157 sequence
<long> startOffset
; // inclusive
158 sequence
<long> endOffset
; // exclusive
163 /** enables an object to search in its content.
165 published
interface XTextSearch
: com
::sun
::star
::uno
::XInterface
167 //-------------------------------------------------------------------------
168 /** set the options for the forward or backward search.
171 void setOptions
([in] SearchOptions options
);
172 //-------------------------------------------------------------------------
173 /** search forward in the searchStr, starts at startPos and ends by endpos.
174 The result is returned in the SearchResult.
177 SearchResult searchForward
([in] string searchStr
, [in] long startPos
, [in] long endPos
);
178 //-------------------------------------------------------------------------
179 /** search backward in the searchStr, starts at startPos and ends by endpos.
180 The endpos must be lower then the startpos, because the function searches backward!
181 The result is returned in the SearchResult.
184 SearchResult searchBackward
([in] string searchStr
, [in] long startPos
, [in] long endPos
);
187 //=============================================================================