xref: /AOO41X/main/svl/inc/svl/srchitem.hxx (revision 39a19a47feaddbaa21988da8c7bf801707fd3d48)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFX_SRCHITEM_HXX
24 #define _SFX_SRCHITEM_HXX
25 
26 #include "sal/config.h"
27 #include "svl/svldllapi.h"
28 #include <com/sun/star/util/XSearchDescriptor.hpp>
29 #include <com/sun/star/util/SearchOptions.hpp>
30 #include <com/sun/star/util/SearchFlags.hpp>
31 #include <com/sun/star/i18n/TransliterationModules.hpp>
32 #include <unotools/configitem.hxx>
33 #include <rsc/rscsfx.hxx>
34 #include <tools/string.hxx>
35 #include <svl/poolitem.hxx>
36 #include <svl/srchdefs.hxx>
37 
38 // defines ---------------------------------------------------------------
39 
40 // commands
41 #define     SVX_SEARCHCMD_FIND          ((sal_uInt16)0)
42 #define     SVX_SEARCHCMD_FIND_ALL      ((sal_uInt16)1)
43 #define     SVX_SEARCHCMD_REPLACE       ((sal_uInt16)2)
44 #define     SVX_SEARCHCMD_REPLACE_ALL   ((sal_uInt16)3)
45 
46 // search flags
47 #define     SVX_SEARCHIN_FORMULA        ((sal_uInt16)0)
48 #define     SVX_SEARCHIN_VALUE          ((sal_uInt16)1)
49 #define     SVX_SEARCHIN_NOTE           ((sal_uInt16)2)
50 #define     SVX_SEARCHAPP_WRITER        ((sal_uInt16)0)
51 #define     SVX_SEARCHAPP_CALC          ((sal_uInt16)1)
52 #define     SVX_SEARCHAPP_DRAW          ((sal_uInt16)2)
53 #define     SVX_SEARCHAPP_BASE          ((sal_uInt16)3)
54 
55 // class SvxSearchItem ---------------------------------------------------
56 
57 class SVL_DLLPUBLIC SvxSearchItem :
58         public SfxPoolItem,
59         public utl::ConfigItem
60 {
61     com::sun::star::util::SearchOptions aSearchOpt;
62 
63     SfxStyleFamily  eFamily;            // Vorlagen-Familie
64 
65     sal_uInt16      nCommand;           // Kommando (Suchen, Alle Suchen, Ersetzen, Alle Ersetzen)
66 
67     // Calc-Spezifische Daten
68     sal_uInt16      nCellType;          // Suche in Formeln/Werten/Notizen
69     sal_uInt16      nAppFlag;           // Fuer welche Applikation ist der Dialog ueberhaupt
70     sal_Bool        bRowDirection;      // Suchrichtung Zeilenweise/Spaltenweise
71     sal_Bool        bAllTables;         // in alle Tabellen suchen
72 
73     // Writer-spezifisch
74     sal_Bool        bNotes;
75 
76     sal_Bool        bBackward;          // Suche Rueckwaerts
77     sal_Bool        bPattern;           // Suche nach Vorlagen
78     sal_Bool        bContent;           // Suche im Inhalt
79     sal_Bool        bAsianOptions;      // use asian options?
80 
81 public:
82     TYPEINFO();
83 
84     SvxSearchItem( const sal_uInt16 nId );
85     SvxSearchItem( const SvxSearchItem& rItem );
86     virtual ~SvxSearchItem();
87 
88     virtual sal_Bool             QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
89     virtual sal_Bool             PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
90     virtual int              operator == ( const SfxPoolItem& ) const;
91     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
92     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
93                                     SfxMapUnit eCoreMetric,
94                                     SfxMapUnit ePresMetric,
95                                     String &rText, const IntlWrapper * = 0 ) const;
96 
97     // ConfigItem
98     virtual void            Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
99     virtual void            Commit();
100 
GetCommand() const101             sal_uInt16      GetCommand() const { return nCommand; }
SetCommand(sal_uInt16 nNewCommand)102             void            SetCommand(sal_uInt16 nNewCommand) { nCommand = nNewCommand; }
103 
104     inline  const String    GetSearchString() const;
105     inline  void            SetSearchString(const String& rNewString);
106 
107     inline  const String    GetReplaceString() const;
108     inline  void            SetReplaceString(const String& rNewString);
109 
110     inline  sal_Bool        GetWordOnly() const;
111             void            SetWordOnly(sal_Bool bNewWordOnly);
112 
113     inline  sal_Bool        GetExact() const;
114             void            SetExact(sal_Bool bNewExact);
115 
GetBackward() const116             sal_Bool        GetBackward() const { return bBackward; }
SetBackward(sal_Bool bNewBackward)117             void            SetBackward(sal_Bool bNewBackward) { bBackward = bNewBackward; }
118 
119     inline sal_Bool         GetSelection() const;
120             void            SetSelection(sal_Bool bNewSelection);
121 
122     inline  sal_Bool        GetRegExp() const;
123             void            SetRegExp( sal_Bool bVal );
124 
GetPattern() const125             sal_Bool        GetPattern() const { return bPattern; }
SetPattern(sal_Bool bNewPattern)126             void            SetPattern(sal_Bool bNewPattern) { bPattern = bNewPattern; }
127 
IsContent() const128             sal_Bool        IsContent() const { return bContent; }
SetContent(sal_Bool bNew)129             void            SetContent( sal_Bool bNew ) { bContent = bNew; }
130 
GetFamily() const131             SfxStyleFamily  GetFamily() const { return eFamily; }
SetFamily(SfxStyleFamily eNewFamily)132             void            SetFamily( SfxStyleFamily eNewFamily )
133                                 { eFamily = eNewFamily; }
134 
GetRowDirection() const135             sal_Bool        GetRowDirection() const { return bRowDirection; }
SetRowDirection(sal_Bool bNewRowDirection)136             void            SetRowDirection(sal_Bool bNewRowDirection) { bRowDirection = bNewRowDirection; }
137 
IsAllTables() const138             sal_Bool        IsAllTables() const { return bAllTables; }
SetAllTables(sal_Bool bNew)139             void            SetAllTables(sal_Bool bNew) { bAllTables = bNew; }
140 
GetCellType() const141             sal_uInt16      GetCellType() const { return nCellType; }
SetCellType(sal_uInt16 nNewCellType)142             void            SetCellType(sal_uInt16 nNewCellType) { nCellType = nNewCellType; }
143 
GetNotes() const144             sal_Bool        GetNotes() const { return bNotes; }
SetNotes(sal_Bool bNew)145             void            SetNotes(sal_Bool bNew) { bNotes = bNew; }
146 
GetAppFlag() const147             sal_uInt16      GetAppFlag() const { return nAppFlag; }
SetAppFlag(sal_uInt16 nNewAppFlag)148             void            SetAppFlag(sal_uInt16 nNewAppFlag) { nAppFlag = nNewAppFlag; }
149 
150     inline  sal_Bool        IsLevenshtein() const;
151             void            SetLevenshtein( sal_Bool bVal );
152 
153     inline  sal_Bool        IsLEVRelaxed() const;
154             void            SetLEVRelaxed(sal_Bool bSet);
155 
156     inline  sal_uInt16      GetLEVOther() const;
157     inline  void            SetLEVOther(sal_uInt16 nSet);
158 
159     inline  sal_uInt16      GetLEVShorter() const;
160     inline  void            SetLEVShorter(sal_uInt16 nSet);
161 
162     inline  sal_uInt16      GetLEVLonger() const;
163     inline  void            SetLEVLonger(sal_uInt16 nSet);
164 
165             void            GetFromDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & rDescr );
166             void            SetToDescriptor( ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & rDescr );
167 
168     inline const com::sun::star::util::SearchOptions &
169                 GetSearchOptions() const;
170     inline void SetSearchOptions( const com::sun::star::util::SearchOptions &rOpt );
171 
172     inline  sal_Int32       GetTransliterationFlags() const;
173             void            SetTransliterationFlags( sal_Int32 nFlags );
174 
175     inline  sal_Bool        IsMatchFullHalfWidthForms() const;
176     void                    SetMatchFullHalfWidthForms( sal_Bool bVal );
177 
IsUseAsianOptions() const178     inline  sal_Bool        IsUseAsianOptions() const           { return bAsianOptions; }
SetUseAsianOptions(sal_Bool bVal)179     inline  void            SetUseAsianOptions( sal_Bool bVal ) { bAsianOptions = bVal; }
180 };
181 
GetSearchString() const182 const String SvxSearchItem::GetSearchString() const
183 {
184     return aSearchOpt.searchString;
185 }
186 
SetSearchString(const String & rNewString)187 void SvxSearchItem::SetSearchString(const String& rNewString)
188 {
189     aSearchOpt.searchString = rNewString;
190 }
191 
GetReplaceString() const192 const String SvxSearchItem::GetReplaceString() const
193 {
194     return aSearchOpt.replaceString;
195 }
196 
SetReplaceString(const String & rNewString)197 void SvxSearchItem::SetReplaceString(const String& rNewString)
198 {
199     aSearchOpt.replaceString = rNewString;
200 }
201 
GetWordOnly() const202 sal_Bool SvxSearchItem::GetWordOnly() const
203 {
204     return 0 != (aSearchOpt.searchFlag &
205                         com::sun::star::util::SearchFlags::NORM_WORD_ONLY);
206 }
207 
GetExact() const208 sal_Bool SvxSearchItem::GetExact() const
209 {
210     return 0 == (aSearchOpt.transliterateFlags &
211                         com::sun::star::i18n::TransliterationModules_IGNORE_CASE);
212 }
213 
GetSelection() const214 sal_Bool SvxSearchItem::GetSelection() const
215 {
216     return 0 != (aSearchOpt.searchFlag &
217                         com::sun::star::util::SearchFlags::REG_NOT_BEGINOFLINE);
218 }
219 
GetRegExp() const220 sal_Bool SvxSearchItem::GetRegExp() const
221 {
222     return aSearchOpt.algorithmType == com::sun::star::util::SearchAlgorithms_REGEXP ;
223 }
224 
IsLEVRelaxed() const225 sal_Bool SvxSearchItem::IsLEVRelaxed() const
226 {
227     return 0 != (aSearchOpt.searchFlag &
228                         com::sun::star::util::SearchFlags::LEV_RELAXED);
229 }
230 
GetLEVOther() const231 sal_uInt16 SvxSearchItem::GetLEVOther() const
232 {
233     return (sal_Int16) aSearchOpt.changedChars;
234 }
235 
SetLEVOther(sal_uInt16 nVal)236 void SvxSearchItem::SetLEVOther( sal_uInt16 nVal )
237 {
238     aSearchOpt.changedChars = nVal;
239 }
240 
GetLEVShorter() const241 sal_uInt16 SvxSearchItem::GetLEVShorter() const
242 {
243     return (sal_Int16) aSearchOpt.insertedChars;
244 }
245 
SetLEVShorter(sal_uInt16 nVal)246 void SvxSearchItem::SetLEVShorter( sal_uInt16 nVal )
247 {
248     aSearchOpt.insertedChars = nVal;
249 }
250 
GetLEVLonger() const251 sal_uInt16 SvxSearchItem::GetLEVLonger() const
252 {
253     return (sal_Int16) aSearchOpt.deletedChars;
254 }
255 
SetLEVLonger(sal_uInt16 nVal)256 void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal )
257 {
258     aSearchOpt.deletedChars = nVal;
259 }
260 
IsLevenshtein() const261 sal_Bool SvxSearchItem::IsLevenshtein() const
262 {
263     return aSearchOpt.algorithmType == com::sun::star::util::SearchAlgorithms_APPROXIMATE;
264 }
265 
GetSearchOptions() const266 const com::sun::star::util::SearchOptions & SvxSearchItem::GetSearchOptions() const
267 {
268     return aSearchOpt;
269 }
270 
SetSearchOptions(const com::sun::star::util::SearchOptions & rOpt)271 void SvxSearchItem::SetSearchOptions( const com::sun::star::util::SearchOptions &rOpt )
272 {
273     aSearchOpt = rOpt;
274 }
275 
GetTransliterationFlags() const276 sal_Int32 SvxSearchItem::GetTransliterationFlags() const
277 {
278     return aSearchOpt.transliterateFlags;
279 }
280 
IsMatchFullHalfWidthForms() const281 sal_Bool SvxSearchItem::IsMatchFullHalfWidthForms() const
282 {
283     return 0 != (aSearchOpt.transliterateFlags &
284                         com::sun::star::i18n::TransliterationModules_IGNORE_WIDTH);
285 }
286 
287 #endif
288 
289 
290