Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / app / scmod2.cxx
blobbe7eccd80b23c5ffe5f143d8f483177046a1d5dd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <editeng/unolingu.hxx>
21 #include <unotools/lingucfg.hxx>
22 #include <i18nlangtag/mslangid.hxx>
23 #include <i18nlangtag/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>
28 using namespace com::sun::star;
30 #include "scmod.hxx"
32 //------------------------------------------------------------------
34 #define LINGUPROP_AUTOSPELL "IsSpellAuto"
36 //------------------------------------------------------------------
38 void ScModule::GetSpellSettings( sal_uInt16& rDefLang, sal_uInt16& rCjkLang, sal_uInt16& rCtlLang,
39 sal_Bool& rAutoSpell )
41 // use SvtLinguConfig instead of service LinguProperties to avoid
42 // loading the linguistic component
43 SvtLinguConfig aConfig;
45 SvtLinguOptions aOptions;
46 aConfig.GetOptions( aOptions );
48 rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
49 rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
50 rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
51 rAutoSpell = aOptions.bIsSpellAuto;
54 void ScModule::SetAutoSpellProperty( sal_Bool bSet )
56 // use SvtLinguConfig instead of service LinguProperties to avoid
57 // loading the linguistic component
58 SvtLinguConfig aConfig;
60 uno::Any aAny;
61 aAny <<= bSet;
62 aConfig.SetProperty( OUString( LINGUPROP_AUTOSPELL ), aAny );
67 sal_Bool ScModule::HasThesaurusLanguage( sal_uInt16 nLang )
69 if ( nLang == LANGUAGE_NONE )
70 return false;
72 sal_Bool bHasLang = false;
73 try
75 uno::Reference< linguistic2::XThesaurus > xThes(LinguMgr::GetThesaurus());
76 if ( xThes.is() )
77 bHasLang = xThes->hasLocale( LanguageTag::convertToLocale( nLang ) );
79 catch( uno::Exception& )
81 OSL_FAIL("Error in Thesaurus");
84 return bHasLang;
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */