LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/linguistic/source - spelldsp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 10 100.0 %
Date: 2013-07-09 Functions: 3 3 100.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             : 
      20             : #ifndef _LINGUISTIC_SPELLDSP_HXX_
      21             : #define _LINGUISTIC_SPELLDSP_HXX_
      22             : 
      23             : #include "lngopt.hxx"
      24             : #include "linguistic/misc.hxx"
      25             : #include "iprcache.hxx"
      26             : 
      27             : #include <uno/lbnames.h>            // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
      28             : #include <cppuhelper/implbase1.hxx>
      29             : #include <cppuhelper/implbase2.hxx>
      30             : #include <cppuhelper/implbase7.hxx>
      31             : #include <com/sun/star/lang/XComponent.hpp>
      32             : #include <com/sun/star/lang/XInitialization.hpp>
      33             : #include <com/sun/star/lang/XServiceDisplayName.hpp>
      34             : #include <com/sun/star/beans/XPropertySet.hpp>
      35             : #include <com/sun/star/beans/PropertyValues.hpp>
      36             : #include <com/sun/star/lang/XServiceInfo.hpp>
      37             : #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
      38             : #include <com/sun/star/linguistic2/XSpellChecker.hpp>
      39             : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
      40             : #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
      41             : 
      42             : #include <boost/shared_ptr.hpp>
      43             : #include <map>
      44             : #include <unotools/charclass.hxx>
      45             : 
      46             : class LngSvcMgr;
      47             : 
      48             : 
      49             : class SpellCheckerDispatcher :
      50             :     public cppu::WeakImplHelper2
      51             :     <
      52             :         ::com::sun::star::linguistic2::XSpellChecker1,
      53             :         ::com::sun::star::linguistic2::XSpellChecker
      54             :     >,
      55             :     public LinguDispatcher
      56             : {
      57             :     typedef boost::shared_ptr< LangSvcEntries_Spell >               LangSvcEntries_Spell_Ptr_t;
      58             :     typedef std::map< LanguageType, LangSvcEntries_Spell_Ptr_t >    SpellSvcByLangMap_t;
      59             :     SpellSvcByLangMap_t     aSvcMap;
      60             :     LinguOptions            aOpt;
      61             : 
      62             :     ::com::sun::star::uno::Reference<
      63             :         ::com::sun::star::linguistic2::XLinguProperties >           xPropSet;
      64             :     ::com::sun::star::uno::Reference<
      65             :         ::com::sun::star::linguistic2::XSearchableDictionaryList >  xDicList;
      66             : 
      67             :     LngSvcMgr                   &rMgr;
      68             :     mutable linguistic::SpellCache      *pCache; // Spell Cache (holds known words)
      69             :     CharClass                   * pCharClass;
      70             : 
      71             :     // disallow copy-constructor and assignment-operator for now
      72             :     SpellCheckerDispatcher(const SpellCheckerDispatcher &);
      73             :     SpellCheckerDispatcher & operator = (const SpellCheckerDispatcher &);
      74             : 
      75             :     inline linguistic::SpellCache &  GetCache() const;
      76             : 
      77             :     inline ::com::sun::star::uno::Reference<
      78             :         ::com::sun::star::linguistic2::XLinguProperties >
      79             :             GetPropSet();
      80             :     inline ::com::sun::star::uno::Reference<
      81             :         ::com::sun::star::linguistic2::XSearchableDictionaryList >
      82             :             GetDicList();
      83             : 
      84             :     void    ClearSvcList();
      85             : 
      86             :     sal_Bool    isValid_Impl(const OUString& aWord, LanguageType nLanguage,
      87             :                     const ::com::sun::star::beans::PropertyValues& aProperties,
      88             :                     sal_Bool bCheckDics)
      89             :                 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
      90             : 
      91             :     ::com::sun::star::uno::Reference<
      92             :         ::com::sun::star::linguistic2::XSpellAlternatives >
      93             :             spell_Impl(const OUString& aWord, LanguageType nLanguage,
      94             :                     const ::com::sun::star::beans::PropertyValues& aProperties,
      95             :                     sal_Bool bCheckDics)
      96             :                 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
      97             : 
      98             : public:
      99             :     SpellCheckerDispatcher( LngSvcMgr &rLngSvcMgr );
     100             :     virtual ~SpellCheckerDispatcher();
     101             : 
     102             :     // XSupportedLocales (for XSpellChecker)
     103             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales() throw(::com::sun::star::uno::RuntimeException);
     104             :     virtual sal_Bool SAL_CALL hasLocale( const ::com::sun::star::lang::Locale& aLocale ) throw(::com::sun::star::uno::RuntimeException);
     105             : 
     106             :     // XSpellChecker
     107             :     virtual sal_Bool SAL_CALL isValid( const OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     108             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL spell( const OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     109             : 
     110             :     // XSupportedLanguages
     111             :     virtual ::com::sun::star::uno::Sequence< ::sal_Int16 > SAL_CALL getLanguages(  ) throw (::com::sun::star::uno::RuntimeException);
     112             :     virtual ::sal_Bool SAL_CALL hasLanguage( ::sal_Int16 nLanguage ) throw (::com::sun::star::uno::RuntimeException);
     113             : 
     114             :     // XSpellChecker1
     115             :     virtual ::sal_Bool SAL_CALL isValid( const OUString& aWord, ::sal_Int16 nLanguage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     116             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL spell( const OUString& aWord, ::sal_Int16 nLanguage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     117             : 
     118             :     // LinguDispatcher
     119             :     virtual void SetServiceList( const ::com::sun::star::lang::Locale &rLocale, const ::com::sun::star::uno::Sequence< OUString > &rSvcImplNames );
     120             :     virtual ::com::sun::star::uno::Sequence< OUString > GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const;
     121             :     virtual DspType GetDspType() const;
     122             : 
     123             :     void    FlushSpellCache();
     124             : 
     125             : private:
     126             :     void setCharClass(const LanguageTag& rLanguageTag);
     127             :     OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
     128             : 
     129             : };
     130             : 
     131       16939 : inline linguistic::SpellCache & SpellCheckerDispatcher::GetCache() const
     132             : {
     133       16939 :     if (!pCache)
     134          19 :         pCache = new linguistic::SpellCache();
     135       16939 :     return *pCache;
     136             : }
     137             : 
     138             : 
     139             : inline ::com::sun::star::uno::Reference<
     140             :     ::com::sun::star::linguistic2::XLinguProperties >
     141       22961 :         SpellCheckerDispatcher::GetPropSet()
     142             : {
     143       22961 :     return xPropSet.is() ?
     144       22961 :         xPropSet : xPropSet = linguistic::GetLinguProperties();
     145             : }
     146             : 
     147             : 
     148             : inline ::com::sun::star::uno::Reference<
     149             :     ::com::sun::star::linguistic2::XSearchableDictionaryList >
     150       11471 :         SpellCheckerDispatcher::GetDicList()
     151             : {
     152       11471 :     return xDicList.is() ?
     153       11471 :         xDicList : xDicList = linguistic::GetDictionaryList();
     154             : }
     155             : 
     156             : 
     157             : #endif
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10