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

Generated by: LCOV version 1.10