LCOV - code coverage report
Current view: top level - svx/source/dialog - langbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 215 0.0 %
Date: 2012-08-25 Functions: 0 19 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 496 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
      30                 :            : #include <com/sun/star/linguistic2/XAvailableLocales.hpp>
      31                 :            : #include <com/sun/star/i18n/ScriptType.hpp>
      32                 :            : #include <linguistic/misc.hxx>
      33                 :            : #include <rtl/ustring.hxx>
      34                 :            : #include <unotools/localedatawrapper.hxx>
      35                 :            : #include <tools/urlobj.hxx>
      36                 :            : #include <svtools/langtab.hxx>
      37                 :            : #include <tools/shl.hxx>
      38                 :            : #include <i18npool/mslangid.hxx>
      39                 :            : #include <i18npool/lang.h>
      40                 :            : #include <editeng/scripttypeitem.hxx>
      41                 :            : #include <editeng/unolingu.hxx>
      42                 :            : #include <svx/langbox.hxx>
      43                 :            : #include <svx/dialmgr.hxx>
      44                 :            : #include <svx/dialogs.hrc>
      45                 :            : 
      46                 :            : using namespace ::com::sun::star::util;
      47                 :            : using namespace ::com::sun::star::lang;
      48                 :            : using namespace ::com::sun::star::linguistic2;
      49                 :            : using namespace ::com::sun::star::uno;
      50                 :            : 
      51                 :            : // -----------------------------------------------------------------------
      52                 :            : 
      53                 :          0 : String GetDicInfoStr( const String& rName, const sal_uInt16 nLang, sal_Bool bNeg )
      54                 :            : {
      55         [ #  # ]:          0 :     INetURLObject aURLObj;
      56                 :          0 :     aURLObj.SetSmartProtocol( INET_PROT_FILE );
      57 [ #  # ][ #  # ]:          0 :     aURLObj.SetSmartURL( rName, INetURLObject::ENCODE_ALL );
      58 [ #  # ][ #  # ]:          0 :     String aTmp( aURLObj.GetBase() );
      59         [ #  # ]:          0 :     aTmp += sal_Unicode( ' ' );
      60                 :            : 
      61         [ #  # ]:          0 :     if ( bNeg )
      62                 :            :     {
      63                 :          0 :         sal_Char const sTmp[] = " (-) ";
      64         [ #  # ]:          0 :         aTmp.AppendAscii( sTmp );
      65                 :            :     }
      66                 :            : 
      67         [ #  # ]:          0 :     if ( LANGUAGE_NONE == nLang )
      68 [ #  # ][ #  # ]:          0 :         aTmp += SVX_RESSTR(RID_SVXSTR_LANGUAGE_ALL);
                 [ #  # ]
      69                 :            :     else
      70                 :            :     {
      71         [ #  # ]:          0 :         aTmp += sal_Unicode( '[' );
      72 [ #  # ][ #  # ]:          0 :         aTmp += SvtLanguageTable::GetLanguageString( (LanguageType)nLang );
                 [ #  # ]
      73         [ #  # ]:          0 :         aTmp += sal_Unicode( ']' );
      74                 :            :     }
      75                 :            : 
      76         [ #  # ]:          0 :     return aTmp;
      77                 :            : }
      78                 :            : 
      79                 :            : //========================================================================
      80                 :            : //  misc local helper functions
      81                 :            : //========================================================================
      82                 :            : 
      83                 :          0 : static Sequence< sal_Int16 > lcl_LocaleSeqToLangSeq( Sequence< Locale > &rSeq )
      84                 :            : {
      85                 :          0 :     const Locale *pLocale = rSeq.getConstArray();
      86                 :          0 :     sal_Int32 nCount = rSeq.getLength();
      87                 :            : 
      88                 :          0 :     Sequence< sal_Int16 >   aLangs( nCount );
      89         [ #  # ]:          0 :     sal_Int16 *pLang = aLangs.getArray();
      90         [ #  # ]:          0 :     for (sal_Int32 i = 0;  i < nCount;  ++i)
      91                 :            :     {
      92         [ #  # ]:          0 :         pLang[i] = SvxLocaleToLanguage( pLocale[i] );
      93                 :            : 
      94                 :            :     }
      95                 :            : 
      96                 :          0 :     return aLangs;
      97                 :            : }
      98                 :            : 
      99                 :            : 
     100                 :          0 : static sal_Bool lcl_SeqHasLang( const Sequence< sal_Int16 > & rLangSeq, sal_Int16 nLang )
     101                 :            : {
     102                 :          0 :     sal_Int32 i = -1;
     103                 :          0 :     sal_Int32 nLen = rLangSeq.getLength();
     104         [ #  # ]:          0 :     if (nLen)
     105                 :            :     {
     106                 :          0 :         const sal_Int16 *pLang = rLangSeq.getConstArray();
     107         [ #  # ]:          0 :         for (i = 0;  i < nLen;  ++i)
     108                 :            :         {
     109         [ #  # ]:          0 :             if (nLang == pLang[i])
     110                 :          0 :                 break;
     111                 :            :         }
     112                 :            :     }
     113 [ #  # ][ #  # ]:          0 :     return i >= 0  &&  i < nLen;
     114                 :            : }
     115                 :            : 
     116                 :            : //========================================================================
     117                 :            : //  class SvxLanguageBox
     118                 :            : //========================================================================
     119                 :            : 
     120                 :          0 : sal_uInt16 TypeToPos_Impl( LanguageType eType, const ListBox& rLb )
     121                 :            : {
     122                 :          0 :     sal_uInt16  nPos   = LISTBOX_ENTRY_NOTFOUND;
     123                 :          0 :     sal_uInt16  nCount = rLb.GetEntryCount();
     124                 :            : 
     125 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 i=0; nPos == LISTBOX_ENTRY_NOTFOUND && i<nCount; i++ )
                 [ #  # ]
     126         [ #  # ]:          0 :         if ( eType == LanguageType((sal_uIntPtr)rLb.GetEntryData(i)) )
     127                 :          0 :             nPos = i;
     128                 :            : 
     129                 :          0 :     return nPos;
     130                 :            : }
     131                 :            : 
     132                 :            : //------------------------------------------------------------------------
     133                 :          0 : SvxLanguageBox::SvxLanguageBox( Window* pParent, const ResId& rResId, sal_Bool bCheck ) :
     134                 :            :     ListBox( pParent, rResId ),
     135                 :            :     m_pSpellUsedLang( NULL ),
     136 [ #  # ][ #  # ]:          0 :     m_bWithCheckmark( bCheck )
                 [ #  # ]
     137                 :            : {
     138         [ #  # ]:          0 :     Init();
     139                 :          0 : }
     140                 :            : //------------------------------------------------------------------------
     141                 :          0 : void SvxLanguageBox::Init()
     142                 :            : {
     143         [ #  # ]:          0 :     m_pLangTable = new SvtLanguageTable;
     144 [ #  # ][ #  # ]:          0 :     m_aNotCheckedImage = Image( SVX_RES( RID_SVXIMG_NOTCHECKED ) );
                 [ #  # ]
     145 [ #  # ][ #  # ]:          0 :     m_aCheckedImage = Image( SVX_RES( RID_SVXIMG_CHECKED ) );
                 [ #  # ]
     146 [ #  # ][ #  # ]:          0 :     m_aAllString            = String( SVX_RESSTR( RID_SVXSTR_LANGUAGE_ALL ) );
         [ #  # ][ #  # ]
     147                 :          0 :     m_nLangList             = LANG_LIST_EMPTY;
     148                 :          0 :     m_bHasLangNone          = sal_False;
     149                 :          0 :     m_bLangNoneIsLangAll    = sal_False;
     150                 :            : 
     151                 :            :     // display entries sorted
     152                 :          0 :     SetStyle( GetStyle() | WB_SORT );
     153                 :            : 
     154         [ #  # ]:          0 :     if ( m_bWithCheckmark )
     155                 :            :     {
     156         [ #  # ]:          0 :         SvtLanguageTable aLangTable;
     157         [ #  # ]:          0 :         sal_uInt32 nCount = aLangTable.GetEntryCount();
     158         [ #  # ]:          0 :         for ( sal_uInt32 i = 0; i < nCount; i++ )
     159                 :            :         {
     160         [ #  # ]:          0 :             LanguageType nLangType = aLangTable.GetTypeAtIndex( i );
     161                 :            : 
     162                 :          0 :             sal_Bool bInsert = sal_True;
     163 [ #  # ][ #  # ]:          0 :             if ((LANGUAGE_DONTKNOW == nLangType)  ||
         [ #  # ][ #  # ]
     164                 :            :                 (LANGUAGE_SYSTEM   == nLangType)  ||
     165                 :            :                 (LANGUAGE_USER1 <= nLangType  &&  nLangType <= LANGUAGE_USER9))
     166                 :            :             {
     167                 :          0 :                 bInsert = sal_False;
     168                 :            :             }
     169                 :            : 
     170         [ #  # ]:          0 :             if ( bInsert )
     171         [ #  # ]:          0 :                 InsertLanguage( nLangType );
     172                 :            :         }
     173         [ #  # ]:          0 :         m_nLangList = LANG_LIST_ALL;
     174                 :            :     }
     175                 :          0 : }
     176                 :            : //------------------------------------------------------------------------
     177                 :            : 
     178 [ #  # ][ #  # ]:          0 : SvxLanguageBox::~SvxLanguageBox()
                 [ #  # ]
     179                 :            : {
     180 [ #  # ][ #  # ]:          0 :     delete m_pSpellUsedLang;
     181 [ #  # ][ #  # ]:          0 :     delete m_pLangTable;
     182         [ #  # ]:          0 : }
     183                 :            : 
     184                 :            : //------------------------------------------------------------------------
     185                 :            : 
     186                 :          0 : sal_uInt16 SvxLanguageBox::ImplInsertImgEntry( const String& rEntry, sal_uInt16 nPos, bool bChecked )
     187                 :            : {
     188                 :          0 :     sal_uInt16 nRet = 0;
     189         [ #  # ]:          0 :     if( !bChecked )
     190                 :          0 :         nRet = InsertEntry( rEntry, m_aNotCheckedImage, nPos );
     191                 :            :     else
     192                 :          0 :         nRet = InsertEntry( rEntry, m_aCheckedImage, nPos );
     193                 :          0 :     return nRet;
     194                 :            : }
     195                 :            : 
     196                 :            : //------------------------------------------------------------------------
     197                 :            : 
     198                 :          0 : void SvxLanguageBox::SetLanguageList( sal_Int16 nLangList,
     199                 :            :         sal_Bool bHasLangNone, sal_Bool bLangNoneIsLangAll, sal_Bool bCheckSpellAvail )
     200                 :            : {
     201                 :          0 :     Clear();
     202                 :            : 
     203                 :          0 :     m_nLangList             = nLangList;
     204                 :          0 :     m_bHasLangNone          = bHasLangNone;
     205                 :          0 :     m_bLangNoneIsLangAll    = bLangNoneIsLangAll;
     206                 :          0 :     m_bWithCheckmark        = bCheckSpellAvail;
     207                 :            : 
     208         [ #  # ]:          0 :     if ( LANG_LIST_EMPTY != nLangList )
     209                 :            :     {
     210         [ #  # ]:          0 :         Sequence< sal_Int16 > aSpellAvailLang;
     211         [ #  # ]:          0 :         Sequence< sal_Int16 > aHyphAvailLang;
     212         [ #  # ]:          0 :         Sequence< sal_Int16 > aThesAvailLang;
     213         [ #  # ]:          0 :         Sequence< sal_Int16 > aSpellUsedLang;
     214         [ #  # ]:          0 :         Sequence< sal_Int16 > aHyphUsedLang;
     215         [ #  # ]:          0 :         Sequence< sal_Int16 > aThesUsedLang;
     216 [ #  # ][ #  # ]:          0 :         Reference< XAvailableLocales > xAvail( LinguMgr::GetLngSvcMgr(), UNO_QUERY );
     217         [ #  # ]:          0 :         if (xAvail.is())
     218                 :            :         {
     219         [ #  # ]:          0 :             Sequence< Locale > aTmp;
     220                 :            : 
     221         [ #  # ]:          0 :             if (LANG_LIST_SPELL_AVAIL & nLangList)
     222                 :            :             {
     223 [ #  # ][ #  # ]:          0 :                 aTmp = xAvail->getAvailableLocales( A2OU( SN_SPELLCHECKER ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     224 [ #  # ][ #  # ]:          0 :                 aSpellAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
                 [ #  # ]
     225                 :            :             }
     226         [ #  # ]:          0 :             if (LANG_LIST_HYPH_AVAIL  & nLangList)
     227                 :            :             {
     228 [ #  # ][ #  # ]:          0 :                 aTmp = xAvail->getAvailableLocales( A2OU( SN_HYPHENATOR ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     229 [ #  # ][ #  # ]:          0 :                 aHyphAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
                 [ #  # ]
     230                 :            :             }
     231         [ #  # ]:          0 :             if (LANG_LIST_THES_AVAIL  & nLangList)
     232                 :            :             {
     233 [ #  # ][ #  # ]:          0 :                 aTmp = xAvail->getAvailableLocales( A2OU( SN_THESAURUS ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     234 [ #  # ][ #  # ]:          0 :                 aThesAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
                 [ #  # ]
     235         [ #  # ]:          0 :             }
     236                 :            :         }
     237         [ #  # ]:          0 :         if (LANG_LIST_SPELL_USED & nLangList)
     238                 :            :         {
     239 [ #  # ][ #  # ]:          0 :             Reference< XSpellChecker1 > xTmp1( SvxGetSpellChecker(), UNO_QUERY );
     240         [ #  # ]:          0 :             if (xTmp1.is())
     241 [ #  # ][ #  # ]:          0 :                 aSpellUsedLang = xTmp1->getLanguages();
         [ #  # ][ #  # ]
     242                 :            :         }
     243         [ #  # ]:          0 :         if (LANG_LIST_HYPH_USED  & nLangList)
     244                 :            :         {
     245         [ #  # ]:          0 :             Reference< XHyphenator > xTmp( SvxGetHyphenator() );
     246         [ #  # ]:          0 :             if (xTmp.is()) {
     247 [ #  # ][ #  # ]:          0 :                 Sequence < Locale > aLocaleSequence( xTmp->getLocales() );
     248 [ #  # ][ #  # ]:          0 :                 aHyphUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
         [ #  # ][ #  # ]
     249                 :          0 :             }
     250                 :            :         }
     251         [ #  # ]:          0 :         if (LANG_LIST_THES_USED  & nLangList)
     252                 :            :         {
     253         [ #  # ]:          0 :             Reference< XThesaurus > xTmp( SvxGetThesaurus() );
     254         [ #  # ]:          0 :             if (xTmp.is()) {
     255 [ #  # ][ #  # ]:          0 :                 Sequence < Locale > aLocaleSequence( xTmp->getLocales() );
     256 [ #  # ][ #  # ]:          0 :                 aThesUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
         [ #  # ][ #  # ]
     257                 :          0 :             }
     258                 :            :         }
     259                 :            : 
     260         [ #  # ]:          0 :         SvtLanguageTable aLangTable;
     261         [ #  # ]:          0 :         ::com::sun::star::uno::Sequence< sal_uInt16 > xKnown;
     262                 :            :         const sal_uInt16* pKnown;
     263                 :            :         sal_uInt32 nCount;
     264         [ #  # ]:          0 :         if ( nLangList & LANG_LIST_ONLY_KNOWN )
     265                 :            :         {
     266 [ #  # ][ #  # ]:          0 :             xKnown = LocaleDataWrapper::getInstalledLanguageTypes();
                 [ #  # ]
     267                 :          0 :             pKnown = xKnown.getConstArray();
     268                 :          0 :             nCount = xKnown.getLength();
     269                 :            :         }
     270                 :            :         else
     271                 :            :         {
     272         [ #  # ]:          0 :             nCount = aLangTable.GetEntryCount();
     273                 :          0 :             pKnown = NULL;
     274                 :            :         }
     275         [ #  # ]:          0 :         for ( sal_uInt32 i = 0; i < nCount; i++ )
     276                 :            :         {
     277                 :            :             LanguageType nLangType;
     278         [ #  # ]:          0 :             if ( nLangList & LANG_LIST_ONLY_KNOWN )
     279                 :          0 :                 nLangType = pKnown[i];
     280                 :            :             else
     281         [ #  # ]:          0 :                 nLangType = aLangTable.GetTypeAtIndex( i );
     282 [ #  # ][ #  # ]:          0 :             if ( nLangType != LANGUAGE_DONTKNOW &&
         [ #  # ][ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     283                 :            :                  nLangType != LANGUAGE_SYSTEM &&
     284                 :            :                  nLangType != LANGUAGE_NONE &&
     285                 :            :                  (nLangType < LANGUAGE_USER1 || nLangType > LANGUAGE_USER9) &&
     286                 :          0 :                  (MsLangId::getSubLanguage( nLangType) != 0 ||
     287                 :            :                   (nLangList & LANG_LIST_ALSO_PRIMARY_ONLY)) &&
     288                 :            :                  ((nLangList & LANG_LIST_ALL) != 0 ||
     289                 :            :                   ((nLangList & LANG_LIST_WESTERN) != 0 &&
     290         [ #  # ]:          0 :                    (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
     291                 :            :                     SCRIPTTYPE_LATIN)) ||
     292                 :            :                   ((nLangList & LANG_LIST_CTL) != 0 &&
     293         [ #  # ]:          0 :                    (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
     294                 :            :                     SCRIPTTYPE_COMPLEX)) ||
     295                 :            :                   ((nLangList & LANG_LIST_CJK) != 0 &&
     296         [ #  # ]:          0 :                    (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
     297                 :            :                     SCRIPTTYPE_ASIAN)) ||
     298                 :            :                   ((nLangList & LANG_LIST_FBD_CHARS) != 0 &&
     299         [ #  # ]:          0 :                    MsLangId::hasForbiddenCharacters(nLangType)) ||
     300                 :            :                   ((nLangList & LANG_LIST_SPELL_AVAIL) != 0 &&
     301         [ #  # ]:          0 :                    lcl_SeqHasLang(aSpellAvailLang, nLangType)) ||
     302                 :            :                   ((nLangList & LANG_LIST_HYPH_AVAIL) != 0 &&
     303         [ #  # ]:          0 :                    lcl_SeqHasLang(aHyphAvailLang, nLangType)) ||
     304                 :            :                   ((nLangList & LANG_LIST_THES_AVAIL) != 0 &&
     305         [ #  # ]:          0 :                    lcl_SeqHasLang(aThesAvailLang, nLangType)) ||
     306                 :            :                   ((nLangList & LANG_LIST_SPELL_USED) != 0 &&
     307         [ #  # ]:          0 :                    lcl_SeqHasLang(aSpellUsedLang, nLangType)) ||
     308                 :            :                   ((nLangList & LANG_LIST_HYPH_USED) != 0 &&
     309         [ #  # ]:          0 :                    lcl_SeqHasLang(aHyphUsedLang, nLangType)) ||
     310                 :            :                   ((nLangList & LANG_LIST_THES_USED) != 0 &&
     311         [ #  # ]:          0 :                    lcl_SeqHasLang(aThesUsedLang, nLangType))) )
     312         [ #  # ]:          0 :                 InsertLanguage( nLangType );
     313                 :            :         }
     314                 :            : 
     315         [ #  # ]:          0 :         if (bHasLangNone)
     316 [ #  # ][ #  # ]:          0 :             InsertLanguage( LANGUAGE_NONE );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     317                 :            :     }
     318                 :          0 : }
     319                 :            : 
     320                 :            : //------------------------------------------------------------------------
     321                 :            : 
     322                 :          0 : sal_uInt16 SvxLanguageBox::InsertLanguage( const LanguageType nLangType, sal_uInt16 nPos )
     323                 :            : {
     324                 :          0 :     return ImplInsertLanguage( nLangType, nPos, ::com::sun::star::i18n::ScriptType::WEAK );
     325                 :            : }
     326                 :            : 
     327                 :            : //------------------------------------------------------------------------
     328                 :            : 
     329                 :          0 : sal_uInt16 SvxLanguageBox::ImplInsertLanguage( const LanguageType nLangType, sal_uInt16 nPos, sal_Int16 nType )
     330                 :            : {
     331         [ #  # ]:          0 :     LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType);
     332                 :            :     // For obsolete and to be replaced languages check whether an entry of the
     333                 :            :     // replacement already exists and if so don't add an entry with identical
     334                 :            :     // string as would be returned by SvtLanguageTable::GetString().
     335         [ #  # ]:          0 :     if (nLang != nLangType)
     336                 :            :     {
     337         [ #  # ]:          0 :         sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
     338         [ #  # ]:          0 :         if ( nAt != LISTBOX_ENTRY_NOTFOUND )
     339                 :          0 :             return nAt;
     340                 :            :     }
     341                 :            : 
     342 [ #  # ][ #  # ]:          0 :     String aStrEntry = m_pLangTable->GetString( nLang );
     343 [ #  # ][ #  # ]:          0 :     if (LANGUAGE_NONE == nLang && m_bHasLangNone && m_bLangNoneIsLangAll)
                 [ #  # ]
     344         [ #  # ]:          0 :         aStrEntry = m_aAllString;
     345                 :            : 
     346                 :          0 :     LanguageType nRealLang = nLang;
     347         [ #  # ]:          0 :     if (nRealLang == LANGUAGE_SYSTEM)
     348                 :            :     {
     349         [ #  # ]:          0 :         nRealLang = MsLangId::resolveSystemLanguageByScriptType(nRealLang, nType);
     350         [ #  # ]:          0 :         aStrEntry.AppendAscii(" - ");
     351 [ #  # ][ #  # ]:          0 :         aStrEntry.Append(m_pLangTable->GetString( nRealLang ));
         [ #  # ][ #  # ]
     352         [ #  # ]:          0 :     } else if (nRealLang == LANGUAGE_USER_SYSTEM_CONFIG) {
     353         [ #  # ]:          0 :         nRealLang = MsLangId::getSystemLanguage();
     354         [ #  # ]:          0 :         aStrEntry.AppendAscii(" - ");
     355 [ #  # ][ #  # ]:          0 :         aStrEntry.Append(m_pLangTable->GetString( nRealLang ));
         [ #  # ][ #  # ]
     356                 :            :     }
     357                 :            : 
     358 [ #  # ][ #  # ]:          0 :     aStrEntry = ApplyLreOrRleEmbedding( aStrEntry );
                 [ #  # ]
     359                 :            : 
     360                 :          0 :     sal_uInt16 nAt = 0;
     361         [ #  # ]:          0 :     if ( m_bWithCheckmark )
     362                 :            :     {
     363                 :          0 :         sal_Bool bFound = sal_False;
     364                 :            : 
     365         [ #  # ]:          0 :         if (!m_pSpellUsedLang)
     366                 :            :         {
     367 [ #  # ][ #  # ]:          0 :             Reference< XSpellChecker1 > xSpell( SvxGetSpellChecker(), UNO_QUERY );
     368         [ #  # ]:          0 :             if ( xSpell.is() )
     369 [ #  # ][ #  # ]:          0 :                 m_pSpellUsedLang = new Sequence< sal_Int16 >( xSpell->getLanguages() );
     370                 :            :         }
     371                 :            :         bFound = m_pSpellUsedLang ?
     372 [ #  # ][ #  # ]:          0 :             lcl_SeqHasLang( *m_pSpellUsedLang, nRealLang ) : sal_False;
     373                 :            : 
     374         [ #  # ]:          0 :         nAt = ImplInsertImgEntry( aStrEntry, nPos, bFound );
     375                 :            :     }
     376                 :            :     else
     377         [ #  # ]:          0 :         nAt = InsertEntry( aStrEntry, nPos );
     378                 :            : 
     379         [ #  # ]:          0 :     SetEntryData( nAt, (void*)(sal_uIntPtr)nLangType );
     380         [ #  # ]:          0 :     return nAt;
     381                 :            : }
     382                 :            : 
     383                 :            : //------------------------------------------------------------------------
     384                 :            : 
     385                 :          0 : sal_uInt16 SvxLanguageBox::InsertDefaultLanguage( sal_Int16 nType, sal_uInt16 nPos )
     386                 :            : {
     387                 :          0 :     return ImplInsertLanguage( LANGUAGE_SYSTEM, nPos, nType );
     388                 :            : }
     389                 :            : 
     390                 :            : //------------------------------------------------------------------------
     391                 :            : 
     392                 :          0 : sal_uInt16 SvxLanguageBox::InsertSystemLanguage( sal_uInt16 nPos )
     393                 :            : {
     394                 :          0 :     return ImplInsertLanguage( LANGUAGE_USER_SYSTEM_CONFIG, nPos, ::com::sun::star::i18n::ScriptType::WEAK );
     395                 :            : }
     396                 :            : 
     397                 :            : //------------------------------------------------------------------------
     398                 :            : 
     399                 :          0 : sal_uInt16 SvxLanguageBox::InsertLanguage( const LanguageType nLangType,
     400                 :            :         sal_Bool bCheckEntry, sal_uInt16 nPos )
     401                 :            : {
     402         [ #  # ]:          0 :     LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType);
     403                 :            :     // For obsolete and to be replaced languages check whether an entry of the
     404                 :            :     // replacement already exists and if so don't add an entry with identical
     405                 :            :     // string as would be returned by SvtLanguageTable::GetString().
     406         [ #  # ]:          0 :     if (nLang != nLangType)
     407                 :            :     {
     408         [ #  # ]:          0 :         sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
     409         [ #  # ]:          0 :         if ( nAt != LISTBOX_ENTRY_NOTFOUND )
     410                 :          0 :             return nAt;
     411                 :            :     }
     412                 :            : 
     413 [ #  # ][ #  # ]:          0 :     String aStrEntry = m_pLangTable->GetString( nLang );
     414 [ #  # ][ #  # ]:          0 :     if (LANGUAGE_NONE == nLang && m_bHasLangNone && m_bLangNoneIsLangAll)
                 [ #  # ]
     415         [ #  # ]:          0 :         aStrEntry = m_aAllString;
     416                 :            : 
     417         [ #  # ]:          0 :     sal_uInt16 nAt = ImplInsertImgEntry( aStrEntry, nPos, bCheckEntry );
     418         [ #  # ]:          0 :     SetEntryData( nAt, (void*)(sal_uIntPtr)nLang );
     419                 :            : 
     420         [ #  # ]:          0 :     return nAt;
     421                 :            : }
     422                 :            : 
     423                 :            : //------------------------------------------------------------------------
     424                 :            : 
     425                 :          0 : void SvxLanguageBox::RemoveLanguage( const LanguageType eLangType )
     426                 :            : {
     427                 :          0 :     sal_uInt16 nAt = TypeToPos_Impl( eLangType, *this );
     428                 :            : 
     429         [ #  # ]:          0 :     if ( nAt != LISTBOX_ENTRY_NOTFOUND )
     430                 :          0 :         RemoveEntry( nAt );
     431                 :          0 : }
     432                 :            : 
     433                 :            : //------------------------------------------------------------------------
     434                 :            : 
     435                 :          0 : LanguageType SvxLanguageBox::GetSelectLanguage() const
     436                 :            : {
     437                 :          0 :     sal_uInt16       nPos   = GetSelectEntryPos();
     438                 :            : 
     439         [ #  # ]:          0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     440                 :          0 :         return LanguageType( (sal_uIntPtr)GetEntryData(nPos) );
     441                 :            :     else
     442                 :          0 :         return LanguageType( LANGUAGE_DONTKNOW );
     443                 :            : }
     444                 :            : 
     445                 :            : //------------------------------------------------------------------------
     446                 :            : 
     447                 :          0 : void SvxLanguageBox::SelectLanguage( const LanguageType eLangType, sal_Bool bSelect )
     448                 :            : {
     449                 :            :     // If the core uses a LangID of an imported MS document and wants to select
     450                 :            :     // a language that is replaced, we need to select the replacement instead.
     451                 :          0 :     LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( eLangType);
     452                 :            : 
     453                 :          0 :     sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
     454                 :            : 
     455         [ #  # ]:          0 :     if ( nAt != LISTBOX_ENTRY_NOTFOUND )
     456                 :          0 :         SelectEntryPos( nAt, bSelect );
     457                 :          0 : }
     458                 :            : 
     459                 :            : //------------------------------------------------------------------------
     460                 :            : 
     461                 :          0 : sal_Bool SvxLanguageBox::IsLanguageSelected( const LanguageType eLangType ) const
     462                 :            : {
     463                 :            :     // Same here, work on the replacement if applicable.
     464                 :          0 :     LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( eLangType);
     465                 :            : 
     466                 :          0 :     sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
     467                 :            : 
     468         [ #  # ]:          0 :     if ( nAt != LISTBOX_ENTRY_NOTFOUND )
     469                 :          0 :         return IsEntryPosSelected( nAt );
     470                 :            :     else
     471                 :          0 :         return sal_False;
     472                 :            : }
     473                 :            : 
     474                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10