xref: /aoo42x/main/sc/source/ui/app/scmod2.cxx (revision b3f79822)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19*b3f79822SAndrew Rist  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //------------------------------------------------------------------
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <editeng/unolingu.hxx>
32cdf0e10cSrcweir #include <unotools/lingucfg.hxx>
33cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
34cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp>
35cdf0e10cSrcweir #include <com/sun/star/linguistic2/XThesaurus.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using namespace com::sun::star;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "scmod.hxx"
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //------------------------------------------------------------------
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #define LINGUPROP_AUTOSPELL			"IsSpellAuto"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //------------------------------------------------------------------
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // static
GetSpellSettings(sal_uInt16 & rDefLang,sal_uInt16 & rCjkLang,sal_uInt16 & rCtlLang,sal_Bool & rAutoSpell)49cdf0e10cSrcweir void ScModule::GetSpellSettings( sal_uInt16& rDefLang, sal_uInt16& rCjkLang, sal_uInt16& rCtlLang,
50cdf0e10cSrcweir                                     sal_Bool& rAutoSpell )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	//	use SvtLinguConfig instead of service LinguProperties to avoid
53cdf0e10cSrcweir 	//	loading the linguistic component
54cdf0e10cSrcweir 	SvtLinguConfig aConfig;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	SvtLinguOptions aOptions;
57cdf0e10cSrcweir 	aConfig.GetOptions( aOptions );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
60cdf0e10cSrcweir 	rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
61cdf0e10cSrcweir 	rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
62cdf0e10cSrcweir 	rAutoSpell = aOptions.bIsSpellAuto;
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // static
SetAutoSpellProperty(sal_Bool bSet)66cdf0e10cSrcweir void ScModule::SetAutoSpellProperty( sal_Bool bSet )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	//	use SvtLinguConfig instead of service LinguProperties to avoid
69cdf0e10cSrcweir 	//	loading the linguistic component
70cdf0e10cSrcweir 	SvtLinguConfig aConfig;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	uno::Any aAny;
73cdf0e10cSrcweir 	aAny <<= bSet;
74cdf0e10cSrcweir 	aConfig.SetProperty( rtl::OUString::createFromAscii( LINGUPROP_AUTOSPELL ), aAny );
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // static
HasThesaurusLanguage(sal_uInt16 nLang)80cdf0e10cSrcweir sal_Bool ScModule::HasThesaurusLanguage( sal_uInt16 nLang )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	if ( nLang == LANGUAGE_NONE )
83cdf0e10cSrcweir 		return sal_False;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	lang::Locale aLocale;
86cdf0e10cSrcweir 	SvxLanguageToLocale( aLocale, nLang );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	sal_Bool bHasLang = sal_False;
89cdf0e10cSrcweir 	try
90cdf0e10cSrcweir 	{
91cdf0e10cSrcweir 		uno::Reference< linguistic2::XThesaurus > xThes(LinguMgr::GetThesaurus());
92cdf0e10cSrcweir 		if ( xThes.is() )
93cdf0e10cSrcweir 			bHasLang = xThes->hasLocale( aLocale );
94cdf0e10cSrcweir 	}
95cdf0e10cSrcweir 	catch( uno::Exception& )
96cdf0e10cSrcweir 	{
97cdf0e10cSrcweir 		DBG_ERROR("Error in Thesaurus");
98cdf0e10cSrcweir 	}
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	return bHasLang;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104