xref: /aoo4110/main/svl/source/numbers/numfmuno.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 _NUMFMUNO_HXX
25 #define _NUMFMUNO_HXX
26 
27 #include <com/sun/star/util/XNumberFormatter.hpp>
28 #include <com/sun/star/util/XNumberFormatPreviewer.hpp>
29 #include <com/sun/star/util/XNumberFormats.hpp>
30 #include <com/sun/star/util/XNumberFormatTypes.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/beans/XPropertyAccess.hpp>
33 #include <cppuhelper/implbase2.hxx>
34 #include <cppuhelper/implbase3.hxx>
35 #include <comphelper/sharedmutex.hxx>
36 #include <rtl/ref.hxx>
37 
38 class SvNumberformat;
39 class SvNumberFormatter;
40 class SvNumberFormatsSupplierObj;
41 
42 
43 //	SvNumberFormatterServiceObj wird global als Service angemeldet
44 
45 class SvNumberFormatterServiceObj : public cppu::WeakImplHelper3<
46 										com::sun::star::util::XNumberFormatter,
47 										com::sun::star::util::XNumberFormatPreviewer,
48 										com::sun::star::lang::XServiceInfo>
49 {
50 private:
51     ::rtl::Reference< SvNumberFormatsSupplierObj >  xSupplier;
52     mutable ::comphelper::SharedMutex               m_aMutex;
53 
54 public:
55 						SvNumberFormatterServiceObj();
56 	virtual				~SvNumberFormatterServiceObj();
57 
58 						// XNumberFormatter
59 	virtual void SAL_CALL attachNumberFormatsSupplier(
60 							const ::com::sun::star::uno::Reference<
61 								::com::sun::star::util::XNumberFormatsSupplier >& xSupplier )
62 									throw(::com::sun::star::uno::RuntimeException);
63 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
64 							SAL_CALL getNumberFormatsSupplier()
65 								throw(::com::sun::star::uno::RuntimeException);
66 	virtual sal_Int32 SAL_CALL detectNumberFormat( sal_Int32 nKey, const ::rtl::OUString& aString )
67 							throw(::com::sun::star::util::NotNumericException,
68 									::com::sun::star::uno::RuntimeException);
69 	virtual double SAL_CALL convertStringToNumber( sal_Int32 nKey, const ::rtl::OUString& aString )
70 							throw(::com::sun::star::util::NotNumericException,
71 									::com::sun::star::uno::RuntimeException);
72 	virtual ::rtl::OUString SAL_CALL convertNumberToString( sal_Int32 nKey, double fValue )
73 							throw(::com::sun::star::uno::RuntimeException);
74 	virtual ::com::sun::star::util::Color SAL_CALL queryColorForNumber( sal_Int32 nKey,
75 							double fValue, ::com::sun::star::util::Color aDefaultColor )
76 								throw(::com::sun::star::uno::RuntimeException);
77 	virtual ::rtl::OUString SAL_CALL formatString( sal_Int32 nKey, const ::rtl::OUString& aString )
78 							throw(::com::sun::star::uno::RuntimeException);
79 	virtual ::com::sun::star::util::Color SAL_CALL queryColorForString( sal_Int32 nKey,
80 							const ::rtl::OUString& aString,
81 								::com::sun::star::util::Color aDefaultColor )
82 									throw(::com::sun::star::uno::RuntimeException);
83 	virtual ::rtl::OUString SAL_CALL getInputString( sal_Int32 nKey, double fValue )
84 							throw(::com::sun::star::uno::RuntimeException);
85 
86 						// XNumberFormatPreviewer
87 	virtual ::rtl::OUString SAL_CALL convertNumberToPreviewString(
88 							const ::rtl::OUString& aFormat, double fValue,
89 							const ::com::sun::star::lang::Locale& nLocale, sal_Bool bAllowEnglish )
90 								throw(::com::sun::star::util::MalformedNumberFormatException,
91 										::com::sun::star::uno::RuntimeException);
92 	virtual ::com::sun::star::util::Color SAL_CALL queryPreviewColorForNumber(
93 							const ::rtl::OUString& aFormat, double fValue,
94 							const ::com::sun::star::lang::Locale& nLocale, sal_Bool bAllowEnglish,
95 							::com::sun::star::util::Color aDefaultColor )
96 								throw(::com::sun::star::util::MalformedNumberFormatException,
97 										::com::sun::star::uno::RuntimeException);
98 
99 						// XServiceInfo
100 	virtual ::rtl::OUString SAL_CALL getImplementationName(  )
101 							throw(::com::sun::star::uno::RuntimeException);
102 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
103 							throw(::com::sun::star::uno::RuntimeException);
104 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
105 							throw(::com::sun::star::uno::RuntimeException);
106 };
107 
108 
109 class SvNumberFormatsObj : public cppu::WeakImplHelper3<
110 										com::sun::star::util::XNumberFormats,
111 										com::sun::star::util::XNumberFormatTypes,
112 										com::sun::star::lang::XServiceInfo>
113 {
114 private:
115 	SvNumberFormatsSupplierObj&         rSupplier;
116     mutable ::comphelper::SharedMutex   m_aMutex;
117 
118 public:
119                     SvNumberFormatsObj(SvNumberFormatsSupplierObj& pParent, ::comphelper::SharedMutex& _rMutex);
120 	virtual			~SvNumberFormatsObj();
121 
122 
123 						// XNumberFormats
124 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
125 							getByKey( sal_Int32 nKey ) throw(::com::sun::star::uno::RuntimeException);
126 	virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL queryKeys( sal_Int16 nType,
127 							const ::com::sun::star::lang::Locale& nLocale, sal_Bool bCreate )
128 								throw(::com::sun::star::uno::RuntimeException);
129 	virtual sal_Int32 SAL_CALL queryKey( const ::rtl::OUString& aFormat,
130 							const ::com::sun::star::lang::Locale& nLocale, sal_Bool bScan )
131 								throw(::com::sun::star::uno::RuntimeException);
132 	virtual sal_Int32 SAL_CALL addNew( const ::rtl::OUString& aFormat,
133 							const ::com::sun::star::lang::Locale& nLocale )
134 								throw(::com::sun::star::util::MalformedNumberFormatException,
135 										::com::sun::star::uno::RuntimeException);
136 	virtual sal_Int32 SAL_CALL addNewConverted( const ::rtl::OUString& aFormat,
137 							const ::com::sun::star::lang::Locale& nLocale,
138 							const ::com::sun::star::lang::Locale& nNewLocale )
139 								throw(::com::sun::star::util::MalformedNumberFormatException,
140 										::com::sun::star::uno::RuntimeException);
141 	virtual void SAL_CALL removeByKey( sal_Int32 nKey ) throw(::com::sun::star::uno::RuntimeException);
142 	virtual ::rtl::OUString SAL_CALL generateFormat( sal_Int32 nBaseKey,
143 							const ::com::sun::star::lang::Locale& nLocale, sal_Bool bThousands,
144 							sal_Bool bRed, sal_Int16 nDecimals, sal_Int16 nLeading )
145 								throw(::com::sun::star::uno::RuntimeException);
146 
147 						// XNumberFormatTypes
148 	virtual sal_Int32 SAL_CALL getStandardIndex( const ::com::sun::star::lang::Locale& nLocale )
149 							throw(::com::sun::star::uno::RuntimeException);
150 	virtual sal_Int32 SAL_CALL getStandardFormat( sal_Int16 nType,
151 							const ::com::sun::star::lang::Locale& nLocale )
152 								throw(::com::sun::star::uno::RuntimeException);
153 	virtual sal_Int32 SAL_CALL getFormatIndex( sal_Int16 nIndex,
154 							const ::com::sun::star::lang::Locale& nLocale )
155 								throw(::com::sun::star::uno::RuntimeException);
156 	virtual sal_Bool SAL_CALL isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType )
157 							throw(::com::sun::star::uno::RuntimeException);
158 	virtual sal_Int32 SAL_CALL getFormatForLocale( sal_Int32 nKey,
159 							const ::com::sun::star::lang::Locale& nLocale )
160 								throw(::com::sun::star::uno::RuntimeException);
161 
162 						// XServiceInfo
163 	virtual ::rtl::OUString SAL_CALL getImplementationName(  )
164 							throw(::com::sun::star::uno::RuntimeException);
165 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
166 							throw(::com::sun::star::uno::RuntimeException);
167 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
168 							throw(::com::sun::star::uno::RuntimeException);
169 
170 private:
171     SvNumberFormatsObj();   // never implemented
172 };
173 
174 
175 class SvNumberFormatObj : public cppu::WeakImplHelper3<
176 										com::sun::star::beans::XPropertySet,
177 										com::sun::star::beans::XPropertyAccess,
178 										com::sun::star::lang::XServiceInfo>
179 {
180 private:
181 	SvNumberFormatsSupplierObj&	        rSupplier;
182 	sal_uLong						        nKey;
183     mutable ::comphelper::SharedMutex   m_aMutex;
184 
185 public:
186     SvNumberFormatObj( SvNumberFormatsSupplierObj& rParent, sal_uLong nK, const ::comphelper::SharedMutex& _rMutex );
187 	virtual			~SvNumberFormatObj();
188 
189 							// XPropertySet
190 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
191 							SAL_CALL getPropertySetInfo(  )
192 								throw(::com::sun::star::uno::RuntimeException);
193 	virtual void SAL_CALL	setPropertyValue( const ::rtl::OUString& aPropertyName,
194 									const ::com::sun::star::uno::Any& aValue )
195 								throw(::com::sun::star::beans::UnknownPropertyException,
196 									::com::sun::star::beans::PropertyVetoException,
197 									::com::sun::star::lang::IllegalArgumentException,
198 									::com::sun::star::lang::WrappedTargetException,
199 									::com::sun::star::uno::RuntimeException);
200 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
201 									const ::rtl::OUString& PropertyName )
202 								throw(::com::sun::star::beans::UnknownPropertyException,
203 									::com::sun::star::lang::WrappedTargetException,
204 									::com::sun::star::uno::RuntimeException);
205 	virtual void SAL_CALL	addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
206 									const ::com::sun::star::uno::Reference<
207 										::com::sun::star::beans::XPropertyChangeListener >& xListener )
208 								throw(::com::sun::star::beans::UnknownPropertyException,
209 									::com::sun::star::lang::WrappedTargetException,
210 									::com::sun::star::uno::RuntimeException);
211 	virtual void SAL_CALL	removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
212 									const ::com::sun::star::uno::Reference<
213 										::com::sun::star::beans::XPropertyChangeListener >& aListener )
214 								throw(::com::sun::star::beans::UnknownPropertyException,
215 									::com::sun::star::lang::WrappedTargetException,
216 									::com::sun::star::uno::RuntimeException);
217 	virtual void SAL_CALL	addVetoableChangeListener( const ::rtl::OUString& PropertyName,
218 									const ::com::sun::star::uno::Reference<
219 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
220 								throw(::com::sun::star::beans::UnknownPropertyException,
221 									::com::sun::star::lang::WrappedTargetException,
222 									::com::sun::star::uno::RuntimeException);
223 	virtual void SAL_CALL	removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
224 									const ::com::sun::star::uno::Reference<
225 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
226 								throw(::com::sun::star::beans::UnknownPropertyException,
227 									::com::sun::star::lang::WrappedTargetException,
228 									::com::sun::star::uno::RuntimeException);
229 
230 							// XPropertyAccess
231 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
232 							getPropertyValues() throw(::com::sun::star::uno::RuntimeException);
233 	virtual void SAL_CALL	setPropertyValues( const ::com::sun::star::uno::Sequence<
234 								::com::sun::star::beans::PropertyValue >& aProps )
235 									throw(::com::sun::star::beans::UnknownPropertyException,
236 											::com::sun::star::beans::PropertyVetoException,
237 											::com::sun::star::lang::IllegalArgumentException,
238 											::com::sun::star::lang::WrappedTargetException,
239 											::com::sun::star::uno::RuntimeException);
240 
241 							// XServiceInfo
242 	virtual ::rtl::OUString SAL_CALL getImplementationName(  )
243 								throw(::com::sun::star::uno::RuntimeException);
244 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
245 								throw(::com::sun::star::uno::RuntimeException);
246 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
247 								throw(::com::sun::star::uno::RuntimeException);
248 };
249 
250 
251 class SvNumberFormatSettingsObj : public cppu::WeakImplHelper2<
252 										com::sun::star::beans::XPropertySet,
253 										com::sun::star::lang::XServiceInfo>
254 {
255 private:
256 	SvNumberFormatsSupplierObj&         rSupplier;
257     mutable ::comphelper::SharedMutex   m_aMutex;
258 
259 public:
260                     SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj& rParent, const ::comphelper::SharedMutex& _rMutex);
261 	virtual			~SvNumberFormatSettingsObj();
262 
263 
264 							// XPropertySet
265 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
266 							SAL_CALL getPropertySetInfo(  )
267 								throw(::com::sun::star::uno::RuntimeException);
268 	virtual void SAL_CALL	setPropertyValue( const ::rtl::OUString& aPropertyName,
269 									const ::com::sun::star::uno::Any& aValue )
270 								throw(::com::sun::star::beans::UnknownPropertyException,
271 									::com::sun::star::beans::PropertyVetoException,
272 									::com::sun::star::lang::IllegalArgumentException,
273 									::com::sun::star::lang::WrappedTargetException,
274 									::com::sun::star::uno::RuntimeException);
275 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
276 									const ::rtl::OUString& PropertyName )
277 								throw(::com::sun::star::beans::UnknownPropertyException,
278 									::com::sun::star::lang::WrappedTargetException,
279 									::com::sun::star::uno::RuntimeException);
280 	virtual void SAL_CALL	addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
281 									const ::com::sun::star::uno::Reference<
282 										::com::sun::star::beans::XPropertyChangeListener >& xListener )
283 								throw(::com::sun::star::beans::UnknownPropertyException,
284 									::com::sun::star::lang::WrappedTargetException,
285 									::com::sun::star::uno::RuntimeException);
286 	virtual void SAL_CALL	removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
287 									const ::com::sun::star::uno::Reference<
288 										::com::sun::star::beans::XPropertyChangeListener >& aListener )
289 								throw(::com::sun::star::beans::UnknownPropertyException,
290 									::com::sun::star::lang::WrappedTargetException,
291 									::com::sun::star::uno::RuntimeException);
292 	virtual void SAL_CALL	addVetoableChangeListener( const ::rtl::OUString& PropertyName,
293 									const ::com::sun::star::uno::Reference<
294 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
295 								throw(::com::sun::star::beans::UnknownPropertyException,
296 									::com::sun::star::lang::WrappedTargetException,
297 									::com::sun::star::uno::RuntimeException);
298 	virtual void SAL_CALL	removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
299 									const ::com::sun::star::uno::Reference<
300 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
301 								throw(::com::sun::star::beans::UnknownPropertyException,
302 									::com::sun::star::lang::WrappedTargetException,
303 									::com::sun::star::uno::RuntimeException);
304 
305 							// XServiceInfo
306 	virtual ::rtl::OUString SAL_CALL getImplementationName(  )
307 								throw(::com::sun::star::uno::RuntimeException);
308 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
309 								throw(::com::sun::star::uno::RuntimeException);
310 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
311 								throw(::com::sun::star::uno::RuntimeException);
312 };
313 
314 
315 
316 #endif
317 
318