Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_TOOLKIT_CONTROLS_FORMATTEDCONTROL_HXX
21 : #define INCLUDED_TOOLKIT_CONTROLS_FORMATTEDCONTROL_HXX
22 :
23 : #include <toolkit/controls/unocontrols.hxx>
24 : #include <toolkit/controls/unocontrolmodel.hxx>
25 : #include <toolkit/helper/servicenames.hxx>
26 :
27 : #include <com/sun/star/util/XNumberFormatter.hpp>
28 :
29 :
30 : namespace toolkit
31 : {
32 :
33 :
34 :
35 : // = UnoControlFormattedFieldModel
36 :
37 : class UnoControlFormattedFieldModel : public UnoControlModel
38 : {
39 : protected:
40 : ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const SAL_OVERRIDE;
41 : ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
42 : ::com::sun::star::uno::Any m_aCachedFormat;
43 : bool m_bRevokedAsClient;
44 : bool m_bSettingValueAndText;
45 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >
46 : m_xCachedFormatter;
47 :
48 : protected:
49 : sal_Bool SAL_CALL convertFastPropertyValue(
50 : ::com::sun::star::uno::Any& rConvertedValue,
51 : ::com::sun::star::uno::Any& rOldValue,
52 : sal_Int32 nPropId,
53 : const ::com::sun::star::uno::Any& rValue
54 : ) throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
55 :
56 : void SAL_CALL setFastPropertyValue_NoBroadcast(
57 : sal_Int32 nHandle,
58 : const ::com::sun::star::uno::Any& rValue
59 : ) throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
60 :
61 : public:
62 : UnoControlFormattedFieldModel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
63 1 : UnoControlFormattedFieldModel( const UnoControlFormattedFieldModel& rModel )
64 : : UnoControlModel(rModel)
65 : , m_bRevokedAsClient(false)
66 1 : , m_bSettingValueAndText(false)
67 : {
68 1 : }
69 :
70 1 : UnoControlModel* Clone() const SAL_OVERRIDE { return new UnoControlFormattedFieldModel( *this ); }
71 :
72 : // ::com::sun::star::io::XPersistObject
73 : OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 :
75 : // ::com::sun::star::beans::XMultiPropertySet
76 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 :
78 :
79 : // ::com::sun::star::lang::XServiceInfo
80 : OUString SAL_CALL getImplementationName()
81 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
82 :
83 : css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
84 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 :
86 : protected:
87 : virtual ~UnoControlFormattedFieldModel();
88 :
89 : // XComponent
90 : void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 :
92 : // XPropertySet
93 : void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& PropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 :
95 : // UnoControlModel
96 : virtual void ImplNormalizePropertySequence(
97 : const sal_Int32 _nCount, /// the number of entries in the arrays
98 : sal_Int32* _pHandles, /// the handles of the properties to set
99 : ::com::sun::star::uno::Any* _pValues, /// the values of the properties to set
100 : sal_Int32* _pValidHandles /// pointer to the valid handles, allowed to be adjusted
101 : ) const SAL_OVERRIDE;
102 : private:
103 : void impl_updateTextFromValue_nothrow();
104 : void impl_updateCachedFormatter_nothrow();
105 : void impl_updateCachedFormatKey_nothrow();
106 : };
107 :
108 :
109 : // = UnoFormattedFieldControl
110 :
111 6 : class UnoFormattedFieldControl : public UnoSpinFieldControl
112 : {
113 : public:
114 : UnoFormattedFieldControl();
115 : OUString GetComponentServiceName() SAL_OVERRIDE;
116 :
117 : // ::com::sun::star::awt::XTextListener
118 : void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 :
120 : // ::com::sun::star::lang::XServiceInfo
121 : OUString SAL_CALL getImplementationName()
122 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 :
124 : css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
125 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : };
127 :
128 :
129 : } // namespace toolkit
130 :
131 :
132 : #endif // INCLUDED_TOOLKIT_CONTROLS_FORMATTEDCONTROL_HXX
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|