LCOV - code coverage report
Current view: top level - unotools/source/config - lingucfg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 352 538 65.4 %
Date: 2015-06-13 12:38:46 Functions: 33 45 73.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/config.h>
      21             : 
      22             : #include <com/sun/star/lang/Locale.hpp>
      23             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      24             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      25             : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      26             : #include <com/sun/star/container/XNameAccess.hpp>
      27             : #include <com/sun/star/container/XNameContainer.hpp>
      28             : #include <com/sun/star/container/XNameReplace.hpp>
      29             : #include <rtl/instance.hxx>
      30             : #include <sal/log.hxx>
      31             : #include <osl/mutex.hxx>
      32             : #include <i18nlangtag/mslangid.hxx>
      33             : #include <i18nlangtag/languagetag.hxx>
      34             : #include <tools/debug.hxx>
      35             : #include <unotools/lingucfg.hxx>
      36             : #include <unotools/linguprops.hxx>
      37             : #include <sal/macros.h>
      38             : #include <comphelper/getexpandeduri.hxx>
      39             : #include <comphelper/processfactory.hxx>
      40             : 
      41             : #include "itemholder1.hxx"
      42             : 
      43             : using namespace com::sun::star;
      44             : 
      45             : #define FILE_PROTOCOL       "file:///"
      46             : 
      47             : namespace
      48             : {
      49             :     class theSvtLinguConfigItemMutex :
      50             :         public rtl::Static< osl::Mutex, theSvtLinguConfigItemMutex > {};
      51             : }
      52             : 
      53           6 : static bool lcl_SetLocale( sal_Int16 &rLanguage, const uno::Any &rVal )
      54             : {
      55           6 :     bool bSucc = false;
      56             : 
      57           6 :     lang::Locale aNew;
      58           6 :     if (rVal >>= aNew)  // conversion successful?
      59             :     {
      60           6 :         sal_Int16 nNew = LanguageTag::convertToLanguageType( aNew, false);
      61           6 :         if (nNew != rLanguage)
      62             :         {
      63           6 :             rLanguage = nNew;
      64           6 :             bSucc = true;
      65             :         }
      66             :     }
      67           6 :     return bSucc;
      68             : }
      69             : 
      70           3 : static inline const OUString lcl_LanguageToCfgLocaleStr( sal_Int16 nLanguage )
      71             : {
      72           3 :     OUString aRes;
      73           3 :     if (LANGUAGE_SYSTEM != nLanguage)
      74           3 :         aRes = LanguageTag::convertToBcp47( nLanguage );
      75           3 :     return aRes;
      76             : }
      77             : 
      78         348 : static sal_Int16 lcl_CfgAnyToLanguage( const uno::Any &rVal )
      79             : {
      80         348 :     OUString aTmp;
      81         348 :     rVal >>= aTmp;
      82         348 :     return (aTmp.isEmpty()) ? LANGUAGE_SYSTEM : LanguageTag::convertToLanguageTypeWithFallback( aTmp );
      83             : }
      84             : 
      85       46752 : SvtLinguOptions::SvtLinguOptions()
      86             :     : bROActiveDics(false)
      87             :     , bROActiveConvDics(false)
      88             :     , nHyphMinLeading(2)
      89             :     , nHyphMinTrailing(2)
      90             :     , nHyphMinWordLength(0)
      91             :     , bROHyphMinLeading(false)
      92             :     , bROHyphMinTrailing(false)
      93             :     , bROHyphMinWordLength(false)
      94             :     , nDefaultLanguage(LANGUAGE_NONE)
      95             :     , nDefaultLanguage_CJK(LANGUAGE_NONE)
      96             :     , nDefaultLanguage_CTL(LANGUAGE_NONE)
      97             :     , bRODefaultLanguage(false)
      98             :     , bRODefaultLanguage_CJK(false)
      99             :     , bRODefaultLanguage_CTL(false)
     100             :     , bIsSpellSpecial(true)
     101             :     , bIsSpellAuto(false)
     102             :     , bIsSpellReverse(false)
     103             :     , bROIsSpellSpecial(false)
     104             :     , bROIsSpellAuto(false)
     105             :     , bROIsSpellReverse(false)
     106             :     , bIsHyphSpecial(true)
     107             :     , bIsHyphAuto(false)
     108             :     , bROIsHyphSpecial(false)
     109             :     , bROIsHyphAuto(false)
     110             :     , bIsUseDictionaryList(true)
     111             :     , bIsIgnoreControlCharacters(true)
     112             :     , bROIsUseDictionaryList(false)
     113             :     , bROIsIgnoreControlCharacters(false)
     114             :     , bIsSpellWithDigits(false)
     115             :     , bIsSpellUpperCase(false)
     116             :     , bIsSpellCapitalization(true)
     117             :     , bROIsSpellWithDigits(false)
     118             :     , bROIsSpellUpperCase(false)
     119             :     , bROIsSpellCapitalization(false)
     120             :     , bIsIgnorePostPositionalWord(true)
     121             :     , bIsAutoCloseDialog(false)
     122             :     , bIsShowEntriesRecentlyUsedFirst(false)
     123             :     , bIsAutoReplaceUniqueEntries(false)
     124             :     , bIsDirectionToSimplified(true)
     125             :     , bIsUseCharacterVariants(false)
     126             :     , bIsTranslateCommonTerms(false)
     127             :     , bIsReverseMapping(false)
     128             :     , bROIsIgnorePostPositionalWord(false)
     129             :     , bROIsAutoCloseDialog(false)
     130             :     , bROIsShowEntriesRecentlyUsedFirst(false)
     131             :     , bROIsAutoReplaceUniqueEntries(false)
     132             :     , bROIsDirectionToSimplified(false)
     133             :     , bROIsUseCharacterVariants(false)
     134             :     , bROIsTranslateCommonTerms(false)
     135             :     , bROIsReverseMapping(false)
     136             :     , nDataFilesChangedCheckValue(0)
     137             :     , bRODataFilesChangedCheckValue(false)
     138             :     , bIsGrammarAuto(false)
     139             :     , bIsGrammarInteractive(false)
     140             :     , bROIsGrammarAuto(false)
     141       46752 :     , bROIsGrammarInteractive(false)
     142             : {
     143       46752 : }
     144             : 
     145             : class SvtLinguConfigItem : public utl::ConfigItem
     146             : {
     147             :     SvtLinguOptions     aOpt;
     148             : 
     149             :     static bool GetHdlByName( sal_Int32 &rnHdl, const OUString &rPropertyName, bool bFullPropName = false );
     150             :     static const uno::Sequence< OUString > GetPropertyNames();
     151             :     bool                LoadOptions( const uno::Sequence< OUString > &rProperyNames );
     152             :     bool                SaveOptions( const uno::Sequence< OUString > &rProperyNames );
     153             : 
     154             :     SvtLinguConfigItem(const SvtLinguConfigItem&) SAL_DELETED_FUNCTION;
     155             :     SvtLinguConfigItem& operator=(const SvtLinguConfigItem&) SAL_DELETED_FUNCTION;
     156             :     virtual void    ImplCommit() SAL_OVERRIDE;
     157             : 
     158             : public:
     159             :     SvtLinguConfigItem();
     160             :     virtual ~SvtLinguConfigItem();
     161             : 
     162             :     // utl::ConfigItem
     163             :     virtual void    Notify( const com::sun::star::uno::Sequence< OUString > &rPropertyNames ) SAL_OVERRIDE;
     164             : 
     165             :     // make some protected functions of utl::ConfigItem public
     166             :     using utl::ConfigItem::GetNodeNames;
     167             :     using utl::ConfigItem::GetProperties;
     168             :     //using utl::ConfigItem::PutProperties;
     169             :     //using utl::ConfigItem::SetSetProperties;
     170             :     using utl::ConfigItem::ReplaceSetProperties;
     171             :     //using utl::ConfigItem::GetReadOnlyStates;
     172             : 
     173             :     com::sun::star::uno::Any
     174             :             GetProperty( const OUString &rPropertyName ) const;
     175             :     com::sun::star::uno::Any
     176             :             GetProperty( sal_Int32 nPropertyHandle ) const;
     177             : 
     178             :     bool    SetProperty( const OUString &rPropertyName,
     179             :                          const com::sun::star::uno::Any &rValue );
     180             :     bool    SetProperty( sal_Int32 nPropertyHandle,
     181             :                          const com::sun::star::uno::Any &rValue );
     182             : 
     183             :     const SvtLinguOptions& GetOptions() const;
     184             : 
     185             :     bool    IsReadOnly( const OUString &rPropertyName ) const;
     186             :     bool    IsReadOnly( sal_Int32 nPropertyHandle ) const;
     187             : };
     188             : 
     189         116 : SvtLinguConfigItem::SvtLinguConfigItem() :
     190         116 :     utl::ConfigItem( OUString("Office.Linguistic") )
     191             : {
     192         116 :     const uno::Sequence< OUString > &rPropertyNames = GetPropertyNames();
     193         116 :     LoadOptions( rPropertyNames );
     194         116 :     ClearModified();
     195             : 
     196             :     // request notify events when properties change
     197         116 :     EnableNotification( rPropertyNames );
     198         116 : }
     199             : 
     200         222 : SvtLinguConfigItem::~SvtLinguConfigItem()
     201             : {
     202             :     //! Commit (SaveOptions) will be called by the d-tor of the base called !
     203         222 : }
     204             : 
     205           0 : void SvtLinguConfigItem::Notify( const uno::Sequence< OUString > &rPropertyNames )
     206             : {
     207           0 :     LoadOptions( rPropertyNames );
     208           0 :     NotifyListeners(0);
     209           0 : }
     210             : 
     211           1 : void SvtLinguConfigItem::ImplCommit()
     212             : {
     213           1 :     SaveOptions( GetPropertyNames() );
     214           1 : }
     215             : 
     216             : static struct NamesToHdl
     217             : {
     218             :     const char   *pFullPropName;      // full qualified name as used in configuration
     219             :     const char   *pPropName;          // property name only (atom) of above
     220             :     sal_Int32   nHdl;               // numeric handle representing the property
     221             : }aNamesToHdl[] =
     222             : {
     223             : {/*  0 */    "General/DefaultLocale",                         UPN_DEFAULT_LOCALE,                    UPH_DEFAULT_LOCALE},
     224             : {/*  1 */    "General/DictionaryList/ActiveDictionaries",     UPN_ACTIVE_DICTIONARIES,               UPH_ACTIVE_DICTIONARIES},
     225             : {/*  2 */    "General/DictionaryList/IsUseDictionaryList",    UPN_IS_USE_DICTIONARY_LIST,            UPH_IS_USE_DICTIONARY_LIST},
     226             : {/*  3 */    "General/IsIgnoreControlCharacters",             UPN_IS_IGNORE_CONTROL_CHARACTERS,      UPH_IS_IGNORE_CONTROL_CHARACTERS},
     227             : {/*  5 */    "General/DefaultLocale_CJK",                     UPN_DEFAULT_LOCALE_CJK,                UPH_DEFAULT_LOCALE_CJK},
     228             : {/*  6 */    "General/DefaultLocale_CTL",                     UPN_DEFAULT_LOCALE_CTL,                UPH_DEFAULT_LOCALE_CTL},
     229             : 
     230             : {/*  7 */    "SpellChecking/IsSpellUpperCase",                UPN_IS_SPELL_UPPER_CASE,               UPH_IS_SPELL_UPPER_CASE},
     231             : {/*  8 */    "SpellChecking/IsSpellWithDigits",               UPN_IS_SPELL_WITH_DIGITS,              UPH_IS_SPELL_WITH_DIGITS},
     232             : {/*  9 */    "SpellChecking/IsSpellCapitalization",           UPN_IS_SPELL_CAPITALIZATION,           UPH_IS_SPELL_CAPITALIZATION},
     233             : {/* 10 */    "SpellChecking/IsSpellAuto",                     UPN_IS_SPELL_AUTO,                     UPH_IS_SPELL_AUTO},
     234             : {/* 11 */    "SpellChecking/IsSpellSpecial",                  UPN_IS_SPELL_SPECIAL,                  UPH_IS_SPELL_SPECIAL},
     235             : {/* 14 */    "SpellChecking/IsReverseDirection",              UPN_IS_WRAP_REVERSE,                   UPH_IS_WRAP_REVERSE},
     236             : 
     237             : {/* 15 */    "Hyphenation/MinLeading",                        UPN_HYPH_MIN_LEADING,                  UPH_HYPH_MIN_LEADING},
     238             : {/* 16 */    "Hyphenation/MinTrailing",                       UPN_HYPH_MIN_TRAILING,                 UPH_HYPH_MIN_TRAILING},
     239             : {/* 17 */    "Hyphenation/MinWordLength",                     UPN_HYPH_MIN_WORD_LENGTH,              UPH_HYPH_MIN_WORD_LENGTH},
     240             : {/* 18 */    "Hyphenation/IsHyphSpecial",                     UPN_IS_HYPH_SPECIAL,                   UPH_IS_HYPH_SPECIAL},
     241             : {/* 19 */    "Hyphenation/IsHyphAuto",                        UPN_IS_HYPH_AUTO,                      UPH_IS_HYPH_AUTO},
     242             : 
     243             : {/* 20 */    "TextConversion/ActiveConversionDictionaries",   UPN_ACTIVE_CONVERSION_DICTIONARIES,        UPH_ACTIVE_CONVERSION_DICTIONARIES},
     244             : {/* 21 */    "TextConversion/IsIgnorePostPositionalWord",     UPN_IS_IGNORE_POST_POSITIONAL_WORD,        UPH_IS_IGNORE_POST_POSITIONAL_WORD},
     245             : {/* 22 */    "TextConversion/IsAutoCloseDialog",              UPN_IS_AUTO_CLOSE_DIALOG,                  UPH_IS_AUTO_CLOSE_DIALOG},
     246             : {/* 23 */    "TextConversion/IsShowEntriesRecentlyUsedFirst", UPN_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST,   UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST},
     247             : {/* 24 */    "TextConversion/IsAutoReplaceUniqueEntries",     UPN_IS_AUTO_REPLACE_UNIQUE_ENTRIES,        UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES},
     248             : {/* 25 */    "TextConversion/IsDirectionToSimplified",        UPN_IS_DIRECTION_TO_SIMPLIFIED,            UPH_IS_DIRECTION_TO_SIMPLIFIED},
     249             : {/* 26 */    "TextConversion/IsUseCharacterVariants",         UPN_IS_USE_CHARACTER_VARIANTS,             UPH_IS_USE_CHARACTER_VARIANTS},
     250             : {/* 27 */    "TextConversion/IsTranslateCommonTerms",         UPN_IS_TRANSLATE_COMMON_TERMS,             UPH_IS_TRANSLATE_COMMON_TERMS},
     251             : {/* 28 */    "TextConversion/IsReverseMapping",               UPN_IS_REVERSE_MAPPING,                    UPH_IS_REVERSE_MAPPING},
     252             : 
     253             : {/* 29 */    "ServiceManager/DataFilesChangedCheckValue",     UPN_DATA_FILES_CHANGED_CHECK_VALUE,        UPH_DATA_FILES_CHANGED_CHECK_VALUE},
     254             : 
     255             : {/* 30 */    "GrammarChecking/IsAutoCheck",                   UPN_IS_GRAMMAR_AUTO,                      UPH_IS_GRAMMAR_AUTO},
     256             : {/* 31 */    "GrammarChecking/IsInteractiveCheck",            UPN_IS_GRAMMAR_INTERACTIVE,               UPH_IS_GRAMMAR_INTERACTIVE},
     257             : 
     258             :             /* similar to entry 0 (thus no own configuration entry) but with different property name and type */
     259             : {            NULL,                                           UPN_DEFAULT_LANGUAGE,                      UPH_DEFAULT_LANGUAGE},
     260             : 
     261             : {            NULL,                                            NULL,                                      -1}
     262             : };
     263             : 
     264         117 : const uno::Sequence< OUString > SvtLinguConfigItem::GetPropertyNames()
     265             : {
     266         117 :     uno::Sequence< OUString > aNames;
     267             : 
     268         117 :     sal_Int32 nMax = SAL_N_ELEMENTS(aNamesToHdl);
     269             : 
     270         117 :     aNames.realloc( nMax );
     271         117 :     OUString *pNames = aNames.getArray();
     272         117 :     sal_Int32 nIdx = 0;
     273        3744 :     for (sal_Int32 i = 0; i < nMax;  ++i)
     274             :     {
     275        3627 :         const sal_Char *pFullPropName = aNamesToHdl[i].pFullPropName;
     276        3627 :         if (pFullPropName)
     277        3393 :             pNames[ nIdx++ ] = OUString::createFromAscii( pFullPropName );
     278             :     }
     279         117 :     aNames.realloc( nIdx );
     280             : 
     281         117 :     return aNames;
     282             : }
     283             : 
     284    26804454 : bool SvtLinguConfigItem::GetHdlByName(
     285             :     sal_Int32 &rnHdl,
     286             :     const OUString &rPropertyName,
     287             :     bool bFullPropName )
     288             : {
     289    26804454 :     NamesToHdl *pEntry = &aNamesToHdl[0];
     290             : 
     291    26804454 :     if (bFullPropName)
     292             :     {
     293       53824 :         while (pEntry && pEntry->pFullPropName != NULL)
     294             :         {
     295       50460 :             if (rPropertyName.equalsAscii( pEntry->pFullPropName ))
     296             :             {
     297        3364 :                 rnHdl = pEntry->nHdl;
     298        3364 :                 break;
     299             :             }
     300       47096 :             ++pEntry;
     301             :         }
     302        3364 :         return pEntry && pEntry->pFullPropName != NULL;
     303             :     }
     304             :     else
     305             :     {
     306   777226930 :         while (pEntry && pEntry->pPropName != NULL)
     307             :         {
     308   750425840 :             if (rPropertyName.equalsAscii( pEntry->pPropName ))
     309             :             {
     310    26801090 :                 rnHdl = pEntry->nHdl;
     311    26801090 :                 break;
     312             :             }
     313   723624750 :             ++pEntry;
     314             :         }
     315    26801090 :         return pEntry && pEntry->pPropName != NULL;
     316             :     }
     317             : }
     318             : 
     319    26801090 : uno::Any SvtLinguConfigItem::GetProperty( const OUString &rPropertyName ) const
     320             : {
     321    26801090 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     322             : 
     323             :     sal_Int32 nHdl;
     324    26801090 :     return GetHdlByName( nHdl, rPropertyName ) ? GetProperty( nHdl ) : uno::Any();
     325             : }
     326             : 
     327   197566810 : uno::Any SvtLinguConfigItem::GetProperty( sal_Int32 nPropertyHandle ) const
     328             : {
     329   197566810 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     330             : 
     331   197566810 :     uno::Any aRes;
     332             : 
     333   197566810 :     const sal_Int16 *pnVal = 0;
     334   197566810 :     const bool  *pbVal = 0;
     335   197566810 :     const sal_Int32 *pnInt32Val = 0;
     336             : 
     337   197566810 :     const SvtLinguOptions &rOpt = const_cast< SvtLinguConfigItem * >(this)->aOpt;
     338   197566810 :     switch (nPropertyHandle)
     339             :     {
     340    85382576 :         case UPH_IS_USE_DICTIONARY_LIST :   pbVal = &rOpt.bIsUseDictionaryList; break;
     341    85382576 :         case UPH_IS_IGNORE_CONTROL_CHARACTERS : pbVal = &rOpt.bIsIgnoreControlCharacters;   break;
     342          13 :         case UPH_IS_HYPH_AUTO :             pbVal = &rOpt.bIsHyphAuto;  break;
     343          13 :         case UPH_IS_HYPH_SPECIAL :          pbVal = &rOpt.bIsHyphSpecial;   break;
     344          16 :         case UPH_IS_SPELL_AUTO :            pbVal = &rOpt.bIsSpellAuto; break;
     345          97 :         case UPH_IS_SPELL_SPECIAL :         pbVal = &rOpt.bIsSpellSpecial;  break;
     346         181 :         case UPH_IS_WRAP_REVERSE :          pbVal = &rOpt.bIsSpellReverse;  break;
     347          13 :         case UPH_DEFAULT_LANGUAGE :         pnVal = &rOpt.nDefaultLanguage; break;
     348          40 :         case UPH_IS_SPELL_CAPITALIZATION :  pbVal = &rOpt.bIsSpellCapitalization;       break;
     349          40 :         case UPH_IS_SPELL_WITH_DIGITS :     pbVal = &rOpt.bIsSpellWithDigits;   break;
     350          41 :         case UPH_IS_SPELL_UPPER_CASE :      pbVal = &rOpt.bIsSpellUpperCase;        break;
     351          18 :         case UPH_HYPH_MIN_LEADING :         pnVal = &rOpt.nHyphMinLeading;      break;
     352          18 :         case UPH_HYPH_MIN_TRAILING :        pnVal = &rOpt.nHyphMinTrailing; break;
     353          18 :         case UPH_HYPH_MIN_WORD_LENGTH :     pnVal = &rOpt.nHyphMinWordLength;   break;
     354             :         case UPH_ACTIVE_DICTIONARIES :
     355             :         {
     356           0 :             aRes <<= rOpt.aActiveDics;
     357           0 :             break;
     358             :         }
     359             :         case UPH_ACTIVE_CONVERSION_DICTIONARIES :
     360             :         {
     361           0 :             aRes <<= rOpt.aActiveConvDics;
     362           0 :             break;
     363             :         }
     364             :         case UPH_DEFAULT_LOCALE :
     365             :         {
     366          78 :             lang::Locale aLocale( LanguageTag::convertToLocale( rOpt.nDefaultLanguage, false) );
     367          78 :             aRes.setValue( &aLocale, cppu::UnoType<lang::Locale>::get());
     368          78 :             break;
     369             :         }
     370             :         case UPH_DEFAULT_LOCALE_CJK :
     371             :         {
     372          78 :             lang::Locale aLocale( LanguageTag::convertToLocale( rOpt.nDefaultLanguage_CJK, false) );
     373          78 :             aRes.setValue( &aLocale, cppu::UnoType<lang::Locale>::get());
     374          78 :             break;
     375             :         }
     376             :         case UPH_DEFAULT_LOCALE_CTL :
     377             :         {
     378          78 :             lang::Locale aLocale( LanguageTag::convertToLocale( rOpt.nDefaultLanguage_CTL, false) );
     379          78 :             aRes.setValue( &aLocale, cppu::UnoType<lang::Locale>::get());
     380          78 :             break;
     381             :         }
     382           4 :         case UPH_IS_IGNORE_POST_POSITIONAL_WORD :       pbVal = &rOpt.bIsIgnorePostPositionalWord; break;
     383           0 :         case UPH_IS_AUTO_CLOSE_DIALOG :                 pbVal = &rOpt.bIsAutoCloseDialog; break;
     384           4 :         case UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST :  pbVal = &rOpt.bIsShowEntriesRecentlyUsedFirst; break;
     385           4 :         case UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES :       pbVal = &rOpt.bIsAutoReplaceUniqueEntries; break;
     386             : 
     387           0 :         case UPH_IS_DIRECTION_TO_SIMPLIFIED:            pbVal = &rOpt.bIsDirectionToSimplified; break;
     388           0 :         case UPH_IS_USE_CHARACTER_VARIANTS :            pbVal = &rOpt.bIsUseCharacterVariants; break;
     389           0 :         case UPH_IS_TRANSLATE_COMMON_TERMS :            pbVal = &rOpt.bIsTranslateCommonTerms; break;
     390           0 :         case UPH_IS_REVERSE_MAPPING :                   pbVal = &rOpt.bIsReverseMapping; break;
     391             : 
     392           0 :         case UPH_DATA_FILES_CHANGED_CHECK_VALUE :       pnInt32Val = &rOpt.nDataFilesChangedCheckValue; break;
     393    26800895 :         case UPH_IS_GRAMMAR_AUTO:                       pbVal = &rOpt.bIsGrammarAuto; break;
     394           0 :         case UPH_IS_GRAMMAR_INTERACTIVE:                pbVal = &rOpt.bIsGrammarInteractive; break;
     395             :         default :
     396             :             DBG_ASSERT( false, "unexpected property handle" );
     397             :     }
     398             : 
     399   197566810 :     if (pbVal)
     400   197566500 :         aRes <<= *pbVal;
     401         310 :     else if (pnVal)
     402          67 :         aRes <<= *pnVal;
     403         243 :     else if (pnInt32Val)
     404           0 :         aRes <<= *pnInt32Val;
     405             : 
     406   197566810 :     return aRes;
     407             : }
     408             : 
     409           0 : bool SvtLinguConfigItem::SetProperty( const OUString &rPropertyName, const uno::Any &rValue )
     410             : {
     411           0 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     412             : 
     413           0 :     bool bSucc = false;
     414             :     sal_Int32 nHdl;
     415           0 :     if (GetHdlByName( nHdl, rPropertyName ))
     416           0 :         bSucc = SetProperty( nHdl, rValue );
     417           0 :     return bSucc;
     418             : }
     419             : 
     420          63 : bool SvtLinguConfigItem::SetProperty( sal_Int32 nPropertyHandle, const uno::Any &rValue )
     421             : {
     422          63 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     423             : 
     424          63 :     bool bSucc = false;
     425          63 :     if (!rValue.hasValue())
     426           0 :         return bSucc;
     427             : 
     428          63 :     bool bMod = false;
     429             : 
     430          63 :     sal_Int16 *pnVal = 0;
     431          63 :     bool  *pbVal = 0;
     432          63 :     sal_Int32 *pnInt32Val = 0;
     433             : 
     434          63 :     SvtLinguOptions &rOpt = aOpt;
     435          63 :     switch (nPropertyHandle)
     436             :     {
     437           4 :         case UPH_IS_USE_DICTIONARY_LIST :   pbVal = &rOpt.bIsUseDictionaryList;    break;
     438           4 :         case UPH_IS_IGNORE_CONTROL_CHARACTERS : pbVal = &rOpt.bIsIgnoreControlCharacters;  break;
     439           4 :         case UPH_IS_HYPH_AUTO :             pbVal = &rOpt.bIsHyphAuto; break;
     440           4 :         case UPH_IS_HYPH_SPECIAL :          pbVal = &rOpt.bIsHyphSpecial;  break;
     441           5 :         case UPH_IS_SPELL_AUTO :            pbVal = &rOpt.bIsSpellAuto;    break;
     442           4 :         case UPH_IS_SPELL_SPECIAL :         pbVal = &rOpt.bIsSpellSpecial; break;
     443           4 :         case UPH_IS_WRAP_REVERSE :          pbVal = &rOpt.bIsSpellReverse; break;
     444           4 :         case UPH_DEFAULT_LANGUAGE :         pnVal = &rOpt.nDefaultLanguage;    break;
     445           4 :         case UPH_IS_SPELL_CAPITALIZATION :  pbVal = &rOpt.bIsSpellCapitalization;      break;
     446           4 :         case UPH_IS_SPELL_WITH_DIGITS :     pbVal = &rOpt.bIsSpellWithDigits;  break;
     447           4 :         case UPH_IS_SPELL_UPPER_CASE :      pbVal = &rOpt.bIsSpellUpperCase;       break;
     448           4 :         case UPH_HYPH_MIN_LEADING :         pnVal = &rOpt.nHyphMinLeading;     break;
     449           4 :         case UPH_HYPH_MIN_TRAILING :        pnVal = &rOpt.nHyphMinTrailing;    break;
     450           4 :         case UPH_HYPH_MIN_WORD_LENGTH :     pnVal = &rOpt.nHyphMinWordLength;  break;
     451             :         case UPH_ACTIVE_DICTIONARIES :
     452             :         {
     453           0 :             rValue >>= rOpt.aActiveDics;
     454           0 :             bMod = true;
     455           0 :             break;
     456             :         }
     457             :         case UPH_ACTIVE_CONVERSION_DICTIONARIES :
     458             :         {
     459           0 :             rValue >>= rOpt.aActiveConvDics;
     460           0 :             bMod = true;
     461           0 :             break;
     462             :         }
     463             :         case UPH_DEFAULT_LOCALE :
     464             :         {
     465           4 :             bSucc = lcl_SetLocale( rOpt.nDefaultLanguage, rValue );
     466           4 :             bMod = bSucc;
     467           4 :             break;
     468             :         }
     469             :         case UPH_DEFAULT_LOCALE_CJK :
     470             :         {
     471           1 :             bSucc = lcl_SetLocale( rOpt.nDefaultLanguage_CJK, rValue );
     472           1 :             bMod = bSucc;
     473           1 :             break;
     474             :         }
     475             :         case UPH_DEFAULT_LOCALE_CTL :
     476             :         {
     477           1 :             bSucc = lcl_SetLocale( rOpt.nDefaultLanguage_CTL, rValue );
     478           1 :             bMod = bSucc;
     479           1 :             break;
     480             :         }
     481           0 :         case UPH_IS_IGNORE_POST_POSITIONAL_WORD :       pbVal = &rOpt.bIsIgnorePostPositionalWord; break;
     482           0 :         case UPH_IS_AUTO_CLOSE_DIALOG :                 pbVal = &rOpt.bIsAutoCloseDialog; break;
     483           0 :         case UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST :  pbVal = &rOpt.bIsShowEntriesRecentlyUsedFirst; break;
     484           0 :         case UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES :       pbVal = &rOpt.bIsAutoReplaceUniqueEntries; break;
     485             : 
     486           0 :         case UPH_IS_DIRECTION_TO_SIMPLIFIED :           pbVal = &rOpt.bIsDirectionToSimplified; break;
     487           0 :         case UPH_IS_USE_CHARACTER_VARIANTS :            pbVal = &rOpt.bIsUseCharacterVariants; break;
     488           0 :         case UPH_IS_TRANSLATE_COMMON_TERMS :            pbVal = &rOpt.bIsTranslateCommonTerms; break;
     489           0 :         case UPH_IS_REVERSE_MAPPING :                   pbVal = &rOpt.bIsReverseMapping; break;
     490             : 
     491           0 :         case UPH_DATA_FILES_CHANGED_CHECK_VALUE :       pnInt32Val = &rOpt.nDataFilesChangedCheckValue; break;
     492           0 :         case UPH_IS_GRAMMAR_AUTO:                       pbVal = &rOpt.bIsGrammarAuto; break;
     493           0 :         case UPH_IS_GRAMMAR_INTERACTIVE:                pbVal = &rOpt.bIsGrammarInteractive; break;
     494             :         default :
     495             :             DBG_ASSERT( false, "unexpected property handle" );
     496             :     }
     497             : 
     498          63 :     if (pbVal)
     499             :     {
     500          41 :         bool bNew = bool();
     501          41 :         if (rValue >>= bNew)
     502             :         {
     503          41 :             if (bNew != *pbVal)
     504             :             {
     505          41 :                 *pbVal = bNew;
     506          41 :                 bMod = true;
     507             :             }
     508          41 :             bSucc = true;
     509             :         }
     510             :     }
     511          22 :     else if (pnVal)
     512             :     {
     513          16 :         sal_Int16 nNew = sal_Int16();
     514          16 :         if (rValue >>= nNew)
     515             :         {
     516          16 :             if (nNew != *pnVal)
     517             :             {
     518          16 :                 *pnVal = nNew;
     519          16 :                 bMod = true;
     520             :             }
     521          16 :             bSucc = true;
     522             :         }
     523             :     }
     524           6 :     else if (pnInt32Val)
     525             :     {
     526           0 :         sal_Int32 nNew = sal_Int32();
     527           0 :         if (rValue >>= nNew)
     528             :         {
     529           0 :             if (nNew != *pnInt32Val)
     530             :             {
     531           0 :                 *pnInt32Val = nNew;
     532           0 :                 bMod = true;
     533             :             }
     534           0 :             bSucc = true;
     535             :         }
     536             :     }
     537             : 
     538          63 :     if (bMod)
     539          63 :         SetModified();
     540             : 
     541          63 :     NotifyListeners(0);
     542          63 :     return bSucc;
     543             : }
     544             : 
     545       46527 : const SvtLinguOptions& SvtLinguConfigItem::GetOptions() const
     546             : {
     547       46527 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     548       46527 :     return aOpt;
     549             : }
     550             : 
     551         116 : bool SvtLinguConfigItem::LoadOptions( const uno::Sequence< OUString > &rProperyNames )
     552             : {
     553         116 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     554             : 
     555         116 :     bool bRes = false;
     556             : 
     557         116 :     const OUString *pProperyNames = rProperyNames.getConstArray();
     558         116 :     sal_Int32 nProps = rProperyNames.getLength();
     559             : 
     560         232 :     const uno::Sequence< uno::Any > aValues = GetProperties( rProperyNames );
     561         232 :     const uno::Sequence< sal_Bool > aROStates = GetReadOnlyStates( rProperyNames );
     562             : 
     563         116 :     if (nProps  &&  aValues.getLength() == nProps &&  aROStates.getLength() == nProps)
     564             :     {
     565         116 :         SvtLinguOptions &rOpt = aOpt;
     566             : 
     567         116 :         const uno::Any *pValue = aValues.getConstArray();
     568         116 :         const sal_Bool *pROStates = aROStates.getConstArray();
     569        3480 :         for (sal_Int32 i = 0;  i < nProps;  ++i)
     570             :         {
     571        3364 :             const uno::Any &rVal = pValue[i];
     572             :             sal_Int32 nPropertyHandle;
     573        3364 :             GetHdlByName( nPropertyHandle, pProperyNames[i], true );
     574        3364 :             switch ( nPropertyHandle )
     575             :             {
     576             :                 case UPH_DEFAULT_LOCALE :
     577         116 :                     { rOpt.bRODefaultLanguage = pROStates[i]; rOpt.nDefaultLanguage = lcl_CfgAnyToLanguage( rVal ); } break;
     578             :                 case UPH_ACTIVE_DICTIONARIES :
     579         116 :                     { rOpt.bROActiveDics = pROStates[i]; rVal >>= rOpt.aActiveDics;   } break;
     580             :                 case UPH_IS_USE_DICTIONARY_LIST :
     581         116 :                     { rOpt.bROIsUseDictionaryList = pROStates[i]; rVal >>= rOpt.bIsUseDictionaryList;  } break;
     582             :                 case UPH_IS_IGNORE_CONTROL_CHARACTERS :
     583         116 :                     { rOpt.bROIsIgnoreControlCharacters = pROStates[i]; rVal >>= rOpt.bIsIgnoreControlCharacters;    } break;
     584             :                 case UPH_DEFAULT_LOCALE_CJK :
     585         116 :                     { rOpt.bRODefaultLanguage_CJK = pROStates[i]; rOpt.nDefaultLanguage_CJK = lcl_CfgAnyToLanguage( rVal );    } break;
     586             :                 case UPH_DEFAULT_LOCALE_CTL :
     587         116 :                     { rOpt.bRODefaultLanguage_CTL = pROStates[i]; rOpt.nDefaultLanguage_CTL = lcl_CfgAnyToLanguage( rVal );    } break;
     588             : 
     589             :                 case UPH_IS_SPELL_UPPER_CASE :
     590         116 :                     { rOpt.bROIsSpellUpperCase = pROStates[i]; rVal >>= rOpt.bIsSpellUpperCase; } break;
     591             :                 case UPH_IS_SPELL_WITH_DIGITS :
     592         116 :                     { rOpt.bROIsSpellWithDigits = pROStates[i]; rVal >>= rOpt.bIsSpellWithDigits;    } break;
     593             :                 case UPH_IS_SPELL_CAPITALIZATION :
     594         116 :                     { rOpt.bROIsSpellCapitalization = pROStates[i]; rVal >>= rOpt.bIsSpellCapitalization;    } break;
     595             :                 case UPH_IS_SPELL_AUTO :
     596         116 :                     { rOpt.bROIsSpellAuto = pROStates[i]; rVal >>= rOpt.bIsSpellAuto;  } break;
     597             :                 case UPH_IS_SPELL_SPECIAL :
     598         116 :                     { rOpt.bROIsSpellSpecial = pROStates[i]; rVal >>= rOpt.bIsSpellSpecial;   } break;
     599             :                 case UPH_IS_WRAP_REVERSE :
     600         116 :                     { rOpt.bROIsSpellReverse = pROStates[i]; rVal >>= rOpt.bIsSpellReverse;   } break;
     601             : 
     602             :                 case UPH_HYPH_MIN_LEADING :
     603         116 :                     { rOpt.bROHyphMinLeading = pROStates[i]; rVal >>= rOpt.nHyphMinLeading;   } break;
     604             :                 case UPH_HYPH_MIN_TRAILING :
     605         116 :                     { rOpt.bROHyphMinTrailing = pROStates[i]; rVal >>= rOpt.nHyphMinTrailing;  } break;
     606             :                 case UPH_HYPH_MIN_WORD_LENGTH :
     607         116 :                     { rOpt.bROHyphMinWordLength = pROStates[i]; rVal >>= rOpt.nHyphMinWordLength;    } break;
     608             :                 case UPH_IS_HYPH_SPECIAL :
     609         116 :                     { rOpt.bROIsHyphSpecial = pROStates[i]; rVal >>= rOpt.bIsHyphSpecial;    } break;
     610             :                 case UPH_IS_HYPH_AUTO :
     611         116 :                     { rOpt.bROIsHyphAuto = pROStates[i]; rVal >>= rOpt.bIsHyphAuto;   } break;
     612             : 
     613         116 :                 case UPH_ACTIVE_CONVERSION_DICTIONARIES : { rOpt.bROActiveConvDics = pROStates[i]; rVal >>= rOpt.aActiveConvDics;   } break;
     614             : 
     615             :                 case UPH_IS_IGNORE_POST_POSITIONAL_WORD :
     616         116 :                     { rOpt.bROIsIgnorePostPositionalWord = pROStates[i]; rVal >>= rOpt.bIsIgnorePostPositionalWord;  } break;
     617             :                 case UPH_IS_AUTO_CLOSE_DIALOG :
     618         116 :                     { rOpt.bROIsAutoCloseDialog = pROStates[i]; rVal >>= rOpt.bIsAutoCloseDialog;  } break;
     619             :                 case UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST :
     620         116 :                     { rOpt.bROIsShowEntriesRecentlyUsedFirst = pROStates[i]; rVal >>= rOpt.bIsShowEntriesRecentlyUsedFirst;  } break;
     621             :                 case UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES :
     622         116 :                     { rOpt.bROIsAutoReplaceUniqueEntries = pROStates[i]; rVal >>= rOpt.bIsAutoReplaceUniqueEntries;  } break;
     623             : 
     624             :                 case UPH_IS_DIRECTION_TO_SIMPLIFIED :
     625         116 :                     { rOpt.bROIsDirectionToSimplified = pROStates[i];
     626         116 :                             if( ! (rVal >>= rOpt.bIsDirectionToSimplified) )
     627             :                             {
     628             :                                 //default is locale dependent:
     629         116 :                                 if (MsLangId::isTraditionalChinese(rOpt.nDefaultLanguage_CJK))
     630             :                                 {
     631           0 :                                     rOpt.bIsDirectionToSimplified = false;
     632             :                                 }
     633             :                                 else
     634             :                                 {
     635         116 :                                     rOpt.bIsDirectionToSimplified = true;
     636             :                                 }
     637             :                             }
     638         116 :                     } break;
     639             :                 case UPH_IS_USE_CHARACTER_VARIANTS :
     640         116 :                     { rOpt.bROIsUseCharacterVariants = pROStates[i]; rVal >>= rOpt.bIsUseCharacterVariants;  } break;
     641             :                 case UPH_IS_TRANSLATE_COMMON_TERMS :
     642         116 :                     { rOpt.bROIsTranslateCommonTerms = pROStates[i]; rVal >>= rOpt.bIsTranslateCommonTerms;  } break;
     643             :                 case UPH_IS_REVERSE_MAPPING :
     644         116 :                     { rOpt.bROIsReverseMapping = pROStates[i]; rVal >>= rOpt.bIsReverseMapping;  } break;
     645             : 
     646             :                 case UPH_DATA_FILES_CHANGED_CHECK_VALUE :
     647         116 :                     { rOpt.bRODataFilesChangedCheckValue = pROStates[i]; rVal >>= rOpt.nDataFilesChangedCheckValue;  } break;
     648             : 
     649             :                 case UPH_IS_GRAMMAR_AUTO:
     650         116 :                     { rOpt.bROIsGrammarAuto = pROStates[i]; rVal >>= rOpt.bIsGrammarAuto; }
     651         116 :                 break;
     652             :                 case UPH_IS_GRAMMAR_INTERACTIVE:
     653         116 :                     { rOpt.bROIsGrammarInteractive = pROStates[i]; rVal >>= rOpt.bIsGrammarInteractive; }
     654         116 :                 break;
     655             : 
     656             :                 default:
     657             :                     DBG_ASSERT( false, "unexpected case" );
     658             :             }
     659             :         }
     660             : 
     661         116 :         bRes = true;
     662             :     }
     663             :     DBG_ASSERT( bRes, "LoadOptions failed" );
     664             : 
     665         232 :     return bRes;
     666             : }
     667             : 
     668           1 : bool SvtLinguConfigItem::SaveOptions( const uno::Sequence< OUString > &rProperyNames )
     669             : {
     670           1 :     if (!IsModified())
     671           0 :         return true;
     672             : 
     673           1 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     674             : 
     675           1 :     bool bRet = false;
     676           1 :     const uno::Type &rBOOL     = cppu::UnoType<bool>::get();
     677           1 :     const uno::Type &rINT16    = cppu::UnoType<sal_Int16>::get();
     678           1 :     const uno::Type &rINT32    = cppu::UnoType<sal_Int32>::get();
     679             : 
     680           1 :     sal_Int32 nProps = rProperyNames.getLength();
     681           2 :     uno::Sequence< uno::Any > aValues( nProps );
     682           1 :     uno::Any *pValue = aValues.getArray();
     683             : 
     684           1 :     if (nProps  &&  aValues.getLength() == nProps)
     685             :     {
     686           1 :         const SvtLinguOptions &rOpt = aOpt;
     687             : 
     688           1 :         OUString aTmp( lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage ) );
     689           1 :         *pValue++ = uno::makeAny( aTmp );                               //   0
     690           1 :         *pValue++ = uno::makeAny( rOpt.aActiveDics );                   //   1
     691           1 :         pValue++->setValue( &rOpt.bIsUseDictionaryList, rBOOL );        //   2
     692           1 :         pValue++->setValue( &rOpt.bIsIgnoreControlCharacters, rBOOL );  //   3
     693           1 :         aTmp = lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage_CJK );
     694           1 :         *pValue++ = uno::makeAny( aTmp );                               //   5
     695           1 :         aTmp = lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage_CTL );
     696           1 :         *pValue++ = uno::makeAny( aTmp );                               //   6
     697             : 
     698           1 :         pValue++->setValue( &rOpt.bIsSpellUpperCase, rBOOL );          //   7
     699           1 :         pValue++->setValue( &rOpt.bIsSpellWithDigits, rBOOL );         //   8
     700           1 :         pValue++->setValue( &rOpt.bIsSpellCapitalization, rBOOL );     //   9
     701           1 :         pValue++->setValue( &rOpt.bIsSpellAuto, rBOOL );               //  10
     702           1 :         pValue++->setValue( &rOpt.bIsSpellSpecial, rBOOL );            //  11
     703           1 :         pValue++->setValue( &rOpt.bIsSpellReverse, rBOOL );            //  14
     704             : 
     705           1 :         pValue++->setValue( &rOpt.nHyphMinLeading, rINT16 );           //  15
     706           1 :         pValue++->setValue( &rOpt.nHyphMinTrailing, rINT16 );          //  16
     707           1 :         pValue++->setValue( &rOpt.nHyphMinWordLength, rINT16 );        //  17
     708           1 :         pValue++->setValue( &rOpt.bIsHyphSpecial, rBOOL );             //  18
     709           1 :         pValue++->setValue( &rOpt.bIsHyphAuto, rBOOL );                //  19
     710             : 
     711           1 :         *pValue++ = uno::makeAny( rOpt.aActiveConvDics );               //   20
     712             : 
     713           1 :         pValue++->setValue( &rOpt.bIsIgnorePostPositionalWord, rBOOL ); //  21
     714           1 :         pValue++->setValue( &rOpt.bIsAutoCloseDialog, rBOOL );          //  22
     715           1 :         pValue++->setValue( &rOpt.bIsShowEntriesRecentlyUsedFirst, rBOOL ); //  23
     716           1 :         pValue++->setValue( &rOpt.bIsAutoReplaceUniqueEntries, rBOOL ); //  24
     717             : 
     718           1 :         pValue++->setValue( &rOpt.bIsDirectionToSimplified, rBOOL ); //  25
     719           1 :         pValue++->setValue( &rOpt.bIsUseCharacterVariants, rBOOL ); //  26
     720           1 :         pValue++->setValue( &rOpt.bIsTranslateCommonTerms, rBOOL ); //  27
     721           1 :         pValue++->setValue( &rOpt.bIsReverseMapping, rBOOL ); //  28
     722             : 
     723           1 :         pValue++->setValue( &rOpt.nDataFilesChangedCheckValue, rINT32 ); //  29
     724           1 :         pValue++->setValue( &rOpt.bIsGrammarAuto, rBOOL ); //  30
     725           1 :         pValue++->setValue( &rOpt.bIsGrammarInteractive, rBOOL ); // 31
     726             : 
     727           1 :         bRet |= PutProperties( rProperyNames, aValues );
     728             :     }
     729             : 
     730           1 :     if (bRet)
     731           1 :         ClearModified();
     732             : 
     733           2 :     return bRet;
     734             : }
     735             : 
     736           0 : bool SvtLinguConfigItem::IsReadOnly( const OUString &rPropertyName ) const
     737             : {
     738           0 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     739             : 
     740           0 :     bool bReadOnly = false;
     741             :     sal_Int32 nHdl;
     742           0 :     if (GetHdlByName( nHdl, rPropertyName ))
     743           0 :         bReadOnly = IsReadOnly( nHdl );
     744           0 :     return bReadOnly;
     745             : }
     746             : 
     747           0 : bool SvtLinguConfigItem::IsReadOnly( sal_Int32 nPropertyHandle ) const
     748             : {
     749           0 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     750             : 
     751           0 :     bool bReadOnly = false;
     752             : 
     753           0 :     const SvtLinguOptions &rOpt = const_cast< SvtLinguConfigItem * >(this)->aOpt;
     754           0 :     switch(nPropertyHandle)
     755             :     {
     756           0 :         case UPH_IS_USE_DICTIONARY_LIST         : bReadOnly = rOpt.bROIsUseDictionaryList; break;
     757           0 :         case UPH_IS_IGNORE_CONTROL_CHARACTERS   : bReadOnly = rOpt.bROIsIgnoreControlCharacters; break;
     758           0 :         case UPH_IS_HYPH_AUTO                   : bReadOnly = rOpt.bROIsHyphAuto; break;
     759           0 :         case UPH_IS_HYPH_SPECIAL                : bReadOnly = rOpt.bROIsHyphSpecial; break;
     760           0 :         case UPH_IS_SPELL_AUTO                  : bReadOnly = rOpt.bROIsSpellAuto; break;
     761           0 :         case UPH_IS_SPELL_SPECIAL               : bReadOnly = rOpt.bROIsSpellSpecial; break;
     762           0 :         case UPH_IS_WRAP_REVERSE                : bReadOnly = rOpt.bROIsSpellReverse; break;
     763           0 :         case UPH_DEFAULT_LANGUAGE               : bReadOnly = rOpt.bRODefaultLanguage; break;
     764           0 :         case UPH_IS_SPELL_CAPITALIZATION        : bReadOnly = rOpt.bROIsSpellCapitalization; break;
     765           0 :         case UPH_IS_SPELL_WITH_DIGITS           : bReadOnly = rOpt.bROIsSpellWithDigits; break;
     766           0 :         case UPH_IS_SPELL_UPPER_CASE            : bReadOnly = rOpt.bROIsSpellUpperCase; break;
     767           0 :         case UPH_HYPH_MIN_LEADING               : bReadOnly = rOpt.bROHyphMinLeading; break;
     768           0 :         case UPH_HYPH_MIN_TRAILING              : bReadOnly = rOpt.bROHyphMinTrailing; break;
     769           0 :         case UPH_HYPH_MIN_WORD_LENGTH           : bReadOnly = rOpt.bROHyphMinWordLength; break;
     770           0 :         case UPH_ACTIVE_DICTIONARIES            : bReadOnly = rOpt.bROActiveDics; break;
     771           0 :         case UPH_ACTIVE_CONVERSION_DICTIONARIES : bReadOnly = rOpt.bROActiveConvDics; break;
     772           0 :         case UPH_DEFAULT_LOCALE                 : bReadOnly = rOpt.bRODefaultLanguage; break;
     773           0 :         case UPH_DEFAULT_LOCALE_CJK             : bReadOnly = rOpt.bRODefaultLanguage_CJK; break;
     774           0 :         case UPH_DEFAULT_LOCALE_CTL             : bReadOnly = rOpt.bRODefaultLanguage_CTL; break;
     775           0 :         case UPH_IS_IGNORE_POST_POSITIONAL_WORD :       bReadOnly = rOpt.bROIsIgnorePostPositionalWord; break;
     776           0 :         case UPH_IS_AUTO_CLOSE_DIALOG :                 bReadOnly = rOpt.bROIsAutoCloseDialog; break;
     777           0 :         case UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST :  bReadOnly = rOpt.bROIsShowEntriesRecentlyUsedFirst; break;
     778           0 :         case UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES :       bReadOnly = rOpt.bROIsAutoReplaceUniqueEntries; break;
     779           0 :         case UPH_IS_DIRECTION_TO_SIMPLIFIED : bReadOnly = rOpt.bROIsDirectionToSimplified; break;
     780           0 :         case UPH_IS_USE_CHARACTER_VARIANTS : bReadOnly = rOpt.bROIsUseCharacterVariants; break;
     781           0 :         case UPH_IS_TRANSLATE_COMMON_TERMS : bReadOnly = rOpt.bROIsTranslateCommonTerms; break;
     782           0 :         case UPH_IS_REVERSE_MAPPING :        bReadOnly = rOpt.bROIsReverseMapping; break;
     783           0 :         case UPH_DATA_FILES_CHANGED_CHECK_VALUE :       bReadOnly = rOpt.bRODataFilesChangedCheckValue; break;
     784           0 :         case UPH_IS_GRAMMAR_AUTO:                       bReadOnly = rOpt.bROIsGrammarAuto; break;
     785           0 :         case UPH_IS_GRAMMAR_INTERACTIVE:                bReadOnly = rOpt.bROIsGrammarInteractive; break;
     786             :         default :
     787             :             DBG_ASSERT( false, "unexpected property handle" );
     788             :     }
     789           0 :     return bReadOnly;
     790             : }
     791             : 
     792             : static SvtLinguConfigItem *pCfgItem = 0;
     793             : static sal_Int32           nCfgItemRefCount = 0;
     794             : 
     795             : static const char aG_SupportedDictionaryFormats[] = "SupportedDictionaryFormats";
     796             : static const char aG_Dictionaries[] = "Dictionaries";
     797             : static const char aG_Locations[] = "Locations";
     798             : static const char aG_Format[] = "Format";
     799             : static const char aG_Locales[] = "Locales";
     800             : static const char aG_DisabledDictionaries[] = "DisabledDictionaries";
     801             : 
     802    53566217 : SvtLinguConfig::SvtLinguConfig()
     803             : {
     804             :     // Global access, must be guarded (multithreading)
     805    53566217 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     806    53566217 :     ++nCfgItemRefCount;
     807    53566217 : }
     808             : 
     809   107132539 : SvtLinguConfig::~SvtLinguConfig()
     810             : {
     811    53566212 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     812             : 
     813    53566212 :     if (pCfgItem && pCfgItem->IsModified())
     814           0 :         pCfgItem->Commit();
     815             : 
     816    53566212 :     if (--nCfgItemRefCount <= 0)
     817             :     {
     818         111 :         if (pCfgItem)
     819         111 :             delete pCfgItem;
     820         111 :         pCfgItem = 0;
     821    53566212 :     }
     822    53566327 : }
     823             : 
     824   197614708 : SvtLinguConfigItem & SvtLinguConfig::GetConfigItem()
     825             : {
     826             :     // Global access, must be guarded (multithreading)
     827   197614708 :     osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
     828   197614708 :     if (!pCfgItem)
     829             :     {
     830         116 :         pCfgItem = new SvtLinguConfigItem;
     831         116 :         ItemHolder1::holdConfigItem(E_LINGUCFG);
     832             :     }
     833   197614708 :     return *pCfgItem;
     834             : }
     835             : 
     836         652 : uno::Sequence< OUString > SvtLinguConfig::GetNodeNames( const OUString &rNode )
     837             : {
     838         652 :     return GetConfigItem().GetNodeNames( rNode );
     839             : }
     840             : 
     841          40 : uno::Sequence< uno::Any > SvtLinguConfig::GetProperties( const uno::Sequence< OUString > &rNames )
     842             : {
     843          40 :     return GetConfigItem().GetProperties(rNames);
     844             : }
     845             : 
     846         616 : bool SvtLinguConfig::ReplaceSetProperties(
     847             :         const OUString &rNode, const uno::Sequence< beans::PropertyValue >& rValues )
     848             : {
     849         616 :     return GetConfigItem().ReplaceSetProperties( rNode, rValues );
     850             : }
     851             : 
     852    26801090 : uno::Any SvtLinguConfig::GetProperty( const OUString &rPropertyName ) const
     853             : {
     854    26801090 :     return GetConfigItem().GetProperty( rPropertyName );
     855             : }
     856             : 
     857   170765720 : uno::Any SvtLinguConfig::GetProperty( sal_Int32 nPropertyHandle ) const
     858             : {
     859   170765720 :     return GetConfigItem().GetProperty( nPropertyHandle );
     860             : }
     861             : 
     862           0 : bool SvtLinguConfig::SetProperty( const OUString &rPropertyName, const uno::Any &rValue )
     863             : {
     864           0 :     return GetConfigItem().SetProperty( rPropertyName, rValue );
     865             : }
     866             : 
     867          63 : bool SvtLinguConfig::SetProperty( sal_Int32 nPropertyHandle, const uno::Any &rValue )
     868             : {
     869          63 :     return GetConfigItem().SetProperty( nPropertyHandle, rValue );
     870             : }
     871             : 
     872       46527 : bool SvtLinguConfig::GetOptions( SvtLinguOptions &rOptions ) const
     873             : {
     874       46527 :     rOptions = GetConfigItem().GetOptions();
     875       46527 :     return true;
     876             : }
     877             : 
     878           0 : bool SvtLinguConfig::IsReadOnly( const OUString &rPropertyName ) const
     879             : {
     880           0 :     return GetConfigItem().IsReadOnly( rPropertyName );
     881             : }
     882             : 
     883         172 : bool SvtLinguConfig::GetElementNamesFor(
     884             :      const OUString &rNodeName,
     885             :      uno::Sequence< OUString > &rElementNames ) const
     886             : {
     887         172 :     bool bSuccess = false;
     888             :     try
     889             :     {
     890         172 :         uno::Reference< container::XNameAccess > xNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW );
     891         172 :         xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW );
     892         172 :         xNA.set( xNA->getByName( rNodeName ), uno::UNO_QUERY_THROW );
     893         172 :         rElementNames = xNA->getElementNames();
     894         172 :         bSuccess = true;
     895             :     }
     896           0 :     catch (uno::Exception &)
     897             :     {
     898             :     }
     899         172 :     return bSuccess;
     900             : }
     901             : 
     902         172 : bool SvtLinguConfig::GetSupportedDictionaryFormatsFor(
     903             :     const OUString &rSetName,
     904             :     const OUString &rSetEntry,
     905             :     uno::Sequence< OUString > &rFormatList ) const
     906             : {
     907         172 :     if (rSetName.isEmpty() || rSetEntry.isEmpty())
     908           0 :         return false;
     909         172 :     bool bSuccess = false;
     910             :     try
     911             :     {
     912         172 :         uno::Reference< container::XNameAccess > xNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW );
     913         172 :         xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW );
     914         172 :         xNA.set( xNA->getByName( rSetName ), uno::UNO_QUERY_THROW );
     915         172 :         xNA.set( xNA->getByName( rSetEntry ), uno::UNO_QUERY_THROW );
     916         172 :         if (xNA->getByName( OUString(aG_SupportedDictionaryFormats) ) >>= rFormatList)
     917         172 :             bSuccess = true;
     918         172 :         DBG_ASSERT( rFormatList.getLength(), "supported dictionary format list is empty" );
     919             :     }
     920           0 :     catch (uno::Exception &)
     921             :     {
     922             :     }
     923         172 :     return bSuccess;
     924             : }
     925             : 
     926           0 : static bool lcl_GetFileUrlFromOrigin(
     927             :     OUString /*out*/ &rFileUrl,
     928             :     const OUString &rOrigin )
     929             : {
     930             :     OUString aURL(
     931             :         comphelper::getExpandedUri(
     932           0 :             comphelper::getProcessComponentContext(), rOrigin));
     933           0 :     if (aURL.startsWith( FILE_PROTOCOL ))
     934             :     {
     935           0 :         rFileUrl = aURL;
     936           0 :         return true;
     937             :     }
     938             :     else
     939             :     {
     940             :         SAL_WARN(
     941             :             "unotools.config", "not a file URL, <" << aURL << ">" );
     942           0 :         return false;
     943           0 :     }
     944             : }
     945             : 
     946           0 : bool SvtLinguConfig::GetDictionaryEntry(
     947             :     const OUString &rNodeName,
     948             :     SvtLinguConfigDictionaryEntry &rDicEntry ) const
     949             : {
     950           0 :     if (rNodeName.isEmpty())
     951           0 :         return false;
     952           0 :     bool bSuccess = false;
     953             :     try
     954             :     {
     955           0 :         uno::Reference< container::XNameAccess > xNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW );
     956           0 :         xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW );
     957           0 :         xNA.set( xNA->getByName(OUString(aG_Dictionaries)), uno::UNO_QUERY_THROW );
     958           0 :         xNA.set( xNA->getByName( rNodeName ), uno::UNO_QUERY_THROW );
     959             : 
     960             :         // read group data...
     961           0 :         uno::Sequence< OUString >  aLocations;
     962           0 :         OUString                   aFormatName;
     963           0 :         uno::Sequence< OUString >  aLocaleNames;
     964           0 :         bSuccess =  (xNA->getByName( OUString(aG_Locations) ) >>= aLocations)  &&
     965           0 :                     (xNA->getByName( OUString(aG_Format) )    >>= aFormatName) &&
     966           0 :                     (xNA->getByName( OUString(aG_Locales) )   >>= aLocaleNames);
     967             :         DBG_ASSERT( aLocations.getLength(), "Dictionary locations not set" );
     968             :         DBG_ASSERT( !aFormatName.isEmpty(), "Dictionary format name not set" );
     969             :         DBG_ASSERT( aLocaleNames.getLength(), "No locales set for the dictionary" );
     970             : 
     971             :         // if successful continue
     972           0 :         if (bSuccess)
     973             :         {
     974             :             // get file URL's for the locations
     975           0 :             for (sal_Int32 i = 0;  i < aLocations.getLength();  ++i)
     976             :             {
     977           0 :                 OUString &rLocation = aLocations[i];
     978           0 :                 if (!lcl_GetFileUrlFromOrigin( rLocation, rLocation ))
     979           0 :                     bSuccess = false;
     980             :             }
     981             : 
     982             :             // if everything was fine return the result
     983           0 :             if (bSuccess)
     984             :             {
     985           0 :                 rDicEntry.aLocations    = aLocations;
     986           0 :                 rDicEntry.aFormatName   = aFormatName;
     987           0 :                 rDicEntry.aLocaleNames  = aLocaleNames;
     988             :             }
     989           0 :         }
     990             :     }
     991           0 :     catch (uno::Exception &)
     992             :     {
     993             :     }
     994           0 :     return bSuccess;
     995             : }
     996             : 
     997         172 : uno::Sequence< OUString > SvtLinguConfig::GetDisabledDictionaries() const
     998             : {
     999         172 :     uno::Sequence< OUString > aResult;
    1000             :     try
    1001             :     {
    1002         172 :         uno::Reference< container::XNameAccess > xNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW );
    1003         172 :         xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW );
    1004         172 :         xNA->getByName( OUString(aG_DisabledDictionaries) ) >>= aResult;
    1005             :     }
    1006           0 :     catch (uno::Exception &)
    1007             :     {
    1008             :     }
    1009         172 :     return aResult;
    1010             : }
    1011             : 
    1012         172 : std::vector< SvtLinguConfigDictionaryEntry > SvtLinguConfig::GetActiveDictionariesByFormat(
    1013             :     const OUString &rFormatName )
    1014             : {
    1015         172 :     std::vector< SvtLinguConfigDictionaryEntry > aRes;
    1016         172 :     if (rFormatName.isEmpty())
    1017           0 :         return aRes;
    1018             : 
    1019             :     try
    1020             :     {
    1021         172 :         uno::Sequence< OUString > aElementNames;
    1022         172 :         GetElementNamesFor( OUString(aG_Dictionaries), aElementNames );
    1023         172 :         sal_Int32 nLen = aElementNames.getLength();
    1024         172 :         const OUString *pElementNames = aElementNames.getConstArray();
    1025             : 
    1026         344 :         const uno::Sequence< OUString > aDisabledDics( GetDisabledDictionaries() );
    1027             : 
    1028         344 :         SvtLinguConfigDictionaryEntry aDicEntry;
    1029         172 :         for (sal_Int32 i = 0;  i < nLen;  ++i)
    1030             :         {
    1031             :             // does dictionary match the format we are looking for?
    1032           0 :             if (GetDictionaryEntry( pElementNames[i], aDicEntry ) &&
    1033           0 :                 aDicEntry.aFormatName == rFormatName)
    1034             :             {
    1035             :                 // check if it is active or not
    1036           0 :                 bool bDicIsActive = true;
    1037           0 :                 for (sal_Int32 k = 0;  bDicIsActive && k < aDisabledDics.getLength();  ++k)
    1038             :                 {
    1039           0 :                     if (aDisabledDics[k] == pElementNames[i])
    1040           0 :                         bDicIsActive = false;
    1041             :                 }
    1042             : 
    1043           0 :                 if (bDicIsActive)
    1044             :                 {
    1045             :                     DBG_ASSERT( !aDicEntry.aFormatName.isEmpty(),
    1046             :                             "FormatName not set" );
    1047             :                     DBG_ASSERT( aDicEntry.aLocations.getLength(),
    1048             :                             "Locations not set" );
    1049             :                     DBG_ASSERT( aDicEntry.aLocaleNames.getLength(),
    1050             :                             "Locales not set" );
    1051           0 :                     aRes.push_back( aDicEntry );
    1052             :                 }
    1053             :             }
    1054         172 :         }
    1055             :     }
    1056           0 :     catch (uno::Exception &)
    1057             :     {
    1058             :     }
    1059             : 
    1060         172 :     return aRes;
    1061             : }
    1062             : 
    1063    26718822 : uno::Reference< util::XChangesBatch > SvtLinguConfig::GetMainUpdateAccess() const
    1064             : {
    1065    26718822 :     if (!m_xMainUpdateAccess.is())
    1066             :     {
    1067             :         try
    1068             :         {
    1069             :             // get configuration provider
    1070    26718478 :             uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
    1071             :             uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider =
    1072    53436956 :                     configuration::theDefaultProvider::get( xContext );
    1073             : 
    1074             :             // get configuration update access
    1075    53436956 :             beans::PropertyValue aValue;
    1076    26718478 :             aValue.Name  = "nodepath";
    1077    26718478 :             aValue.Value = uno::makeAny(OUString("org.openoffice.Office.Linguistic"));
    1078    53436956 :             uno::Sequence< uno::Any > aProps(1);
    1079    26718478 :             aProps[0] <<= aValue;
    1080    53436956 :             m_xMainUpdateAccess = uno::Reference< util::XChangesBatch >(
    1081    26718478 :                     xConfigurationProvider->createInstanceWithArguments(
    1082    26718478 :                         OUString("com.sun.star.configuration.ConfigurationUpdateAccess"), aProps),
    1083    53436956 :                         uno::UNO_QUERY_THROW );
    1084             :         }
    1085           0 :         catch (uno::Exception &)
    1086             :         {
    1087             :         }
    1088             :     }
    1089             : 
    1090    26718822 :     return m_xMainUpdateAccess;
    1091             : }
    1092             : 
    1093           0 : OUString SvtLinguConfig::GetVendorImageUrl_Impl(
    1094             :     const OUString &rServiceImplName,
    1095             :     const OUString &rImageName ) const
    1096             : {
    1097           0 :     OUString aRes;
    1098             :     try
    1099             :     {
    1100           0 :         uno::Reference< container::XNameAccess > xImagesNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW );
    1101           0 :         xImagesNA.set( xImagesNA->getByName("Images"), uno::UNO_QUERY_THROW );
    1102             : 
    1103           0 :         uno::Reference< container::XNameAccess > xNA( xImagesNA->getByName("ServiceNameEntries"), uno::UNO_QUERY_THROW );
    1104           0 :         xNA.set( xNA->getByName( rServiceImplName ), uno::UNO_QUERY_THROW );
    1105           0 :         uno::Any aAny(xNA->getByName("VendorImagesNode"));
    1106           0 :         OUString aVendorImagesNode;
    1107           0 :         if (aAny >>= aVendorImagesNode)
    1108             :         {
    1109           0 :             xNA = xImagesNA;
    1110           0 :             xNA.set( xNA->getByName("VendorImages"), uno::UNO_QUERY_THROW );
    1111           0 :             xNA.set( xNA->getByName( aVendorImagesNode ), uno::UNO_QUERY_THROW );
    1112           0 :             aAny = xNA->getByName( rImageName );
    1113           0 :             OUString aTmp;
    1114           0 :             if (aAny >>= aTmp)
    1115             :             {
    1116           0 :                 if (lcl_GetFileUrlFromOrigin( aTmp, aTmp ))
    1117           0 :                     aRes = aTmp;
    1118           0 :             }
    1119           0 :         }
    1120             :     }
    1121           0 :     catch (uno::Exception &)
    1122             :     {
    1123             :         DBG_ASSERT( false, "exception caught. GetVendorImageUrl_Impl failed" );
    1124             :     }
    1125           0 :     return aRes;
    1126             : }
    1127             : 
    1128           0 : OUString SvtLinguConfig::GetSpellAndGrammarContextSuggestionImage(
    1129             :     const OUString &rServiceImplName
    1130             : ) const
    1131             : {
    1132           0 :     OUString   aRes;
    1133           0 :     if (!rServiceImplName.isEmpty())
    1134             :     {
    1135           0 :         OUString aImageName( "SpellAndGrammarContextMenuSuggestionImage" );
    1136           0 :         OUString aPath( GetVendorImageUrl_Impl( rServiceImplName, aImageName ) );
    1137           0 :         aRes = aPath;
    1138             :     }
    1139           0 :     return aRes;
    1140             : }
    1141             : 
    1142           0 : OUString SvtLinguConfig::GetSpellAndGrammarContextDictionaryImage(
    1143             :     const OUString &rServiceImplName
    1144             : ) const
    1145             : {
    1146           0 :     OUString   aRes;
    1147           0 :     if (!rServiceImplName.isEmpty())
    1148             :     {
    1149           0 :         OUString aImageName( "SpellAndGrammarContextMenuDictionaryImage" );
    1150           0 :         OUString aPath( GetVendorImageUrl_Impl( rServiceImplName, aImageName ) );
    1151           0 :         aRes = aPath;
    1152             :     }
    1153           0 :     return aRes;
    1154             : }
    1155             : 
    1156           0 : OUString SvtLinguConfig::GetSynonymsContextImage(
    1157             :     const OUString &rServiceImplName
    1158             : ) const
    1159             : {
    1160           0 :     OUString   aRes;
    1161           0 :     if (!rServiceImplName.isEmpty())
    1162             :     {
    1163           0 :         OUString aImageName( "SynonymsContextMenuImage" );
    1164           0 :         OUString aPath( GetVendorImageUrl_Impl( rServiceImplName, aImageName ) );
    1165           0 :         aRes = aPath;
    1166             :     }
    1167           0 :     return aRes;
    1168             : }
    1169             : 
    1170    26718306 : bool SvtLinguConfig::HasGrammarChecker() const
    1171             : {
    1172    26718306 :     bool bRes = false;
    1173             : 
    1174             :     try
    1175             :     {
    1176    26718306 :         uno::Reference< container::XNameAccess > xNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW );
    1177    26718306 :         xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW );
    1178    26718306 :         xNA.set( xNA->getByName("GrammarCheckerList"), uno::UNO_QUERY_THROW );
    1179             : 
    1180    53436612 :         uno::Sequence< OUString > aElementNames( xNA->getElementNames() );
    1181    53436612 :         bRes = aElementNames.getLength() > 0;
    1182             :     }
    1183           0 :     catch (const uno::Exception&)
    1184             :     {
    1185             :     }
    1186             : 
    1187    26718306 :     return bRes;
    1188             : }
    1189             : 
    1190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11