Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / forms / source / inc / limitedformats.hxx
blob5922fd6db8f10525a1e5c97c0b1822019a1fbd3f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_FORMS_SOURCE_INC_LIMITEDFORMATS_HXX
21 #define INCLUDED_FORMS_SOURCE_INC_LIMITEDFORMATS_HXX
23 #include <osl/mutex.hxx>
24 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <com/sun/star/beans/XFastPropertySet.hpp>
29 namespace frm
33 //= OLimitedFormats
35 /** maintains translation tables format key <-> enum value
36 <p>Used for controls which provide a limited number for (standard) formats, which
37 should be available as format keys.</p>
39 class OLimitedFormats
41 private:
42 static sal_Int32 s_nInstanceCount;
43 static ::osl::Mutex s_aMutex;
44 static css::uno::Reference< css::util::XNumberFormatsSupplier >
45 s_xStandardFormats;
47 protected:
48 sal_Int32 m_nFormatEnumPropertyHandle;
49 const sal_Int16 m_nTableId;
50 css::uno::Reference< css::beans::XFastPropertySet >
51 m_xAggregate;
53 protected:
54 /** ctor
55 <p>The class id is used to determine the translation table to use. All instances which
56 pass the same value here share one table.</p>
58 OLimitedFormats(
59 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
60 const sal_Int16 _nClassId
62 ~OLimitedFormats();
64 protected:
65 void setAggregateSet(
66 const css::uno::Reference< css::beans::XFastPropertySet >& _rxAggregate,
67 sal_Int32 _nOriginalPropertyHandle
70 protected:
71 void getFormatKeyPropertyValue( css::uno::Any& _rValue ) const;
72 bool convertFormatKeyPropertyValue(
73 css::uno::Any& _rConvertedValue,
74 css::uno::Any& _rOldValue,
75 const css::uno::Any& _rNewValue
77 void setFormatKeyPropertyValue( const css::uno::Any& _rNewValue );
78 // setFormatKeyPropertyValue should only be called with a value got from convertFormatKeyPropertyValue!
80 const css::uno::Reference< css::util::XNumberFormatsSupplier >&
81 getFormatsSupplier() const { return s_xStandardFormats; }
83 private:
84 void acquireSupplier(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
85 void releaseSupplier();
87 static void ensureTableInitialized(const sal_Int16 _nTableId);
88 static void clearTable(const sal_Int16 _nTableId);
92 } // namespace frm
95 #endif // INCLUDED_FORMS_SOURCE_INC_LIMITEDFORMATS_HXX
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */