LCOV - code coverage report
Current view: top level - include/linguistic - lngprophelp.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 10 90.0 %
Date: 2015-06-13 12:38:46 Functions: 9 10 90.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_LNGPROPHELP_HXX
      21             : #define INCLUDED_LINGUISTIC_LNGPROPHELP_HXX
      22             : 
      23             : #include <cppuhelper/implbase2.hxx>
      24             : #include <cppuhelper/interfacecontainer.h>
      25             : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
      26             : #include <com/sun/star/beans/PropertyValues.hpp>
      27             : #include <com/sun/star/linguistic2/XLinguProperties.hpp>
      28             : #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
      29             : #include <linguistic/lngdllapi.h>
      30             : 
      31             : namespace com { namespace sun { namespace star { namespace beans {
      32             :     class   XPropertySet;
      33             : }}}}
      34             : 
      35             : namespace com { namespace sun { namespace star { namespace linguistic2 {
      36             :     struct  LinguServiceEvent;
      37             : }}}}
      38             : 
      39             : 
      40             : namespace linguistic
      41             : {
      42             : 
      43             : // PropertyChgHelper
      44             : // Base class for all XPropertyChangeListener members of the
      45             : // various lingu services.
      46             : 
      47             : 
      48             : // Flags for type of events allowed to be launched
      49             : #define AE_SPELLCHECKER 1
      50             : #define AE_HYPHENATOR   2
      51             : 
      52             : typedef cppu::WeakImplHelper2
      53             : <
      54             :     ::com::sun::star::beans::XPropertyChangeListener,
      55             :     ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster
      56             : > PropertyChgHelperBase;
      57             : 
      58             : class PropertyChgHelper :
      59             :     public PropertyChgHelperBase
      60             : {
      61             :     ::com::sun::star::uno::Sequence< OUString >  aPropNames;
      62             :     ::com::sun::star::uno::Reference<
      63             :         ::com::sun::star::uno::XInterface >             xMyEvtObj;
      64             :     ::cppu::OInterfaceContainerHelper                   aLngSvcEvtListeners;
      65             :     ::com::sun::star::uno::Reference<
      66             :         ::com::sun::star::beans::XPropertySet >         xPropSet;
      67             : 
      68             :     int     nEvtFlags;  // flags for event types allowed to be launched
      69             : 
      70             :     // default values
      71             :     bool    bIsIgnoreControlCharacters;
      72             :     bool    bIsUseDictionaryList;
      73             : 
      74             :     // return values, will be set to default value or current temporary value
      75             :     bool    bResIsIgnoreControlCharacters;
      76             :     bool    bResIsUseDictionaryList;
      77             : 
      78             :     PropertyChgHelper( const PropertyChgHelper & ) SAL_DELETED_FUNCTION;
      79             :     PropertyChgHelper & operator = ( const PropertyChgHelper & ) SAL_DELETED_FUNCTION;
      80             : 
      81             : protected:
      82             :     virtual void    SetDefaultValues();
      83             :     virtual void    GetCurrentValues();
      84             : 
      85             :     ::com::sun::star::uno::Sequence< OUString > &
      86         224 :             GetPropNames()  { return aPropNames; }
      87             :     ::com::sun::star::uno::Reference<
      88             :         ::com::sun::star::beans::XPropertySet > &
      89         224 :             GetPropSet()    { return xPropSet; }
      90             : 
      91             :     void    AddPropNames( const char *pNewNames[], sal_Int32 nCount );
      92             : 
      93             :     virtual bool    propertyChange_Impl(
      94             :                             const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
      95             : 
      96             : public:
      97             :     PropertyChgHelper(
      98             :             const ::com::sun::star::uno::Reference<
      99             :                 ::com::sun::star::uno::XInterface > &rxSource,
     100             :             ::com::sun::star::uno::Reference<
     101             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet,
     102             :             int nAllowedEvents );
     103             :     virtual ~PropertyChgHelper();
     104             : 
     105             :     virtual void    SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
     106             : 
     107             :     // XEventListener
     108             :     virtual void SAL_CALL
     109             :         disposing( const ::com::sun::star::lang::EventObject& rSource )
     110             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     111             : 
     112             :     // XPropertyChangeListener
     113             :     virtual void SAL_CALL
     114             :         propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
     115             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     116             : 
     117             :     // XLinguServiceEventBroadcaster
     118             :     virtual sal_Bool SAL_CALL
     119             :         addLinguServiceEventListener(
     120             :                 const ::com::sun::star::uno::Reference<
     121             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     122             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             :     virtual sal_Bool SAL_CALL
     124             :         removeLinguServiceEventListener(
     125             :                 const ::com::sun::star::uno::Reference<
     126             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     127             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     128             : 
     129             :     // non-UNO functions
     130             :     void    LNG_DLLPUBLIC AddAsPropListener();
     131             :     void    LNG_DLLPUBLIC RemoveAsPropListener();
     132             :     void    LaunchEvent(
     133             :                 const ::com::sun::star::linguistic2::LinguServiceEvent& rEvt );
     134             : 
     135             :     const ::com::sun::star::uno::Sequence< OUString > &
     136             :             GetPropNames() const    { return aPropNames; }
     137             :     const ::com::sun::star::uno::Reference<
     138             :         ::com::sun::star::beans::XPropertySet > &
     139             :             GetPropSet() const      { return xPropSet; }
     140             :     const ::com::sun::star::uno::Reference<
     141             :         ::com::sun::star::uno::XInterface > &
     142           0 :             GetEvtObj() const       { return xMyEvtObj; }
     143             : 
     144             :     bool    IsIgnoreControlCharacters() const   { return bResIsIgnoreControlCharacters; }
     145             :     bool    IsUseDictionaryList() const         { return bResIsUseDictionaryList; }
     146             : };
     147             : 
     148             : 
     149             : class PropertyHelper_Thes :
     150             :     public PropertyChgHelper
     151             : {
     152             :     PropertyHelper_Thes( const PropertyHelper_Thes & ) SAL_DELETED_FUNCTION;
     153             :     PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & ) SAL_DELETED_FUNCTION;
     154             : 
     155             : public:
     156             :     PropertyHelper_Thes(
     157             :             const ::com::sun::star::uno::Reference<
     158             :                 ::com::sun::star::uno::XInterface > &rxSource,
     159             :             ::com::sun::star::uno::Reference<
     160             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
     161             :     virtual ~PropertyHelper_Thes();
     162             : 
     163             :     // XPropertyChangeListener
     164             :     virtual void SAL_CALL
     165             :         propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
     166             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             : };
     168             : 
     169             : class LNG_DLLPUBLIC PropertyHelper_Thesaurus
     170             : {
     171             :     PropertyHelper_Thes* pInst;
     172             :     com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >    xPropHelper;
     173             : 
     174             :     // disallow use of copy-constructor and assignment-operator
     175             :     PropertyHelper_Thesaurus( const PropertyHelper_Thes & );
     176             :     PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & );
     177             : 
     178             : public:
     179             :     PropertyHelper_Thesaurus(
     180             :             const ::com::sun::star::uno::Reference<
     181             :                 ::com::sun::star::uno::XInterface > &rxSource,
     182             :             ::com::sun::star::uno::Reference<
     183             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
     184             :     ~PropertyHelper_Thesaurus();
     185             :     void    AddAsPropListener();
     186             :     void    RemoveAsPropListener();
     187             :     void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
     188             : };
     189             : 
     190             : 
     191             : class LNG_DLLPUBLIC PropertyHelper_Spell :
     192             :     public PropertyChgHelper
     193             : {
     194             :     // default values
     195             :     bool        bIsSpellUpperCase;
     196             :     bool        bIsSpellWithDigits;
     197             :     bool        bIsSpellCapitalization;
     198             : 
     199             :     // return values, will be set to default value or current temporary value
     200             :     sal_Int16   nResMaxNumberOfSuggestions; // special value that is not part of the property set and thus needs to be handled differently
     201             :     bool        bResIsSpellUpperCase;
     202             :     bool        bResIsSpellWithDigits;
     203             :     bool        bResIsSpellCapitalization;
     204             : 
     205             :     PropertyHelper_Spell( const PropertyHelper_Spell & ) SAL_DELETED_FUNCTION;
     206             :     PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ) SAL_DELETED_FUNCTION;
     207             : 
     208             : protected:
     209             :     // PropertyChgHelper
     210             :     virtual void    SetDefaultValues() SAL_OVERRIDE;
     211             :     virtual void    GetCurrentValues() SAL_OVERRIDE;
     212             :     virtual bool    propertyChange_Impl(
     213             :                             const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) SAL_OVERRIDE;
     214             : 
     215             : public:
     216             :     PropertyHelper_Spell(
     217             :             const ::com::sun::star::uno::Reference<
     218             :                 ::com::sun::star::uno::XInterface > &rxSource,
     219             :             ::com::sun::star::uno::Reference<
     220             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
     221             :     virtual ~PropertyHelper_Spell();
     222             : 
     223             :     virtual void    SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ) SAL_OVERRIDE;
     224             : 
     225             :     // XPropertyChangeListener
     226             :     virtual void SAL_CALL
     227             :         propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
     228             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     229             : 
     230    71072155 :     static sal_Int16 GetDefaultNumberOfSuggestions() { return 16; }
     231             : 
     232             :     sal_Int16   GetMaxNumberOfSuggestions() const   { return nResMaxNumberOfSuggestions; }
     233    71070576 :     bool        IsSpellUpperCase() const            { return bResIsSpellUpperCase; }
     234    71070576 :     bool        IsSpellWithDigits() const           { return bResIsSpellWithDigits; }
     235    71065185 :     bool        IsSpellCapitalization() const       { return bResIsSpellCapitalization; }
     236             : };
     237             : 
     238             : 
     239             : class LNG_DLLPUBLIC PropertyHelper_Spelling
     240             : {
     241             :     PropertyHelper_Spell* pInst;
     242             :     com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >    xPropHelper;
     243             : 
     244             :     // disallow use of copy-constructor and assignment-operator
     245             :     PropertyHelper_Spelling( const PropertyHelper_Spell & );
     246             :     PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & );
     247             : 
     248             : public:
     249             :     PropertyHelper_Spelling(
     250             :             const ::com::sun::star::uno::Reference<
     251             :                 ::com::sun::star::uno::XInterface > &rxSource,
     252             :             ::com::sun::star::uno::Reference<
     253             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
     254             :     ~PropertyHelper_Spelling();
     255             : 
     256             :     void    AddAsPropListener();
     257             :     void    RemoveAsPropListener();
     258             :     void    SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
     259             :     bool    IsSpellUpperCase() const;
     260             :     bool    IsSpellWithDigits() const;
     261             :     bool    IsSpellCapitalization() const;
     262             :     bool addLinguServiceEventListener(
     263             :                 const ::com::sun::star::uno::Reference<
     264             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     265             :             throw(::com::sun::star::uno::RuntimeException);
     266             :     bool removeLinguServiceEventListener(
     267             :                 const ::com::sun::star::uno::Reference<
     268             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     269             :             throw(::com::sun::star::uno::RuntimeException);
     270             : };
     271             : 
     272             : 
     273             : class PropertyHelper_Hyphen :
     274             :     public PropertyChgHelper
     275             : {
     276             :     // default values
     277             :     sal_Int16   nHyphMinLeading,
     278             :             nHyphMinTrailing,
     279             :             nHyphMinWordLength;
     280             : 
     281             :     // return values, will be set to default value or current temporary value
     282             :     sal_Int16   nResHyphMinLeading,
     283             :             nResHyphMinTrailing,
     284             :             nResHyphMinWordLength;
     285             : 
     286             :     PropertyHelper_Hyphen( const PropertyHelper_Hyphen & ) SAL_DELETED_FUNCTION;
     287             :     PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & ) SAL_DELETED_FUNCTION;
     288             : 
     289             : protected:
     290             :     // PropertyChgHelper
     291             :     virtual void    SetDefaultValues() SAL_OVERRIDE;
     292             :     virtual void    GetCurrentValues() SAL_OVERRIDE;
     293             :     virtual bool    propertyChange_Impl(
     294             :                             const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) SAL_OVERRIDE;
     295             : 
     296             : public:
     297             :     PropertyHelper_Hyphen(
     298             :             const ::com::sun::star::uno::Reference<
     299             :                 ::com::sun::star::uno::XInterface > &rxSource,
     300             :             ::com::sun::star::uno::Reference<
     301             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet);
     302             :     virtual ~PropertyHelper_Hyphen();
     303             : 
     304             :     virtual void    SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ) SAL_OVERRIDE;
     305             : 
     306             :     // XPropertyChangeListener
     307             :     virtual void SAL_CALL
     308             :         propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
     309             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     310             : 
     311        5235 :     sal_Int16   GetMinLeading() const               { return nResHyphMinLeading; }
     312        5235 :     sal_Int16   GetMinTrailing() const              { return nResHyphMinTrailing; }
     313        5235 :     sal_Int16   GetMinWordLength() const            { return nResHyphMinWordLength; }
     314             : };
     315             : 
     316             : class LNG_DLLPUBLIC PropertyHelper_Hyphenation
     317             : {
     318             :     PropertyHelper_Hyphen* pInst;
     319             :     com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >    xPropHelper;
     320             : 
     321             :     // disallow use of copy-constructor and assignment-operator
     322             :     PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & );
     323             :     PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & );
     324             : 
     325             : public:
     326             :     PropertyHelper_Hyphenation(
     327             :             const ::com::sun::star::uno::Reference<
     328             :                 ::com::sun::star::uno::XInterface > &rxSource,
     329             :             ::com::sun::star::uno::Reference<
     330             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet);
     331             :     ~PropertyHelper_Hyphenation();
     332             : 
     333             :     void    AddAsPropListener();
     334             :     void    RemoveAsPropListener();
     335             :     void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
     336             :     sal_Int16   GetMinLeading() const;
     337             :     sal_Int16   GetMinTrailing() const;
     338             :     sal_Int16   GetMinWordLength() const;
     339             :     bool addLinguServiceEventListener(
     340             :                 const ::com::sun::star::uno::Reference<
     341             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     342             :             throw(::com::sun::star::uno::RuntimeException);
     343             :     bool removeLinguServiceEventListener(
     344             :                 const ::com::sun::star::uno::Reference<
     345             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     346             :             throw(::com::sun::star::uno::RuntimeException);
     347             : };
     348             : 
     349             : }   // namespace linguistic
     350             : 
     351             : #endif
     352             : 
     353             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11