LCOV - code coverage report
Current view: top level - include/linguistic - lngprophelp.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 8 9 88.9 %
Date: 2014-04-11 Functions: 8 9 88.9 %
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             : 
      79             :     // disallow use of copy-constructor and assignment-operator
      80             :     PropertyChgHelper( const PropertyChgHelper & );
      81             :     PropertyChgHelper & operator = ( const PropertyChgHelper & );
      82             : 
      83             : protected:
      84             :     virtual void    SetDefaultValues();
      85             :     virtual void    GetCurrentValues();
      86             : 
      87             :     ::com::sun::star::uno::Sequence< OUString > &
      88         168 :             GetPropNames()  { return aPropNames; }
      89             :     ::com::sun::star::uno::Reference<
      90             :         ::com::sun::star::beans::XPropertySet > &
      91         168 :             GetPropSet()    { return xPropSet; }
      92             : 
      93             :     void    AddPropNames( const char *pNewNames[], sal_Int32 nCount );
      94             : 
      95             :     virtual bool    propertyChange_Impl(
      96             :                             const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
      97             : 
      98             : public:
      99             :     PropertyChgHelper(
     100             :             const ::com::sun::star::uno::Reference<
     101             :                 ::com::sun::star::uno::XInterface > &rxSource,
     102             :             ::com::sun::star::uno::Reference<
     103             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet,
     104             :             int nAllowedEvents );
     105             :     virtual ~PropertyChgHelper();
     106             : 
     107             :     virtual void    SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
     108             : 
     109             :     // XEventListener
     110             :     virtual void SAL_CALL
     111             :         disposing( const ::com::sun::star::lang::EventObject& rSource )
     112             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             : 
     114             :     // XPropertyChangeListener
     115             :     virtual void SAL_CALL
     116             :         propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
     117             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     118             : 
     119             :     // XLinguServiceEventBroadcaster
     120             :     virtual sal_Bool SAL_CALL
     121             :         addLinguServiceEventListener(
     122             :                 const ::com::sun::star::uno::Reference<
     123             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     124             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     125             :     virtual sal_Bool SAL_CALL
     126             :         removeLinguServiceEventListener(
     127             :                 const ::com::sun::star::uno::Reference<
     128             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     129             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             : 
     131             :     // non-UNO functions
     132             :     void    LNG_DLLPUBLIC AddAsPropListener();
     133             :     void    LNG_DLLPUBLIC RemoveAsPropListener();
     134             :     void    LaunchEvent(
     135             :                 const ::com::sun::star::linguistic2::LinguServiceEvent& rEvt );
     136             : 
     137             :     const ::com::sun::star::uno::Sequence< OUString > &
     138             :             GetPropNames() const    { return aPropNames; }
     139             :     const ::com::sun::star::uno::Reference<
     140             :         ::com::sun::star::beans::XPropertySet > &
     141             :             GetPropSet() const      { return xPropSet; }
     142             :     const ::com::sun::star::uno::Reference<
     143             :         ::com::sun::star::uno::XInterface > &
     144           0 :             GetEvtObj() const       { return xMyEvtObj; }
     145             : 
     146             :     bool    IsIgnoreControlCharacters() const   { return bResIsIgnoreControlCharacters; }
     147             :     bool    IsUseDictionaryList() const         { return bResIsUseDictionaryList; }
     148             : };
     149             : 
     150             : 
     151             : class PropertyHelper_Thes :
     152             :     public PropertyChgHelper
     153             : {
     154             :     // disallow use of copy-constructor and assignment-operator
     155             :     PropertyHelper_Thes( const PropertyHelper_Thes & );
     156             :     PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & );
     157             : 
     158             : public:
     159             :     PropertyHelper_Thes(
     160             :             const ::com::sun::star::uno::Reference<
     161             :                 ::com::sun::star::uno::XInterface > &rxSource,
     162             :             ::com::sun::star::uno::Reference<
     163             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
     164             :     virtual ~PropertyHelper_Thes();
     165             : 
     166             :     // XPropertyChangeListener
     167             :     virtual void SAL_CALL
     168             :         propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
     169             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     170             : };
     171             : 
     172             : class LNG_DLLPUBLIC PropertyHelper_Thesaurus
     173             : {
     174             :     PropertyHelper_Thes* pInst;
     175             :     com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >    xPropHelper;
     176             : 
     177             :     // disallow use of copy-constructor and assignment-operator
     178             :     PropertyHelper_Thesaurus( const PropertyHelper_Thes & );
     179             :     PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & );
     180             : 
     181             : public:
     182             :     PropertyHelper_Thesaurus(
     183             :             const ::com::sun::star::uno::Reference<
     184             :                 ::com::sun::star::uno::XInterface > &rxSource,
     185             :             ::com::sun::star::uno::Reference<
     186             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
     187             :     ~PropertyHelper_Thesaurus();
     188             :     void    AddAsPropListener();
     189             :     void    RemoveAsPropListener();
     190             :     void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
     191             : };
     192             : 
     193             : 
     194             : class LNG_DLLPUBLIC PropertyHelper_Spell :
     195             :     public PropertyChgHelper
     196             : {
     197             :     // default values
     198             :     bool        bIsSpellUpperCase;
     199             :     bool        bIsSpellWithDigits;
     200             :     bool        bIsSpellCapitalization;
     201             : 
     202             :     // return values, will be set to default value or current temporary value
     203             :     sal_Int16   nResMaxNumberOfSuggestions; // special value that is not part of the property set and thus needs to be handled differently
     204             :     bool        bResIsSpellUpperCase;
     205             :     bool        bResIsSpellWithDigits;
     206             :     bool        bResIsSpellCapitalization;
     207             : 
     208             : 
     209             :     // disallow use of copy-constructor and assignment-operator
     210             :     PropertyHelper_Spell( const PropertyHelper_Spell & );
     211             :     PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & );
     212             : 
     213             : protected:
     214             :     // PropertyChgHelper
     215             :     virtual void    SetDefaultValues() SAL_OVERRIDE;
     216             :     virtual void    GetCurrentValues() SAL_OVERRIDE;
     217             :     virtual bool    propertyChange_Impl(
     218             :                             const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) SAL_OVERRIDE;
     219             : 
     220             : public:
     221             :     PropertyHelper_Spell(
     222             :             const ::com::sun::star::uno::Reference<
     223             :                 ::com::sun::star::uno::XInterface > &rxSource,
     224             :             ::com::sun::star::uno::Reference<
     225             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
     226             :     virtual ~PropertyHelper_Spell();
     227             : 
     228             :     virtual void    SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ) SAL_OVERRIDE;
     229             : 
     230             :     // XPropertyChangeListener
     231             :     virtual void SAL_CALL
     232             :         propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
     233             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     234             : 
     235             :     virtual sal_Int16   GetDefaultNumberOfSuggestions() const;
     236             : 
     237             :     sal_Int16   GetMaxNumberOfSuggestions() const   { return nResMaxNumberOfSuggestions; }
     238        5563 :     bool        IsSpellUpperCase() const            { return bResIsSpellUpperCase; }
     239        5489 :     bool        IsSpellWithDigits() const           { return bResIsSpellWithDigits; }
     240        1123 :     bool        IsSpellCapitalization() const       { return bResIsSpellCapitalization; }
     241             : };
     242             : 
     243             : 
     244             : class LNG_DLLPUBLIC PropertyHelper_Spelling
     245             : {
     246             :     PropertyHelper_Spell* pInst;
     247             :     com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >    xPropHelper;
     248             : 
     249             :     // disallow use of copy-constructor and assignment-operator
     250             :     PropertyHelper_Spelling( const PropertyHelper_Spell & );
     251             :     PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & );
     252             : 
     253             : public:
     254             :     PropertyHelper_Spelling(
     255             :             const ::com::sun::star::uno::Reference<
     256             :                 ::com::sun::star::uno::XInterface > &rxSource,
     257             :             ::com::sun::star::uno::Reference<
     258             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
     259             :     ~PropertyHelper_Spelling();
     260             : 
     261             :     void    AddAsPropListener();
     262             :     void    RemoveAsPropListener();
     263             :     void    SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
     264             :     bool    IsSpellUpperCase() const;
     265             :     bool    IsSpellWithDigits() const;
     266             :     bool    IsSpellCapitalization() const;
     267             :     bool addLinguServiceEventListener(
     268             :                 const ::com::sun::star::uno::Reference<
     269             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     270             :             throw(::com::sun::star::uno::RuntimeException);
     271             :     bool removeLinguServiceEventListener(
     272             :                 const ::com::sun::star::uno::Reference<
     273             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     274             :             throw(::com::sun::star::uno::RuntimeException);
     275             : };
     276             : 
     277             : 
     278             : class PropertyHelper_Hyphen :
     279             :     public PropertyChgHelper
     280             : {
     281             :     // default values
     282             :     sal_Int16   nHyphMinLeading,
     283             :             nHyphMinTrailing,
     284             :             nHyphMinWordLength;
     285             : 
     286             :     // return values, will be set to default value or current temporary value
     287             :     sal_Int16   nResHyphMinLeading,
     288             :             nResHyphMinTrailing,
     289             :             nResHyphMinWordLength;
     290             : 
     291             :     // disallow use of copy-constructor and assignment-operator
     292             :     PropertyHelper_Hyphen( const PropertyHelper_Hyphen & );
     293             :     PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & );
     294             : 
     295             : protected:
     296             :     // PropertyChgHelper
     297             :     virtual void    SetDefaultValues() SAL_OVERRIDE;
     298             :     virtual void    GetCurrentValues() SAL_OVERRIDE;
     299             :     virtual bool    propertyChange_Impl(
     300             :                             const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) SAL_OVERRIDE;
     301             : 
     302             : public:
     303             :     PropertyHelper_Hyphen(
     304             :             const ::com::sun::star::uno::Reference<
     305             :                 ::com::sun::star::uno::XInterface > &rxSource,
     306             :             ::com::sun::star::uno::Reference<
     307             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet);
     308             :     virtual ~PropertyHelper_Hyphen();
     309             : 
     310             :     virtual void    SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ) SAL_OVERRIDE;
     311             : 
     312             :     // XPropertyChangeListener
     313             :     virtual void SAL_CALL
     314             :         propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
     315             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     316             : 
     317       22974 :     sal_Int16   GetMinLeading() const               { return nResHyphMinLeading; }
     318       22974 :     sal_Int16   GetMinTrailing() const              { return nResHyphMinTrailing; }
     319       22974 :     sal_Int16   GetMinWordLength() const            { return nResHyphMinWordLength; }
     320             : };
     321             : 
     322             : class LNG_DLLPUBLIC PropertyHelper_Hyphenation
     323             : {
     324             :     PropertyHelper_Hyphen* pInst;
     325             :     com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >    xPropHelper;
     326             : 
     327             :     // disallow use of copy-constructor and assignment-operator
     328             :     PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & );
     329             :     PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & );
     330             : 
     331             : public:
     332             :     PropertyHelper_Hyphenation(
     333             :             const ::com::sun::star::uno::Reference<
     334             :                 ::com::sun::star::uno::XInterface > &rxSource,
     335             :             ::com::sun::star::uno::Reference<
     336             :                 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet);
     337             :     ~PropertyHelper_Hyphenation();
     338             : 
     339             :     void    AddAsPropListener();
     340             :     void    RemoveAsPropListener();
     341             :     void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
     342             :     sal_Int16   GetMinLeading() const;
     343             :     sal_Int16   GetMinTrailing() const;
     344             :     sal_Int16   GetMinWordLength() const;
     345             :     sal_Bool addLinguServiceEventListener(
     346             :                 const ::com::sun::star::uno::Reference<
     347             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     348             :             throw(::com::sun::star::uno::RuntimeException);
     349             :     sal_Bool removeLinguServiceEventListener(
     350             :                 const ::com::sun::star::uno::Reference<
     351             :                     ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
     352             :             throw(::com::sun::star::uno::RuntimeException);
     353             : };
     354             : 
     355             : }   // namespace linguistic
     356             : 
     357             : #endif
     358             : 
     359             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10