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

Generated by: LCOV version 1.10