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