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/implbase.hxx>
30 #include <comphelper/sharedmutex.hxx>
31 #include <rtl/ref.hxx>
32 #include <tools/solar.h>
34 class SvNumberFormatsSupplierObj
;
38 * SvNumberFormatterServiceObj is registered globally as a Service
40 class SvNumberFormatterServiceObj
: public cppu::WeakImplHelper
<
41 css::util::XNumberFormatter2
,
42 css::lang::XServiceInfo
>
45 ::rtl::Reference
< SvNumberFormatsSupplierObj
> xSupplier
;
46 mutable ::comphelper::SharedMutex m_aMutex
;
49 SvNumberFormatterServiceObj();
50 virtual ~SvNumberFormatterServiceObj() override
;
53 virtual void SAL_CALL
attachNumberFormatsSupplier(
54 const css::uno::Reference
< css::util::XNumberFormatsSupplier
>& xSupplier
) override
;
55 virtual css::uno::Reference
< css::util::XNumberFormatsSupplier
>
56 SAL_CALL
getNumberFormatsSupplier() override
;
57 virtual sal_Int32 SAL_CALL
detectNumberFormat( sal_Int32 nKey
, const OUString
& aString
) override
;
58 virtual double SAL_CALL
convertStringToNumber( sal_Int32 nKey
, const OUString
& aString
) override
;
59 virtual OUString SAL_CALL
convertNumberToString( sal_Int32 nKey
, double fValue
) override
;
60 virtual css::util::Color SAL_CALL
queryColorForNumber( sal_Int32 nKey
,
61 double fValue
, css::util::Color aDefaultColor
) override
;
62 virtual OUString SAL_CALL
formatString( sal_Int32 nKey
, const OUString
& aString
) override
;
63 virtual css::util::Color SAL_CALL
queryColorForString( sal_Int32 nKey
,
64 const OUString
& aString
,
65 css::util::Color aDefaultColor
) override
;
66 virtual OUString SAL_CALL
getInputString( sal_Int32 nKey
, double fValue
) override
;
68 // XNumberFormatPreviewer
69 virtual OUString SAL_CALL
convertNumberToPreviewString(
70 const OUString
& aFormat
, double fValue
,
71 const css::lang::Locale
& nLocale
, sal_Bool bAllowEnglish
) override
;
72 virtual css::util::Color SAL_CALL
queryPreviewColorForNumber(
73 const OUString
& aFormat
, double fValue
,
74 const css::lang::Locale
& nLocale
, sal_Bool bAllowEnglish
,
75 css::util::Color aDefaultColor
) override
;
78 virtual OUString SAL_CALL
getImplementationName( ) override
;
79 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
80 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
84 class SvNumberFormatsObj
: public cppu::WeakImplHelper
<
85 css::util::XNumberFormats
,
86 css::util::XNumberFormatTypes
,
87 css::lang::XServiceInfo
>
90 rtl::Reference
<SvNumberFormatsSupplierObj
> m_xSupplier
;
91 mutable ::comphelper::SharedMutex m_aMutex
;
94 SvNumberFormatsObj(SvNumberFormatsSupplierObj
& pParent
, ::comphelper::SharedMutex
const & _rMutex
);
95 virtual ~SvNumberFormatsObj() override
;
99 virtual css::uno::Reference
< css::beans::XPropertySet
> SAL_CALL
100 getByKey( sal_Int32 nKey
) override
;
101 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
queryKeys( sal_Int16 nType
,
102 const css::lang::Locale
& nLocale
, sal_Bool bCreate
) override
;
103 virtual sal_Int32 SAL_CALL
queryKey( const OUString
& aFormat
,
104 const css::lang::Locale
& nLocale
, sal_Bool bScan
) override
;
105 virtual sal_Int32 SAL_CALL
addNew( const OUString
& aFormat
,
106 const css::lang::Locale
& nLocale
) override
;
107 virtual sal_Int32 SAL_CALL
addNewConverted( const OUString
& aFormat
,
108 const css::lang::Locale
& nLocale
,
109 const css::lang::Locale
& nNewLocale
) override
;
110 virtual void SAL_CALL
removeByKey( sal_Int32 nKey
) override
;
111 virtual OUString SAL_CALL
generateFormat( sal_Int32 nBaseKey
,
112 const css::lang::Locale
& nLocale
, sal_Bool bThousands
,
113 sal_Bool bRed
, sal_Int16 nDecimals
, sal_Int16 nLeading
) override
;
115 // XNumberFormatTypes
116 virtual sal_Int32 SAL_CALL
getStandardIndex( const css::lang::Locale
& nLocale
) override
;
117 virtual sal_Int32 SAL_CALL
getStandardFormat( sal_Int16 nType
,
118 const css::lang::Locale
& nLocale
) override
;
119 virtual sal_Int32 SAL_CALL
getFormatIndex( sal_Int16 nIndex
,
120 const css::lang::Locale
& nLocale
) override
;
121 virtual sal_Bool SAL_CALL
isTypeCompatible( sal_Int16 nOldType
, sal_Int16 nNewType
) override
;
122 virtual sal_Int32 SAL_CALL
getFormatForLocale( sal_Int32 nKey
,
123 const css::lang::Locale
& nLocale
) override
;
126 virtual OUString SAL_CALL
getImplementationName( ) override
;
127 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
128 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
132 class SvNumberFormatObj
: public cppu::WeakImplHelper
<
133 css::beans::XPropertySet
,
134 css::beans::XPropertyAccess
,
135 css::lang::XServiceInfo
>
138 rtl::Reference
<SvNumberFormatsSupplierObj
>
141 mutable ::comphelper::SharedMutex m_aMutex
;
144 SvNumberFormatObj( SvNumberFormatsSupplierObj
& rParent
, sal_uLong nK
, const ::comphelper::SharedMutex
& _rMutex
);
145 virtual ~SvNumberFormatObj() override
;
148 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
149 SAL_CALL
getPropertySetInfo( ) override
;
150 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
151 const css::uno::Any
& aValue
) override
;
152 virtual css::uno::Any SAL_CALL
getPropertyValue(
153 const OUString
& PropertyName
) override
;
154 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
155 const css::uno::Reference
<
156 css::beans::XPropertyChangeListener
>& xListener
) override
;
157 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
158 const css::uno::Reference
<
159 css::beans::XPropertyChangeListener
>& aListener
) override
;
160 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
161 const css::uno::Reference
<
162 css::beans::XVetoableChangeListener
>& aListener
) override
;
163 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
164 const css::uno::Reference
<
165 css::beans::XVetoableChangeListener
>& aListener
) override
;
168 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
169 getPropertyValues() override
;
170 virtual void SAL_CALL
setPropertyValues( const css::uno::Sequence
<
171 css::beans::PropertyValue
>& aProps
) override
;
174 virtual OUString SAL_CALL
getImplementationName( ) override
;
175 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
176 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
180 class SvNumberFormatSettingsObj
: public cppu::WeakImplHelper
<
181 css::beans::XPropertySet
,
182 css::lang::XServiceInfo
>
185 rtl::Reference
<SvNumberFormatsSupplierObj
>
187 mutable ::comphelper::SharedMutex m_aMutex
;
190 SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj
& rParent
, const ::comphelper::SharedMutex
& _rMutex
);
191 virtual ~SvNumberFormatSettingsObj() override
;
195 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
196 SAL_CALL
getPropertySetInfo( ) override
;
197 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
198 const css::uno::Any
& aValue
) override
;
199 virtual css::uno::Any SAL_CALL
getPropertyValue(
200 const OUString
& PropertyName
) override
;
201 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
202 const css::uno::Reference
<
203 css::beans::XPropertyChangeListener
>& xListener
) override
;
204 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
205 const css::uno::Reference
<
206 css::beans::XPropertyChangeListener
>& aListener
) override
;
207 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
208 const css::uno::Reference
<
209 css::beans::XVetoableChangeListener
>& aListener
) override
;
210 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
211 const css::uno::Reference
<
212 css::beans::XVetoableChangeListener
>& aListener
) override
;
215 virtual OUString SAL_CALL
getImplementationName( ) override
;
216 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
217 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */