masterfix DEV300: #i10000# build fix
[LibreOffice.git] / forms / source / inc / limitedformats.hxx
blobfee3221ce17fe33c85fc1232a6d0b0b5baa8f334
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _FORMS_LIMITED_FORMATS_HXX_
29 #define _FORMS_LIMITED_FORMATS_HXX_
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>
36 //.........................................................................
37 namespace frm
39 //.........................................................................
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>
48 class OLimitedFormats
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;
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;
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>
67 OLimitedFormats(
68 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
69 const sal_Int16 _nClassId
71 ~OLimitedFormats();
73 protected:
74 void setAggregateSet(
75 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet >& _rxAggregate,
76 sal_Int32 _nOriginalPropertyHandle
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
86 void setFormatKeyPropertyValue( const ::com::sun::star::uno::Any& _rNewValue );
87 // setFormatKeyPropertyValue should only be called with a value got from convertFormatKeyPropertyValue!
89 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
90 getFormatsSupplier() const { return s_xStandardFormats; }
92 private:
93 void acquireSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
94 void releaseSupplier();
96 static void ensureTableInitialized(const sal_Int16 _nTableId);
97 static void clearTable(const sal_Int16 _nTableId);
100 //.........................................................................
101 } // namespace frm
102 //.........................................................................
104 #endif // _FORMS_LIMITED_FORMATS_HXX_