LCOV - code coverage report
Current view: top level - editeng/source/misc - unolingu.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 142 349 40.7 %
Date: 2012-08-25 Functions: 37 68 54.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 103 507 20.3 %

           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                 :            : 
      30                 :            : #include <map>
      31                 :            : #include <vector>
      32                 :            : #include <list>
      33                 :            : #include <memory>
      34                 :            : #include <editeng/unolingu.hxx>
      35                 :            : #include <rtl/logfile.hxx>
      36                 :            : #include <unotools/pathoptions.hxx>
      37                 :            : #include <com/sun/star/frame/XModel.hpp>
      38                 :            : #include <com/sun/star/frame/XStorable.hpp>
      39                 :            : #include <com/sun/star/lang/XEventListener.hpp>
      40                 :            : #include <com/sun/star/linguistic2/XAvailableLocales.hpp>
      41                 :            : #include <com/sun/star/ucb/XAnyCompareFactory.hpp>
      42                 :            : #include <com/sun/star/ucb/XContentAccess.hpp>
      43                 :            : #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
      44                 :            : #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
      45                 :            : #include <com/sun/star/sdbc/XResultSet.hpp>
      46                 :            : #include <com/sun/star/sdbc/XRow.hpp>
      47                 :            : #include <com/sun/star/util/DateTime.hpp>
      48                 :            : 
      49                 :            : #include <comphelper/processfactory.hxx>
      50                 :            : #include <cppuhelper/implbase1.hxx> // helper for implementations
      51                 :            : #include <i18npool/mslangid.hxx>
      52                 :            : #include <unotools/lingucfg.hxx>
      53                 :            : #include <unotools/ucbhelper.hxx>
      54                 :            : #include <unotools/localfilehelper.hxx>
      55                 :            : #include <ucbhelper/commandenvironment.hxx>
      56                 :            : #include <ucbhelper/content.hxx>
      57                 :            : #include <vcl/msgbox.hxx>
      58                 :            : #include <tools/shl.hxx>
      59                 :            : #include <linguistic/misc.hxx>
      60                 :            : #include <editeng/eerdll.hxx>
      61                 :            : #include <editeng/editrids.hrc>
      62                 :            : 
      63                 :            : using namespace ::rtl;
      64                 :            : using namespace ::comphelper;
      65                 :            : using namespace ::linguistic;
      66                 :            : using namespace ::com::sun::star;
      67                 :            : using namespace ::com::sun::star::util;
      68                 :            : using namespace ::com::sun::star::uno;
      69                 :            : using namespace ::com::sun::star::lang;
      70                 :            : using namespace ::com::sun::star::beans;
      71                 :            : using namespace ::com::sun::star::frame;
      72                 :            : using namespace ::com::sun::star::linguistic2;
      73                 :            : 
      74                 :            : #define CSS com::sun::star
      75                 :            : 
      76                 :       1246 : static uno::Reference< XLinguServiceManager > GetLngSvcMgr_Impl()
      77                 :            : {
      78                 :       1246 :     uno::Reference< XLinguServiceManager > xRes;
      79         [ +  - ]:       1246 :     uno::Reference< XMultiServiceFactory >  xMgr = getProcessServiceFactory();
      80         [ +  - ]:       1246 :     if (xMgr.is())
      81                 :            :     {
      82         [ +  - ]:       1246 :         xRes = uno::Reference< XLinguServiceManager > ( xMgr->createInstance(
      83                 :            :                 OUString( RTL_CONSTASCII_USTRINGPARAM(
      84 [ +  - ][ +  - ]:       1246 :                     "com.sun.star.linguistic2.LinguServiceManager" ) ) ), UNO_QUERY ) ;
         [ +  - ][ +  - ]
      85                 :            :     }
      86                 :       1246 :     return xRes;
      87                 :            : }
      88                 :            : 
      89                 :            : //! Dummy implementation in order to avoid loading of lingu DLL
      90                 :            : //! when only the XSupportedLocales interface is used.
      91                 :            : //! The dummy accesses the real implementation (and thus loading the DLL)
      92                 :            : //! when "real" work needs to be done only.
      93                 :            : class ThesDummy_Impl :
      94                 :            :     public cppu::WeakImplHelper1< XThesaurus >
      95                 :            : {
      96                 :            :     uno::Reference< XThesaurus >     xThes;      // the real one...
      97                 :            :     Sequence< Locale >         *pLocaleSeq;
      98                 :            : 
      99                 :            :     void GetCfgLocales();
     100                 :            : 
     101                 :            :     void GetThes_Impl();
     102                 :            : 
     103                 :            : public:
     104                 :          0 :     ThesDummy_Impl() : pLocaleSeq(0)  {}
     105                 :            :     ~ThesDummy_Impl();
     106                 :            : 
     107                 :            :     // XSupportedLocales
     108                 :            :     virtual ::com::sun::star::uno::Sequence<
     109                 :            :             ::com::sun::star::lang::Locale > SAL_CALL
     110                 :            :         getLocales()
     111                 :            :             throw(::com::sun::star::uno::RuntimeException);
     112                 :            :     virtual sal_Bool SAL_CALL
     113                 :            :         hasLocale( const ::com::sun::star::lang::Locale& rLocale )
     114                 :            :             throw(::com::sun::star::uno::RuntimeException);
     115                 :            : 
     116                 :            :     // XThesaurus
     117                 :            :     virtual ::com::sun::star::uno::Sequence<
     118                 :            :             ::com::sun::star::uno::Reference<
     119                 :            :                 ::com::sun::star::linguistic2::XMeaning > > SAL_CALL
     120                 :            :         queryMeanings( const ::rtl::OUString& rTerm,
     121                 :            :                 const ::com::sun::star::lang::Locale& rLocale,
     122                 :            :                 const ::com::sun::star::beans::PropertyValues& rProperties )
     123                 :            :             throw(::com::sun::star::lang::IllegalArgumentException,
     124                 :            :                   ::com::sun::star::uno::RuntimeException);
     125                 :            : };
     126                 :            : 
     127                 :            : 
     128                 :          0 : ThesDummy_Impl::~ThesDummy_Impl()
     129                 :            : {
     130 [ #  # ][ #  # ]:          0 :     delete pLocaleSeq;
     131         [ #  # ]:          0 : }
     132                 :            : 
     133                 :            : 
     134                 :          0 : void ThesDummy_Impl::GetCfgLocales()
     135                 :            : {
     136         [ #  # ]:          0 :     if (!pLocaleSeq)
     137                 :            :     {
     138         [ #  # ]:          0 :         SvtLinguConfig aCfg;
     139 [ #  # ][ #  # ]:          0 :         String  aNode( A2OU( "ServiceManager/ThesaurusList" ) );
     140 [ #  # ][ #  # ]:          0 :         Sequence < OUString > aNodeNames( aCfg.GetNodeNames( aNode ) );
     141                 :          0 :         const OUString *pNodeNames = aNodeNames.getConstArray();
     142                 :          0 :         sal_Int32 nLen = aNodeNames.getLength();
     143         [ #  # ]:          0 :         pLocaleSeq = new Sequence< Locale >( nLen );
     144         [ #  # ]:          0 :         Locale *pLocale = pLocaleSeq->getArray();
     145         [ #  # ]:          0 :         for (sal_Int32 i = 0;  i < nLen;  ++i)
     146                 :            :         {
     147                 :            :             pLocale[i] = SvxCreateLocale(
     148 [ #  # ][ #  # ]:          0 :                             MsLangId::convertIsoStringToLanguage( pNodeNames[i] ) );
     149 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     150                 :            :     }
     151                 :          0 : }
     152                 :            : 
     153                 :            : 
     154                 :          0 : void ThesDummy_Impl::GetThes_Impl()
     155                 :            : {
     156         [ #  # ]:          0 :     if (!xThes.is())
     157                 :            :     {
     158         [ #  # ]:          0 :         uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
     159         [ #  # ]:          0 :         if (xLngSvcMgr.is())
     160 [ #  # ][ #  # ]:          0 :             xThes = xLngSvcMgr->getThesaurus();
                 [ #  # ]
     161                 :            : 
     162         [ #  # ]:          0 :         if (xThes.is())
     163                 :            :         {
     164                 :            :             // no longer needed...
     165 [ #  # ][ #  # ]:          0 :             delete pLocaleSeq;    pLocaleSeq = 0;
     166                 :          0 :         }
     167                 :            :     }
     168                 :          0 : }
     169                 :            : 
     170                 :            : 
     171                 :            : uno::Sequence< lang::Locale > SAL_CALL
     172                 :          0 :         ThesDummy_Impl::getLocales()
     173                 :            :             throw(uno::RuntimeException)
     174                 :            : {
     175                 :          0 :     GetThes_Impl();
     176         [ #  # ]:          0 :     if (xThes.is())
     177                 :          0 :         return xThes->getLocales();
     178         [ #  # ]:          0 :     else if (!pLocaleSeq)       // if not already loaded save startup time by avoiding loading them now
     179                 :          0 :         GetCfgLocales();
     180                 :          0 :     return *pLocaleSeq;
     181                 :            : }
     182                 :            : 
     183                 :            : 
     184                 :            : sal_Bool SAL_CALL
     185                 :          0 :         ThesDummy_Impl::hasLocale( const lang::Locale& rLocale )
     186                 :            :             throw(uno::RuntimeException)
     187                 :            : {
     188                 :          0 :     GetThes_Impl();
     189         [ #  # ]:          0 :     if (xThes.is())
     190                 :          0 :         return xThes->hasLocale( rLocale );
     191         [ #  # ]:          0 :     else if (!pLocaleSeq)       // if not already loaded save startup time by avoiding loading them now
     192                 :          0 :         GetCfgLocales();
     193                 :          0 :         GetCfgLocales();
     194                 :          0 :     sal_Bool bFound = sal_False;
     195                 :          0 :     sal_Int32 nLen = pLocaleSeq->getLength();
     196                 :          0 :     const Locale *pLocale = pLocaleSeq->getConstArray();
     197                 :          0 :     const Locale *pEnd = pLocale + nLen;
     198 [ #  # ][ #  # ]:          0 :     for ( ;  pLocale < pEnd  &&  !bFound;  ++pLocale)
                 [ #  # ]
     199                 :            :     {
     200                 :          0 :         bFound = pLocale->Language == rLocale.Language  &&
     201                 :          0 :                  pLocale->Country  == rLocale.Country   &&
     202         [ #  # ]:          0 :                  pLocale->Variant  == rLocale.Variant;
           [ #  #  #  # ]
     203                 :            :     }
     204                 :          0 :     return bFound;
     205                 :            : }
     206                 :            : 
     207                 :            : 
     208                 :            : uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL
     209                 :          0 :         ThesDummy_Impl::queryMeanings(
     210                 :            :                 const rtl::OUString& rTerm,
     211                 :            :                 const lang::Locale& rLocale,
     212                 :            :                 const beans::PropertyValues& rProperties )
     213                 :            :             throw(lang::IllegalArgumentException,
     214                 :            :                   uno::RuntimeException)
     215                 :            : {
     216                 :          0 :     GetThes_Impl();
     217                 :          0 :     uno::Sequence< uno::Reference< linguistic2::XMeaning > > aRes;
     218                 :            :     OSL_ENSURE( xThes.is(), "Thesaurus missing" );
     219         [ #  # ]:          0 :     if (xThes.is())
     220 [ #  # ][ #  # ]:          0 :         aRes = xThes->queryMeanings( rTerm, rLocale, rProperties );
         [ #  # ][ #  # ]
     221                 :          0 :     return aRes;
     222                 :            : }
     223                 :            : 
     224                 :            : 
     225                 :            : //! Dummy implementation in order to avoid loading of lingu DLL.
     226                 :            : //! The dummy accesses the real implementation (and thus loading the DLL)
     227                 :            : //! when it needs to be done only.
     228         [ -  + ]:        272 : class SpellDummy_Impl :
     229                 :            :     public cppu::WeakImplHelper1< XSpellChecker1 >
     230                 :            : {
     231                 :            :     uno::Reference< XSpellChecker1 >     xSpell;      // the real one...
     232                 :            : 
     233                 :            :     void    GetSpell_Impl();
     234                 :            : 
     235                 :            : public:
     236                 :            : 
     237                 :            :     // XSupportedLanguages (for XSpellChecker1)
     238                 :            :     virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL
     239                 :            :         getLanguages()
     240                 :            :             throw(::com::sun::star::uno::RuntimeException);
     241                 :            :     virtual sal_Bool SAL_CALL
     242                 :            :         hasLanguage( sal_Int16 nLanguage )
     243                 :            :             throw(::com::sun::star::uno::RuntimeException);
     244                 :            : 
     245                 :            :     // XSpellChecker1 (same as XSpellChecker but sal_Int16 for language)
     246                 :            :     virtual sal_Bool SAL_CALL
     247                 :            :         isValid( const ::rtl::OUString& rWord, sal_Int16 nLanguage,
     248                 :            :                 const ::com::sun::star::beans::PropertyValues& rProperties )
     249                 :            :             throw(::com::sun::star::lang::IllegalArgumentException,
     250                 :            :                   ::com::sun::star::uno::RuntimeException);
     251                 :            :     virtual ::com::sun::star::uno::Reference<
     252                 :            :             ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL
     253                 :            :         spell( const ::rtl::OUString& rWord, sal_Int16 nLanguage,
     254                 :            :                 const ::com::sun::star::beans::PropertyValues& rProperties )
     255                 :            :             throw(::com::sun::star::lang::IllegalArgumentException,
     256                 :            :                   ::com::sun::star::uno::RuntimeException);
     257                 :            : };
     258                 :            : 
     259                 :            : 
     260                 :      61947 : void SpellDummy_Impl::GetSpell_Impl()
     261                 :            : {
     262         [ +  + ]:      61947 :     if (!xSpell.is())
     263                 :            :     {
     264         [ +  - ]:        518 :         uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
     265         [ +  + ]:        518 :         if (xLngSvcMgr.is())
     266 [ +  - ][ +  - ]:        518 :             xSpell = uno::Reference< XSpellChecker1 >( xLngSvcMgr->getSpellChecker(), UNO_QUERY );
         [ +  - ][ +  - ]
     267                 :            :     }
     268                 :      61947 : }
     269                 :            : 
     270                 :            : 
     271                 :            : uno::Sequence< sal_Int16 > SAL_CALL
     272                 :          0 :     SpellDummy_Impl::getLanguages()
     273                 :            :         throw(uno::RuntimeException)
     274                 :            : {
     275                 :          0 :     GetSpell_Impl();
     276         [ #  # ]:          0 :     if (xSpell.is())
     277                 :          0 :         return xSpell->getLanguages();
     278                 :            :     else
     279                 :          0 :         return uno::Sequence< sal_Int16 >();
     280                 :            : }
     281                 :            : 
     282                 :            : 
     283                 :            : sal_Bool SAL_CALL
     284                 :      29664 :     SpellDummy_Impl::hasLanguage( sal_Int16 nLanguage )
     285                 :            :         throw(uno::RuntimeException)
     286                 :            : {
     287                 :      29664 :     GetSpell_Impl();
     288                 :      29664 :     sal_Bool bRes = sal_False;
     289         [ +  + ]:      29664 :     if (xSpell.is())
     290                 :      29241 :         bRes = xSpell->hasLanguage( nLanguage );
     291                 :      29664 :     return bRes;
     292                 :            : }
     293                 :            : 
     294                 :            : 
     295                 :            : sal_Bool SAL_CALL
     296                 :      32283 :     SpellDummy_Impl::isValid( const rtl::OUString& rWord, sal_Int16 nLanguage,
     297                 :            :             const beans::PropertyValues& rProperties )
     298                 :            :         throw(lang::IllegalArgumentException,
     299                 :            :               uno::RuntimeException)
     300                 :            : {
     301                 :      32283 :     GetSpell_Impl();
     302                 :      32283 :     sal_Bool bRes = sal_True;
     303         [ +  + ]:      32283 :     if (xSpell.is())
     304                 :      32229 :         bRes = xSpell->isValid( rWord, nLanguage, rProperties );
     305                 :      32283 :     return bRes;
     306                 :            : }
     307                 :            : 
     308                 :            : 
     309                 :            : uno::Reference< linguistic2::XSpellAlternatives > SAL_CALL
     310                 :          0 :     SpellDummy_Impl::spell( const rtl::OUString& rWord, sal_Int16 nLanguage,
     311                 :            :             const beans::PropertyValues& rProperties )
     312                 :            :         throw(lang::IllegalArgumentException,
     313                 :            :               uno::RuntimeException)
     314                 :            : {
     315                 :          0 :     GetSpell_Impl();
     316                 :          0 :     uno::Reference< linguistic2::XSpellAlternatives > xRes;
     317         [ #  # ]:          0 :     if (xSpell.is())
     318 [ #  # ][ #  # ]:          0 :         xRes = xSpell->spell( rWord, nLanguage, rProperties );
                 [ #  # ]
     319                 :          0 :     return xRes;
     320                 :            : }
     321                 :            : 
     322                 :            : 
     323                 :            : //! Dummy implementation in order to avoid loading of lingu DLL.
     324                 :            : //! The dummy accesses the real implementation (and thus loading the DLL)
     325                 :            : //! when it needs to be done only.
     326         [ -  + ]:        296 : class HyphDummy_Impl :
     327                 :            :     public cppu::WeakImplHelper1< XHyphenator >
     328                 :            : {
     329                 :            :     uno::Reference< XHyphenator >     xHyph;      // the real one...
     330                 :            : 
     331                 :            :     void    GetHyph_Impl();
     332                 :            : 
     333                 :            : public:
     334                 :            : 
     335                 :            :     // XSupportedLocales
     336                 :            :     virtual ::com::sun::star::uno::Sequence<
     337                 :            :             ::com::sun::star::lang::Locale > SAL_CALL
     338                 :            :         getLocales()
     339                 :            :             throw(::com::sun::star::uno::RuntimeException);
     340                 :            :     virtual sal_Bool SAL_CALL
     341                 :            :         hasLocale( const ::com::sun::star::lang::Locale& rLocale )
     342                 :            :             throw(::com::sun::star::uno::RuntimeException);
     343                 :            : 
     344                 :            :     // XHyphenator
     345                 :            :     virtual ::com::sun::star::uno::Reference<
     346                 :            :             ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL
     347                 :            :         hyphenate( const ::rtl::OUString& rWord,
     348                 :            :                 const ::com::sun::star::lang::Locale& rLocale,
     349                 :            :                 sal_Int16 nMaxLeading,
     350                 :            :                 const ::com::sun::star::beans::PropertyValues& rProperties )
     351                 :            :             throw(::com::sun::star::lang::IllegalArgumentException,
     352                 :            :                   ::com::sun::star::uno::RuntimeException);
     353                 :            :     virtual ::com::sun::star::uno::Reference<
     354                 :            :             ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL
     355                 :            :         queryAlternativeSpelling( const ::rtl::OUString& rWord,
     356                 :            :                 const ::com::sun::star::lang::Locale& rLocale,
     357                 :            :                 sal_Int16 nIndex,
     358                 :            :                 const ::com::sun::star::beans::PropertyValues& rProperties )
     359                 :            :             throw(::com::sun::star::lang::IllegalArgumentException,
     360                 :            :                   ::com::sun::star::uno::RuntimeException);
     361                 :            :     virtual ::com::sun::star::uno::Reference<
     362                 :            :             ::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL
     363                 :            :         createPossibleHyphens(
     364                 :            :                 const ::rtl::OUString& rWord,
     365                 :            :                 const ::com::sun::star::lang::Locale& rLocale,
     366                 :            :                 const ::com::sun::star::beans::PropertyValues& rProperties )
     367                 :            :             throw(::com::sun::star::lang::IllegalArgumentException,
     368                 :            :                   ::com::sun::star::uno::RuntimeException);
     369                 :            : };
     370                 :            : 
     371                 :            : 
     372                 :      90574 : void HyphDummy_Impl::GetHyph_Impl()
     373                 :            : {
     374         [ +  + ]:      90574 :     if (!xHyph.is())
     375                 :            :     {
     376         [ +  - ]:        728 :         uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
     377         [ +  + ]:        728 :         if (xLngSvcMgr.is())
     378 [ +  - ][ +  - ]:        728 :             xHyph = xLngSvcMgr->getHyphenator();
                 [ +  - ]
     379                 :            :     }
     380                 :      90574 : }
     381                 :            : 
     382                 :            : 
     383                 :            : uno::Sequence< lang::Locale > SAL_CALL
     384                 :          0 :     HyphDummy_Impl::getLocales()
     385                 :            :         throw(uno::RuntimeException)
     386                 :            : {
     387                 :          0 :     GetHyph_Impl();
     388         [ #  # ]:          0 :     if (xHyph.is())
     389                 :          0 :         return xHyph->getLocales();
     390                 :            :     else
     391                 :          0 :         return uno::Sequence< lang::Locale >();
     392                 :            : }
     393                 :            : 
     394                 :            : 
     395                 :            : sal_Bool SAL_CALL
     396                 :          0 :     HyphDummy_Impl::hasLocale( const lang::Locale& rLocale )
     397                 :            :         throw(uno::RuntimeException)
     398                 :            : {
     399                 :          0 :     GetHyph_Impl();
     400                 :          0 :     sal_Bool bRes = sal_False;
     401         [ #  # ]:          0 :     if (xHyph.is())
     402                 :          0 :         bRes = xHyph->hasLocale( rLocale );
     403                 :          0 :     return bRes;
     404                 :            : }
     405                 :            : 
     406                 :            : 
     407                 :            : uno::Reference< linguistic2::XHyphenatedWord > SAL_CALL
     408                 :      90574 :     HyphDummy_Impl::hyphenate(
     409                 :            :             const rtl::OUString& rWord,
     410                 :            :             const lang::Locale& rLocale,
     411                 :            :             sal_Int16 nMaxLeading,
     412                 :            :             const beans::PropertyValues& rProperties )
     413                 :            :         throw(lang::IllegalArgumentException,
     414                 :            :               uno::RuntimeException)
     415                 :            : {
     416                 :      90574 :     GetHyph_Impl();
     417                 :      90574 :     uno::Reference< linguistic2::XHyphenatedWord > xRes;
     418         [ +  + ]:      90574 :     if (xHyph.is())
     419 [ +  - ][ +  - ]:      89857 :         xRes = xHyph->hyphenate( rWord, rLocale, nMaxLeading, rProperties );
                 [ +  - ]
     420                 :      90574 :     return xRes;
     421                 :            : }
     422                 :            : 
     423                 :            : 
     424                 :            : uno::Reference< linguistic2::XHyphenatedWord > SAL_CALL
     425                 :          0 :     HyphDummy_Impl::queryAlternativeSpelling(
     426                 :            :             const rtl::OUString& rWord,
     427                 :            :             const lang::Locale& rLocale,
     428                 :            :             sal_Int16 nIndex,
     429                 :            :             const PropertyValues& rProperties )
     430                 :            :         throw(lang::IllegalArgumentException,
     431                 :            :               uno::RuntimeException)
     432                 :            : {
     433                 :          0 :     GetHyph_Impl();
     434                 :          0 :     uno::Reference< linguistic2::XHyphenatedWord > xRes;
     435         [ #  # ]:          0 :     if (xHyph.is())
     436 [ #  # ][ #  # ]:          0 :         xRes = xHyph->queryAlternativeSpelling( rWord, rLocale, nIndex, rProperties );
                 [ #  # ]
     437                 :          0 :     return xRes;
     438                 :            : }
     439                 :            : 
     440                 :            : 
     441                 :            : uno::Reference< linguistic2::XPossibleHyphens > SAL_CALL
     442                 :          0 :     HyphDummy_Impl::createPossibleHyphens(
     443                 :            :             const rtl::OUString& rWord,
     444                 :            :             const lang::Locale& rLocale,
     445                 :            :             const beans::PropertyValues& rProperties )
     446                 :            :         throw(lang::IllegalArgumentException,
     447                 :            :               uno::RuntimeException)
     448                 :            : {
     449                 :          0 :     GetHyph_Impl();
     450                 :          0 :     uno::Reference< linguistic2::XPossibleHyphens > xRes;
     451         [ #  # ]:          0 :     if (xHyph.is())
     452 [ #  # ][ #  # ]:          0 :         xRes = xHyph->createPossibleHyphens( rWord, rLocale, rProperties );
                 [ #  # ]
     453                 :          0 :     return xRes;
     454                 :            : }
     455                 :            : 
     456                 :            : 
     457                 :            : typedef cppu::WeakImplHelper1 < XEventListener > LinguMgrAppExitLstnrBaseClass;
     458                 :            : 
     459                 :            : 
     460                 :            : class LinguMgrAppExitLstnr : public LinguMgrAppExitLstnrBaseClass
     461                 :            : {
     462                 :            :     uno::Reference< XComponent >        xDesktop;
     463                 :            : 
     464                 :            : public:
     465                 :            :     LinguMgrAppExitLstnr();
     466                 :            :     virtual ~LinguMgrAppExitLstnr();
     467                 :            : 
     468                 :            :     virtual void    AtExit() = 0;
     469                 :            : 
     470                 :            : 
     471                 :            :     // lang::XEventListener
     472                 :            :     virtual void    SAL_CALL disposing(const EventObject& rSource)
     473                 :            :             throw( RuntimeException );
     474                 :            : };
     475                 :            : 
     476                 :        106 : LinguMgrAppExitLstnr::LinguMgrAppExitLstnr()
     477                 :            : {
     478                 :            :     // add object to frame::Desktop EventListeners in order to properly call
     479                 :            :     // the AtExit function at appliction exit.
     480                 :            : 
     481         [ +  - ]:        106 :     uno::Reference< XMultiServiceFactory >  xMgr = getProcessServiceFactory();
     482         [ +  - ]:        106 :     if ( xMgr.is() )
     483                 :            :     {
     484         [ +  - ]:        106 :         xDesktop = uno::Reference< XComponent > ( xMgr->createInstance(
     485 [ +  - ][ +  - ]:        106 :                 OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) ) ), UNO_QUERY ) ;
         [ +  - ][ +  - ]
     486         [ +  - ]:        106 :         if (xDesktop.is())
     487 [ +  - ][ +  - ]:        106 :             xDesktop->addEventListener( this );
                 [ +  - ]
     488                 :        106 :     }
     489                 :        106 : }
     490                 :            : 
     491                 :        106 : LinguMgrAppExitLstnr::~LinguMgrAppExitLstnr()
     492                 :            : {
     493         [ -  + ]:        106 :     if (xDesktop.is())
     494                 :            :     {
     495 [ #  # ][ #  # ]:          0 :         xDesktop->removeEventListener( this );
                 [ #  # ]
     496         [ #  # ]:          0 :         xDesktop = NULL;    //! release reference to desktop
     497                 :            :     }
     498                 :            :     OSL_ENSURE(!xDesktop.is(), "reference to desktop should be realeased");
     499         [ -  + ]:        106 : }
     500                 :            : 
     501                 :        106 : void LinguMgrAppExitLstnr::disposing(const EventObject& rSource)
     502                 :            :         throw( RuntimeException )
     503                 :            : {
     504 [ +  - ][ +  - ]:        106 :     if (xDesktop.is()  &&  rSource.Source == xDesktop)
                 [ +  - ]
     505                 :            :     {
     506         [ +  - ]:        106 :         xDesktop->removeEventListener( this );
     507                 :        106 :         xDesktop = NULL;    //! release reference to desktop
     508                 :            : 
     509                 :        106 :         AtExit();
     510                 :            :     }
     511                 :        106 : }
     512                 :            : 
     513         [ -  + ]:        318 : class LinguMgrExitLstnr : public LinguMgrAppExitLstnr
     514                 :            : {
     515                 :            : public:
     516                 :            :     virtual void    AtExit();
     517                 :            : };
     518                 :            : 
     519                 :        106 : void LinguMgrExitLstnr::AtExit()
     520                 :            : {
     521                 :            :     // release references
     522                 :        106 :     LinguMgr::xLngSvcMgr    = 0;
     523                 :        106 :     LinguMgr::xSpell        = 0;
     524                 :        106 :     LinguMgr::xHyph         = 0;
     525                 :        106 :     LinguMgr::xThes         = 0;
     526                 :        106 :     LinguMgr::xDicList      = 0;
     527                 :        106 :     LinguMgr::xProp         = 0;
     528                 :        106 :     LinguMgr::xIgnoreAll    = 0;
     529                 :        106 :     LinguMgr::xChangeAll    = 0;
     530                 :            : 
     531                 :        106 :     LinguMgr::bExiting      = sal_True;
     532                 :            : 
     533                 :        106 :     LinguMgr::pExitLstnr    = 0;
     534                 :        106 : }
     535                 :            : 
     536                 :            : 
     537                 :            : LinguMgrExitLstnr *             LinguMgr::pExitLstnr    = 0;
     538                 :            : sal_Bool                        LinguMgr::bExiting      = sal_False;
     539                 :        159 : uno::Reference< XLinguServiceManager >  LinguMgr::xLngSvcMgr    = 0;
     540                 :        159 : uno::Reference< XSpellChecker1 >    LinguMgr::xSpell        = 0;
     541                 :        159 : uno::Reference< XHyphenator >       LinguMgr::xHyph         = 0;
     542                 :        159 : uno::Reference< XThesaurus >        LinguMgr::xThes         = 0;
     543                 :        159 : uno::Reference< XDictionaryList >   LinguMgr::xDicList      = 0;
     544                 :        159 : uno::Reference< XPropertySet >      LinguMgr::xProp         = 0;
     545                 :        159 : uno::Reference< XDictionary >       LinguMgr::xIgnoreAll    = 0;
     546                 :        159 : uno::Reference< XDictionary >       LinguMgr::xChangeAll    = 0;
     547                 :            : 
     548                 :            : 
     549                 :          0 : uno::Reference< XLinguServiceManager > LinguMgr::GetLngSvcMgr()
     550                 :            : {
     551         [ #  # ]:          0 :     if (bExiting)
     552                 :          0 :         return 0;
     553                 :            : 
     554         [ #  # ]:          0 :     if (!pExitLstnr)
     555         [ #  # ]:          0 :         pExitLstnr = new LinguMgrExitLstnr;
     556                 :            : 
     557         [ #  # ]:          0 :     if (!xLngSvcMgr.is())
     558         [ #  # ]:          0 :         xLngSvcMgr = GetLngSvcMgr_Impl();
     559                 :            : 
     560                 :          0 :     return xLngSvcMgr;
     561                 :            : }
     562                 :            : 
     563                 :            : 
     564                 :       9354 : uno::Reference< XSpellChecker1 > LinguMgr::GetSpellChecker()
     565                 :            : {
     566         [ +  + ]:       9354 :     return xSpell.is() ? xSpell : GetSpell();
     567                 :            : }
     568                 :            : 
     569                 :       3259 : uno::Reference< XHyphenator > LinguMgr::GetHyphenator()
     570                 :            : {
     571         [ +  + ]:       3259 :     return xHyph.is() ? xHyph : GetHyph();
     572                 :            : }
     573                 :            : 
     574                 :          0 : uno::Reference< XThesaurus > LinguMgr::GetThesaurus()
     575                 :            : {
     576         [ #  # ]:          0 :     return xThes.is() ? xThes : GetThes();
     577                 :            : }
     578                 :            : 
     579                 :         18 : uno::Reference< XDictionaryList > LinguMgr::GetDictionaryList()
     580                 :            : {
     581         [ -  + ]:         18 :     return xDicList.is() ? xDicList : GetDicList();
     582                 :            : }
     583                 :            : 
     584                 :         36 : uno::Reference< XPropertySet > LinguMgr::GetLinguPropertySet()
     585                 :            : {
     586         [ -  + ]:         36 :     return xProp.is() ? xProp : GetProp();
     587                 :            : }
     588                 :            : 
     589                 :          0 : uno::Reference< XDictionary > LinguMgr::GetStandardDic()
     590                 :            : {
     591                 :            :     //! don't hold reference to this
     592                 :            :     //! (it may be removed from dictionary list and needs to be
     593                 :            :     //! created empty if accessed again)
     594                 :          0 :     return GetStandard();
     595                 :            : }
     596                 :            : 
     597                 :          0 : uno::Reference< XDictionary > LinguMgr::GetIgnoreAllList()
     598                 :            : {
     599         [ #  # ]:          0 :     return xIgnoreAll.is() ? xIgnoreAll : GetIgnoreAll();
     600                 :            : }
     601                 :            : 
     602                 :         18 : uno::Reference< XDictionary > LinguMgr::GetChangeAllList()
     603                 :            : {
     604         [ -  + ]:         18 :     return xChangeAll.is() ? xChangeAll : GetChangeAll();
     605                 :            : }
     606                 :            : 
     607                 :         98 : uno::Reference< XSpellChecker1 > LinguMgr::GetSpell()
     608                 :            : {
     609         [ -  + ]:         98 :     if (bExiting)
     610                 :          0 :         return 0;
     611                 :            : 
     612         [ +  + ]:         98 :     if (!pExitLstnr)
     613         [ +  - ]:         85 :         pExitLstnr = new LinguMgrExitLstnr;
     614                 :            : 
     615                 :            :     //! use dummy implementation in order to avoid loading of lingu DLL
     616 [ +  - ][ +  - ]:         98 :     xSpell = new SpellDummy_Impl;
     617                 :         98 :     return xSpell;
     618                 :            : }
     619                 :            : 
     620                 :        106 : uno::Reference< XHyphenator > LinguMgr::GetHyph()
     621                 :            : {
     622         [ -  + ]:        106 :     if (bExiting)
     623                 :          0 :         return 0;
     624                 :            : 
     625         [ +  + ]:        106 :     if (!pExitLstnr)
     626         [ +  - ]:         21 :         pExitLstnr = new LinguMgrExitLstnr;
     627                 :            : 
     628                 :            :     //! use dummy implementation in order to avoid loading of lingu DLL
     629 [ +  - ][ +  - ]:        106 :     xHyph = new HyphDummy_Impl;
     630                 :        106 :     return xHyph;
     631                 :            : }
     632                 :            : 
     633                 :          0 : uno::Reference< XThesaurus > LinguMgr::GetThes()
     634                 :            : {
     635         [ #  # ]:          0 :     if (bExiting)
     636                 :          0 :         return 0;
     637                 :            : 
     638         [ #  # ]:          0 :     if (!pExitLstnr)
     639         [ #  # ]:          0 :         pExitLstnr = new LinguMgrExitLstnr;
     640                 :            : 
     641                 :            :     //! use dummy implementation in order to avoid loading of lingu DLL
     642                 :            :     //! when only the XSupportedLocales interface is used.
     643                 :            :     //! The dummy accesses the real implementation (and thus loading the DLL)
     644                 :            :     //! when "real" work needs to be done only.
     645 [ #  # ][ #  # ]:          0 :     xThes = new ThesDummy_Impl;
     646                 :          0 :     return xThes;
     647                 :            : }
     648                 :            : 
     649                 :         18 : uno::Reference< XDictionaryList > LinguMgr::GetDicList()
     650                 :            : {
     651         [ -  + ]:         18 :     if (bExiting)
     652         [ #  # ]:          0 :         return 0;
     653                 :            : 
     654         [ -  + ]:         18 :     if (!pExitLstnr)
     655         [ #  # ]:          0 :         pExitLstnr = new LinguMgrExitLstnr;
     656                 :            : 
     657         [ +  - ]:         18 :     uno::Reference< XMultiServiceFactory >  xMgr( getProcessServiceFactory() );
     658         [ +  - ]:         18 :     if (xMgr.is())
     659                 :            :     {
     660         [ +  - ]:         18 :         xDicList = uno::Reference< XDictionaryList > ( xMgr->createInstance(
     661 [ +  - ][ +  - ]:         18 :                     A2OU("com.sun.star.linguistic2.DictionaryList") ), UNO_QUERY );
         [ +  - ][ +  - ]
     662                 :            :     }
     663                 :         18 :     return xDicList;
     664                 :            : }
     665                 :            : 
     666                 :         36 : uno::Reference< XPropertySet > LinguMgr::GetProp()
     667                 :            : {
     668         [ -  + ]:         36 :     if (bExiting)
     669         [ #  # ]:          0 :         return 0;
     670                 :            : 
     671         [ -  + ]:         36 :     if (!pExitLstnr)
     672         [ #  # ]:          0 :         pExitLstnr = new LinguMgrExitLstnr;
     673                 :            : 
     674         [ +  - ]:         36 :     uno::Reference< XMultiServiceFactory >  xMgr( getProcessServiceFactory() );
     675         [ +  - ]:         36 :     if (xMgr.is())
     676                 :            :     {
     677         [ +  - ]:         36 :         xProp = uno::Reference< XPropertySet > ( xMgr->createInstance(
     678 [ +  - ][ +  - ]:         36 :                     A2OU("com.sun.star.linguistic2.LinguProperties") ), UNO_QUERY );
         [ +  - ][ +  - ]
     679                 :            :     }
     680                 :         36 :     return xProp;
     681                 :            : }
     682                 :            : 
     683                 :          0 : uno::Reference< XDictionary > LinguMgr::GetIgnoreAll()
     684                 :            : {
     685         [ #  # ]:          0 :     if (bExiting)
     686         [ #  # ]:          0 :         return 0;
     687                 :            : 
     688         [ #  # ]:          0 :     if (!pExitLstnr)
     689         [ #  # ]:          0 :         pExitLstnr = new LinguMgrExitLstnr;
     690                 :            : 
     691         [ #  # ]:          0 :     uno::Reference< XDictionaryList >  xTmpDicList( GetDictionaryList() );
     692         [ #  # ]:          0 :     if (xTmpDicList.is())
     693                 :            :     {
     694         [ #  # ]:          0 :         xIgnoreAll = uno::Reference< XDictionary > ( xTmpDicList->getDictionaryByName(
     695 [ #  # ][ #  # ]:          0 :                     A2OU("IgnoreAllList") ), UNO_QUERY );
         [ #  # ][ #  # ]
     696                 :            :     }
     697                 :          0 :     return xIgnoreAll;
     698                 :            : }
     699                 :            : 
     700                 :         18 : uno::Reference< XDictionary > LinguMgr::GetChangeAll()
     701                 :            : {
     702         [ -  + ]:         18 :     if (bExiting)
     703         [ #  # ]:          0 :         return 0;
     704                 :            : 
     705         [ -  + ]:         18 :     if (!pExitLstnr)
     706         [ #  # ]:          0 :         pExitLstnr = new LinguMgrExitLstnr;
     707                 :            : 
     708 [ +  - ][ +  - ]:         18 :     uno::Reference< XDictionaryList > _xDicList( GetDictionaryList() , UNO_QUERY );
     709         [ -  + ]:         18 :     if (_xDicList.is())
     710                 :            :     {
     711                 :            :         xChangeAll = uno::Reference< XDictionary > (
     712         [ #  # ]:          0 :                         _xDicList->createDictionary(
     713                 :            :                             A2OU("ChangeAllList"),
     714                 :            :                             SvxCreateLocale( LANGUAGE_NONE ),
     715 [ #  # ][ #  # ]:          0 :                             DictionaryType_NEGATIVE, String() ), UNO_QUERY );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     716                 :            :     }
     717                 :         18 :     return xChangeAll;
     718                 :            : }
     719                 :            : 
     720                 :          0 : uno::Reference< XDictionary > LinguMgr::GetStandard()
     721                 :            : {
     722                 :            :     // Tries to return a dictionary which may hold positive entries is
     723                 :            :     // persistent and not read-only.
     724                 :            : 
     725         [ #  # ]:          0 :     if (bExiting)
     726         [ #  # ]:          0 :         return 0;
     727                 :            : 
     728         [ #  # ]:          0 :     uno::Reference< XDictionaryList >  xTmpDicList( GetDictionaryList() );
     729         [ #  # ]:          0 :     if (!xTmpDicList.is())
     730         [ #  # ]:          0 :         return NULL;
     731                 :            : 
     732         [ #  # ]:          0 :     const OUString aDicName( RTL_CONSTASCII_USTRINGPARAM( "standard.dic" ) );
     733         [ #  # ]:          0 :     uno::Reference< XDictionary >   xDic( xTmpDicList->getDictionaryByName( aDicName ),
     734 [ #  # ][ #  # ]:          0 :                                       UNO_QUERY );
     735         [ #  # ]:          0 :     if (!xDic.is())
     736                 :            :     {
     737                 :            :         // try to create standard dictionary
     738                 :          0 :         uno::Reference< XDictionary >    xTmp;
     739                 :            :         try
     740                 :            :         {
     741         [ #  # ]:          0 :             xTmp =  xTmpDicList->createDictionary( aDicName,
     742                 :            :                         SvxCreateLocale( LANGUAGE_NONE ),
     743                 :            :                         DictionaryType_POSITIVE,
     744 [ #  # ][ #  # ]:          0 :                         linguistic::GetWritableDictionaryURL( aDicName ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     745                 :            :         }
     746         [ #  # ]:          0 :         catch(const com::sun::star::uno::Exception &)
     747                 :            :         {
     748                 :            :         }
     749                 :            : 
     750                 :            :         // add new dictionary to list
     751         [ #  # ]:          0 :         if (xTmp.is())
     752                 :            :         {
     753 [ #  # ][ #  # ]:          0 :             xTmpDicList->addDictionary( xTmp );
     754 [ #  # ][ #  # ]:          0 :             xTmp->setActive( sal_True );
     755                 :            :         }
     756 [ #  # ][ #  # ]:          0 :         xDic = uno::Reference< XDictionary > ( xTmp, UNO_QUERY );
     757                 :            :     }
     758                 :            : #if OSL_DEBUG_LEVEL > 1
     759                 :            :     uno::Reference< XStorable >      xStor( xDic, UNO_QUERY );
     760                 :            :     OSL_ENSURE( xDic.is() && xDic->getDictionaryType() == DictionaryType_POSITIVE,
     761                 :            :             "wrong dictionary type");
     762                 :            :     OSL_ENSURE( xDic.is() && SvxLocaleToLanguage( xDic->getLocale() ) == LANGUAGE_NONE,
     763                 :            :             "wrong dictionary language");
     764                 :            :     OSL_ENSURE( !xStor.is() || (xStor->hasLocation() && !xStor->isReadonly()),
     765                 :            :             "dictionary not editable" );
     766                 :            : #endif
     767                 :            : 
     768                 :          0 :     return xDic;
     769                 :            : }
     770                 :            : 
     771                 :         18 : uno::Reference< XSpellChecker1 >  SvxGetSpellChecker()
     772                 :            : {
     773                 :         18 :     return LinguMgr::GetSpellChecker();
     774                 :            : }
     775                 :            : 
     776                 :          0 : uno::Reference< XHyphenator >  SvxGetHyphenator()
     777                 :            : {
     778                 :          0 :     return LinguMgr::GetHyphenator();
     779                 :            : }
     780                 :            : 
     781                 :          0 : uno::Reference< XThesaurus >  SvxGetThesaurus()
     782                 :            : {
     783                 :          0 :     return LinguMgr::GetThesaurus();
     784                 :            : }
     785                 :            : 
     786                 :          0 : uno::Reference< XDictionaryList >  SvxGetDictionaryList()
     787                 :            : {
     788                 :          0 :     return LinguMgr::GetDictionaryList();
     789                 :            : }
     790                 :            : 
     791                 :         36 : uno::Reference< XPropertySet >  SvxGetLinguPropertySet()
     792                 :            : {
     793                 :         36 :     return LinguMgr::GetLinguPropertySet();
     794                 :            : }
     795                 :            : 
     796                 :            : //TODO: remove argument or provide SvxGetIgnoreAllList with the same one
     797                 :          0 : uno::Reference< XDictionary >  SvxGetOrCreatePosDic(
     798                 :            :         uno::Reference< XDictionaryList >  /* xDicList */ )
     799                 :            : {
     800                 :          0 :     return LinguMgr::GetStandardDic();
     801                 :            : }
     802                 :            : 
     803                 :          0 : uno::Reference< XDictionary >  SvxGetIgnoreAllList()
     804                 :            : {
     805                 :          0 :     return LinguMgr::GetIgnoreAllList();
     806                 :            : }
     807                 :            : 
     808                 :         18 : uno::Reference< XDictionary >  SvxGetChangeAllList()
     809                 :            : {
     810                 :         18 :     return LinguMgr::GetChangeAllList();
     811                 :            : }
     812                 :            : 
     813                 :            : #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
     814                 :            : 
     815                 :          0 : SvxAlternativeSpelling SvxGetAltSpelling(
     816                 :            :         const ::com::sun::star::uno::Reference<
     817                 :            :             ::com::sun::star::linguistic2::XHyphenatedWord > & rHyphWord )
     818                 :            : {
     819                 :          0 :     SvxAlternativeSpelling aRes;
     820 [ #  # ][ #  # ]:          0 :     if (rHyphWord.is() && rHyphWord->isAlternativeSpelling())
         [ #  # ][ #  # ]
                 [ #  # ]
     821                 :            :     {
     822 [ #  # ][ #  # ]:          0 :         OUString aWord( rHyphWord->getWord() ),
     823 [ #  # ][ #  # ]:          0 :                  aAltWord( rHyphWord->getHyphenatedWord() );
     824 [ #  # ][ #  # ]:          0 :         sal_Int16   nHyphenationPos     = rHyphWord->getHyphenationPos(),
     825 [ #  # ][ #  # ]:          0 :                 nHyphenPos          = rHyphWord->getHyphenPos();
     826                 :          0 :         sal_Int16   nLen    = (sal_Int16)aWord.getLength();
     827                 :          0 :         sal_Int16   nAltLen = (sal_Int16)aAltWord.getLength();
     828                 :          0 :         const sal_Unicode *pWord    = aWord.getStr(),
     829                 :          0 :                           *pAltWord = aAltWord.getStr();
     830                 :            : 
     831                 :            :         // count number of chars from the left to the
     832                 :            :         // hyphenation pos / hyphen pos that are equal
     833                 :          0 :         sal_Int16 nL = 0;
     834 [ #  # ][ #  # ]:          0 :         while (nL <= nHyphenationPos && nL <= nHyphenPos
         [ #  # ][ #  # ]
     835                 :          0 :                && pWord[ nL ] == pAltWord[ nL ])
     836                 :          0 :             ++nL;
     837                 :            :         // count number of chars from the right to the
     838                 :            :         // hyphenation pos / hyphen pos that are equal
     839                 :          0 :         sal_Int16 nR = 0;
     840                 :          0 :         sal_Int32 nIdx    = nLen - 1;
     841                 :          0 :         sal_Int32 nAltIdx = nAltLen - 1;
     842 [ #  # ][ #  # ]:          0 :         while (nIdx > nHyphenationPos && nAltIdx > nHyphenPos
         [ #  # ][ #  # ]
     843                 :          0 :                && pWord[ nIdx-- ] == pAltWord[ nAltIdx-- ])
     844                 :          0 :             ++nR;
     845                 :            : 
     846         [ #  # ]:          0 :         aRes.aReplacement       = OUString( aAltWord.copy( nL, nAltLen - nL - nR ) );
     847                 :          0 :         aRes.nChangedPos        = (sal_Int16) nL;
     848                 :          0 :         aRes.nChangedLength     = nLen - nL - nR;
     849                 :          0 :         aRes.bIsAltSpelling     = sal_True;
     850         [ #  # ]:          0 :         aRes.xHyphWord          = rHyphWord;
     851                 :            :     }
     852                 :          0 :     return aRes;
     853                 :            : }
     854                 :            : 
     855                 :            : 
     856                 :          0 : SvxDicListChgClamp::SvxDicListChgClamp( uno::Reference< XDictionaryList >  &rxDicList ) :
     857                 :          0 :     xDicList    ( rxDicList )
     858                 :            : {
     859         [ #  # ]:          0 :     if (xDicList.is())
     860                 :            :     {
     861 [ #  # ][ #  # ]:          0 :         xDicList->beginCollectEvents();
     862                 :            :     }
     863                 :          0 : }
     864                 :            : 
     865                 :          0 : SvxDicListChgClamp::~SvxDicListChgClamp()
     866                 :            : {
     867         [ #  # ]:          0 :     if (xDicList.is())
     868                 :            :     {
     869 [ #  # ][ #  # ]:          0 :         xDicList->endCollectEvents();
     870                 :            :     }
     871                 :          0 : }
     872                 :            : 
     873                 :          0 : short SvxDicError( Window *pParent, sal_Int16 nError )
     874                 :            : {
     875                 :          0 :     short nRes = 0;
     876         [ #  # ]:          0 :     if (DIC_ERR_NONE != nError)
     877                 :            :     {
     878                 :            :         int nRid;
     879      [ #  #  # ]:          0 :         switch (nError)
     880                 :            :         {
     881                 :          0 :             case DIC_ERR_FULL     : nRid = RID_SVXSTR_DIC_ERR_FULL;  break;
     882                 :          0 :             case DIC_ERR_READONLY : nRid = RID_SVXSTR_DIC_ERR_READONLY;  break;
     883                 :            :             default:
     884                 :          0 :                 nRid = RID_SVXSTR_DIC_ERR_UNKNOWN;
     885                 :            :                 OSL_FAIL("unexpected case");
     886                 :            :         }
     887 [ #  # ][ #  # ]:          0 :         nRes = InfoBox( pParent, EE_RESSTR( nRid ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     888                 :            :     }
     889                 :          0 :     return nRes;
     890                 :            : }
     891                 :            : 
     892                 :     100895 : LanguageType SvxLocaleToLanguage( const Locale& rLocale )
     893                 :            : {
     894         [ +  + ]:     100895 :     if ( rLocale.Language.isEmpty() )
     895                 :      38677 :         return LANGUAGE_NONE;
     896                 :            : 
     897                 :     100895 :     return MsLangId::convertLocaleToLanguage( rLocale );
     898                 :            : }
     899                 :            : 
     900                 :         19 : Locale& SvxLanguageToLocale( Locale& rLocale, LanguageType eLang )
     901                 :            : {
     902         [ +  - ]:         19 :     if ( eLang != LANGUAGE_NONE )
     903                 :         19 :         MsLangId::convertLanguageToLocale( eLang, rLocale );
     904                 :            :     else
     905                 :          0 :         rLocale = Locale();
     906                 :            : 
     907                 :         19 :     return rLocale;
     908                 :            : }
     909                 :            : 
     910                 :     248202 : Locale SvxCreateLocale( LanguageType eLang )
     911                 :            : {
     912                 :     248202 :     Locale aLocale;
     913         [ +  + ]:     248202 :     if ( eLang != LANGUAGE_NONE )
     914         [ +  - ]:     233996 :         MsLangId::convertLanguageToLocale( eLang, aLocale );
     915                 :            : 
     916                 :     248202 :     return aLocale;
     917 [ +  - ][ +  - ]:        477 : }
     918                 :            : 
     919                 :            : 
     920                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10