1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _FORMS_LIMITED_FORMATS_HXX_ 29 #define _FORMS_LIMITED_FORMATS_HXX_ 30 31 #include <osl/mutex.hxx> 32 #include <com/sun/star/util/XNumberFormatsSupplier.hpp> 33 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 34 #include <com/sun/star/beans/XFastPropertySet.hpp> 35 36 //......................................................................... 37 namespace frm 38 { 39 //......................................................................... 40 41 //===================================================================== 42 //= OLimitedFormats 43 //===================================================================== 44 /** maintains translation tables format key <-> enum value 45 <p>Used for controls which provide a limited number for (standard) formats, which 46 should be available as format keys.</p> 47 */ 48 class OLimitedFormats 49 { 50 private: 51 static sal_Int32 s_nInstanceCount; 52 static ::osl::Mutex s_aMutex; 53 static ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > 54 s_xStandardFormats; 55 56 protected: 57 sal_Int32 m_nFormatEnumPropertyHandle; 58 const sal_Int16 m_nTableId; 59 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > 60 m_xAggregate; 61 62 protected: 63 /** ctor 64 <p>The class id is used to determine the translation table to use. All instances which 65 pass the same value here share one table.</p> 66 */ 67 OLimitedFormats( 68 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 69 const sal_Int16 _nClassId 70 ); 71 ~OLimitedFormats(); 72 73 protected: 74 void setAggregateSet( 75 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet >& _rxAggregate, 76 sal_Int32 _nOriginalPropertyHandle 77 ); 78 79 protected: 80 void getFormatKeyPropertyValue( ::com::sun::star::uno::Any& _rValue ) const; 81 sal_Bool convertFormatKeyPropertyValue( 82 ::com::sun::star::uno::Any& _rConvertedValue, 83 ::com::sun::star::uno::Any& _rOldValue, 84 const ::com::sun::star::uno::Any& _rNewValue 85 ); 86 void setFormatKeyPropertyValue( const ::com::sun::star::uno::Any& _rNewValue ); 87 // setFormatKeyPropertyValue should only be called with a value got from convertFormatKeyPropertyValue! 88 89 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > 90 getFormatsSupplier() const { return s_xStandardFormats; } 91 92 private: 93 void acquireSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); 94 void releaseSupplier(); 95 96 static void ensureTableInitialized(const sal_Int16 _nTableId); 97 static void clearTable(const sal_Int16 _nTableId); 98 }; 99 100 //......................................................................... 101 } // namespace frm 102 //......................................................................... 103 104 #endif // _FORMS_LIMITED_FORMATS_HXX_ 105 106