LCOV - code coverage report
Current view: top level - linguistic/source - convdic.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 6 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 3 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             : #ifndef INCLUDED_LINGUISTIC_SOURCE_CONVDIC_HXX
      20             : #define INCLUDED_LINGUISTIC_SOURCE_CONVDIC_HXX
      21             : 
      22             : #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
      23             : #include <com/sun/star/linguistic2/XConversionPropertyType.hpp>
      24             : #include <com/sun/star/util/XFlushable.hpp>
      25             : #include <com/sun/star/lang/XServiceInfo.hpp>
      26             : #include <cppuhelper/implbase4.hxx>
      27             : #include <cppuhelper/interfacecontainer.h>
      28             : 
      29             : #include <memory>
      30             : #include <set>
      31             : #include <unordered_map>
      32             : #include "linguistic/misc.hxx"
      33             : #include "defs.hxx"
      34             : 
      35             : // text conversion dictionary extension
      36             : #define CONV_DIC_EXT            "tcd"
      37             : #define CONV_DIC_DOT_EXT        ".tcd"
      38             : 
      39             : #define SN_CONV_DICTIONARY      "com.sun.star.linguistic2.ConversionDictionary"
      40             : 
      41             : 
      42             : bool    IsConvDic( const OUString &rFileURL, sal_Int16 &nLang, sal_Int16 &nConvType );
      43             : 
      44             : struct StrLT
      45             : {
      46           0 :     bool operator()( const OUString &rTxt1, const OUString &rTxt2 ) const
      47             :     {
      48           0 :         return rTxt1 < rTxt2;
      49             :     }
      50             : };
      51             : 
      52             : struct StrEQ
      53             : {
      54           0 :     bool operator()( const OUString &rTxt1, const OUString &rTxt2 ) const
      55             :     {
      56           0 :         return rTxt1 == rTxt2;
      57             :     }
      58             : };
      59             : 
      60             : typedef std::unordered_multimap< OUString, OUString,
      61             :                        const OUStringHash, StrEQ > ConvMap;
      62             : 
      63             : typedef std::set< OUString, StrLT > ConvMapKeySet;
      64             : 
      65             : typedef std::unordered_multimap< OUString, sal_Int16,
      66             :                        OUStringHash, StrEQ > PropTypeMap;
      67             : 
      68             : 
      69             : class ConvDic :
      70             :     public ::cppu::WeakImplHelper4
      71             :     <
      72             :         ::com::sun::star::linguistic2::XConversionDictionary,
      73             :         ::com::sun::star::linguistic2::XConversionPropertyType,
      74             :         ::com::sun::star::util::XFlushable,
      75             :         ::com::sun::star::lang::XServiceInfo
      76             :     >
      77             : {
      78             :     friend class ConvDicXMLExport;
      79             : 
      80             : protected:
      81             : 
      82             :     ::cppu::OInterfaceContainerHelper       aFlushListeners;
      83             : 
      84             :     ConvMap                         aFromLeft;
      85             :     std::unique_ptr< ConvMap >        pFromRight;     // only available for bidirectional conversion dictionaries
      86             : 
      87             :     std::unique_ptr< PropTypeMap >    pConvPropType;
      88             : 
      89             :     OUString        aMainURL;   // URL to file
      90             :     OUString        aName;
      91             :     sal_Int16       nLanguage;
      92             :     sal_Int16       nConversionType;
      93             :     sal_Int16       nMaxLeftCharCount;
      94             :     sal_Int16       nMaxRightCharCount;
      95             :     bool            bMaxCharCountIsValid;
      96             :     bool            bNeedEntries;
      97             :     bool            bIsModified;
      98             :     bool            bIsActive;
      99             :     bool            bIsReadonly;
     100             : 
     101             :     // disallow copy-constructor and assignment-operator for now
     102             :     ConvDic(const ConvDic &);
     103             :     ConvDic & operator = (const ConvDic &);
     104             : 
     105             :     static ConvMap::iterator GetEntry( ConvMap &rMap, const OUString &rFirstText, const OUString &rSecondText );
     106             :     void    Load();
     107             :     void    Save();
     108             : 
     109             : public:
     110             :     ConvDic( const OUString &rName,
     111             :              sal_Int16 nLanguage,
     112             :              sal_Int16 nConversionType,
     113             :              bool bBiDirectional,
     114             :              const OUString &rMainURL);
     115             :     virtual ~ConvDic();
     116             : 
     117             :     // XConversionDictionary
     118             :     virtual OUString SAL_CALL getName(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :     virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     120             :     virtual sal_Int16 SAL_CALL getConversionType(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             :     virtual void SAL_CALL setActive( sal_Bool bActivate ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     122             :     virtual sal_Bool SAL_CALL isActive(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             :     virtual void SAL_CALL clear(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     124             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, ::com::sun::star::linguistic2::ConversionDirection eDirection, sal_Int32 nTextConversionOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     125             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getConversionEntries( ::com::sun::star::linguistic2::ConversionDirection eDirection ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     126             :     virtual void SAL_CALL addEntry( const OUString& aLeftText, const OUString& aRightText ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             :     virtual void SAL_CALL removeEntry( const OUString& aLeftText, const OUString& aRightText ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     128             :     virtual sal_Int16 SAL_CALL getMaxCharCount( ::com::sun::star::linguistic2::ConversionDirection eDirection ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     129             : 
     130             :     // XConversionPropertyType
     131             :     virtual void SAL_CALL setPropertyType( const OUString& aLeftText, const OUString& aRightText, ::sal_Int16 nPropertyType ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     132             :     virtual ::sal_Int16 SAL_CALL getPropertyType( const OUString& aLeftText, const OUString& aRightText ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             : 
     134             :     // XFlushable
     135             :     virtual void SAL_CALL flush(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     136             :     virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     137             :     virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             : 
     139             :     // XServiceInfo
     140             :     virtual OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     142             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     143             : 
     144             : 
     145             :     static inline OUString
     146             :         getImplementationName_Static() throw();
     147             :     static com::sun::star::uno::Sequence< OUString >
     148             :         getSupportedServiceNames_Static() throw();
     149             : 
     150             :     bool    HasEntry( const OUString &rLeftText, const OUString &rRightText );
     151             :     void    AddEntry( const OUString &rLeftText, const OUString &rRightText );
     152             :     void    RemoveEntry( const OUString &rLeftText, const OUString &rRightText );
     153             : };
     154             : 
     155           0 : inline OUString ConvDic::getImplementationName_Static() throw()
     156             : {
     157           0 :     return OUString( "com.sun.star.lingu2.ConvDic" );
     158             : }
     159             : 
     160             : 
     161             : #endif
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11