xref: /trunk/main/linguistic/workben/sprophelp.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _LINGU2_PROPHELP_HXX_
25 #define _LINGU2_PROPHELP_HXX_
26 
27 #include <tools/solar.h>
28 
29 #include <uno/lbnames.h>            // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
30 #include <cppuhelper/implbase2.hxx> // helper for implementations
31 #include <cppuhelper/interfacecontainer.h>
32 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
33 #include <com/sun/star/beans/PropertyValues.hpp>
34 
35 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
36 
37 namespace com { namespace sun { namespace star { namespace beans {
38     class   XPropertySet;
39 }}}};
40 
41 namespace com { namespace sun { namespace star { namespace linguistic2 {
42     struct  LinguServiceEvent;
43 }}}};
44 
45 
46 using namespace ::rtl;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::beans;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::linguistic2;
51 
52 ///////////////////////////////////////////////////////////////////////////
53 // PropertyChgHelper
54 // virtual base class for all XPropertyChangeListener members of the
55 // various lingu services.
56 // Only propertyChange needs to be implemented.
57 
58 class PropertyChgHelper :
59     public cppu::WeakImplHelper2
60     <
61         XPropertyChangeListener,
62         XLinguServiceEventBroadcaster
63     >
64 {
65     Sequence< OUString >                aPropNames;
66     Reference< XInterface >             xMyEvtObj;
67     ::cppu::OInterfaceContainerHelper   aLngSvcEvtListeners;
68     Reference< XPropertySet >           xPropSet;
69 
70     // disallow use of copy-constructor and assignment-operator
71     PropertyChgHelper( const PropertyChgHelper & );
72     PropertyChgHelper & operator = ( const PropertyChgHelper & );
73 
74 public:
75     PropertyChgHelper(
76             const Reference< XInterface > &rxSource,
77             Reference< XPropertySet > &rxPropSet,
78             const char *pPropNames[], USHORT nPropCount );
79     virtual ~PropertyChgHelper();
80 
81     // XEventListener
82     virtual void SAL_CALL
83         disposing( const EventObject& rSource );
84 
85     // XPropertyChangeListener
86     virtual void SAL_CALL
87         propertyChange( const PropertyChangeEvent& rEvt ) = 0;
88 
89     // XLinguServiceEventBroadcaster
90     virtual sal_Bool SAL_CALL
91         addLinguServiceEventListener(
92                 const Reference< XLinguServiceEventListener >& rxListener );
93     virtual sal_Bool SAL_CALL
94         removeLinguServiceEventListener(
95                 const Reference< XLinguServiceEventListener >& rxListener );
96 
97     // non UNO functions
98     void    AddAsPropListener();
99     void    RemoveAsPropListener();
100     void    LaunchEvent( const LinguServiceEvent& rEvt );
101 
102     const Sequence< OUString > &
GetPropNames() const103             GetPropNames() const    { return aPropNames; }
104     const Reference< XPropertySet > &
GetPropSet() const105             GetPropSet() const      { return xPropSet; }
106     const Reference< XInterface > &
GetEvtObj() const107             GetEvtObj() const       { return xMyEvtObj; }
108 };
109 
110 
111 ///////////////////////////////////////////////////////////////////////////
112 
113 
114 class PropertyHelper_Spell :
115     public PropertyChgHelper
116 {
117     // default values
118     BOOL    bIsGermanPreReform;
119     BOOL    bIsIgnoreControlCharacters;
120     BOOL    bIsUseDictionaryList;
121     BOOL    bIsSpellUpperCase;
122     BOOL    bIsSpellWithDigits;
123     BOOL    bIsSpellCapitalization;
124 
125     // return values, will be set to default value or current temporary value
126     BOOL    bResIsGermanPreReform;
127     BOOL    bResIsIgnoreControlCharacters;
128     BOOL    bResIsUseDictionaryList;
129     BOOL    bResIsSpellUpperCase;
130     BOOL    bResIsSpellWithDigits;
131     BOOL    bResIsSpellCapitalization;
132 
133 
134     // disallow use of copy-constructor and assignment-operator
135     PropertyHelper_Spell( const PropertyHelper_Spell & );
136     PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & );
137 
138     void    SetDefault();
139 
140 public:
141     PropertyHelper_Spell(
142             const Reference< XInterface > &rxSource,
143             Reference< XPropertySet > &rxPropSet );
144     virtual ~PropertyHelper_Spell();
145 
146     // XPropertyChangeListener
147     virtual void SAL_CALL
148         propertyChange( const PropertyChangeEvent& rEvt );
149 
150     void    SetTmpPropVals( const PropertyValues &rPropVals );
151 
IsGermanPreReform() const152     BOOL    IsGermanPreReform() const           { return bResIsGermanPreReform; }
IsIgnoreControlCharacters() const153     BOOL    IsIgnoreControlCharacters() const   { return bResIsIgnoreControlCharacters; }
IsUseDictionaryList() const154     BOOL    IsUseDictionaryList() const         { return bResIsUseDictionaryList; }
IsSpellUpperCase() const155     BOOL    IsSpellUpperCase() const            { return bResIsSpellUpperCase; }
IsSpellWithDigits() const156     BOOL    IsSpellWithDigits() const           { return bResIsSpellWithDigits; }
IsSpellCapitalization() const157     BOOL    IsSpellCapitalization() const       { return bResIsSpellCapitalization; }
158 };
159 
160 ///////////////////////////////////////////////////////////////////////////
161 
162 #endif
163