LCOV - code coverage report
Current view: top level - svl/source/config - languageoptions.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 45 92 48.9 %
Date: 2012-08-25 Functions: 9 22 40.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 37 82 45.1 %

           Branch data     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                 :            : 
      21                 :            : #include <svl/languageoptions.hxx>
      22                 :            : #include <svl/cjkoptions.hxx>
      23                 :            : #include <svl/ctloptions.hxx>
      24                 :            : #include <i18npool/mslangid.hxx>
      25                 :            : #include <osl/mutex.hxx>
      26                 :            : #include <rtl/instance.hxx>
      27                 :            : #include <com/sun/star/i18n/ScriptType.hpp>
      28                 :            : #include <unotools/syslocale.hxx>
      29                 :            : 
      30                 :            : using namespace ::com::sun::star;
      31                 :            : // global ----------------------------------------------------------------------
      32                 :            : 
      33                 :            : namespace { struct ALMutex : public rtl::Static< ::osl::Mutex, ALMutex > {}; }
      34                 :            : 
      35                 :            : // class SvtLanguageOptions ----------------------------------------------------
      36                 :            : 
      37                 :      23408 : SvtLanguageOptions::SvtLanguageOptions( sal_Bool _bDontLoad )
      38                 :            : {
      39                 :            :     // Global access, must be guarded (multithreading)
      40 [ +  - ][ +  - ]:      23408 :     ::osl::MutexGuard aGuard( ALMutex::get() );
      41                 :            : 
      42 [ +  - ][ +  - ]:      23408 :     m_pCJKOptions = new SvtCJKOptions( _bDontLoad );
      43 [ +  - ][ +  - ]:      23408 :     m_pCTLOptions = new SvtCTLOptions( _bDontLoad );
      44         [ +  - ]:      23408 :     m_pCTLOptions->AddListener(this);
      45 [ +  - ][ +  - ]:      23408 :     m_pCJKOptions->AddListener(this);
      46                 :      23408 : }
      47                 :            : //------------------------------------------------------------------------------
      48                 :      23408 : SvtLanguageOptions::~SvtLanguageOptions()
      49                 :            : {
      50                 :            :     // Global access, must be guarded (multithreading)
      51 [ +  - ][ +  - ]:      23408 :     ::osl::MutexGuard aGuard( ALMutex::get() );
      52                 :            : 
      53         [ +  - ]:      23408 :     m_pCTLOptions->RemoveListener(this);
      54         [ +  - ]:      23408 :     m_pCJKOptions->RemoveListener(this);
      55                 :            : 
      56 [ +  - ][ +  - ]:      23408 :     delete m_pCJKOptions;
      57 [ +  - ][ +  - ]:      23408 :     delete m_pCTLOptions;
                 [ +  - ]
      58         [ -  + ]:      23566 : }
      59                 :            : //------------------------------------------------------------------------------
      60                 :            : // CJK options -----------------------------------------------------------------
      61                 :            : //------------------------------------------------------------------------------
      62                 :          0 : sal_Bool SvtLanguageOptions::IsCJKFontEnabled() const
      63                 :            : {
      64                 :          0 :     return m_pCJKOptions->IsCJKFontEnabled();
      65                 :            : }
      66                 :            : //------------------------------------------------------------------------------
      67                 :      10916 : sal_Bool SvtLanguageOptions::IsVerticalTextEnabled() const
      68                 :            : {
      69                 :      10916 :     return m_pCJKOptions->IsVerticalTextEnabled();
      70                 :            : }
      71                 :            : //------------------------------------------------------------------------------
      72                 :          0 : sal_Bool SvtLanguageOptions::IsAsianTypographyEnabled() const
      73                 :            : {
      74                 :          0 :     return m_pCJKOptions->IsAsianTypographyEnabled();
      75                 :            : }
      76                 :            : //------------------------------------------------------------------------------
      77                 :          0 : sal_Bool SvtLanguageOptions::IsJapaneseFindEnabled() const
      78                 :            : {
      79                 :          0 :     return m_pCJKOptions->IsJapaneseFindEnabled();
      80                 :            : }
      81                 :            : //------------------------------------------------------------------------------
      82                 :          0 : void SvtLanguageOptions::SetAll( sal_Bool _bSet )
      83                 :            : {
      84                 :          0 :     m_pCJKOptions->SetAll( _bSet );
      85                 :          0 : }
      86                 :            : //------------------------------------------------------------------------------
      87                 :          0 : sal_Bool SvtLanguageOptions::IsAnyEnabled() const
      88                 :            : {
      89                 :          0 :     return m_pCJKOptions->IsAnyEnabled();
      90                 :            : }
      91                 :            : //------------------------------------------------------------------------------
      92                 :            : // CTL options -----------------------------------------------------------------
      93                 :            : //------------------------------------------------------------------------------
      94                 :          0 : void SvtLanguageOptions::SetCTLFontEnabled( sal_Bool _bEnabled )
      95                 :            : {
      96                 :          0 :     m_pCTLOptions->SetCTLFontEnabled( _bEnabled );
      97                 :          0 : }
      98                 :            : //------------------------------------------------------------------------------
      99                 :       9242 : sal_Bool SvtLanguageOptions::IsCTLFontEnabled() const
     100                 :            : {
     101                 :       9242 :     return m_pCTLOptions->IsCTLFontEnabled();
     102                 :            : }
     103                 :            : //------------------------------------------------------------------------------
     104                 :          0 : void SvtLanguageOptions::SetCTLSequenceChecking( sal_Bool _bEnabled )
     105                 :            : {
     106                 :          0 :     m_pCTLOptions->SetCTLSequenceChecking( _bEnabled );
     107                 :          0 : }
     108                 :            : 
     109                 :          0 : void SvtLanguageOptions::SetCTLSequenceCheckingRestricted( sal_Bool _bEnable )
     110                 :            : {
     111                 :          0 :     m_pCTLOptions->SetCTLSequenceCheckingRestricted( _bEnable );
     112                 :          0 : }
     113                 :            : 
     114                 :          0 : void SvtLanguageOptions::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable )
     115                 :            : {
     116                 :          0 :     m_pCTLOptions->SetCTLSequenceCheckingTypeAndReplace( _bEnable );
     117                 :          0 : }
     118                 :            : 
     119                 :            : //------------------------------------------------------------------------------
     120                 :          0 : sal_Bool SvtLanguageOptions::IsReadOnly(SvtLanguageOptions::EOption eOption) const
     121                 :            : {
     122                 :          0 :     sal_Bool bReadOnly = sal_False;
     123   [ #  #  #  #  :          0 :     switch(eOption)
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     124                 :            :     {
     125                 :            :         // cjk options
     126                 :          0 :         case SvtLanguageOptions::E_CJKFONT          : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_CJKFONT        ); break;
     127                 :          0 :         case SvtLanguageOptions::E_VERTICALTEXT     : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_VERTICALTEXT   ); break;
     128                 :          0 :         case SvtLanguageOptions::E_ASIANTYPOGRAPHY  : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_ASIANTYPOGRAPHY); break;
     129                 :          0 :         case SvtLanguageOptions::E_JAPANESEFIND     : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_JAPANESEFIND   ); break;
     130                 :          0 :         case SvtLanguageOptions::E_RUBY             : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_RUBY           ); break;
     131                 :          0 :         case SvtLanguageOptions::E_CHANGECASEMAP    : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_CHANGECASEMAP  ); break;
     132                 :          0 :         case SvtLanguageOptions::E_DOUBLELINES      : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_DOUBLELINES    ); break;
     133                 :          0 :         case SvtLanguageOptions::E_EMPHASISMARKS    : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_EMPHASISMARKS  ); break;
     134                 :          0 :         case SvtLanguageOptions::E_VERTICALCALLOUT  : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_VERTICALCALLOUT); break;
     135                 :          0 :         case SvtLanguageOptions::E_ALLCJK           : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_ALL            ); break;
     136                 :            :         // ctl options
     137                 :          0 :         case SvtLanguageOptions::E_CTLFONT              : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLFONT            ); break;
     138                 :          0 :         case SvtLanguageOptions::E_CTLSEQUENCECHECKING  : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLSEQUENCECHECKING); break;
     139                 :          0 :         case SvtLanguageOptions::E_CTLCURSORMOVEMENT    : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLCURSORMOVEMENT  ); break;
     140                 :          0 :         case SvtLanguageOptions::E_CTLTEXTNUMERALS      : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLTEXTNUMERALS    ); break;
     141                 :            :     }
     142                 :          0 :     return bReadOnly;
     143                 :            : }
     144                 :            : 
     145                 :            : // returns for a language the scripttype
     146                 :    2105909 : sal_uInt16 SvtLanguageOptions::GetScriptTypeOfLanguage( sal_uInt16 nLang )
     147                 :            : {
     148         [ +  + ]:    2105909 :     if( LANGUAGE_DONTKNOW == nLang )
     149                 :     188993 :         nLang = LANGUAGE_ENGLISH_US;
     150         [ +  + ]:    1916916 :     else if( LANGUAGE_SYSTEM == nLang  )
     151         [ +  - ]:       2308 :         nLang = SvtSysLocale().GetLanguage();
     152                 :            : 
     153                 :    2105909 :     sal_Int16 nScriptType = MsLangId::getScriptType( nLang );
     154                 :            :     sal_uInt16 nScript;
     155      [ +  -  + ]:    2105909 :     switch (nScriptType)
     156                 :            :     {
     157                 :            :         case ::com::sun::star::i18n::ScriptType::ASIAN:
     158                 :          3 :             nScript = SCRIPTTYPE_ASIAN;
     159                 :          3 :             break;
     160                 :            :         case ::com::sun::star::i18n::ScriptType::COMPLEX:
     161                 :          0 :             nScript = SCRIPTTYPE_COMPLEX;
     162                 :          0 :             break;
     163                 :            :         default:
     164                 :    2105906 :             nScript = SCRIPTTYPE_LATIN;
     165                 :            :     }
     166                 :    2105909 :     return nScript;
     167                 :            : }
     168                 :            : // -----------------------------------------------------------------------------
     169                 :            : 
     170                 :        391 : SvtSystemLanguageOptions::SvtSystemLanguageOptions() :
     171         [ +  - ]:        391 :     utl::ConfigItem( "System/L10N")
     172                 :            : {
     173         [ +  - ]:        391 :     uno::Sequence< rtl::OUString > aPropertyNames(1);
     174         [ +  - ]:        391 :     rtl::OUString* pNames = aPropertyNames.getArray();
     175                 :        391 :     pNames[0] = "SystemLocale";
     176         [ +  - ]:        391 :     uno::Sequence< uno::Any > aValues = GetProperties( aPropertyNames );
     177                 :            : 
     178         [ +  - ]:        391 :     if ( aValues.getLength() )
     179                 :            :     {
     180         [ +  - ]:        391 :         aValues[0]>>= m_sWin16SystemLocale;
     181 [ +  - ][ +  - ]:        391 :     }
     182                 :        391 : }
     183                 :            : 
     184                 :        391 : SvtSystemLanguageOptions::~SvtSystemLanguageOptions()
     185                 :            : {
     186         [ -  + ]:        391 : }
     187                 :            : 
     188                 :          0 : void    SvtSystemLanguageOptions::Commit()
     189                 :            : {
     190                 :            :     //does nothing
     191                 :          0 : }
     192                 :            : 
     193                 :          0 : void    SvtSystemLanguageOptions::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
     194                 :            : {
     195                 :            :     // no listeners supported yet
     196                 :          0 : }
     197                 :            : 
     198                 :            : 
     199                 :        391 : LanguageType SvtSystemLanguageOptions::GetWin16SystemLanguage()
     200                 :            : {
     201         [ +  + ]:        391 :     if( m_sWin16SystemLocale.isEmpty() )
     202                 :         75 :         return LANGUAGE_NONE;
     203                 :        391 :     return MsLangId::convertIsoStringToLanguage( m_sWin16SystemLocale );
     204                 :            : }
     205                 :            : 
     206                 :            : 
     207                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10