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