xref: /trunk/main/svl/source/numbers/numfmuno.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 _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     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
63                             SAL_CALL getNumberFormatsSupplier();
64     virtual sal_Int32 SAL_CALL detectNumberFormat( sal_Int32 nKey, const ::rtl::OUString& aString );
65     virtual double SAL_CALL convertStringToNumber( sal_Int32 nKey, const ::rtl::OUString& aString );
66     virtual ::rtl::OUString SAL_CALL convertNumberToString( sal_Int32 nKey, double fValue );
67     virtual ::com::sun::star::util::Color SAL_CALL queryColorForNumber( sal_Int32 nKey,
68                             double fValue, ::com::sun::star::util::Color aDefaultColor );
69     virtual ::rtl::OUString SAL_CALL formatString( sal_Int32 nKey, const ::rtl::OUString& aString );
70     virtual ::com::sun::star::util::Color SAL_CALL queryColorForString( sal_Int32 nKey,
71                             const ::rtl::OUString& aString,
72                                 ::com::sun::star::util::Color aDefaultColor );
73     virtual ::rtl::OUString SAL_CALL getInputString( sal_Int32 nKey, double fValue );
74 
75                         // XNumberFormatPreviewer
76     virtual ::rtl::OUString SAL_CALL convertNumberToPreviewString(
77                             const ::rtl::OUString& aFormat, double fValue,
78                             const ::com::sun::star::lang::Locale& nLocale, sal_Bool bAllowEnglish );
79     virtual ::com::sun::star::util::Color SAL_CALL queryPreviewColorForNumber(
80                             const ::rtl::OUString& aFormat, double fValue,
81                             const ::com::sun::star::lang::Locale& nLocale, sal_Bool bAllowEnglish,
82                             ::com::sun::star::util::Color aDefaultColor );
83 
84                         // XServiceInfo
85     virtual ::rtl::OUString SAL_CALL getImplementationName(  );
86     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
87     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
88 };
89 
90 
91 class SvNumberFormatsObj : public cppu::WeakImplHelper3<
92                                         com::sun::star::util::XNumberFormats,
93                                         com::sun::star::util::XNumberFormatTypes,
94                                         com::sun::star::lang::XServiceInfo>
95 {
96 private:
97     SvNumberFormatsSupplierObj&         rSupplier;
98     mutable ::comphelper::SharedMutex   m_aMutex;
99 
100 public:
101                     SvNumberFormatsObj(SvNumberFormatsSupplierObj& pParent, ::comphelper::SharedMutex& _rMutex);
102     virtual         ~SvNumberFormatsObj();
103 
104 
105                         // XNumberFormats
106     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
107                             getByKey( sal_Int32 nKey );
108     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL queryKeys( sal_Int16 nType,
109                             const ::com::sun::star::lang::Locale& nLocale, sal_Bool bCreate );
110     virtual sal_Int32 SAL_CALL queryKey( const ::rtl::OUString& aFormat,
111                             const ::com::sun::star::lang::Locale& nLocale, sal_Bool bScan );
112     virtual sal_Int32 SAL_CALL addNew( const ::rtl::OUString& aFormat,
113                             const ::com::sun::star::lang::Locale& nLocale );
114     virtual sal_Int32 SAL_CALL addNewConverted( const ::rtl::OUString& aFormat,
115                             const ::com::sun::star::lang::Locale& nLocale,
116                             const ::com::sun::star::lang::Locale& nNewLocale );
117     virtual void SAL_CALL removeByKey( sal_Int32 nKey );
118     virtual ::rtl::OUString SAL_CALL generateFormat( sal_Int32 nBaseKey,
119                             const ::com::sun::star::lang::Locale& nLocale, sal_Bool bThousands,
120                             sal_Bool bRed, sal_Int16 nDecimals, sal_Int16 nLeading );
121 
122                         // XNumberFormatTypes
123     virtual sal_Int32 SAL_CALL getStandardIndex( const ::com::sun::star::lang::Locale& nLocale );
124     virtual sal_Int32 SAL_CALL getStandardFormat( sal_Int16 nType,
125                             const ::com::sun::star::lang::Locale& nLocale );
126     virtual sal_Int32 SAL_CALL getFormatIndex( sal_Int16 nIndex,
127                             const ::com::sun::star::lang::Locale& nLocale );
128     virtual sal_Bool SAL_CALL isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType );
129     virtual sal_Int32 SAL_CALL getFormatForLocale( sal_Int32 nKey,
130                             const ::com::sun::star::lang::Locale& nLocale );
131 
132                         // XServiceInfo
133     virtual ::rtl::OUString SAL_CALL getImplementationName(  );
134     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
135     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
136 
137 private:
138     SvNumberFormatsObj();   // never implemented
139 };
140 
141 
142 class SvNumberFormatObj : public cppu::WeakImplHelper3<
143                                         com::sun::star::beans::XPropertySet,
144                                         com::sun::star::beans::XPropertyAccess,
145                                         com::sun::star::lang::XServiceInfo>
146 {
147 private:
148     SvNumberFormatsSupplierObj&         rSupplier;
149     sal_uLong                               nKey;
150     mutable ::comphelper::SharedMutex   m_aMutex;
151 
152 public:
153     SvNumberFormatObj( SvNumberFormatsSupplierObj& rParent, sal_uLong nK, const ::comphelper::SharedMutex& _rMutex );
154     virtual         ~SvNumberFormatObj();
155 
156                             // XPropertySet
157     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
158                             SAL_CALL getPropertySetInfo(  );
159     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
160                                     const ::com::sun::star::uno::Any& aValue );
161     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
162                                     const ::rtl::OUString& PropertyName );
163     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
164                                     const ::com::sun::star::uno::Reference<
165                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener );
166     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
167                                     const ::com::sun::star::uno::Reference<
168                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener );
169     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
170                                     const ::com::sun::star::uno::Reference<
171                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
172     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
173                                     const ::com::sun::star::uno::Reference<
174                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
175 
176                             // XPropertyAccess
177     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
178                             getPropertyValues();
179     virtual void SAL_CALL   setPropertyValues( const ::com::sun::star::uno::Sequence<
180                                 ::com::sun::star::beans::PropertyValue >& aProps );
181 
182                             // XServiceInfo
183     virtual ::rtl::OUString SAL_CALL getImplementationName(  );
184     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
185     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
186 };
187 
188 
189 class SvNumberFormatSettingsObj : public cppu::WeakImplHelper2<
190                                         com::sun::star::beans::XPropertySet,
191                                         com::sun::star::lang::XServiceInfo>
192 {
193 private:
194     SvNumberFormatsSupplierObj&         rSupplier;
195     mutable ::comphelper::SharedMutex   m_aMutex;
196 
197 public:
198                     SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj& rParent, const ::comphelper::SharedMutex& _rMutex);
199     virtual         ~SvNumberFormatSettingsObj();
200 
201 
202                             // XPropertySet
203     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
204                             SAL_CALL getPropertySetInfo(  );
205     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
206                                     const ::com::sun::star::uno::Any& aValue );
207     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
208                                     const ::rtl::OUString& PropertyName );
209     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
210                                     const ::com::sun::star::uno::Reference<
211                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener );
212     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
213                                     const ::com::sun::star::uno::Reference<
214                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener );
215     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
216                                     const ::com::sun::star::uno::Reference<
217                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
218     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
219                                     const ::com::sun::star::uno::Reference<
220                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
221 
222                             // XServiceInfo
223     virtual ::rtl::OUString SAL_CALL getImplementationName(  );
224     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
225     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
226 };
227 
228 
229 
230 #endif
231