xref: /aoo4110/main/linguistic/source/lngopt.hxx (revision b1cdbd2c)
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 _LINGUISTIC_LNGOPT_HHX_
25 #define _LINGUISTIC_LNGOPT_HHX_
26 
27 #include <functional>
28 
29 #include <uno/lbnames.h>			// CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
30 #include <cppuhelper/implbase5.hxx>	// helper for implementations
31 #include <cppuhelper/interfacecontainer.hxx>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/beans/XFastPropertySet.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/beans/XPropertyAccess.hpp>
36 #include <com/sun/star/lang/XComponent.hpp>
37 #include <unotools/lingucfg.hxx>
38 #include <svl/itemprop.hxx>
39 #include <unotools/configitem.hxx>
40 #include <com/sun/star/uno/Any.h>
41 #include <tools/solar.h>
42 
43 #include <svl/itemprop.hxx>
44 #include "linguistic/misc.hxx"
45 #include "defs.hxx"
46 #include <vos/refernce.hxx>
47 
48 namespace com { namespace sun { namespace star {
49 	namespace beans {
50 		struct PropertyChangeEvent;
51 	}
52 	namespace registry {
53 		class XRegistryKey;
54 	}
55 }}}
56 
57 
58 
59 ///////////////////////////////////////////////////////////////////////////
60 // LinguOptions
61 // This class represents all Linguistik relevant options.
62 //
63 
64 class LinguOptions
65 {
66 	static SvtLinguOptions	   *pData;
67 	static vos::ORefCount		aRefCount;	// number of objects of this class
68 
69 	//! uses default assignment-operator
70 
71 	sal_Bool SetLocale_Impl( sal_Int16 &rLanguage,
72 			::com::sun::star::uno::Any &rOld,
73 			const ::com::sun::star::uno::Any &rVal, sal_Int16 nType );
74 
75 public:
76 	LinguOptions();
77 	LinguOptions(const LinguOptions &rOpt);
78 	~LinguOptions();
79 
80 	sal_Bool			SetValue( ::com::sun::star::uno::Any &rOld,
81 							const ::com::sun::star::uno::Any &rVal, sal_Int32 nWID );
82 	void			GetValue( ::com::sun::star::uno::Any &rVal, sal_Int32 nWID ) const;
83 
84     static ::rtl::OUString    GetName( sal_Int32 nWID );
85 
86 	const ::com::sun::star::uno::Sequence< rtl::OUString >
GetActiveDics() const87 			GetActiveDics() const	{ return pData->aActiveDics; }
88 
89     const ::com::sun::star::uno::Sequence< rtl::OUString >
GetActiveConvDics() const90             GetActiveConvDics() const   { return pData->aActiveConvDics; }
91 };
92 
93 
94 ///////////////////////////////////////////////////////////////////////////
95 
96 // uses templates from <cppuhelper/interfacecontainer.h>
97 
98 
99 // helper function call class
100 struct PropHashType_Impl
101 {
operator ()PropHashType_Impl102 	size_t operator()(const sal_Int32 &s) const	{ return s; }
103 };
104 
105 typedef cppu::OMultiTypeInterfaceContainerHelperVar
106 	<
107 		sal_Int32,
108 		PropHashType_Impl,
109 		std::equal_to< sal_Int32 >
110 	> OPropertyListenerContainerHelper;
111 
112 ///////////////////////////////////////////////////////////////////////////
113 
114 
115 class LinguProps :
116 	public cppu::WeakImplHelper5
117 	<
118 		com::sun::star::beans::XPropertySet,
119 		com::sun::star::beans::XFastPropertySet,
120 		com::sun::star::beans::XPropertyAccess,
121 		com::sun::star::lang::XComponent,
122 		com::sun::star::lang::XServiceInfo
123 	>
124 {
125 	::cppu::OInterfaceContainerHelper			aEvtListeners;
126 	OPropertyListenerContainerHelper			aPropListeners;
127 
128     SfxItemPropertyMap                          aPropertyMap;
129     SvtLinguConfig                              aConfig;
130 
131 	sal_Bool										bDisposing;
132 
133 	// disallow copy-constructor and assignment-operator for now
134 	LinguProps(const LinguProps &);
135 	LinguProps & operator = (const LinguProps &);
136 
137 	void	launchEvent( const ::com::sun::star::beans::PropertyChangeEvent &rEvt ) const;
138 
139 public:
140     LinguProps();
141 
142     // XPropertySet
143     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
144     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
145     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
146     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
147     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
148     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
149     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
150 
151     // XFastPropertySet
152     virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
153     virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
154 
155     // XPropertyAccess
156     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues() throw(::com::sun::star::uno::RuntimeException);
157     virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
158 
159     // XComponent
160     virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
161     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException);
162     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException);
163 
164     // XServiceInfo
165     virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
166     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
167     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
168 
169 
170     static inline ::rtl::OUString getImplementationName_Static() throw();
171     static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
172 };
173 
getImplementationName_Static()174 inline ::rtl::OUString LinguProps::getImplementationName_Static() throw()
175 {
176 	return A2OU( "com.sun.star.lingu2.LinguProps" );
177 }
178 
179 ///////////////////////////////////////////////////////////////////////////
180 
181 #endif
182 
183