1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVL_SOURCE_NUMBERS_NUMFMUNO_HXX
21 #define INCLUDED_SVL_SOURCE_NUMBERS_NUMFMUNO_HXX
23 #include <com/sun/star/util/XNumberFormatter2.hpp>
24 #include <com/sun/star/util/XNumberFormatPreviewer.hpp>
25 #include <com/sun/star/util/XNumberFormats.hpp>
26 #include <com/sun/star/util/XNumberFormatTypes.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/beans/XPropertyAccess.hpp>
29 #include <cppuhelper/implbase2.hxx>
30 #include <cppuhelper/implbase3.hxx>
31 #include <comphelper/sharedmutex.hxx>
32 #include <rtl/ref.hxx>
33 #include <tools/solar.h>
35 class SvNumberFormatsSupplierObj
;
38 // SvNumberFormatterServiceObj wird global als Service angemeldet
40 class SvNumberFormatterServiceObj
: public cppu::WeakImplHelper2
<
41 com::sun::star::util::XNumberFormatter2
,
42 com::sun::star::lang::XServiceInfo
>
45 ::rtl::Reference
< SvNumberFormatsSupplierObj
> xSupplier
;
46 mutable ::comphelper::SharedMutex m_aMutex
;
49 SvNumberFormatterServiceObj();
50 virtual ~SvNumberFormatterServiceObj();
53 virtual void SAL_CALL
attachNumberFormatsSupplier(
54 const ::com::sun::star::uno::Reference
<
55 ::com::sun::star::util::XNumberFormatsSupplier
>& xSupplier
)
56 throw(::com::sun::star::uno::RuntimeException
);
57 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatsSupplier
>
58 SAL_CALL
getNumberFormatsSupplier()
59 throw(::com::sun::star::uno::RuntimeException
);
60 virtual sal_Int32 SAL_CALL
detectNumberFormat( sal_Int32 nKey
, const OUString
& aString
)
61 throw(::com::sun::star::util::NotNumericException
,
62 ::com::sun::star::uno::RuntimeException
);
63 virtual double SAL_CALL
convertStringToNumber( sal_Int32 nKey
, const OUString
& aString
)
64 throw(::com::sun::star::util::NotNumericException
,
65 ::com::sun::star::uno::RuntimeException
);
66 virtual OUString SAL_CALL
convertNumberToString( sal_Int32 nKey
, double fValue
)
67 throw(::com::sun::star::uno::RuntimeException
);
68 virtual ::com::sun::star::util::Color SAL_CALL
queryColorForNumber( sal_Int32 nKey
,
69 double fValue
, ::com::sun::star::util::Color aDefaultColor
)
70 throw(::com::sun::star::uno::RuntimeException
);
71 virtual OUString SAL_CALL
formatString( sal_Int32 nKey
, const OUString
& aString
)
72 throw(::com::sun::star::uno::RuntimeException
);
73 virtual ::com::sun::star::util::Color SAL_CALL
queryColorForString( sal_Int32 nKey
,
74 const OUString
& aString
,
75 ::com::sun::star::util::Color aDefaultColor
)
76 throw(::com::sun::star::uno::RuntimeException
);
77 virtual OUString SAL_CALL
getInputString( sal_Int32 nKey
, double fValue
)
78 throw(::com::sun::star::uno::RuntimeException
);
80 // XNumberFormatPreviewer
81 virtual OUString SAL_CALL
convertNumberToPreviewString(
82 const OUString
& aFormat
, double fValue
,
83 const ::com::sun::star::lang::Locale
& nLocale
, sal_Bool bAllowEnglish
)
84 throw(::com::sun::star::util::MalformedNumberFormatException
,
85 ::com::sun::star::uno::RuntimeException
);
86 virtual ::com::sun::star::util::Color SAL_CALL
queryPreviewColorForNumber(
87 const OUString
& aFormat
, double fValue
,
88 const ::com::sun::star::lang::Locale
& nLocale
, sal_Bool bAllowEnglish
,
89 ::com::sun::star::util::Color aDefaultColor
)
90 throw(::com::sun::star::util::MalformedNumberFormatException
,
91 ::com::sun::star::uno::RuntimeException
);
94 virtual OUString SAL_CALL
getImplementationName( )
95 throw(::com::sun::star::uno::RuntimeException
);
96 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
97 throw(::com::sun::star::uno::RuntimeException
);
98 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
99 throw(::com::sun::star::uno::RuntimeException
);
103 class SvNumberFormatsObj
: public cppu::WeakImplHelper3
<
104 com::sun::star::util::XNumberFormats
,
105 com::sun::star::util::XNumberFormatTypes
,
106 com::sun::star::lang::XServiceInfo
>
109 SvNumberFormatsSupplierObj
& rSupplier
;
110 mutable ::comphelper::SharedMutex m_aMutex
;
113 SvNumberFormatsObj(SvNumberFormatsSupplierObj
& pParent
, ::comphelper::SharedMutex
& _rMutex
);
114 virtual ~SvNumberFormatsObj();
118 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> SAL_CALL
119 getByKey( sal_Int32 nKey
) throw(::com::sun::star::uno::RuntimeException
);
120 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
queryKeys( sal_Int16 nType
,
121 const ::com::sun::star::lang::Locale
& nLocale
, sal_Bool bCreate
)
122 throw(::com::sun::star::uno::RuntimeException
);
123 virtual sal_Int32 SAL_CALL
queryKey( const OUString
& aFormat
,
124 const ::com::sun::star::lang::Locale
& nLocale
, sal_Bool bScan
)
125 throw(::com::sun::star::uno::RuntimeException
);
126 virtual sal_Int32 SAL_CALL
addNew( const OUString
& aFormat
,
127 const ::com::sun::star::lang::Locale
& nLocale
)
128 throw(::com::sun::star::util::MalformedNumberFormatException
,
129 ::com::sun::star::uno::RuntimeException
);
130 virtual sal_Int32 SAL_CALL
addNewConverted( const OUString
& aFormat
,
131 const ::com::sun::star::lang::Locale
& nLocale
,
132 const ::com::sun::star::lang::Locale
& nNewLocale
)
133 throw(::com::sun::star::util::MalformedNumberFormatException
,
134 ::com::sun::star::uno::RuntimeException
);
135 virtual void SAL_CALL
removeByKey( sal_Int32 nKey
) throw(::com::sun::star::uno::RuntimeException
);
136 virtual OUString SAL_CALL
generateFormat( sal_Int32 nBaseKey
,
137 const ::com::sun::star::lang::Locale
& nLocale
, sal_Bool bThousands
,
138 sal_Bool bRed
, sal_Int16 nDecimals
, sal_Int16 nLeading
)
139 throw(::com::sun::star::uno::RuntimeException
);
141 // XNumberFormatTypes
142 virtual sal_Int32 SAL_CALL
getStandardIndex( const ::com::sun::star::lang::Locale
& nLocale
)
143 throw(::com::sun::star::uno::RuntimeException
);
144 virtual sal_Int32 SAL_CALL
getStandardFormat( sal_Int16 nType
,
145 const ::com::sun::star::lang::Locale
& nLocale
)
146 throw(::com::sun::star::uno::RuntimeException
);
147 virtual sal_Int32 SAL_CALL
getFormatIndex( sal_Int16 nIndex
,
148 const ::com::sun::star::lang::Locale
& nLocale
)
149 throw(::com::sun::star::uno::RuntimeException
);
150 virtual sal_Bool SAL_CALL
isTypeCompatible( sal_Int16 nOldType
, sal_Int16 nNewType
)
151 throw(::com::sun::star::uno::RuntimeException
);
152 virtual sal_Int32 SAL_CALL
getFormatForLocale( sal_Int32 nKey
,
153 const ::com::sun::star::lang::Locale
& nLocale
)
154 throw(::com::sun::star::uno::RuntimeException
);
157 virtual OUString SAL_CALL
getImplementationName( )
158 throw(::com::sun::star::uno::RuntimeException
);
159 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
160 throw(::com::sun::star::uno::RuntimeException
);
161 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
162 throw(::com::sun::star::uno::RuntimeException
);
165 SvNumberFormatsObj(); // never implemented
169 class SvNumberFormatObj
: public cppu::WeakImplHelper3
<
170 com::sun::star::beans::XPropertySet
,
171 com::sun::star::beans::XPropertyAccess
,
172 com::sun::star::lang::XServiceInfo
>
175 SvNumberFormatsSupplierObj
& rSupplier
;
177 mutable ::comphelper::SharedMutex m_aMutex
;
180 SvNumberFormatObj( SvNumberFormatsSupplierObj
& rParent
, sal_uLong nK
, const ::comphelper::SharedMutex
& _rMutex
);
181 virtual ~SvNumberFormatObj();
184 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
185 SAL_CALL
getPropertySetInfo( )
186 throw(::com::sun::star::uno::RuntimeException
);
187 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
188 const ::com::sun::star::uno::Any
& aValue
)
189 throw(::com::sun::star::beans::UnknownPropertyException
,
190 ::com::sun::star::beans::PropertyVetoException
,
191 ::com::sun::star::lang::IllegalArgumentException
,
192 ::com::sun::star::lang::WrappedTargetException
,
193 ::com::sun::star::uno::RuntimeException
);
194 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
195 const OUString
& PropertyName
)
196 throw(::com::sun::star::beans::UnknownPropertyException
,
197 ::com::sun::star::lang::WrappedTargetException
,
198 ::com::sun::star::uno::RuntimeException
);
199 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
200 const ::com::sun::star::uno::Reference
<
201 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
202 throw(::com::sun::star::beans::UnknownPropertyException
,
203 ::com::sun::star::lang::WrappedTargetException
,
204 ::com::sun::star::uno::RuntimeException
);
205 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
206 const ::com::sun::star::uno::Reference
<
207 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
208 throw(::com::sun::star::beans::UnknownPropertyException
,
209 ::com::sun::star::lang::WrappedTargetException
,
210 ::com::sun::star::uno::RuntimeException
);
211 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
212 const ::com::sun::star::uno::Reference
<
213 ::com::sun::star::beans::XVetoableChangeListener
>& 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
removeVetoableChangeListener( const 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
);
225 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
226 getPropertyValues() throw(::com::sun::star::uno::RuntimeException
);
227 virtual void SAL_CALL
setPropertyValues( const ::com::sun::star::uno::Sequence
<
228 ::com::sun::star::beans::PropertyValue
>& aProps
)
229 throw(::com::sun::star::beans::UnknownPropertyException
,
230 ::com::sun::star::beans::PropertyVetoException
,
231 ::com::sun::star::lang::IllegalArgumentException
,
232 ::com::sun::star::lang::WrappedTargetException
,
233 ::com::sun::star::uno::RuntimeException
);
236 virtual OUString SAL_CALL
getImplementationName( )
237 throw(::com::sun::star::uno::RuntimeException
);
238 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
239 throw(::com::sun::star::uno::RuntimeException
);
240 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
241 throw(::com::sun::star::uno::RuntimeException
);
245 class SvNumberFormatSettingsObj
: public cppu::WeakImplHelper2
<
246 com::sun::star::beans::XPropertySet
,
247 com::sun::star::lang::XServiceInfo
>
250 SvNumberFormatsSupplierObj
& rSupplier
;
251 mutable ::comphelper::SharedMutex m_aMutex
;
254 SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj
& rParent
, const ::comphelper::SharedMutex
& _rMutex
);
255 virtual ~SvNumberFormatSettingsObj();
259 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
260 SAL_CALL
getPropertySetInfo( )
261 throw(::com::sun::star::uno::RuntimeException
);
262 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
263 const ::com::sun::star::uno::Any
& aValue
)
264 throw(::com::sun::star::beans::UnknownPropertyException
,
265 ::com::sun::star::beans::PropertyVetoException
,
266 ::com::sun::star::lang::IllegalArgumentException
,
267 ::com::sun::star::lang::WrappedTargetException
,
268 ::com::sun::star::uno::RuntimeException
);
269 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
270 const OUString
& PropertyName
)
271 throw(::com::sun::star::beans::UnknownPropertyException
,
272 ::com::sun::star::lang::WrappedTargetException
,
273 ::com::sun::star::uno::RuntimeException
);
274 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
275 const ::com::sun::star::uno::Reference
<
276 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
277 throw(::com::sun::star::beans::UnknownPropertyException
,
278 ::com::sun::star::lang::WrappedTargetException
,
279 ::com::sun::star::uno::RuntimeException
);
280 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
281 const ::com::sun::star::uno::Reference
<
282 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
283 throw(::com::sun::star::beans::UnknownPropertyException
,
284 ::com::sun::star::lang::WrappedTargetException
,
285 ::com::sun::star::uno::RuntimeException
);
286 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
287 const ::com::sun::star::uno::Reference
<
288 ::com::sun::star::beans::XVetoableChangeListener
>& 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
removeVetoableChangeListener( const 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
);
300 virtual OUString SAL_CALL
getImplementationName( )
301 throw(::com::sun::star::uno::RuntimeException
);
302 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
303 throw(::com::sun::star::uno::RuntimeException
);
304 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
305 throw(::com::sun::star::uno::RuntimeException
);
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */