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 _I18N_NUMBERFORMATCODE_HXX_ 25 #define _I18N_NUMBERFORMATCODE_HXX_ 26 27 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28 #include <comphelper/processfactory.hxx> 29 #include <cppuhelper/implbase2.hxx> // helper for implementations 30 31 #include <com/sun/star/i18n/XNumberFormatCode.hpp> 32 #include <com/sun/star/i18n/XLocaleData.hpp> 33 #include <com/sun/star/uno/Sequence.hxx> 34 #include <com/sun/star/lang/XServiceInfo.hpp> 35 36 class NumberFormatCodeMapper : public cppu::WeakImplHelper2 37 < 38 ::com::sun::star::i18n::XNumberFormatCode, 39 ::com::sun::star::lang::XServiceInfo 40 > 41 { 42 public: 43 NumberFormatCodeMapper( const ::com::sun::star::uno::Reference < 44 ::com::sun::star::lang::XMultiServiceFactory >& rxMSF ); 45 ~NumberFormatCodeMapper(); 46 47 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); 48 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); 49 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); 50 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); 51 52 //XServiceInfo 53 virtual rtl::OUString SAL_CALL getImplementationName(void) 54 throw( ::com::sun::star::uno::RuntimeException ); 55 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) 56 throw( ::com::sun::star::uno::RuntimeException ); 57 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) 58 throw( ::com::sun::star::uno::RuntimeException ); 59 60 private: 61 ::com::sun::star::lang::Locale aLocale; 62 ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > xMSF; 63 ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::FormatElement > aFormatSeq; 64 ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XLocaleData > xlocaleData; 65 sal_Bool bFormatsValid; 66 67 void setupLocale( const ::com::sun::star::lang::Locale& rLocale ); 68 void getFormats( const ::com::sun::star::lang::Locale& rLocale ); 69 ::rtl::OUString mapElementTypeShortToString(sal_Int16 formatType); 70 sal_Int16 mapElementTypeStringToShort(const ::rtl::OUString& formatType); 71 ::rtl::OUString mapElementUsageShortToString(sal_Int16 formatUsage); 72 sal_Int16 mapElementUsageStringToShort(const ::rtl::OUString& formatUsage); 73 void createLocaleDataObject(); 74 }; 75 76 77 #endif // _I18N_NUMBERFORMATCODE_HXX_ 78