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

           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_TRANSLITERATIONWRAPPER_HXX
      22                 :            : #define _UNOTOOLS_TRANSLITERATIONWRAPPER_HXX
      23                 :            : #include <tools/string.hxx>
      24                 :            : #include <tools/solar.h>
      25                 :            : #include <com/sun/star/i18n/XExtendedTransliteration.hpp>
      26                 :            : 
      27                 :            : namespace com { namespace sun { namespace star {
      28                 :            :     namespace lang {
      29                 :            :         class XMultiServiceFactory;
      30                 :            :     }
      31                 :            : }}}
      32                 :            : 
      33                 :            : namespace utl
      34                 :            : {
      35                 :            : 
      36                 :            : class UNOTOOLS_DLLPUBLIC TransliterationWrapper
      37                 :            : {
      38                 :            :     ::com::sun::star::uno::Reference<
      39                 :            :                     ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
      40                 :            :     ::com::sun::star::uno::Reference<
      41                 :            :         ::com::sun::star::i18n::XExtendedTransliteration > xTrans;
      42                 :            :     ::com::sun::star::lang::Locale aLocale;
      43                 :            :     sal_uInt32 nType;
      44                 :            :     sal_uInt16 nLanguage;
      45                 :            :     mutable sal_Bool bFirstCall;
      46                 :            : 
      47                 :            :                                 // not implemented, prevent usage
      48                 :            :     TransliterationWrapper( const TransliterationWrapper& );
      49                 :            :     TransliterationWrapper& operator=( const TransliterationWrapper& );
      50                 :            : 
      51                 :            :     void loadModuleImpl() const;
      52                 :            :     void setLanguageLocaleImpl( sal_uInt16 nLang );
      53                 :            : 
      54                 :            : public:
      55                 :            :     TransliterationWrapper( const ::com::sun::star::uno::Reference<
      56                 :            :                     ::com::sun::star::lang::XMultiServiceFactory > & xSF,
      57                 :            :                     sal_uInt32 nType );
      58                 :            : 
      59                 :            :     ~TransliterationWrapper();
      60                 :            : 
      61                 :            :     // get current Locale / Language
      62                 :            :     const ::com::sun::star::lang::Locale& getLocale() const { return aLocale;}
      63                 :            :     sal_uInt16 getLanguage() const { return nLanguage; }
      64                 :            : 
      65                 :          0 :     sal_uInt32 getType() const { return nType; }
      66                 :            : 
      67                 :            :     sal_Bool needLanguageForTheMode() const;
      68                 :            : 
      69                 :            :     /** set a new language and load the corresponding transliteration module if
      70                 :            :         needed for the mode set with nType in the ctor */
      71                 :            :     void loadModuleIfNeeded( sal_uInt16 nLang );
      72                 :            : 
      73                 :            :     /** Load the transliteration module specified by rModuleName, which has to
      74                 :            :         be the UNO service implementation name that is expanded to the full UNO
      75                 :            :         service implementation name, for example, "NumToCharKanjiShort_ja_JP"
      76                 :            :         expands to
      77                 :            :         "com.sun.star.i18n.Transliteration.NumToCharKanjiShort_ja_JP".
      78                 :            :         @ATTENTION!
      79                 :            :         This method ignores the mode type set with the constructor and
      80                 :            :         interferes with the loadModuleIfNeeded() method and the transliterate()
      81                 :            :         method that gets a LanguageType passed as parameter.  Using one of
      82                 :            :         those may load a different module and overwrite this setting. Only the
      83                 :            :         transliterate() method that takes no LanguageType parameter may be used
      84                 :            :         for a specific module loaded with this method.  */
      85                 :            :     void loadModuleByImplName( const String& rModuleName, sal_uInt16 nLang );
      86                 :            : 
      87                 :            :     /** This transliteration method corresponds with the loadModuleByImplName()
      88                 :            :         method. It relies on a module being loaded and does not try load one.
      89                 :            :         If for any reason the string can't be transliterated the original
      90                 :            :         string is returned.  */
      91                 :            :     String transliterate( const String& rStr,
      92                 :            :                         xub_StrLen nStart, xub_StrLen nLen,
      93                 :            :                         ::com::sun::star::uno::Sequence <sal_Int32>* pOffset ) const;
      94                 :            : 
      95                 :            :     // Wrapper implementations of class Transliteration
      96                 :            :     String transliterate( const String& rStr, sal_uInt16 nLanguage,
      97                 :            :                         xub_StrLen nStart, xub_StrLen nLen,
      98                 :            :                         ::com::sun::star::uno::Sequence <sal_Int32>* pOffset );
      99                 :            : 
     100                 :            :     /** If two strings are equal per this transliteration.
     101                 :            :         Returns the number of matched code points in any case, even if strings
     102                 :            :         are not equal, for example:
     103                 :            :         equals( "a", 0, 1, nMatch1, "aaa", 0, 3, nMatch2 )
     104                 :            :         returns false and nMatch:=1 and nMatch2:=1
     105                 :            :         equals( "aab", 0, 3, nMatch1, "aaa", 0, 3, nMatch2 )
     106                 :            :         returns false and nMatch:=2 and nMatch2:=2
     107                 :            :      */
     108                 :            :     sal_Bool equals(
     109                 :            :         const String& rStr1, sal_Int32 nPos1, sal_Int32 nCount1, sal_Int32& nMatch1,
     110                 :            :         const String& rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) const;
     111                 :            : 
     112                 :            :     sal_Int32 compareString( const String& rStr1, const String& rStr2 ) const;
     113                 :            : 
     114                 :            : 
     115                 :            :     // helpers
     116                 :            : 
     117                 :            :     /** If two strings are really equal as per this translation, and not just
     118                 :            :         one string is matching the start of the other. Use this method instead
     119                 :            :         of compareString()==0 because it is much faster.
     120                 :            :      */
     121                 :            :     sal_Bool isEqual( const String& rStr1, const String& rStr2 ) const;
     122                 :            : 
     123                 :            :     /** If string rStr1 matches the start of string rStr2, i.e. "a" in "aaa"
     124                 :            :      */
     125                 :            :     sal_Bool isMatch( const String& rStr1, const String& rStr2 ) const;
     126                 :            : 
     127                 :            : };
     128                 :            : 
     129                 :            : // ............................................................................
     130                 :            : }       // namespace utl
     131                 :            : // ............................................................................
     132                 :            : 
     133                 :            : #endif
     134                 :            : 
     135                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10