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 <editeng/unolingu.hxx>
21 : #include <unotools/lingucfg.hxx>
22 : #include <i18npool/mslangid.hxx>
23 : #include <i18npool/languagetag.hxx>
24 : #include <com/sun/star/i18n/ScriptType.hpp>
25 : #include <com/sun/star/linguistic2/XThesaurus.hpp>
26 : #include <com/sun/star/lang/Locale.hpp>
27 :
28 : using namespace com::sun::star;
29 :
30 : #include "scmod.hxx"
31 :
32 : //------------------------------------------------------------------
33 :
34 : #define LINGUPROP_AUTOSPELL "IsSpellAuto"
35 :
36 : //------------------------------------------------------------------
37 :
38 71 : void ScModule::GetSpellSettings( sal_uInt16& rDefLang, sal_uInt16& rCjkLang, sal_uInt16& rCtlLang,
39 : sal_Bool& rAutoSpell )
40 : {
41 : // use SvtLinguConfig instead of service LinguProperties to avoid
42 : // loading the linguistic component
43 71 : SvtLinguConfig aConfig;
44 :
45 71 : SvtLinguOptions aOptions;
46 71 : aConfig.GetOptions( aOptions );
47 :
48 71 : rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
49 71 : rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
50 71 : rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
51 71 : rAutoSpell = aOptions.bIsSpellAuto;
52 71 : }
53 :
54 0 : void ScModule::SetAutoSpellProperty( sal_Bool bSet )
55 : {
56 : // use SvtLinguConfig instead of service LinguProperties to avoid
57 : // loading the linguistic component
58 0 : SvtLinguConfig aConfig;
59 :
60 0 : uno::Any aAny;
61 0 : aAny <<= bSet;
62 0 : aConfig.SetProperty( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( LINGUPROP_AUTOSPELL )), aAny );
63 0 : }
64 :
65 :
66 :
67 0 : sal_Bool ScModule::HasThesaurusLanguage( sal_uInt16 nLang )
68 : {
69 0 : if ( nLang == LANGUAGE_NONE )
70 0 : return false;
71 :
72 0 : sal_Bool bHasLang = false;
73 : try
74 : {
75 0 : uno::Reference< linguistic2::XThesaurus > xThes(LinguMgr::GetThesaurus());
76 0 : if ( xThes.is() )
77 0 : bHasLang = xThes->hasLocale( LanguageTag( nLang ).getLocale() );
78 : }
79 0 : catch( uno::Exception& )
80 : {
81 : OSL_FAIL("Error in Thesaurus");
82 : }
83 :
84 0 : return bHasLang;
85 : }
86 :
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|