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
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svl.hxx"
26
27 // include ---------------------------------------------------------------
28
29 #include <svl/srchitem.hxx>
30
31 #include <unotools/searchopt.hxx>
32 #include <com/sun/star/util/XReplaceable.hpp>
33 #include <com/sun/star/util/XSearchable.hpp>
34 #include <com/sun/star/util/XSearchDescriptor.hpp>
35 #include <com/sun/star/util/XPropertyReplace.hpp>
36 #include <com/sun/star/util/XReplaceDescriptor.hpp>
37 #include <com/sun/star/lang/Locale.hpp>
38 #include <svl/memberid.hrc>
39 #include <i18npool/mslangid.hxx>
40
41 using namespace utl;
42 using namespace com::sun::star::beans;
43 using namespace com::sun::star::i18n;
44 using namespace com::sun::star::lang;
45 using namespace com::sun::star::uno;
46 using namespace com::sun::star::util;
47
48 #define CFG_ROOT_NODE "Office.Common/SearchOptions"
49
50 #define SRCH_PARAMS 11
51 #define SRCH_PARA_OPTIONS "Options"
52 #define SRCH_PARA_FAMILY "Family"
53 #define SRCH_PARA_COMMAND "Command"
54 #define SRCH_PARA_CELLTYPE "CellType"
55 #define SRCH_PARA_APPFLAG "AppFlag"
56 #define SRCH_PARA_ROWDIR "RowDirection"
57 #define SRCH_PARA_ALLTABLES "AllTables"
58 #define SRCH_PARA_BACKWARD "Backward"
59 #define SRCH_PARA_PATTERN "Pattern"
60 #define SRCH_PARA_CONTENT "Content"
61 #define SRCH_PARA_ASIANOPT "AsianOptions"
62
63 // STATIC DATA -----------------------------------------------------------
64
65 TYPEINIT1_FACTORY(SvxSearchItem, SfxPoolItem, new SvxSearchItem(0));
66
67 // -----------------------------------------------------------------------
68
lcl_GetNotifyNames()69 static Sequence< ::rtl::OUString > lcl_GetNotifyNames()
70 {
71 // names of transliteration relevant properties
72 static const char* aTranslitNames[] =
73 {
74 "IsMatchCase", // 0
75 "Japanese/IsMatchFullHalfWidthForms", // 1
76 "Japanese/IsMatchHiraganaKatakana", // 2
77 "Japanese/IsMatchContractions", // 3
78 "Japanese/IsMatchMinusDashCho-on", // 4
79 "Japanese/IsMatchRepeatCharMarks", // 5
80 "Japanese/IsMatchVariantFormKanji", // 6
81 "Japanese/IsMatchOldKanaForms", // 7
82 "Japanese/IsMatch_DiZi_DuZu", // 8
83 "Japanese/IsMatch_BaVa_HaFa", // 9
84 "Japanese/IsMatch_TsiThiChi_DhiZi", // 10
85 "Japanese/IsMatch_HyuIyu_ByuVyu", // 11
86 "Japanese/IsMatch_SeShe_ZeJe", // 12
87 "Japanese/IsMatch_IaIya", // 13
88 "Japanese/IsMatch_KiKu", // 14
89 "Japanese/IsIgnorePunctuation", // 15
90 "Japanese/IsIgnoreWhitespace", // 16
91 "Japanese/IsIgnoreProlongedSoundMark", // 17
92 "Japanese/IsIgnoreMiddleDot" // 18
93 };
94
95 const int nCount = sizeof( aTranslitNames ) / sizeof( aTranslitNames[0] );
96 Sequence< ::rtl::OUString > aNames( nCount );
97 ::rtl::OUString* pNames = aNames.getArray();
98 for (sal_Int32 i = 0; i < nCount; ++i)
99 pNames[i] = ::rtl::OUString::createFromAscii( aTranslitNames[i] );
100
101 return aNames;
102 }
103
104 // -----------------------------------------------------------------------
SvxSearchItem(const sal_uInt16 nId)105 SvxSearchItem::SvxSearchItem( const sal_uInt16 nId ) :
106
107 SfxPoolItem( nId ),
108 ConfigItem( ::rtl::OUString::createFromAscii( CFG_ROOT_NODE ) ),
109
110 aSearchOpt ( SearchAlgorithms_ABSOLUTE,
111 SearchFlags::LEV_RELAXED,
112 ::rtl::OUString(),
113 ::rtl::OUString(),
114 Locale(),
115 2, 2, 2,
116 TransliterationModules_IGNORE_CASE ),
117 eFamily ( SFX_STYLE_FAMILY_PARA ),
118 nCommand ( 0 ),
119 nCellType ( SVX_SEARCHIN_FORMULA ),
120 nAppFlag ( SVX_SEARCHAPP_WRITER ),
121 bRowDirection ( sal_True ),
122 bAllTables ( sal_False ),
123 bNotes ( sal_False),
124 bBackward ( sal_False ),
125 bPattern ( sal_False ),
126 bContent ( sal_False ),
127 bAsianOptions ( sal_False )
128 {
129 EnableNotification( lcl_GetNotifyNames() );
130
131 SvtSearchOptions aOpt;
132
133 bBackward = aOpt.IsBackwards();
134 bAsianOptions = aOpt.IsUseAsianOptions();
135 bNotes = aOpt.IsNotes();
136
137 if (aOpt.IsUseRegularExpression())
138 aSearchOpt.algorithmType = SearchAlgorithms_REGEXP;
139 if (aOpt.IsSimilaritySearch())
140 aSearchOpt.algorithmType = SearchAlgorithms_APPROXIMATE;
141 if (aOpt.IsWholeWordsOnly())
142 aSearchOpt.searchFlag |= SearchFlags::NORM_WORD_ONLY;
143
144 sal_Int32 &rFlags = aSearchOpt.transliterateFlags;
145
146 if (!aOpt.IsMatchCase())
147 rFlags |= TransliterationModules_IGNORE_CASE;
148 if ( aOpt.IsMatchFullHalfWidthForms())
149 rFlags |= TransliterationModules_IGNORE_WIDTH;
150 if ( bAsianOptions )
151 {
152 if ( aOpt.IsMatchHiraganaKatakana())
153 rFlags |= TransliterationModules_IGNORE_KANA;
154 if ( aOpt.IsMatchContractions())
155 rFlags |= TransliterationModules_ignoreSize_ja_JP;
156 if ( aOpt.IsMatchMinusDashChoon())
157 rFlags |= TransliterationModules_ignoreMinusSign_ja_JP;
158 if ( aOpt.IsMatchRepeatCharMarks())
159 rFlags |= TransliterationModules_ignoreIterationMark_ja_JP;
160 if ( aOpt.IsMatchVariantFormKanji())
161 rFlags |= TransliterationModules_ignoreTraditionalKanji_ja_JP;
162 if ( aOpt.IsMatchOldKanaForms())
163 rFlags |= TransliterationModules_ignoreTraditionalKana_ja_JP;
164 if ( aOpt.IsMatchDiziDuzu())
165 rFlags |= TransliterationModules_ignoreZiZu_ja_JP;
166 if ( aOpt.IsMatchBavaHafa())
167 rFlags |= TransliterationModules_ignoreBaFa_ja_JP;
168 if ( aOpt.IsMatchTsithichiDhizi())
169 rFlags |= TransliterationModules_ignoreTiJi_ja_JP;
170 if ( aOpt.IsMatchHyuiyuByuvyu())
171 rFlags |= TransliterationModules_ignoreHyuByu_ja_JP;
172 if ( aOpt.IsMatchSesheZeje())
173 rFlags |= TransliterationModules_ignoreSeZe_ja_JP;
174 if ( aOpt.IsMatchIaiya())
175 rFlags |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP;
176 if ( aOpt.IsMatchKiku())
177 rFlags |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP;
178 if ( aOpt.IsIgnorePunctuation())
179 rFlags |= TransliterationModules_ignoreSeparator_ja_JP;
180 if ( aOpt.IsIgnoreWhitespace())
181 rFlags |= TransliterationModules_ignoreSpace_ja_JP;
182 if ( aOpt.IsIgnoreProlongedSoundMark())
183 rFlags |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
184 if ( aOpt.IsIgnoreMiddleDot())
185 rFlags |= TransliterationModules_ignoreMiddleDot_ja_JP;
186 }
187
188 }
189
190 // -----------------------------------------------------------------------
191
SvxSearchItem(const SvxSearchItem & rItem)192 SvxSearchItem::SvxSearchItem( const SvxSearchItem& rItem ) :
193
194 SfxPoolItem ( rItem ),
195 ConfigItem( ::rtl::OUString::createFromAscii( CFG_ROOT_NODE ) ),
196
197 aSearchOpt ( rItem.aSearchOpt ),
198 eFamily ( rItem.eFamily ),
199 nCommand ( rItem.nCommand ),
200 nCellType ( rItem.nCellType ),
201 nAppFlag ( rItem.nAppFlag ),
202 bRowDirection ( rItem.bRowDirection ),
203 bAllTables ( rItem.bAllTables ),
204 bNotes ( rItem.bNotes),
205 bBackward ( rItem.bBackward ),
206 bPattern ( rItem.bPattern ),
207 bContent ( rItem.bContent ),
208 bAsianOptions ( rItem.bAsianOptions )
209 {
210 EnableNotification( lcl_GetNotifyNames() );
211 }
212
213 // -----------------------------------------------------------------------
214
~SvxSearchItem()215 SvxSearchItem::~SvxSearchItem()
216 {
217 }
218
219 // -----------------------------------------------------------------------
Clone(SfxItemPool *) const220 SfxPoolItem* SvxSearchItem::Clone( SfxItemPool *) const
221 {
222 return new SvxSearchItem(*this);
223 }
224
225 // -----------------------------------------------------------------------
226
227 //! used below
operator ==(const SearchOptions & rItem1,const SearchOptions & rItem2)228 static sal_Bool operator == ( const SearchOptions& rItem1, const SearchOptions& rItem2 )
229 {
230 return rItem1.algorithmType == rItem2.algorithmType &&
231 rItem1.searchFlag == rItem2.searchFlag &&
232 rItem1.searchString == rItem2.searchString &&
233 rItem1.replaceString == rItem2.replaceString &&
234 //rItem1.Locale == rItem2.Locale &&
235 rItem1.changedChars == rItem2.changedChars &&
236 rItem1.deletedChars == rItem2.deletedChars &&
237 rItem1.insertedChars == rItem2.insertedChars &&
238 rItem1.transliterateFlags == rItem2.transliterateFlags;
239 }
240
241
operator ==(const SfxPoolItem & rItem) const242 int SvxSearchItem::operator==( const SfxPoolItem& rItem ) const
243 {
244 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
245 const SvxSearchItem &rSItem = (SvxSearchItem &) rItem;
246 return ( nCommand == rSItem.nCommand ) &&
247 ( bBackward == rSItem.bBackward ) &&
248 ( bPattern == rSItem.bPattern ) &&
249 ( bContent == rSItem.bContent ) &&
250 ( eFamily == rSItem.eFamily ) &&
251 ( bRowDirection == rSItem.bRowDirection ) &&
252 ( bAllTables == rSItem.bAllTables ) &&
253 ( nCellType == rSItem.nCellType ) &&
254 ( nAppFlag == rSItem.nAppFlag ) &&
255 ( bAsianOptions == rSItem.bAsianOptions ) &&
256 ( aSearchOpt == rSItem.aSearchOpt ) &&
257 ( bNotes == rSItem.bNotes );
258 }
259
260
261 //------------------------------------------------------------------------
262
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString &,const IntlWrapper *) const263 SfxItemPresentation SvxSearchItem::GetPresentation
264 (
265 SfxItemPresentation ,
266 SfxMapUnit ,
267 SfxMapUnit ,
268 XubString& ,
269 const IntlWrapper *
270 ) const
271 {
272 return SFX_ITEM_PRESENTATION_NONE;
273 }
274
GetFromDescriptor(const::com::sun::star::uno::Reference<::com::sun::star::util::XSearchDescriptor> & rDescr)275 void SvxSearchItem::GetFromDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& rDescr )
276 {
277 SetSearchString( rDescr->getSearchString() );
278 ::com::sun::star::uno::Any aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchWords") ) );
279 sal_Bool bTemp = false;
280 aAny >>= bTemp ;
281 SetWordOnly( bTemp );
282 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchCaseSensitive") ) );
283 aAny >>= bTemp ;
284 SetExact( bTemp );
285 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchBackwards") ) );
286 aAny >>= bTemp ;
287 SetBackward( bTemp );
288 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchInSelection") ) );
289 aAny >>= bTemp ;
290 SetSelection( bTemp );
291 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchRegularExpression") ) );
292 aAny >>= bTemp ;
293 SetRegExp( bTemp );
294 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ) );
295 aAny >>= bTemp ;
296 SetLevenshtein( bTemp );
297 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityRelax") ) );
298 aAny >>= bTemp ;
299 SetLEVRelaxed( bTemp );
300 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityExchange") ) );
301 sal_Int16 nTemp = 0;
302 aAny >>= nTemp ;
303 SetLEVOther( nTemp );
304 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityRemove") ) );
305 aAny >>= nTemp ;
306 SetLEVShorter( nTemp );
307 aAny = rDescr->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityAdd") ) );
308 aAny >>= nTemp ;
309 SetLEVLonger( nTemp );
310 }
311
SetToDescriptor(::com::sun::star::uno::Reference<::com::sun::star::util::XSearchDescriptor> & rDescr)312 void SvxSearchItem::SetToDescriptor( ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & rDescr )
313 {
314 rDescr->setSearchString( GetSearchString() );
315 ::com::sun::star::uno::Any aAny;
316 aAny <<= GetWordOnly() ;
317 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchWords") ), aAny );
318 aAny <<= GetExact() ;
319 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchCaseSensitive") ), aAny );
320 aAny <<= GetBackward() ;
321 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchBackwards") ), aAny );
322 aAny <<= GetSelection() ;
323 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchInSelection") ), aAny );
324 aAny <<= GetRegExp() ;
325 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchRegularExpression") ), aAny );
326 aAny <<= IsLevenshtein() ;
327 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ), aAny );
328 aAny <<= IsLEVRelaxed() ;
329 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityRelax") ), aAny );
330 aAny <<= GetLEVOther() ;
331 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityExchange") ), aAny );
332 aAny <<= GetLEVShorter() ;
333 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityRemove") ), aAny );
334 aAny <<= GetLEVLonger() ;
335 rDescr->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityAdd") ), aAny );
336 }
337
338
Notify(const Sequence<::rtl::OUString> &)339 void SvxSearchItem::Notify( const Sequence< ::rtl::OUString > & )
340 {
341 // applies transliteration changes in the configuration database
342 // to the current SvxSearchItem
343 SetTransliterationFlags( SvtSearchOptions().GetTransliterationFlags() );
344 }
345
Commit()346 void SvxSearchItem::Commit()
347 {
348 }
349
SetMatchFullHalfWidthForms(sal_Bool bVal)350 void SvxSearchItem::SetMatchFullHalfWidthForms( sal_Bool bVal )
351 {
352 if (bVal)
353 aSearchOpt.transliterateFlags |= TransliterationModules_IGNORE_WIDTH;
354 else
355 aSearchOpt.transliterateFlags &= ~TransliterationModules_IGNORE_WIDTH;
356 }
357
358
SetWordOnly(sal_Bool bVal)359 void SvxSearchItem::SetWordOnly( sal_Bool bVal )
360 {
361 if (bVal)
362 aSearchOpt.searchFlag |= SearchFlags::NORM_WORD_ONLY;
363 else
364 aSearchOpt.searchFlag &= ~SearchFlags::NORM_WORD_ONLY;
365 }
366
367
SetExact(sal_Bool bVal)368 void SvxSearchItem::SetExact( sal_Bool bVal )
369 {
370 if (!bVal)
371 aSearchOpt.transliterateFlags |= TransliterationModules_IGNORE_CASE;
372 else
373 aSearchOpt.transliterateFlags &= ~TransliterationModules_IGNORE_CASE;
374 }
375
376
SetSelection(sal_Bool bVal)377 void SvxSearchItem::SetSelection( sal_Bool bVal )
378 {
379 if (bVal)
380 {
381 aSearchOpt.searchFlag |= (SearchFlags::REG_NOT_BEGINOFLINE |
382 SearchFlags::REG_NOT_ENDOFLINE);
383 }
384 else
385 {
386 aSearchOpt.searchFlag &= ~(SearchFlags::REG_NOT_BEGINOFLINE |
387 SearchFlags::REG_NOT_ENDOFLINE);
388 }
389 }
390
391
SetRegExp(sal_Bool bVal)392 void SvxSearchItem::SetRegExp( sal_Bool bVal )
393 {
394 if ( bVal )
395 aSearchOpt.algorithmType = SearchAlgorithms_REGEXP;
396 else if ( SearchAlgorithms_REGEXP == aSearchOpt.algorithmType )
397 aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
398 }
399
400
SetLEVRelaxed(sal_Bool bVal)401 void SvxSearchItem::SetLEVRelaxed( sal_Bool bVal )
402 {
403 if (bVal)
404 aSearchOpt.searchFlag |= SearchFlags::LEV_RELAXED;
405 else
406 aSearchOpt.searchFlag &= ~SearchFlags::LEV_RELAXED;
407 }
408
409
SetLevenshtein(sal_Bool bVal)410 void SvxSearchItem::SetLevenshtein( sal_Bool bVal )
411 {
412 if ( bVal )
413 aSearchOpt.algorithmType = SearchAlgorithms_APPROXIMATE;
414 else if ( SearchAlgorithms_APPROXIMATE == aSearchOpt.algorithmType )
415 aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
416 }
417
418
SetTransliterationFlags(sal_Int32 nFlags)419 void SvxSearchItem::SetTransliterationFlags( sal_Int32 nFlags )
420 {
421 aSearchOpt.transliterateFlags = nFlags;
422 }
423
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId) const424 sal_Bool SvxSearchItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
425 {
426 nMemberId &= ~CONVERT_TWIPS;
427 switch ( nMemberId )
428 {
429 case 0 :
430 {
431 Sequence< PropertyValue > aSeq( SRCH_PARAMS );
432 aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_OPTIONS ) );
433 aSeq[0].Value <<= aSearchOpt;
434 aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_FAMILY ));
435 aSeq[1].Value <<= sal_Int16( eFamily );
436 aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_COMMAND ));
437 aSeq[2].Value <<= nCommand;
438 aSeq[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_CELLTYPE ));
439 aSeq[3].Value <<= nCellType;
440 aSeq[4].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_APPFLAG ));
441 aSeq[4].Value <<= nAppFlag;
442 aSeq[5].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_ROWDIR ));
443 aSeq[5].Value <<= bRowDirection;
444 aSeq[6].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_ALLTABLES ));
445 aSeq[6].Value <<= bAllTables;
446 aSeq[7].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_BACKWARD ));
447 aSeq[7].Value <<= bBackward;
448 aSeq[8].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_PATTERN ));
449 aSeq[8].Value <<= bPattern;
450 aSeq[9].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_CONTENT ));
451 aSeq[9].Value <<= bContent;
452 aSeq[10].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_ASIANOPT ));
453 aSeq[10].Value <<= bAsianOptions;
454 rVal <<= aSeq;
455 }
456 break;
457 case MID_SEARCH_COMMAND:
458 rVal <<= (sal_Int16) nCommand; break;
459 case MID_SEARCH_STYLEFAMILY:
460 rVal <<= (sal_Int16) eFamily; break;
461 case MID_SEARCH_CELLTYPE:
462 rVal <<= (sal_Int32) nCellType; break;
463 case MID_SEARCH_ROWDIRECTION:
464 rVal <<= (sal_Bool) bRowDirection; break;
465 case MID_SEARCH_ALLTABLES:
466 rVal <<= (sal_Bool) bAllTables; break;
467 case MID_SEARCH_BACKWARD:
468 rVal <<= (sal_Bool) bBackward; break;
469 case MID_SEARCH_PATTERN:
470 rVal <<= (sal_Bool) bPattern; break;
471 case MID_SEARCH_CONTENT:
472 rVal <<= (sal_Bool) bContent; break;
473 case MID_SEARCH_ASIANOPTIONS:
474 rVal <<= (sal_Bool) bAsianOptions; break;
475 case MID_SEARCH_ALGORITHMTYPE:
476 rVal <<= (sal_Int16) aSearchOpt.algorithmType; break;
477 case MID_SEARCH_FLAGS:
478 rVal <<= aSearchOpt.searchFlag; break;
479 case MID_SEARCH_SEARCHSTRING:
480 rVal <<= aSearchOpt.searchString; break;
481 case MID_SEARCH_REPLACESTRING:
482 rVal <<= aSearchOpt.replaceString; break;
483 case MID_SEARCH_CHANGEDCHARS:
484 rVal <<= aSearchOpt.changedChars; break;
485 case MID_SEARCH_DELETEDCHARS:
486 rVal <<= aSearchOpt.deletedChars; break;
487 case MID_SEARCH_INSERTEDCHARS:
488 rVal <<= aSearchOpt.insertedChars; break;
489 case MID_SEARCH_TRANSLITERATEFLAGS:
490 rVal <<= aSearchOpt.transliterateFlags; break;
491 case MID_SEARCH_LOCALE:
492 {
493 sal_Int16 nLocale;
494 if (aSearchOpt.Locale.Language.getLength() || aSearchOpt.Locale.Country.getLength() )
495 nLocale = MsLangId::convertLocaleToLanguage( aSearchOpt.Locale );
496 else
497 nLocale = LANGUAGE_NONE;
498 rVal <<= nLocale;
499 break;
500 }
501
502 default:
503 DBG_ERRORFILE( "SvxSearchItem::QueryValue(): Unknown MemberId" );
504 return sal_False;
505 }
506
507 return sal_True;
508 }
509
510 // -----------------------------------------------------------------------
511
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId)512 sal_Bool SvxSearchItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
513 {
514 nMemberId &= ~CONVERT_TWIPS;
515 sal_Bool bRet = sal_False;
516 sal_Int32 nInt = 0;
517 switch ( nMemberId )
518 {
519 case 0 :
520 {
521 Sequence< PropertyValue > aSeq;
522 if ( ( rVal >>= aSeq ) && ( aSeq.getLength() == SRCH_PARAMS ) )
523 {
524 sal_Int16 nConvertedCount( 0 );
525 for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
526 {
527 if ( aSeq[i].Name.equalsAscii( SRCH_PARA_OPTIONS ) )
528 {
529 if ( ( aSeq[i].Value >>= aSearchOpt ) == sal_True )
530 ++nConvertedCount;
531 }
532 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_FAMILY ) )
533 {
534 sal_uInt16 nTemp( 0 );
535 if ( ( aSeq[i].Value >>= nTemp ) == sal_True )
536 {
537 eFamily = SfxStyleFamily( nTemp );
538 ++nConvertedCount;
539 }
540 }
541 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_COMMAND ) )
542 {
543 if ( ( aSeq[i].Value >>= nCommand ) == sal_True )
544 ++nConvertedCount;
545 }
546 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_CELLTYPE ) )
547 {
548 if ( ( aSeq[i].Value >>= nCellType ) == sal_True )
549 ++nConvertedCount;
550 }
551 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_APPFLAG ) )
552 {
553 if ( ( aSeq[i].Value >>= nAppFlag ) == sal_True )
554 ++nConvertedCount;
555 }
556 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_ROWDIR ) )
557 {
558 if ( ( aSeq[i].Value >>= bRowDirection ) == sal_True )
559 ++nConvertedCount;
560 }
561 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_ALLTABLES ) )
562 {
563 if ( ( aSeq[i].Value >>= bAllTables ) == sal_True )
564 ++nConvertedCount;
565 }
566 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_BACKWARD ) )
567 {
568 if ( ( aSeq[i].Value >>= bBackward ) == sal_True )
569 ++nConvertedCount;
570 }
571 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_PATTERN ) )
572 {
573 if ( ( aSeq[i].Value >>= bPattern ) == sal_True )
574 ++nConvertedCount;
575 }
576 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_CONTENT ) )
577 {
578 if ( ( aSeq[i].Value >>= bContent ) == sal_True )
579 ++nConvertedCount;
580 }
581 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_ASIANOPT ) )
582 {
583 if ( ( aSeq[i].Value >>= bAsianOptions ) == sal_True )
584 ++nConvertedCount;
585 }
586 }
587
588 bRet = ( nConvertedCount == SRCH_PARAMS );
589 }
590 break;
591 }
592 case MID_SEARCH_COMMAND:
593 bRet = (rVal >>= nInt); nCommand = (sal_uInt16) nInt; break;
594 case MID_SEARCH_STYLEFAMILY:
595 bRet = (rVal >>= nInt); eFamily = (SfxStyleFamily) (sal_Int16) nInt; break;
596 case MID_SEARCH_CELLTYPE:
597 bRet = (rVal >>= nInt); nCellType = (sal_uInt16) nInt; break;
598 case MID_SEARCH_ROWDIRECTION:
599 bRet = (rVal >>= bRowDirection); break;
600 case MID_SEARCH_ALLTABLES:
601 bRet = (rVal >>= bAllTables); break;
602 case MID_SEARCH_BACKWARD:
603 bRet = (rVal >>= bBackward); break;
604 case MID_SEARCH_PATTERN:
605 bRet = (rVal >>= bPattern); break;
606 case MID_SEARCH_CONTENT:
607 bRet = (rVal >>= bContent); break;
608 case MID_SEARCH_ASIANOPTIONS:
609 bRet = (rVal >>= bAsianOptions); break;
610 case MID_SEARCH_ALGORITHMTYPE:
611 bRet = (rVal >>= nInt); aSearchOpt.algorithmType = (SearchAlgorithms)(sal_Int16)nInt; break;
612 case MID_SEARCH_FLAGS:
613 bRet = (rVal >>= aSearchOpt.searchFlag); break;
614 case MID_SEARCH_SEARCHSTRING:
615 bRet = (rVal >>= aSearchOpt.searchString); break;
616 case MID_SEARCH_REPLACESTRING:
617 bRet = (rVal >>= aSearchOpt.replaceString); break;
618 case MID_SEARCH_CHANGEDCHARS:
619 bRet = (rVal >>= aSearchOpt.changedChars); break;
620 case MID_SEARCH_DELETEDCHARS:
621 bRet = (rVal >>= aSearchOpt.deletedChars); break;
622 case MID_SEARCH_INSERTEDCHARS:
623 bRet = (rVal >>= aSearchOpt.insertedChars); break;
624 case MID_SEARCH_TRANSLITERATEFLAGS:
625 bRet = (rVal >>= aSearchOpt.transliterateFlags); break;
626 case MID_SEARCH_LOCALE:
627 {
628 bRet = (rVal >>= nInt);
629 if ( bRet )
630 {
631 if ( nInt == LANGUAGE_NONE )
632 {
633 aSearchOpt.Locale = ::com::sun::star::lang::Locale();
634 }
635 else
636 {
637 MsLangId::convertLanguageToLocale( (sal_Int16) nInt, aSearchOpt.Locale );
638 }
639 }
640 break;
641 }
642 default:
643 DBG_ERROR( "Unknown MemberId" );
644 }
645
646 return bRet;
647 }
648
649
650