1*f7bd9df4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f7bd9df4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f7bd9df4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f7bd9df4SAndrew Rist  * distributed with this work for additional information
6*f7bd9df4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f7bd9df4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f7bd9df4SAndrew Rist  * "License"); you may not use this file except in compliance
9*f7bd9df4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f7bd9df4SAndrew Rist  *
11*f7bd9df4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f7bd9df4SAndrew Rist  *
13*f7bd9df4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f7bd9df4SAndrew Rist  * software distributed under the License is distributed on an
15*f7bd9df4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f7bd9df4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f7bd9df4SAndrew Rist  * specific language governing permissions and limitations
18*f7bd9df4SAndrew Rist  * under the License.
19*f7bd9df4SAndrew Rist  *
20*f7bd9df4SAndrew Rist  *************************************************************/
21*f7bd9df4SAndrew Rist 
22*f7bd9df4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _I18N_NUMBERFORMATCODE_HXX_
25cdf0e10cSrcweir #define _I18N_NUMBERFORMATCODE_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
29cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> // helper for implementations
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/i18n/XNumberFormatCode.hpp>
32cdf0e10cSrcweir #include <com/sun/star/i18n/XLocaleData.hpp>
33cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
34cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class NumberFormatCodeMapper : public cppu::WeakImplHelper2
37cdf0e10cSrcweir <
38cdf0e10cSrcweir 	::com::sun::star::i18n::XNumberFormatCode,
39cdf0e10cSrcweir 	::com::sun::star::lang::XServiceInfo
40cdf0e10cSrcweir >
41cdf0e10cSrcweir {
42cdf0e10cSrcweir public:
43cdf0e10cSrcweir 	NumberFormatCodeMapper( const ::com::sun::star::uno::Reference <
44cdf0e10cSrcweir 					::com::sun::star::lang::XMultiServiceFactory >& rxMSF );
45cdf0e10cSrcweir 	~NumberFormatCodeMapper();
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     virtual ::com::sun::star::i18n::NumberFormatCode SAL_CALL getDefault( sal_Int16 nFormatType, sal_Int16 nFormatUsage, const ::com::sun::star::lang::Locale& rLocale ) throw(::com::sun::star::uno::RuntimeException);
48cdf0e10cSrcweir     virtual ::com::sun::star::i18n::NumberFormatCode SAL_CALL getFormatCode( sal_Int16 nFormatIndex, const ::com::sun::star::lang::Locale& rLocale ) throw(::com::sun::star::uno::RuntimeException);
49cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > SAL_CALL getAllFormatCode( sal_Int16 nFormatUsage, const ::com::sun::star::lang::Locale& rLocale ) throw(::com::sun::star::uno::RuntimeException);
50cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > SAL_CALL getAllFormatCodes( const ::com::sun::star::lang::Locale& rLocale ) throw(::com::sun::star::uno::RuntimeException);
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     //XServiceInfo
53cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getImplementationName(void)
54cdf0e10cSrcweir                 throw( ::com::sun::star::uno::RuntimeException );
55cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
56cdf0e10cSrcweir                 throw( ::com::sun::star::uno::RuntimeException );
57cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
58cdf0e10cSrcweir                 throw( ::com::sun::star::uno::RuntimeException );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir private:
61cdf0e10cSrcweir 	::com::sun::star::lang::Locale aLocale;
62cdf0e10cSrcweir 	::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > xMSF;
63cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::i18n::FormatElement > aFormatSeq;
64cdf0e10cSrcweir 	::com::sun::star::uno::Reference < ::com::sun::star::i18n::XLocaleData > xlocaleData;
65cdf0e10cSrcweir 	sal_Bool bFormatsValid;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	void setupLocale( const ::com::sun::star::lang::Locale& rLocale );
68cdf0e10cSrcweir 	void getFormats( const ::com::sun::star::lang::Locale& rLocale );
69cdf0e10cSrcweir 	::rtl::OUString mapElementTypeShortToString(sal_Int16 formatType);
70cdf0e10cSrcweir 	sal_Int16 mapElementTypeStringToShort(const ::rtl::OUString& formatType);
71cdf0e10cSrcweir 	::rtl::OUString mapElementUsageShortToString(sal_Int16 formatUsage);
72cdf0e10cSrcweir 	sal_Int16 mapElementUsageStringToShort(const ::rtl::OUString& formatUsage);
73cdf0e10cSrcweir 	void createLocaleDataObject();
74cdf0e10cSrcweir };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir #endif // _I18N_NUMBERFORMATCODE_HXX_
78