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