LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/unotools - intlwrapper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 13 30.8 %
Date: 2012-08-25 Functions: 1 4 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 6 33.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : #include "unotools/unotoolsdllapi.h"
      20                 :            : 
      21                 :            : #ifndef _UNOTOOLS_INTLWRAPPER_HXX
      22                 :            : #define _UNOTOOLS_INTLWRAPPER_HXX
      23                 :            : #include <unotools/charclass.hxx>
      24                 :            : #include <unotools/localedatawrapper.hxx>
      25                 :            : #include <unotools/calendarwrapper.hxx>
      26                 :            : #include <unotools/collatorwrapper.hxx>
      27                 :            : #include <i18npool/lang.h>
      28                 :            : 
      29                 :            : 
      30                 :            : /**
      31                 :            :     A wrapper of I18N wrappers. Using this is more expensive than using some
      32                 :            :     single wrapper classes so use it only if you must pass a single pointer
      33                 :            :     without knowing in advance what is needed, e.g. for
      34                 :            :     SfxPoolItem::GetPresentation(). Remember that this wrapper was only created
      35                 :            :     for convenience to bypass some oddities, if possible don't use it. <p>
      36                 :            : 
      37                 :            :     Implemented are only the const get...() methods of the wrappers, which are
      38                 :            :     loaded on demand, for consistency reasons no change of locale is possible.
      39                 :            :     Only default calendar and default collator are supported. <p>
      40                 :            : 
      41                 :            :     One exception though is the calendar wrapper: to be able to set a value and
      42                 :            :     retrieve calendar values it is not const, so methods using this should
      43                 :            :     reset the calendar to the previous value if it isn't sure where the
      44                 :            :     IntlWrapper did come from. <p>
      45                 :            :  */
      46                 :            : class UNOTOOLS_DLLPUBLIC IntlWrapper
      47                 :            : {
      48                 :            : private:
      49                 :            : 
      50                 :            :     ::com::sun::star::lang::Locale  aLocale;
      51                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
      52                 :            : 
      53                 :            :             LocaleDataWrapper*  pLocaleData;
      54                 :            :             CollatorWrapper*    pCollator;
      55                 :            :             CollatorWrapper*    pCaseCollator;
      56                 :            : 
      57                 :            :             LanguageType        eLanguage;
      58                 :            : 
      59                 :            :             void                ImplNewLocaleData() const;
      60                 :            :             void                ImplNewCollator( sal_Bool bCaseSensitive ) const;
      61                 :            : 
      62                 :            : 
      63                 :            : public:
      64                 :            :                                 IntlWrapper(
      65                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
      66                 :            :                                     const ::com::sun::star::lang::Locale& rLocale
      67                 :            :                                     );
      68                 :            :                                 IntlWrapper(
      69                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
      70                 :            :                                     LanguageType eLang
      71                 :            :                                     );
      72                 :            :                                 ~IntlWrapper();
      73                 :            : 
      74                 :            :     LanguageType                getLanguage() const { return eLanguage; }
      75                 :          0 :     const ::com::sun::star::lang::Locale&   getLocale() const { return aLocale; }
      76                 :            : 
      77                 :          0 :     const LocaleDataWrapper*    getLocaleData() const
      78                 :            :                                     {
      79         [ #  # ]:          0 :                                         if ( !pLocaleData )
      80                 :          0 :                                             ImplNewLocaleData();
      81                 :          0 :                                         return pLocaleData;
      82                 :            :                                     }
      83                 :            :     /// case insensitive collator, simple IGNORE_CASE
      84                 :          0 :     const CollatorWrapper*      getCollator() const
      85                 :            :                                     {
      86         [ #  # ]:          0 :                                         if ( !pCollator )
      87                 :          0 :                                             ImplNewCollator( sal_False );
      88                 :          0 :                                         return pCollator;
      89                 :            :                                     }
      90                 :            :     /// case sensitive collator
      91                 :         44 :     const CollatorWrapper*      getCaseCollator() const
      92                 :            :                                     {
      93         [ +  + ]:         44 :                                         if ( !pCaseCollator )
      94                 :          2 :                                             ImplNewCollator( sal_True );
      95                 :         44 :                                         return pCaseCollator;
      96                 :            :                                     }
      97                 :            : };
      98                 :            : 
      99                 :            : #endif // _UNOTOOLS_INTLWRAPPER_HXX
     100                 :            : 
     101                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10