merge the formfield patch from ooo-build
[ooovba.git] / sfx2 / source / control / srchitem.cxx
blob1af26b9c3834512dc224198a2637272e425183c5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: srchitem.cxx,v $
10 * $Revision: 1.24 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 // include ---------------------------------------------------------------
36 #ifndef __SBX_SBXVARIABLE_HXX
37 #include <basic/sbxvar.hxx>
38 #endif
39 #include <svtools/searchopt.hxx>
40 #include <com/sun/star/util/XReplaceable.hpp>
41 #include <com/sun/star/util/XSearchable.hpp>
42 #include <com/sun/star/util/XSearchDescriptor.hpp>
43 #include <com/sun/star/util/XPropertyReplace.hpp>
44 #include <com/sun/star/util/XReplaceDescriptor.hpp>
45 #include <com/sun/star/lang/Locale.hpp>
47 #include <svtools/memberid.hrc>
48 #include <i18npool/mslangid.hxx>
50 #ifndef GCC
51 #endif
53 #define _SVX_SRCHITEM_CXX
55 #include <sfx2/sfxsids.hrc>
56 #define ITEMID_SEARCH SID_SEARCH_ITEM
57 #include <sfx2/srchitem.hxx>
59 #include <sfx2/sfxuno.hxx>
61 using namespace utl;
62 using namespace com::sun::star::beans;
63 using namespace com::sun::star::i18n;
64 using namespace com::sun::star::lang;
65 using namespace com::sun::star::uno;
66 using namespace com::sun::star::util;
68 #define CFG_ROOT_NODE "Office.Common/SearchOptions"
70 #define SRCH_PARAMS 11
71 #define SRCH_PARA_OPTIONS "Options"
72 #define SRCH_PARA_FAMILY "Family"
73 #define SRCH_PARA_COMMAND "Command"
74 #define SRCH_PARA_CELLTYPE "CellType"
75 #define SRCH_PARA_APPFLAG "AppFlag"
76 #define SRCH_PARA_ROWDIR "RowDirection"
77 #define SRCH_PARA_ALLTABLES "AllTables"
78 #define SRCH_PARA_BACKWARD "Backward"
79 #define SRCH_PARA_PATTERN "Pattern"
80 #define SRCH_PARA_CONTENT "Content"
81 #define SRCH_PARA_ASIANOPT "AsianOptions"
83 // STATIC DATA -----------------------------------------------------------
85 TYPEINIT1_FACTORY(SvxSearchItem, SfxPoolItem, new SvxSearchItem(0));
87 // -----------------------------------------------------------------------
89 static Sequence< ::rtl::OUString > lcl_GetNotifyNames()
91 // names of transliteration relevant properties
92 static const char* aTranslitNames[] =
94 "IsMatchCase", // 0
95 "Japanese/IsMatchFullHalfWidthForms", // 1
96 "Japanese/IsMatchHiraganaKatakana", // 2
97 "Japanese/IsMatchContractions", // 3
98 "Japanese/IsMatchMinusDashCho-on", // 4
99 "Japanese/IsMatchRepeatCharMarks", // 5
100 "Japanese/IsMatchVariantFormKanji", // 6
101 "Japanese/IsMatchOldKanaForms", // 7
102 "Japanese/IsMatch_DiZi_DuZu", // 8
103 "Japanese/IsMatch_BaVa_HaFa", // 9
104 "Japanese/IsMatch_TsiThiChi_DhiZi", // 10
105 "Japanese/IsMatch_HyuIyu_ByuVyu", // 11
106 "Japanese/IsMatch_SeShe_ZeJe", // 12
107 "Japanese/IsMatch_IaIya", // 13
108 "Japanese/IsMatch_KiKu", // 14
109 "Japanese/IsIgnorePunctuation", // 15
110 "Japanese/IsIgnoreWhitespace", // 16
111 "Japanese/IsIgnoreProlongedSoundMark", // 17
112 "Japanese/IsIgnoreMiddleDot" // 18
115 const int nCount = sizeof( aTranslitNames ) / sizeof( aTranslitNames[0] );
116 Sequence< ::rtl::OUString > aNames( nCount );
117 ::rtl::OUString* pNames = aNames.getArray();
118 for (INT32 i = 0; i < nCount; ++i)
119 pNames[i] = ::rtl::OUString::createFromAscii( aTranslitNames[i] );
121 return aNames;
124 // -----------------------------------------------------------------------
125 SvxSearchItem::SvxSearchItem( const sal_uInt16 nId ) :
127 SfxPoolItem( nId ),
128 ConfigItem( ::rtl::OUString::createFromAscii( CFG_ROOT_NODE ) ),
130 aSearchOpt ( SearchAlgorithms_ABSOLUTE,
131 SearchFlags::LEV_RELAXED,
132 ::rtl::OUString(),
133 ::rtl::OUString(),
134 Locale(),
135 2, 2, 2,
136 TransliterationModules_IGNORE_CASE ),
137 eFamily ( SFX_STYLE_FAMILY_PARA ),
138 nCommand ( 0 ),
139 nCellType ( SVX_SEARCHIN_FORMULA ),
140 nAppFlag ( SVX_SEARCHAPP_WRITER ),
141 bRowDirection ( sal_True ),
142 bAllTables ( sal_False ),
143 bNotes ( sal_False),
144 bBackward ( sal_False ),
145 bPattern ( sal_False ),
146 bContent ( sal_False ),
147 bAsianOptions ( FALSE )
149 EnableNotification( lcl_GetNotifyNames() );
151 SvtSearchOptions aOpt;
153 bBackward = aOpt.IsBackwards();
154 bAsianOptions = aOpt.IsUseAsianOptions();
155 bNotes = aOpt.IsNotes();
157 if (aOpt.IsUseRegularExpression())
158 aSearchOpt.algorithmType = SearchAlgorithms_REGEXP;
159 if (aOpt.IsSimilaritySearch())
160 aSearchOpt.algorithmType = SearchAlgorithms_APPROXIMATE;
161 if (aOpt.IsWholeWordsOnly())
162 aSearchOpt.searchFlag |= SearchFlags::NORM_WORD_ONLY;
164 INT32 &rFlags = aSearchOpt.transliterateFlags;
166 if (!aOpt.IsMatchCase())
167 rFlags |= TransliterationModules_IGNORE_CASE;
168 if ( aOpt.IsMatchFullHalfWidthForms())
169 rFlags |= TransliterationModules_IGNORE_WIDTH;
170 if ( aOpt.IsMatchHiraganaKatakana())
171 rFlags |= TransliterationModules_IGNORE_KANA;
172 if ( aOpt.IsMatchContractions())
173 rFlags |= TransliterationModules_ignoreSize_ja_JP;
174 if ( aOpt.IsMatchMinusDashChoon())
175 rFlags |= TransliterationModules_ignoreMinusSign_ja_JP;
176 if ( aOpt.IsMatchRepeatCharMarks())
177 rFlags |= TransliterationModules_ignoreIterationMark_ja_JP;
178 if ( aOpt.IsMatchVariantFormKanji())
179 rFlags |= TransliterationModules_ignoreTraditionalKanji_ja_JP;
180 if ( aOpt.IsMatchOldKanaForms())
181 rFlags |= TransliterationModules_ignoreTraditionalKana_ja_JP;
182 if ( aOpt.IsMatchDiziDuzu())
183 rFlags |= TransliterationModules_ignoreZiZu_ja_JP;
184 if ( aOpt.IsMatchBavaHafa())
185 rFlags |= TransliterationModules_ignoreBaFa_ja_JP;
186 if ( aOpt.IsMatchTsithichiDhizi())
187 rFlags |= TransliterationModules_ignoreTiJi_ja_JP;
188 if ( aOpt.IsMatchHyuiyuByuvyu())
189 rFlags |= TransliterationModules_ignoreHyuByu_ja_JP;
190 if ( aOpt.IsMatchSesheZeje())
191 rFlags |= TransliterationModules_ignoreSeZe_ja_JP;
192 if ( aOpt.IsMatchIaiya())
193 rFlags |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP;
194 if ( aOpt.IsMatchKiku())
195 rFlags |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP;
196 if ( aOpt.IsIgnorePunctuation())
197 rFlags |= TransliterationModules_ignoreSeparator_ja_JP;
198 if ( aOpt.IsIgnoreWhitespace())
199 rFlags |= TransliterationModules_ignoreSpace_ja_JP;
200 if ( aOpt.IsIgnoreProlongedSoundMark())
201 rFlags |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
202 if ( aOpt.IsIgnoreMiddleDot())
203 rFlags |= TransliterationModules_ignoreMiddleDot_ja_JP;
206 // -----------------------------------------------------------------------
208 SvxSearchItem::SvxSearchItem( const SvxSearchItem& rItem ) :
210 SfxPoolItem ( rItem ),
211 ConfigItem( ::rtl::OUString::createFromAscii( CFG_ROOT_NODE ) ),
213 aSearchOpt ( rItem.aSearchOpt ),
214 eFamily ( rItem.eFamily ),
215 nCommand ( rItem.nCommand ),
216 nCellType ( rItem.nCellType ),
217 nAppFlag ( rItem.nAppFlag ),
218 bRowDirection ( rItem.bRowDirection ),
219 bAllTables ( rItem.bAllTables ),
220 bNotes ( rItem.bNotes),
221 bBackward ( rItem.bBackward ),
222 bPattern ( rItem.bPattern ),
223 bContent ( rItem.bContent ),
224 bAsianOptions ( rItem.bAsianOptions )
226 EnableNotification( lcl_GetNotifyNames() );
229 // -----------------------------------------------------------------------
231 SvxSearchItem::~SvxSearchItem()
235 // -----------------------------------------------------------------------
236 SfxPoolItem* SvxSearchItem::Clone( SfxItemPool *) const
238 return new SvxSearchItem(*this);
241 // -----------------------------------------------------------------------
243 //! used below
244 static BOOL operator == ( const SearchOptions& rItem1, const SearchOptions& rItem2 )
246 return rItem1.algorithmType == rItem2.algorithmType &&
247 rItem1.searchFlag == rItem2.searchFlag &&
248 rItem1.searchString == rItem2.searchString &&
249 rItem1.replaceString == rItem2.replaceString &&
250 //rItem1.Locale == rItem2.Locale &&
251 rItem1.changedChars == rItem2.changedChars &&
252 rItem1.deletedChars == rItem2.deletedChars &&
253 rItem1.insertedChars == rItem2.insertedChars &&
254 rItem1.transliterateFlags == rItem2.transliterateFlags;
258 int SvxSearchItem::operator==( const SfxPoolItem& rItem ) const
260 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
261 const SvxSearchItem &rSItem = (SvxSearchItem &) rItem;
262 return ( nCommand == rSItem.nCommand ) &&
263 ( bBackward == rSItem.bBackward ) &&
264 ( bPattern == rSItem.bPattern ) &&
265 ( bContent == rSItem.bContent ) &&
266 ( eFamily == rSItem.eFamily ) &&
267 ( bRowDirection == rSItem.bRowDirection ) &&
268 ( bAllTables == rSItem.bAllTables ) &&
269 ( nCellType == rSItem.nCellType ) &&
270 ( nAppFlag == rSItem.nAppFlag ) &&
271 ( bAsianOptions == rSItem.bAsianOptions ) &&
272 ( aSearchOpt == rSItem.aSearchOpt ) &&
273 ( bNotes == rSItem.bNotes );
277 //------------------------------------------------------------------------
279 SfxItemPresentation SvxSearchItem::GetPresentation
281 SfxItemPresentation ,
282 SfxMapUnit ,
283 SfxMapUnit ,
284 XubString& ,
285 const IntlWrapper *
286 ) const
288 return SFX_ITEM_PRESENTATION_NONE;
291 void SvxSearchItem::GetFromDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& rDescr )
293 SetSearchString( rDescr->getSearchString() );
294 ::com::sun::star::uno::Any aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchWords") );
295 sal_Bool bTemp = false;
296 aAny >>= bTemp ;
297 SetWordOnly( bTemp );
298 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchCaseSensitive") );
299 aAny >>= bTemp ;
300 SetExact( bTemp );
301 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchBackwards") );
302 aAny >>= bTemp ;
303 SetBackward( bTemp );
304 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchInSelection") );
305 aAny >>= bTemp ;
306 SetSelection( bTemp );
307 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchRegularExpression") );
308 aAny >>= bTemp ;
309 SetRegExp( bTemp );
310 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarity") );
311 aAny >>= bTemp ;
312 SetLevenshtein( bTemp );
313 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarityRelax") );
314 aAny >>= bTemp ;
315 SetLEVRelaxed( bTemp );
316 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarityExchange") );
317 sal_Int16 nTemp = 0;
318 aAny >>= nTemp ;
319 SetLEVOther( nTemp );
320 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarityRemove") );
321 aAny >>= nTemp ;
322 SetLEVShorter( nTemp );
323 aAny = rDescr->getPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarityAdd") );
324 aAny >>= nTemp ;
325 SetLEVLonger( nTemp );
328 void SvxSearchItem::SetToDescriptor( ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & rDescr )
330 rDescr->setSearchString( GetSearchString() );
331 ::com::sun::star::uno::Any aAny;
332 aAny <<= GetWordOnly() ;
333 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchWords"), aAny );
334 aAny <<= GetExact() ;
335 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchCaseSensitive"), aAny );
336 aAny <<= GetBackward() ;
337 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchBackwards"), aAny );
338 aAny <<= GetSelection() ;
339 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchInSelection"), aAny );
340 aAny <<= GetRegExp() ;
341 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchRegularExpression"), aAny );
342 aAny <<= IsLevenshtein() ;
343 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarity"), aAny );
344 aAny <<= IsLEVRelaxed() ;
345 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarityRelax"), aAny );
346 aAny <<= GetLEVOther() ;
347 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarityExchange"), aAny );
348 aAny <<= GetLEVShorter() ;
349 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarityRemove"), aAny );
350 aAny <<= GetLEVLonger() ;
351 rDescr->setPropertyValue( DEFINE_CONST_UNICODE("SearchSimilarityAdd"), aAny );
355 void SvxSearchItem::Notify( const Sequence< ::rtl::OUString > & )
357 // applies transliteration changes in the configuration database
358 // to the current SvxSearchItem
359 SetTransliterationFlags( SvtSearchOptions().GetTransliterationFlags() );
363 void SvxSearchItem::SetMatchFullHalfWidthForms( sal_Bool bVal )
365 if (bVal)
366 aSearchOpt.transliterateFlags |= TransliterationModules_IGNORE_WIDTH;
367 else
368 aSearchOpt.transliterateFlags &= ~TransliterationModules_IGNORE_WIDTH;
372 void SvxSearchItem::SetWordOnly( sal_Bool bVal )
374 if (bVal)
375 aSearchOpt.searchFlag |= SearchFlags::NORM_WORD_ONLY;
376 else
377 aSearchOpt.searchFlag &= ~SearchFlags::NORM_WORD_ONLY;
381 void SvxSearchItem::SetExact( sal_Bool bVal )
383 if (!bVal)
384 aSearchOpt.transliterateFlags |= TransliterationModules_IGNORE_CASE;
385 else
386 aSearchOpt.transliterateFlags &= ~TransliterationModules_IGNORE_CASE;
390 void SvxSearchItem::SetSelection( sal_Bool bVal )
392 if (bVal)
394 aSearchOpt.searchFlag |= (SearchFlags::REG_NOT_BEGINOFLINE |
395 SearchFlags::REG_NOT_ENDOFLINE);
397 else
399 aSearchOpt.searchFlag &= ~(SearchFlags::REG_NOT_BEGINOFLINE |
400 SearchFlags::REG_NOT_ENDOFLINE);
405 void SvxSearchItem::SetRegExp( sal_Bool bVal )
407 if ( bVal )
408 aSearchOpt.algorithmType = SearchAlgorithms_REGEXP;
409 else if ( SearchAlgorithms_REGEXP == aSearchOpt.algorithmType )
410 aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
414 void SvxSearchItem::SetLEVRelaxed( sal_Bool bVal )
416 if (bVal)
417 aSearchOpt.searchFlag |= SearchFlags::LEV_RELAXED;
418 else
419 aSearchOpt.searchFlag &= ~SearchFlags::LEV_RELAXED;
423 void SvxSearchItem::SetLevenshtein( sal_Bool bVal )
425 if ( bVal )
426 aSearchOpt.algorithmType = SearchAlgorithms_APPROXIMATE;
427 else if ( SearchAlgorithms_APPROXIMATE == aSearchOpt.algorithmType )
428 aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE;
432 void SvxSearchItem::SetTransliterationFlags( sal_Int32 nFlags )
434 aSearchOpt.transliterateFlags = nFlags;
437 sal_Bool SvxSearchItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
439 nMemberId &= ~CONVERT_TWIPS;
440 switch ( nMemberId )
442 case 0 :
444 Sequence< PropertyValue > aSeq( SRCH_PARAMS );
445 aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_OPTIONS ) );
446 aSeq[0].Value <<= aSearchOpt;
447 aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_FAMILY ));
448 aSeq[1].Value <<= sal_Int16( eFamily );
449 aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_COMMAND ));
450 aSeq[2].Value <<= nCommand;
451 aSeq[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_CELLTYPE ));
452 aSeq[3].Value <<= nCellType;
453 aSeq[4].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_APPFLAG ));
454 aSeq[4].Value <<= nAppFlag;
455 aSeq[5].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_ROWDIR ));
456 aSeq[5].Value <<= bRowDirection;
457 aSeq[6].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_ALLTABLES ));
458 aSeq[6].Value <<= bAllTables;
459 aSeq[7].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_BACKWARD ));
460 aSeq[7].Value <<= bBackward;
461 aSeq[8].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_PATTERN ));
462 aSeq[8].Value <<= bPattern;
463 aSeq[9].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_CONTENT ));
464 aSeq[9].Value <<= bContent;
465 aSeq[10].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SRCH_PARA_ASIANOPT ));
466 aSeq[10].Value <<= bAsianOptions;
467 rVal <<= aSeq;
469 break;
470 case MID_SEARCH_COMMAND:
471 rVal <<= (sal_Int16) nCommand; break;
472 case MID_SEARCH_STYLEFAMILY:
473 rVal <<= (sal_Int16) eFamily; break;
474 case MID_SEARCH_CELLTYPE:
475 rVal <<= (sal_Int32) nCellType; break;
476 case MID_SEARCH_ROWDIRECTION:
477 rVal <<= (sal_Bool) bRowDirection; break;
478 case MID_SEARCH_ALLTABLES:
479 rVal <<= (sal_Bool) bAllTables; break;
480 case MID_SEARCH_BACKWARD:
481 rVal <<= (sal_Bool) bBackward; break;
482 case MID_SEARCH_PATTERN:
483 rVal <<= (sal_Bool) bPattern; break;
484 case MID_SEARCH_CONTENT:
485 rVal <<= (sal_Bool) bContent; break;
486 case MID_SEARCH_ASIANOPTIONS:
487 rVal <<= (sal_Bool) bAsianOptions; break;
488 case MID_SEARCH_ALGORITHMTYPE:
489 rVal <<= (sal_Int16) aSearchOpt.algorithmType; break;
490 case MID_SEARCH_FLAGS:
491 rVal <<= aSearchOpt.searchFlag; break;
492 case MID_SEARCH_SEARCHSTRING:
493 rVal <<= aSearchOpt.searchString; break;
494 case MID_SEARCH_REPLACESTRING:
495 rVal <<= aSearchOpt.replaceString; break;
496 case MID_SEARCH_CHANGEDCHARS:
497 rVal <<= aSearchOpt.changedChars; break;
498 case MID_SEARCH_DELETEDCHARS:
499 rVal <<= aSearchOpt.deletedChars; break;
500 case MID_SEARCH_INSERTEDCHARS:
501 rVal <<= aSearchOpt.insertedChars; break;
502 case MID_SEARCH_TRANSLITERATEFLAGS:
503 rVal <<= aSearchOpt.transliterateFlags; break;
504 case MID_SEARCH_LOCALE:
506 sal_Int16 nLocale;
507 if (aSearchOpt.Locale.Language.getLength() || aSearchOpt.Locale.Country.getLength() )
508 nLocale = MsLangId::convertLocaleToLanguage( aSearchOpt.Locale );
509 else
510 nLocale = LANGUAGE_NONE;
511 rVal <<= nLocale;
512 break;
515 default:
516 DBG_ERRORFILE( "SvxSearchItem::QueryValue(): Unknown MemberId" );
517 return sal_False;
520 return sal_True;
523 // -----------------------------------------------------------------------
525 sal_Bool SvxSearchItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId )
527 nMemberId &= ~CONVERT_TWIPS;
528 sal_Bool bRet = sal_False;
529 sal_Int32 nInt = 0;
530 switch ( nMemberId )
532 case 0 :
534 Sequence< PropertyValue > aSeq;
535 if ( ( rVal >>= aSeq ) && ( aSeq.getLength() == SRCH_PARAMS ) )
537 sal_Int16 nConvertedCount( 0 );
538 for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
540 if ( aSeq[i].Name.equalsAscii( SRCH_PARA_OPTIONS ) )
542 if ( ( aSeq[i].Value >>= aSearchOpt ) == sal_True )
543 ++nConvertedCount;
545 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_FAMILY ) )
547 sal_uInt16 nTemp( 0 );
548 if ( ( aSeq[i].Value >>= nTemp ) == sal_True )
550 eFamily = SfxStyleFamily( nTemp );
551 ++nConvertedCount;
554 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_COMMAND ) )
556 if ( ( aSeq[i].Value >>= nCommand ) == sal_True )
557 ++nConvertedCount;
559 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_CELLTYPE ) )
561 if ( ( aSeq[i].Value >>= nCellType ) == sal_True )
562 ++nConvertedCount;
564 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_APPFLAG ) )
566 if ( ( aSeq[i].Value >>= nAppFlag ) == sal_True )
567 ++nConvertedCount;
569 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_ROWDIR ) )
571 if ( ( aSeq[i].Value >>= bRowDirection ) == sal_True )
572 ++nConvertedCount;
574 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_ALLTABLES ) )
576 if ( ( aSeq[i].Value >>= bAllTables ) == sal_True )
577 ++nConvertedCount;
579 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_BACKWARD ) )
581 if ( ( aSeq[i].Value >>= bBackward ) == sal_True )
582 ++nConvertedCount;
584 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_PATTERN ) )
586 if ( ( aSeq[i].Value >>= bPattern ) == sal_True )
587 ++nConvertedCount;
589 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_CONTENT ) )
591 if ( ( aSeq[i].Value >>= bContent ) == sal_True )
592 ++nConvertedCount;
594 else if ( aSeq[i].Name.equalsAscii( SRCH_PARA_ASIANOPT ) )
596 if ( ( aSeq[i].Value >>= bAsianOptions ) == sal_True )
597 ++nConvertedCount;
601 bRet = ( nConvertedCount == SRCH_PARAMS );
603 break;
605 case MID_SEARCH_COMMAND:
606 bRet = (rVal >>= nInt); nCommand = (sal_uInt16) nInt; break;
607 case MID_SEARCH_STYLEFAMILY:
608 bRet = (rVal >>= nInt); eFamily = (SfxStyleFamily) (sal_Int16) nInt; break;
609 case MID_SEARCH_CELLTYPE:
610 bRet = (rVal >>= nInt); nCellType = (sal_uInt16) nInt; break;
611 case MID_SEARCH_ROWDIRECTION:
612 bRet = (rVal >>= bRowDirection); break;
613 case MID_SEARCH_ALLTABLES:
614 bRet = (rVal >>= bAllTables); break;
615 case MID_SEARCH_BACKWARD:
616 bRet = (rVal >>= bBackward); break;
617 case MID_SEARCH_PATTERN:
618 bRet = (rVal >>= bPattern); break;
619 case MID_SEARCH_CONTENT:
620 bRet = (rVal >>= bContent); break;
621 case MID_SEARCH_ASIANOPTIONS:
622 bRet = (rVal >>= bAsianOptions); break;
623 case MID_SEARCH_ALGORITHMTYPE:
624 bRet = (rVal >>= nInt); aSearchOpt.algorithmType = (SearchAlgorithms)(sal_Int16)nInt; break;
625 case MID_SEARCH_FLAGS:
626 bRet = (rVal >>= aSearchOpt.searchFlag); break;
627 case MID_SEARCH_SEARCHSTRING:
628 bRet = (rVal >>= aSearchOpt.searchString); break;
629 case MID_SEARCH_REPLACESTRING:
630 bRet = (rVal >>= aSearchOpt.replaceString); break;
631 case MID_SEARCH_CHANGEDCHARS:
632 bRet = (rVal >>= aSearchOpt.changedChars); break;
633 case MID_SEARCH_DELETEDCHARS:
634 bRet = (rVal >>= aSearchOpt.deletedChars); break;
635 case MID_SEARCH_INSERTEDCHARS:
636 bRet = (rVal >>= aSearchOpt.insertedChars); break;
637 case MID_SEARCH_TRANSLITERATEFLAGS:
638 bRet = (rVal >>= aSearchOpt.transliterateFlags); break;
639 case MID_SEARCH_LOCALE:
641 bRet = (rVal >>= nInt);
642 if ( bRet )
644 if ( nInt == LANGUAGE_NONE )
646 aSearchOpt.Locale = ::com::sun::star::lang::Locale();
648 else
650 MsLangId::convertLanguageToLocale( (sal_Int16) nInt, aSearchOpt.Locale );
653 break;
655 default:
656 DBG_ERROR( "Unknown MemberId" );
659 return bRet;