LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/unotools - transliterationwrapper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1 0.0 %
Date: 2012-12-27 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10