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 0 : UnoControlFormattedFieldModel( const UnoControlFormattedFieldModel& rModel )
64 : : UnoControlModel(rModel)
65 : , m_bRevokedAsClient(false)
66 0 : , m_bSettingValueAndText(false)
67 : {
68 0 : }
69 :
70 0 : 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 0 : DECLIMPL_SERVICEINFO_DERIVED( UnoControlFormattedFieldModel, UnoControlModel, szServiceName2_UnoControlFormattedFieldModel )
81 :
82 : protected:
83 : virtual ~UnoControlFormattedFieldModel();
84 :
85 : // XComponent
86 : void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 :
88 : // XPropertySet
89 : 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;
90 :
91 : // UnoControlModel
92 : virtual void ImplNormalizePropertySequence(
93 : const sal_Int32 _nCount, /// the number of entries in the arrays
94 : sal_Int32* _pHandles, /// the handles of the properties to set
95 : ::com::sun::star::uno::Any* _pValues, /// the values of the properties to set
96 : sal_Int32* _pValidHandles /// pointer to the valid handles, allowed to be adjusted
97 : ) const SAL_THROW(()) SAL_OVERRIDE;
98 : private:
99 : void impl_updateTextFromValue_nothrow();
100 : void impl_updateCachedFormatter_nothrow();
101 : void impl_updateCachedFormatKey_nothrow();
102 : };
103 :
104 :
105 : // = UnoFormattedFieldControl
106 :
107 0 : class UnoFormattedFieldControl : public UnoSpinFieldControl
108 : {
109 : public:
110 : UnoFormattedFieldControl();
111 : OUString GetComponentServiceName() SAL_OVERRIDE;
112 :
113 : // ::com::sun::star::awt::XTextListener
114 : void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 :
116 : // ::com::sun::star::lang::XServiceInfo
117 0 : DECLIMPL_SERVICEINFO_DERIVED( UnoFormattedFieldControl, UnoEditControl, szServiceName2_UnoControlFormattedField )
118 : };
119 :
120 :
121 : } // namespace toolkit
122 :
123 :
124 : #endif // INCLUDED_TOOLKIT_CONTROLS_FORMATTEDCONTROL_HXX
125 :
126 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|