xref: /trunk/main/sc/source/ui/app/scmod2.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 //------------------------------------------------------------------
34 
35 #include <editeng/unolingu.hxx>
36 #include <unotools/lingucfg.hxx>
37 #include <i18npool/mslangid.hxx>
38 #include <com/sun/star/i18n/ScriptType.hpp>
39 #include <com/sun/star/linguistic2/XThesaurus.hpp>
40 #include <com/sun/star/lang/Locale.hpp>
41 
42 using namespace com::sun::star;
43 
44 #include "scmod.hxx"
45 
46 //------------------------------------------------------------------
47 
48 #define LINGUPROP_AUTOSPELL			"IsSpellAuto"
49 
50 //------------------------------------------------------------------
51 
52 // static
53 void ScModule::GetSpellSettings( sal_uInt16& rDefLang, sal_uInt16& rCjkLang, sal_uInt16& rCtlLang,
54                                     sal_Bool& rAutoSpell )
55 {
56 	//	use SvtLinguConfig instead of service LinguProperties to avoid
57 	//	loading the linguistic component
58 	SvtLinguConfig aConfig;
59 
60 	SvtLinguOptions aOptions;
61 	aConfig.GetOptions( aOptions );
62 
63 	rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
64 	rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
65 	rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
66 	rAutoSpell = aOptions.bIsSpellAuto;
67 }
68 
69 // static
70 void ScModule::SetAutoSpellProperty( sal_Bool bSet )
71 {
72 	//	use SvtLinguConfig instead of service LinguProperties to avoid
73 	//	loading the linguistic component
74 	SvtLinguConfig aConfig;
75 
76 	uno::Any aAny;
77 	aAny <<= bSet;
78 	aConfig.SetProperty( rtl::OUString::createFromAscii( LINGUPROP_AUTOSPELL ), aAny );
79 }
80 
81 
82 
83 // static
84 sal_Bool ScModule::HasThesaurusLanguage( sal_uInt16 nLang )
85 {
86 	if ( nLang == LANGUAGE_NONE )
87 		return sal_False;
88 
89 	lang::Locale aLocale;
90 	SvxLanguageToLocale( aLocale, nLang );
91 
92 	sal_Bool bHasLang = sal_False;
93 	try
94 	{
95 		uno::Reference< linguistic2::XThesaurus > xThes(LinguMgr::GetThesaurus());
96 		if ( xThes.is() )
97 			bHasLang = xThes->hasLocale( aLocale );
98 	}
99 	catch( uno::Exception& )
100 	{
101 		DBG_ERROR("Error in Thesaurus");
102 	}
103 
104 	return bHasLang;
105 }
106 
107 
108