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/XNumberFormats.hpp>
25 #include <com/sun/star/util/XNumberFormatTypes.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/beans/XPropertyAccess.hpp>
28 #include <cppuhelper/implbase.hxx>
29 #include <comphelper/sharedmutex.hxx>
30 #include <rtl/ref.hxx>
31 #include <tools/solar.h>
33 class SvNumberFormatsSupplierObj
;
37 * SvNumberFormatterServiceObj is registered globally as a Service
39 class SvNumberFormatterServiceObj
: public cppu::WeakImplHelper
<
40 css::util::XNumberFormatter2
,
41 css::lang::XServiceInfo
>
44 ::rtl::Reference
< SvNumberFormatsSupplierObj
> xSupplier
;
45 mutable ::comphelper::SharedMutex m_aMutex
;
48 SvNumberFormatterServiceObj();
49 virtual ~SvNumberFormatterServiceObj() override
;
52 virtual void SAL_CALL
attachNumberFormatsSupplier(
53 const css::uno::Reference
< css::util::XNumberFormatsSupplier
>& xSupplier
) override
;
54 virtual css::uno::Reference
< css::util::XNumberFormatsSupplier
>
55 SAL_CALL
getNumberFormatsSupplier() override
;
56 virtual sal_Int32 SAL_CALL
detectNumberFormat( sal_Int32 nKey
, const OUString
& aString
) override
;
57 virtual double SAL_CALL
convertStringToNumber( sal_Int32 nKey
, const OUString
& aString
) override
;
58 virtual OUString SAL_CALL
convertNumberToString( sal_Int32 nKey
, double fValue
) override
;
59 virtual sal_Int32 SAL_CALL
queryColorForNumber( sal_Int32 nKey
,
60 double fValue
, sal_Int32 aDefaultColor
) override
;
61 virtual OUString SAL_CALL
formatString( sal_Int32 nKey
, const OUString
& aString
) override
;
62 virtual sal_Int32 SAL_CALL
queryColorForString( sal_Int32 nKey
,
63 const OUString
& aString
,
64 sal_Int32 aDefaultColor
) override
;
65 virtual OUString SAL_CALL
getInputString( sal_Int32 nKey
, double fValue
) override
;
67 // XNumberFormatPreviewer
68 virtual OUString SAL_CALL
convertNumberToPreviewString(
69 const OUString
& aFormat
, double fValue
,
70 const css::lang::Locale
& nLocale
, sal_Bool bAllowEnglish
) override
;
71 virtual sal_Int32 SAL_CALL
queryPreviewColorForNumber(
72 const OUString
& aFormat
, double fValue
,
73 const css::lang::Locale
& nLocale
, sal_Bool bAllowEnglish
,
74 sal_Int32 aDefaultColor
) override
;
77 virtual OUString SAL_CALL
getImplementationName( ) override
;
78 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
79 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
83 class SvNumberFormatsObj
: public cppu::WeakImplHelper
<
84 css::util::XNumberFormats
,
85 css::util::XNumberFormatTypes
,
86 css::lang::XServiceInfo
>
89 rtl::Reference
<SvNumberFormatsSupplierObj
> m_xSupplier
;
90 mutable ::comphelper::SharedMutex m_aMutex
;
93 SvNumberFormatsObj(SvNumberFormatsSupplierObj
& pParent
, ::comphelper::SharedMutex _aMutex
);
94 virtual ~SvNumberFormatsObj() override
;
98 virtual css::uno::Reference
< css::beans::XPropertySet
> SAL_CALL
99 getByKey( sal_Int32 nKey
) override
;
100 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
queryKeys( sal_Int16 nType
,
101 const css::lang::Locale
& nLocale
, sal_Bool bCreate
) override
;
102 virtual sal_Int32 SAL_CALL
queryKey( const OUString
& aFormat
,
103 const css::lang::Locale
& nLocale
, sal_Bool bScan
) override
;
104 virtual sal_Int32 SAL_CALL
addNew( const OUString
& aFormat
,
105 const css::lang::Locale
& nLocale
) override
;
106 virtual sal_Int32 SAL_CALL
addNewConverted( const OUString
& aFormat
,
107 const css::lang::Locale
& nLocale
,
108 const css::lang::Locale
& nNewLocale
) override
;
109 virtual void SAL_CALL
removeByKey( sal_Int32 nKey
) override
;
110 virtual OUString SAL_CALL
generateFormat( sal_Int32 nBaseKey
,
111 const css::lang::Locale
& nLocale
, sal_Bool bThousands
,
112 sal_Bool bRed
, sal_Int16 nDecimals
, sal_Int16 nLeading
) override
;
114 // XNumberFormatTypes
115 virtual sal_Int32 SAL_CALL
getStandardIndex( const css::lang::Locale
& nLocale
) override
;
116 virtual sal_Int32 SAL_CALL
getStandardFormat( sal_Int16 nType
,
117 const css::lang::Locale
& nLocale
) override
;
118 virtual sal_Int32 SAL_CALL
getFormatIndex( sal_Int16 nIndex
,
119 const css::lang::Locale
& nLocale
) override
;
120 virtual sal_Bool SAL_CALL
isTypeCompatible( sal_Int16 nOldType
, sal_Int16 nNewType
) override
;
121 virtual sal_Int32 SAL_CALL
getFormatForLocale( sal_Int32 nKey
,
122 const css::lang::Locale
& nLocale
) override
;
125 virtual OUString SAL_CALL
getImplementationName( ) override
;
126 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
127 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
131 class SvNumberFormatObj
: public cppu::WeakImplHelper
<
132 css::beans::XPropertySet
,
133 css::beans::XPropertyAccess
,
134 css::lang::XServiceInfo
>
137 rtl::Reference
<SvNumberFormatsSupplierObj
>
140 mutable ::comphelper::SharedMutex m_aMutex
;
143 SvNumberFormatObj( SvNumberFormatsSupplierObj
& rParent
, sal_Int32 nK
, ::comphelper::SharedMutex _aMutex
);
144 virtual ~SvNumberFormatObj() override
;
147 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
148 SAL_CALL
getPropertySetInfo( ) override
;
149 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
150 const css::uno::Any
& aValue
) override
;
151 virtual css::uno::Any SAL_CALL
getPropertyValue(
152 const OUString
& PropertyName
) override
;
153 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
154 const css::uno::Reference
<
155 css::beans::XPropertyChangeListener
>& xListener
) override
;
156 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
157 const css::uno::Reference
<
158 css::beans::XPropertyChangeListener
>& aListener
) override
;
159 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
160 const css::uno::Reference
<
161 css::beans::XVetoableChangeListener
>& aListener
) override
;
162 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
163 const css::uno::Reference
<
164 css::beans::XVetoableChangeListener
>& aListener
) override
;
167 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
168 getPropertyValues() override
;
169 virtual void SAL_CALL
setPropertyValues( const css::uno::Sequence
<
170 css::beans::PropertyValue
>& aProps
) override
;
173 virtual OUString SAL_CALL
getImplementationName( ) override
;
174 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
175 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
179 class SvNumberFormatSettingsObj
: public cppu::WeakImplHelper
<
180 css::beans::XPropertySet
,
181 css::lang::XServiceInfo
>
184 rtl::Reference
<SvNumberFormatsSupplierObj
>
186 mutable ::comphelper::SharedMutex m_aMutex
;
189 SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj
& rParent
, ::comphelper::SharedMutex _aMutex
);
190 virtual ~SvNumberFormatSettingsObj() override
;
194 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
195 SAL_CALL
getPropertySetInfo( ) override
;
196 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
197 const css::uno::Any
& aValue
) override
;
198 virtual css::uno::Any SAL_CALL
getPropertyValue(
199 const OUString
& PropertyName
) override
;
200 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
201 const css::uno::Reference
<
202 css::beans::XPropertyChangeListener
>& xListener
) override
;
203 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
204 const css::uno::Reference
<
205 css::beans::XPropertyChangeListener
>& aListener
) override
;
206 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
207 const css::uno::Reference
<
208 css::beans::XVetoableChangeListener
>& aListener
) override
;
209 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
210 const css::uno::Reference
<
211 css::beans::XVetoableChangeListener
>& aListener
) override
;
214 virtual OUString SAL_CALL
getImplementationName( ) override
;
215 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
216 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */