1*40df464eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*40df464eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*40df464eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*40df464eSAndrew Rist * distributed with this work for additional information 6*40df464eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*40df464eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*40df464eSAndrew Rist * "License"); you may not use this file except in compliance 9*40df464eSAndrew Rist * with the License. You may obtain a copy of the License at 10*40df464eSAndrew Rist * 11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*40df464eSAndrew Rist * 13*40df464eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*40df464eSAndrew Rist * software distributed under the License is distributed on an 15*40df464eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*40df464eSAndrew Rist * KIND, either express or implied. See the License for the 17*40df464eSAndrew Rist * specific language governing permissions and limitations 18*40df464eSAndrew Rist * under the License. 19*40df464eSAndrew Rist * 20*40df464eSAndrew Rist *************************************************************/ 21*40df464eSAndrew Rist 22*40df464eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svl/languageoptions.hxx> 28cdf0e10cSrcweir #include <svl/cjkoptions.hxx> 29cdf0e10cSrcweir #include <svl/ctloptions.hxx> 30cdf0e10cSrcweir #include <i18npool/mslangid.hxx> 31cdf0e10cSrcweir #include <vos/mutex.hxx> 32cdf0e10cSrcweir #include <osl/mutex.hxx> 33cdf0e10cSrcweir #include <rtl/instance.hxx> 34cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp> 35cdf0e10cSrcweir #include <unotools/syslocale.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir using namespace ::com::sun::star; 38cdf0e10cSrcweir // global ---------------------------------------------------------------------- 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace { struct ALMutex : public rtl::Static< ::osl::Mutex, ALMutex > {}; } 41cdf0e10cSrcweir 42cdf0e10cSrcweir // class SvtLanguageOptions ---------------------------------------------------- 43cdf0e10cSrcweir SvtLanguageOptions(sal_Bool _bDontLoad)44cdf0e10cSrcweirSvtLanguageOptions::SvtLanguageOptions( sal_Bool _bDontLoad ) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir // Global access, must be guarded (multithreading) 47cdf0e10cSrcweir ::osl::MutexGuard aGuard( ALMutex::get() ); 48cdf0e10cSrcweir 49cdf0e10cSrcweir m_pCJKOptions = new SvtCJKOptions( _bDontLoad ); 50cdf0e10cSrcweir m_pCTLOptions = new SvtCTLOptions( _bDontLoad ); 51cdf0e10cSrcweir m_pCTLOptions->AddListener(this); 52cdf0e10cSrcweir m_pCJKOptions->AddListener(this); 53cdf0e10cSrcweir } 54cdf0e10cSrcweir //------------------------------------------------------------------------------ ~SvtLanguageOptions()55cdf0e10cSrcweirSvtLanguageOptions::~SvtLanguageOptions() 56cdf0e10cSrcweir { 57cdf0e10cSrcweir // Global access, must be guarded (multithreading) 58cdf0e10cSrcweir ::osl::MutexGuard aGuard( ALMutex::get() ); 59cdf0e10cSrcweir 60cdf0e10cSrcweir m_pCTLOptions->RemoveListener(this); 61cdf0e10cSrcweir m_pCJKOptions->RemoveListener(this); 62cdf0e10cSrcweir 63cdf0e10cSrcweir delete m_pCJKOptions; 64cdf0e10cSrcweir delete m_pCTLOptions; 65cdf0e10cSrcweir } 66cdf0e10cSrcweir //------------------------------------------------------------------------------ 67cdf0e10cSrcweir // CJK options ----------------------------------------------------------------- 68cdf0e10cSrcweir //------------------------------------------------------------------------------ IsCJKFontEnabled() const69cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsCJKFontEnabled() const 70cdf0e10cSrcweir { 71cdf0e10cSrcweir return m_pCJKOptions->IsCJKFontEnabled(); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir //------------------------------------------------------------------------------ IsVerticalTextEnabled() const74cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsVerticalTextEnabled() const 75cdf0e10cSrcweir { 76cdf0e10cSrcweir return m_pCJKOptions->IsVerticalTextEnabled(); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir //------------------------------------------------------------------------------ IsAsianTypographyEnabled() const79cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsAsianTypographyEnabled() const 80cdf0e10cSrcweir { 81cdf0e10cSrcweir return m_pCJKOptions->IsAsianTypographyEnabled(); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir //------------------------------------------------------------------------------ IsJapaneseFindEnabled() const84cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsJapaneseFindEnabled() const 85cdf0e10cSrcweir { 86cdf0e10cSrcweir return m_pCJKOptions->IsJapaneseFindEnabled(); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir //------------------------------------------------------------------------------ IsRubyEnabled() const89cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsRubyEnabled() const 90cdf0e10cSrcweir { 91cdf0e10cSrcweir return m_pCJKOptions->IsRubyEnabled(); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir //------------------------------------------------------------------------------ IsChangeCaseMapEnabled() const94cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsChangeCaseMapEnabled() const 95cdf0e10cSrcweir { 96cdf0e10cSrcweir return m_pCJKOptions->IsChangeCaseMapEnabled(); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir //------------------------------------------------------------------------------ IsDoubleLinesEnabled() const99cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsDoubleLinesEnabled() const 100cdf0e10cSrcweir { 101cdf0e10cSrcweir return m_pCJKOptions->IsDoubleLinesEnabled(); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir //------------------------------------------------------------------------------ IsEmphasisMarksEnabled() const104cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsEmphasisMarksEnabled() const 105cdf0e10cSrcweir { 106cdf0e10cSrcweir return m_pCJKOptions->IsEmphasisMarksEnabled(); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir //------------------------------------------------------------------------------ IsVerticalCallOutEnabled() const109cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsVerticalCallOutEnabled() const 110cdf0e10cSrcweir { 111cdf0e10cSrcweir return m_pCJKOptions->IsVerticalCallOutEnabled(); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir //------------------------------------------------------------------------------ SetAll(sal_Bool _bSet)114cdf0e10cSrcweirvoid SvtLanguageOptions::SetAll( sal_Bool _bSet ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir m_pCJKOptions->SetAll( _bSet ); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir //------------------------------------------------------------------------------ IsAnyEnabled() const119cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsAnyEnabled() const 120cdf0e10cSrcweir { 121cdf0e10cSrcweir return m_pCJKOptions->IsAnyEnabled(); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir //------------------------------------------------------------------------------ 124cdf0e10cSrcweir // CTL options ----------------------------------------------------------------- 125cdf0e10cSrcweir //------------------------------------------------------------------------------ SetCTLFontEnabled(sal_Bool _bEnabled)126cdf0e10cSrcweirvoid SvtLanguageOptions::SetCTLFontEnabled( sal_Bool _bEnabled ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir m_pCTLOptions->SetCTLFontEnabled( _bEnabled ); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir //------------------------------------------------------------------------------ IsCTLFontEnabled() const131cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsCTLFontEnabled() const 132cdf0e10cSrcweir { 133cdf0e10cSrcweir return m_pCTLOptions->IsCTLFontEnabled(); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir //------------------------------------------------------------------------------ SetCTLSequenceChecking(sal_Bool _bEnabled)136cdf0e10cSrcweirvoid SvtLanguageOptions::SetCTLSequenceChecking( sal_Bool _bEnabled ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir m_pCTLOptions->SetCTLSequenceChecking( _bEnabled ); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir //------------------------------------------------------------------------------ IsCTLSequenceChecking() const141cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsCTLSequenceChecking() const 142cdf0e10cSrcweir { 143cdf0e10cSrcweir return m_pCTLOptions->IsCTLSequenceChecking(); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir /*-- 26.09.2005 15:48:23--------------------------------------------------- 146cdf0e10cSrcweir 147cdf0e10cSrcweir -----------------------------------------------------------------------*/ SetCTLSequenceCheckingRestricted(sal_Bool _bEnable)148cdf0e10cSrcweirvoid SvtLanguageOptions::SetCTLSequenceCheckingRestricted( sal_Bool _bEnable ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir m_pCTLOptions->SetCTLSequenceCheckingRestricted( _bEnable ); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir /*-- 26.09.2005 15:48:23--------------------------------------------------- 153cdf0e10cSrcweir 154cdf0e10cSrcweir -----------------------------------------------------------------------*/ IsCTLSequenceCheckingRestricted(void) const155cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsCTLSequenceCheckingRestricted( void ) const 156cdf0e10cSrcweir { 157cdf0e10cSrcweir return m_pCTLOptions->IsCTLSequenceCheckingRestricted(); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir /*-- 26.09.2005 15:48:23--------------------------------------------------- 160cdf0e10cSrcweir 161cdf0e10cSrcweir -----------------------------------------------------------------------*/ SetCTLSequenceCheckingTypeAndReplace(sal_Bool _bEnable)162cdf0e10cSrcweirvoid SvtLanguageOptions::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable ) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir m_pCTLOptions->SetCTLSequenceCheckingTypeAndReplace( _bEnable ); 165cdf0e10cSrcweir } 166cdf0e10cSrcweir /*-- 26.09.2005 15:48:24--------------------------------------------------- 167cdf0e10cSrcweir 168cdf0e10cSrcweir -----------------------------------------------------------------------*/ IsCTLSequenceCheckingTypeAndReplace() const169cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsCTLSequenceCheckingTypeAndReplace() const 170cdf0e10cSrcweir { 171cdf0e10cSrcweir return m_pCTLOptions->IsCTLSequenceCheckingTypeAndReplace(); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir //------------------------------------------------------------------------------ IsReadOnly(SvtLanguageOptions::EOption eOption) const175cdf0e10cSrcweirsal_Bool SvtLanguageOptions::IsReadOnly(SvtLanguageOptions::EOption eOption) const 176cdf0e10cSrcweir { 177cdf0e10cSrcweir sal_Bool bReadOnly = sal_False; 178cdf0e10cSrcweir switch(eOption) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir // cjk options 181cdf0e10cSrcweir case SvtLanguageOptions::E_CJKFONT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_CJKFONT ); break; 182cdf0e10cSrcweir case SvtLanguageOptions::E_VERTICALTEXT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_VERTICALTEXT ); break; 183cdf0e10cSrcweir case SvtLanguageOptions::E_ASIANTYPOGRAPHY : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_ASIANTYPOGRAPHY); break; 184cdf0e10cSrcweir case SvtLanguageOptions::E_JAPANESEFIND : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_JAPANESEFIND ); break; 185cdf0e10cSrcweir case SvtLanguageOptions::E_RUBY : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_RUBY ); break; 186cdf0e10cSrcweir case SvtLanguageOptions::E_CHANGECASEMAP : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_CHANGECASEMAP ); break; 187cdf0e10cSrcweir case SvtLanguageOptions::E_DOUBLELINES : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_DOUBLELINES ); break; 188cdf0e10cSrcweir case SvtLanguageOptions::E_EMPHASISMARKS : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_EMPHASISMARKS ); break; 189cdf0e10cSrcweir case SvtLanguageOptions::E_VERTICALCALLOUT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_VERTICALCALLOUT); break; 190cdf0e10cSrcweir case SvtLanguageOptions::E_ALLCJK : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_ALL ); break; 191cdf0e10cSrcweir // ctl options 192cdf0e10cSrcweir case SvtLanguageOptions::E_CTLFONT : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLFONT ); break; 193cdf0e10cSrcweir case SvtLanguageOptions::E_CTLSEQUENCECHECKING : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLSEQUENCECHECKING); break; 194cdf0e10cSrcweir case SvtLanguageOptions::E_CTLCURSORMOVEMENT : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLCURSORMOVEMENT ); break; 195cdf0e10cSrcweir case SvtLanguageOptions::E_CTLTEXTNUMERALS : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLTEXTNUMERALS ); break; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir return bReadOnly; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir /* -----------------30.04.2003 11:03-----------------*/ 200cdf0e10cSrcweir 201cdf0e10cSrcweir // returns for a language the scripttype GetScriptTypeOfLanguage(sal_uInt16 nLang)202cdf0e10cSrcweirsal_uInt16 SvtLanguageOptions::GetScriptTypeOfLanguage( sal_uInt16 nLang ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir if( LANGUAGE_DONTKNOW == nLang ) 205cdf0e10cSrcweir nLang = LANGUAGE_ENGLISH_US; 206cdf0e10cSrcweir else if( LANGUAGE_SYSTEM == nLang ) 207cdf0e10cSrcweir nLang = SvtSysLocale().GetLanguage(); 208cdf0e10cSrcweir 209cdf0e10cSrcweir sal_Int16 nScriptType = MsLangId::getScriptType( nLang ); 210cdf0e10cSrcweir sal_uInt16 nScript; 211cdf0e10cSrcweir switch (nScriptType) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir case ::com::sun::star::i18n::ScriptType::ASIAN: 214cdf0e10cSrcweir nScript = SCRIPTTYPE_ASIAN; 215cdf0e10cSrcweir break; 216cdf0e10cSrcweir case ::com::sun::star::i18n::ScriptType::COMPLEX: 217cdf0e10cSrcweir nScript = SCRIPTTYPE_COMPLEX; 218cdf0e10cSrcweir break; 219cdf0e10cSrcweir default: 220cdf0e10cSrcweir nScript = SCRIPTTYPE_LATIN; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir return nScript; 223cdf0e10cSrcweir } 224cdf0e10cSrcweir // ----------------------------------------------------------------------------- 225cdf0e10cSrcweir 226cdf0e10cSrcweir 227cdf0e10cSrcweir /*-- 27.10.2005 08:18:01--------------------------------------------------- 228cdf0e10cSrcweir 229cdf0e10cSrcweir -----------------------------------------------------------------------*/ SvtSystemLanguageOptions()230cdf0e10cSrcweirSvtSystemLanguageOptions::SvtSystemLanguageOptions() : 231cdf0e10cSrcweir utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("System/L10N") )) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir uno::Sequence< rtl::OUString > aPropertyNames(1); 234cdf0e10cSrcweir rtl::OUString* pNames = aPropertyNames.getArray(); 235cdf0e10cSrcweir pNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SystemLocale")); 236cdf0e10cSrcweir uno::Sequence< uno::Any > aValues = GetProperties( aPropertyNames ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir if ( aValues.getLength() ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir aValues[0]>>= m_sWin16SystemLocale; 241cdf0e10cSrcweir } 242cdf0e10cSrcweir } 243cdf0e10cSrcweir /*-- 27.10.2005 08:18:01--------------------------------------------------- 244cdf0e10cSrcweir 245cdf0e10cSrcweir -----------------------------------------------------------------------*/ ~SvtSystemLanguageOptions()246cdf0e10cSrcweirSvtSystemLanguageOptions::~SvtSystemLanguageOptions() 247cdf0e10cSrcweir { 248cdf0e10cSrcweir } 249cdf0e10cSrcweir /*-- 27.10.2005 08:18:02--------------------------------------------------- 250cdf0e10cSrcweir 251cdf0e10cSrcweir -----------------------------------------------------------------------*/ Commit()252cdf0e10cSrcweirvoid SvtSystemLanguageOptions::Commit() 253cdf0e10cSrcweir { 254cdf0e10cSrcweir //does nothing 255cdf0e10cSrcweir } 256cdf0e10cSrcweir Notify(const com::sun::star::uno::Sequence<rtl::OUString> &)257cdf0e10cSrcweirvoid SvtSystemLanguageOptions::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir // no listeners supported yet 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir /*-- 27.10.2005 08:36:14--------------------------------------------------- 263cdf0e10cSrcweir 264cdf0e10cSrcweir -----------------------------------------------------------------------*/ GetWin16SystemLanguage()265cdf0e10cSrcweirLanguageType SvtSystemLanguageOptions::GetWin16SystemLanguage() 266cdf0e10cSrcweir { 267cdf0e10cSrcweir if( m_sWin16SystemLocale.getLength() == 0 ) 268cdf0e10cSrcweir return LANGUAGE_NONE; 269cdf0e10cSrcweir return MsLangId::convertIsoStringToLanguage( m_sWin16SystemLocale ); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir 273