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_linguistic.hxx" 30 31 #include <tools/debug.hxx> 32 33 #include <com/sun/star/linguistic2/LinguServiceEvent.hpp> 34 #include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp> 35 #include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp> 36 #include <com/sun/star/beans/XPropertySet.hpp> 37 #include <osl/mutex.hxx> 38 39 #include <linguistic/misc.hxx> 40 #include <linguistic/lngprops.hxx> 41 42 #include <linguistic/lngprophelp.hxx> 43 44 45 //using namespace utl; 46 using namespace osl; 47 using namespace rtl; 48 using namespace com::sun::star; 49 using namespace com::sun::star::beans; 50 using namespace com::sun::star::lang; 51 using namespace com::sun::star::uno; 52 using namespace com::sun::star::linguistic2; 53 using namespace linguistic; 54 55 namespace linguistic 56 { 57 58 /////////////////////////////////////////////////////////////////////////// 59 60 static const char *aCH[] = 61 { 62 UPN_IS_IGNORE_CONTROL_CHARACTERS, 63 UPN_IS_USE_DICTIONARY_LIST, 64 }; 65 66 static int nCHCount = sizeof(aCH) / sizeof(aCH[0]); 67 68 69 PropertyChgHelper::PropertyChgHelper( 70 const Reference< XInterface > &rxSource, 71 Reference< XPropertySet > &rxPropSet, 72 int nAllowedEvents ) : 73 PropertyChgHelperBase(), 74 aPropNames (nCHCount), 75 xMyEvtObj (rxSource), 76 aLngSvcEvtListeners (GetLinguMutex()), 77 xPropSet (rxPropSet), 78 nEvtFlags (nAllowedEvents) 79 { 80 OUString *pName = aPropNames.getArray(); 81 for (sal_Int32 i = 0; i < nCHCount; ++i) 82 { 83 pName[i] = A2OU( aCH[i] ); 84 } 85 86 SetDefaultValues(); 87 } 88 89 90 PropertyChgHelper::PropertyChgHelper( const PropertyChgHelper &rHelper ) : 91 PropertyChgHelperBase(), 92 aLngSvcEvtListeners (GetLinguMutex()) 93 { 94 RemoveAsPropListener(); 95 aPropNames = rHelper.aPropNames; 96 xMyEvtObj = rHelper.xMyEvtObj; 97 xPropSet = rHelper.xPropSet; 98 nEvtFlags = rHelper.nEvtFlags; 99 AddAsPropListener(); 100 101 SetDefaultValues(); 102 GetCurrentValues(); 103 } 104 105 106 PropertyChgHelper::~PropertyChgHelper() 107 { 108 } 109 110 111 void PropertyChgHelper::AddPropNames( const char *pNewNames[], sal_Int32 nCount ) 112 { 113 if (pNewNames && nCount) 114 { 115 sal_Int32 nLen = GetPropNames().getLength(); 116 GetPropNames().realloc( nLen + nCount ); 117 OUString *pName = GetPropNames().getArray(); 118 for (sal_Int32 i = 0; i < nCount; ++i) 119 { 120 pName[ nLen + i ] = A2OU( pNewNames[ i ] ); 121 } 122 } 123 } 124 125 126 void PropertyChgHelper::SetDefaultValues() 127 { 128 bResIsIgnoreControlCharacters = bIsIgnoreControlCharacters = sal_True; 129 bResIsUseDictionaryList = bIsUseDictionaryList = sal_True; 130 } 131 132 133 void PropertyChgHelper::GetCurrentValues() 134 { 135 sal_Int32 nLen = GetPropNames().getLength(); 136 if (GetPropSet().is() && nLen) 137 { 138 const OUString *pPropName = GetPropNames().getConstArray(); 139 for (sal_Int32 i = 0; i < nLen; ++i) 140 { 141 sal_Bool *pbVal = NULL, 142 *pbResVal = NULL; 143 144 if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_IS_IGNORE_CONTROL_CHARACTERS ) )) 145 { 146 pbVal = &bIsIgnoreControlCharacters; 147 pbResVal = &bResIsIgnoreControlCharacters; 148 } 149 else if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_IS_USE_DICTIONARY_LIST ) )) 150 { 151 pbVal = &bIsUseDictionaryList; 152 pbResVal = &bResIsUseDictionaryList; 153 } 154 155 if (pbVal && pbResVal) 156 { 157 GetPropSet()->getPropertyValue( pPropName[i] ) >>= *pbVal; 158 *pbResVal = *pbVal; 159 } 160 } 161 } 162 } 163 164 165 void PropertyChgHelper::SetTmpPropVals( const PropertyValues &rPropVals ) 166 { 167 // return value is default value unless there is an explicitly supplied 168 // temporary value 169 bResIsIgnoreControlCharacters = bIsIgnoreControlCharacters; 170 bResIsUseDictionaryList = bIsUseDictionaryList; 171 // 172 sal_Int32 nLen = rPropVals.getLength(); 173 if (nLen) 174 { 175 const PropertyValue *pVal = rPropVals.getConstArray(); 176 for (sal_Int32 i = 0; i < nLen; ++i) 177 { 178 sal_Bool *pbResVal = NULL; 179 switch (pVal[i].Handle) 180 { 181 case UPH_IS_IGNORE_CONTROL_CHARACTERS : 182 pbResVal = &bResIsIgnoreControlCharacters; break; 183 case UPH_IS_USE_DICTIONARY_LIST : 184 pbResVal = &bResIsUseDictionaryList; break; 185 default: 186 ; 187 //DBG_ASSERT( 0, "unknown property" ); 188 } 189 if (pbResVal) 190 pVal[i].Value >>= *pbResVal; 191 } 192 } 193 } 194 195 196 sal_Bool PropertyChgHelper::propertyChange_Impl( const PropertyChangeEvent& rEvt ) 197 { 198 sal_Bool bRes = sal_False; 199 200 if (GetPropSet().is() && rEvt.Source == GetPropSet()) 201 { 202 sal_Int16 nLngSvcFlags = (nEvtFlags & AE_HYPHENATOR) ? 203 LinguServiceEventFlags::HYPHENATE_AGAIN : 0; 204 sal_Bool bSCWA = sal_False, // SPELL_CORRECT_WORDS_AGAIN ? 205 bSWWA = sal_False; // SPELL_WRONG_WORDS_AGAIN ? 206 207 sal_Bool *pbVal = NULL; 208 switch (rEvt.PropertyHandle) 209 { 210 case UPH_IS_IGNORE_CONTROL_CHARACTERS : 211 { 212 pbVal = &bIsIgnoreControlCharacters; 213 nLngSvcFlags = 0; 214 break; 215 } 216 case UPH_IS_USE_DICTIONARY_LIST : 217 { 218 pbVal = &bIsUseDictionaryList; 219 bSCWA = bSWWA = sal_True; 220 break; 221 } 222 default: 223 { 224 bRes = sal_False; 225 //DBG_ASSERT( 0, "unknown property" ); 226 } 227 } 228 if (pbVal) 229 rEvt.NewValue >>= *pbVal; 230 231 bRes = 0 != pbVal; // sth changed? 232 if (bRes) 233 { 234 sal_Bool bSpellEvts = (nEvtFlags & AE_SPELLCHECKER) ? sal_True : sal_False; 235 if (bSCWA && bSpellEvts) 236 nLngSvcFlags |= LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN; 237 if (bSWWA && bSpellEvts) 238 nLngSvcFlags |= LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN; 239 if (nLngSvcFlags) 240 { 241 LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags ); 242 LaunchEvent( aEvt ); 243 } 244 } 245 } 246 247 return bRes; 248 } 249 250 251 void SAL_CALL 252 PropertyChgHelper::propertyChange( const PropertyChangeEvent& rEvt ) 253 throw(RuntimeException) 254 { 255 MutexGuard aGuard( GetLinguMutex() ); 256 propertyChange_Impl( rEvt ); 257 } 258 259 260 void PropertyChgHelper::AddAsPropListener() 261 { 262 if (xPropSet.is()) 263 { 264 sal_Int32 nLen = aPropNames.getLength(); 265 const OUString *pPropName = aPropNames.getConstArray(); 266 for (sal_Int32 i = 0; i < nLen; ++i) 267 { 268 if (pPropName[i].getLength()) 269 xPropSet->addPropertyChangeListener( pPropName[i], this ); 270 } 271 } 272 } 273 274 void PropertyChgHelper::RemoveAsPropListener() 275 { 276 if (xPropSet.is()) 277 { 278 sal_Int32 nLen = aPropNames.getLength(); 279 const OUString *pPropName = aPropNames.getConstArray(); 280 for (sal_Int32 i = 0; i < nLen; ++i) 281 { 282 if (pPropName[i].getLength()) 283 xPropSet->removePropertyChangeListener( pPropName[i], this ); 284 } 285 } 286 } 287 288 289 void PropertyChgHelper::LaunchEvent( const LinguServiceEvent &rEvt ) 290 { 291 cppu::OInterfaceIteratorHelper aIt( aLngSvcEvtListeners ); 292 while (aIt.hasMoreElements()) 293 { 294 Reference< XLinguServiceEventListener > xRef( aIt.next(), UNO_QUERY ); 295 if (xRef.is()) 296 xRef->processLinguServiceEvent( rEvt ); 297 } 298 } 299 300 301 void SAL_CALL PropertyChgHelper::disposing( const EventObject& rSource ) 302 throw(RuntimeException) 303 { 304 MutexGuard aGuard( GetLinguMutex() ); 305 if (rSource.Source == xPropSet) 306 { 307 RemoveAsPropListener(); 308 xPropSet = NULL; 309 aPropNames.realloc( 0 ); 310 } 311 } 312 313 314 sal_Bool SAL_CALL 315 PropertyChgHelper::addLinguServiceEventListener( 316 const Reference< XLinguServiceEventListener >& rxListener ) 317 throw(RuntimeException) 318 { 319 MutexGuard aGuard( GetLinguMutex() ); 320 321 sal_Bool bRes = sal_False; 322 if (rxListener.is()) 323 { 324 sal_Int32 nCount = aLngSvcEvtListeners.getLength(); 325 bRes = aLngSvcEvtListeners.addInterface( rxListener ) != nCount; 326 } 327 return bRes; 328 } 329 330 331 sal_Bool SAL_CALL 332 PropertyChgHelper::removeLinguServiceEventListener( 333 const Reference< XLinguServiceEventListener >& rxListener ) 334 throw(RuntimeException) 335 { 336 MutexGuard aGuard( GetLinguMutex() ); 337 338 sal_Bool bRes = sal_False; 339 if (rxListener.is()) 340 { 341 sal_Int32 nCount = aLngSvcEvtListeners.getLength(); 342 bRes = aLngSvcEvtListeners.removeInterface( rxListener ) != nCount; 343 } 344 return bRes; 345 } 346 347 /////////////////////////////////////////////////////////////////////////// 348 349 350 PropertyHelper_Thes::PropertyHelper_Thes( 351 const Reference< XInterface > &rxSource, 352 Reference< XPropertySet > &rxPropSet ) : 353 PropertyChgHelper ( rxSource, rxPropSet, 0 ) 354 { 355 SetDefaultValues(); 356 GetCurrentValues(); 357 } 358 359 360 PropertyHelper_Thes::~PropertyHelper_Thes() 361 { 362 } 363 364 365 void SAL_CALL 366 PropertyHelper_Thes::propertyChange( const PropertyChangeEvent& rEvt ) 367 throw(RuntimeException) 368 { 369 MutexGuard aGuard( GetLinguMutex() ); 370 PropertyChgHelper::propertyChange_Impl( rEvt ); 371 } 372 373 374 /////////////////////////////////////////////////////////////////////////// 375 376 // list of properties from the property set to be used 377 // and listened to 378 static const char *aSP[] = 379 { 380 UPN_IS_SPELL_UPPER_CASE, 381 UPN_IS_SPELL_WITH_DIGITS, 382 UPN_IS_SPELL_CAPITALIZATION 383 }; 384 385 386 PropertyHelper_Spell::PropertyHelper_Spell( 387 const Reference< XInterface > & rxSource, 388 Reference< XPropertySet > &rxPropSet ) : 389 PropertyChgHelper ( rxSource, rxPropSet, AE_SPELLCHECKER ) 390 { 391 AddPropNames( aSP, sizeof(aSP) / sizeof(aSP[0]) ); 392 SetDefaultValues(); 393 GetCurrentValues(); 394 395 nResMaxNumberOfSuggestions = GetDefaultNumberOfSuggestions(); 396 } 397 398 399 PropertyHelper_Spell::~PropertyHelper_Spell() 400 { 401 } 402 403 404 void PropertyHelper_Spell::SetDefaultValues() 405 { 406 PropertyChgHelper::SetDefaultValues(); 407 408 bResIsSpellUpperCase = bIsSpellUpperCase = sal_False; 409 bResIsSpellWithDigits = bIsSpellWithDigits = sal_False; 410 bResIsSpellCapitalization = bIsSpellCapitalization = sal_True; 411 } 412 413 414 void PropertyHelper_Spell::GetCurrentValues() 415 { 416 PropertyChgHelper::GetCurrentValues(); 417 418 sal_Int32 nLen = GetPropNames().getLength(); 419 if (GetPropSet().is() && nLen) 420 { 421 const OUString *pPropName = GetPropNames().getConstArray(); 422 for (sal_Int32 i = 0; i < nLen; ++i) 423 { 424 sal_Bool *pbVal = NULL, 425 *pbResVal = NULL; 426 427 if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_IS_SPELL_UPPER_CASE ) )) 428 { 429 pbVal = &bIsSpellUpperCase; 430 pbResVal = &bResIsSpellUpperCase; 431 } 432 else if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_IS_SPELL_WITH_DIGITS ) )) 433 { 434 pbVal = &bIsSpellWithDigits; 435 pbResVal = &bResIsSpellWithDigits; 436 } 437 else if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_IS_SPELL_CAPITALIZATION ) )) 438 { 439 pbVal = &bIsSpellCapitalization; 440 pbResVal = &bResIsSpellCapitalization; 441 } 442 443 if (pbVal && pbResVal) 444 { 445 GetPropSet()->getPropertyValue( pPropName[i] ) >>= *pbVal; 446 *pbResVal = *pbVal; 447 } 448 } 449 } 450 } 451 452 453 sal_Bool PropertyHelper_Spell::propertyChange_Impl( const PropertyChangeEvent& rEvt ) 454 { 455 sal_Bool bRes = PropertyChgHelper::propertyChange_Impl( rEvt ); 456 457 if (!bRes && GetPropSet().is() && rEvt.Source == GetPropSet()) 458 { 459 sal_Int16 nLngSvcFlags = 0; 460 sal_Bool bSCWA = sal_False, // SPELL_CORRECT_WORDS_AGAIN ? 461 bSWWA = sal_False; // SPELL_WRONG_WORDS_AGAIN ? 462 463 sal_Bool *pbVal = NULL; 464 switch (rEvt.PropertyHandle) 465 { 466 case UPH_IS_SPELL_UPPER_CASE : 467 { 468 pbVal = &bIsSpellUpperCase; 469 bSCWA = sal_False == *pbVal; // sal_False->sal_True change? 470 bSWWA = !bSCWA; // sal_True->sal_False change? 471 break; 472 } 473 case UPH_IS_SPELL_WITH_DIGITS : 474 { 475 pbVal = &bIsSpellWithDigits; 476 bSCWA = sal_False == *pbVal; // sal_False->sal_True change? 477 bSWWA = !bSCWA; // sal_True->sal_False change? 478 break; 479 } 480 case UPH_IS_SPELL_CAPITALIZATION : 481 { 482 pbVal = &bIsSpellCapitalization; 483 bSCWA = sal_False == *pbVal; // sal_False->sal_True change? 484 bSWWA = !bSCWA; // sal_True->sal_False change? 485 break; 486 } 487 default: 488 DBG_ASSERT( 0, "unknown property" ); 489 } 490 if (pbVal) 491 rEvt.NewValue >>= *pbVal; 492 493 bRes = (pbVal != 0); 494 if (bRes) 495 { 496 if (bSCWA) 497 nLngSvcFlags |= LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN; 498 if (bSWWA) 499 nLngSvcFlags |= LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN; 500 if (nLngSvcFlags) 501 { 502 LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags ); 503 LaunchEvent( aEvt ); 504 } 505 } 506 } 507 508 return bRes; 509 } 510 511 512 void SAL_CALL 513 PropertyHelper_Spell::propertyChange( const PropertyChangeEvent& rEvt ) 514 throw(RuntimeException) 515 { 516 MutexGuard aGuard( GetLinguMutex() ); 517 propertyChange_Impl( rEvt ); 518 } 519 520 521 void PropertyHelper_Spell::SetTmpPropVals( const PropertyValues &rPropVals ) 522 { 523 PropertyChgHelper::SetTmpPropVals( rPropVals ); 524 525 // return value is default value unless there is an explicitly supplied 526 // temporary value 527 nResMaxNumberOfSuggestions = GetDefaultNumberOfSuggestions(); 528 bResIsSpellWithDigits = bIsSpellWithDigits; 529 bResIsSpellCapitalization = bIsSpellCapitalization; 530 // 531 sal_Int32 nLen = rPropVals.getLength(); 532 if (nLen) 533 { 534 const PropertyValue *pVal = rPropVals.getConstArray(); 535 for (sal_Int32 i = 0; i < nLen; ++i) 536 { 537 if (pVal[i].Name.equalsAscii( UPN_MAX_NUMBER_OF_SUGGESTIONS )) 538 { 539 pVal[i].Value >>= nResMaxNumberOfSuggestions; 540 } 541 else 542 { 543 sal_Bool *pbResVal = NULL; 544 switch (pVal[i].Handle) 545 { 546 case UPH_IS_SPELL_UPPER_CASE : pbResVal = &bResIsSpellUpperCase; break; 547 case UPH_IS_SPELL_WITH_DIGITS : pbResVal = &bResIsSpellWithDigits; break; 548 case UPH_IS_SPELL_CAPITALIZATION : pbResVal = &bResIsSpellCapitalization; break; 549 default: 550 DBG_ASSERT( 0, "unknown property" ); 551 } 552 if (pbResVal) 553 pVal[i].Value >>= *pbResVal; 554 } 555 } 556 } 557 } 558 559 sal_Int16 PropertyHelper_Spell::GetDefaultNumberOfSuggestions() const 560 { 561 return 16; 562 } 563 564 /////////////////////////////////////////////////////////////////////////// 565 566 static const char *aHP[] = 567 { 568 UPN_HYPH_MIN_LEADING, 569 UPN_HYPH_MIN_TRAILING, 570 UPN_HYPH_MIN_WORD_LENGTH 571 }; 572 573 574 PropertyHelper_Hyphen::PropertyHelper_Hyphen( 575 const Reference< XInterface > & rxSource, 576 Reference< XPropertySet > &rxPropSet ) : 577 PropertyChgHelper ( rxSource, rxPropSet, AE_HYPHENATOR ) 578 { 579 AddPropNames( aHP, sizeof(aHP) / sizeof(aHP[0]) ); 580 SetDefaultValues(); 581 GetCurrentValues(); 582 } 583 584 585 PropertyHelper_Hyphen::~PropertyHelper_Hyphen() 586 { 587 } 588 589 590 void PropertyHelper_Hyphen::SetDefaultValues() 591 { 592 PropertyChgHelper::SetDefaultValues(); 593 594 nResHyphMinLeading = nHyphMinLeading = 2; 595 nResHyphMinTrailing = nHyphMinTrailing = 2; 596 nResHyphMinWordLength = nHyphMinWordLength = 0; 597 } 598 599 600 void PropertyHelper_Hyphen::GetCurrentValues() 601 { 602 PropertyChgHelper::GetCurrentValues(); 603 604 sal_Int32 nLen = GetPropNames().getLength(); 605 if (GetPropSet().is() && nLen) 606 { 607 const OUString *pPropName = GetPropNames().getConstArray(); 608 for (sal_Int32 i = 0; i < nLen; ++i) 609 { 610 sal_Int16 *pnVal = NULL, 611 *pnResVal = NULL; 612 613 if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_HYPH_MIN_LEADING ) )) 614 { 615 pnVal = &nHyphMinLeading; 616 pnResVal = &nResHyphMinLeading; 617 } 618 else if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_HYPH_MIN_TRAILING ) )) 619 { 620 pnVal = &nHyphMinTrailing; 621 pnResVal = &nResHyphMinTrailing; 622 } 623 else if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_HYPH_MIN_WORD_LENGTH ) )) 624 { 625 pnVal = &nHyphMinWordLength; 626 pnResVal = &nResHyphMinWordLength; 627 } 628 629 if (pnVal && pnResVal) 630 { 631 GetPropSet()->getPropertyValue( pPropName[i] ) >>= *pnVal; 632 *pnResVal = *pnVal; 633 } 634 } 635 } 636 } 637 638 639 sal_Bool PropertyHelper_Hyphen::propertyChange_Impl( const PropertyChangeEvent& rEvt ) 640 { 641 sal_Bool bRes = PropertyChgHelper::propertyChange_Impl( rEvt ); 642 643 if (!bRes && GetPropSet().is() && rEvt.Source == GetPropSet()) 644 { 645 sal_Int16 nLngSvcFlags = LinguServiceEventFlags::HYPHENATE_AGAIN; 646 647 sal_Int16 *pnVal = NULL; 648 switch (rEvt.PropertyHandle) 649 { 650 case UPH_HYPH_MIN_LEADING : pnVal = &nHyphMinLeading; break; 651 case UPH_HYPH_MIN_TRAILING : pnVal = &nHyphMinTrailing; break; 652 case UPH_HYPH_MIN_WORD_LENGTH : pnVal = &nHyphMinWordLength; break; 653 default: 654 DBG_ASSERT( 0, "unknown property" ); 655 } 656 if (pnVal) 657 rEvt.NewValue >>= *pnVal; 658 659 bRes = (pnVal != 0); 660 if (bRes) 661 { 662 if (nLngSvcFlags) 663 { 664 LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags ); 665 LaunchEvent( aEvt ); 666 } 667 } 668 } 669 670 return bRes; 671 } 672 673 674 void SAL_CALL 675 PropertyHelper_Hyphen::propertyChange( const PropertyChangeEvent& rEvt ) 676 throw(RuntimeException) 677 { 678 MutexGuard aGuard( GetLinguMutex() ); 679 propertyChange_Impl( rEvt ); 680 } 681 682 683 void PropertyHelper_Hyphen::SetTmpPropVals( const PropertyValues &rPropVals ) 684 { 685 PropertyChgHelper::SetTmpPropVals( rPropVals ); 686 687 // return value is default value unless there is an explicitly supplied 688 // temporary value 689 nResHyphMinLeading = nHyphMinLeading; 690 nResHyphMinTrailing = nHyphMinTrailing; 691 nResHyphMinWordLength = nHyphMinWordLength; 692 // 693 sal_Int32 nLen = rPropVals.getLength(); 694 if (nLen) 695 { 696 const PropertyValue *pVal = rPropVals.getConstArray(); 697 for (sal_Int32 i = 0; i < nLen; ++i) 698 { 699 sal_Int16 *pnResVal = NULL; 700 switch (pVal[i].Handle) 701 { 702 case UPH_HYPH_MIN_LEADING : pnResVal = &nResHyphMinLeading; break; 703 case UPH_HYPH_MIN_TRAILING : pnResVal = &nResHyphMinTrailing; break; 704 case UPH_HYPH_MIN_WORD_LENGTH : pnResVal = &nResHyphMinWordLength; break; 705 default: 706 DBG_ASSERT( 0, "unknown property" ); 707 } 708 if (pnResVal) 709 pVal[i].Value >>= *pnResVal; 710 } 711 } 712 } 713 714 /////////////////////////////////////////////////////////////////////////// 715 716 } // namespace linguistic 717 718