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

Generated by: LCOV version 1.10