bump product version to 5.0.4.1
[LibreOffice.git] / forms / source / component / FormattedField.hxx
blob424f0dbc27a0ec13c0f1cd7602f91d8ca4da3bc2
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_COMPONENT_FORMATTEDFIELD_HXX
21 #define INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELD_HXX
23 #include "EditBase.hxx"
24 #include <tools/link.hxx>
25 #include <comphelper/propmultiplex.hxx>
26 #include <cppuhelper/implbase1.hxx>
27 #include "errorbroadcaster.hxx"
29 struct ImplSVEvent;
31 namespace frm
33 class OFormattedModel
34 :public OEditBaseModel
35 ,public OErrorBroadcaster
37 // the original, in case I faked the format properties of my aggregated model,
38 // i.e. I just passed on the attributes of the field to which I am bound
39 // (only valid if loaded)
41 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> m_xOriginalFormatter;
42 ::com::sun::star::util::Date m_aNullDate;
43 ::com::sun::star::uno::Any m_aSaveValue;
45 sal_Int32 m_nFieldType;
46 sal_Int16 m_nKeyType;
47 bool m_bOriginalNumeric : 1,
48 m_bNumeric : 1; // analogous for the TreatAsNumeric-property
50 protected:
51 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcDefaultFormatsSupplier() const;
52 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcFormFormatsSupplier() const;
53 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcFormatsSupplier() const;
55 DECLARE_DEFAULT_LEAF_XTOR( OFormattedModel );
57 friend class OFormattedFieldWrapper;
59 protected:
60 // XInterface
61 DECLARE_UNO3_AGG_DEFAULTS( OFormattedModel, OEditBaseModel )
63 // XTypeProvider
64 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
66 // XAggregation
67 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
69 // OComponentHelper
70 virtual void SAL_CALL disposing() SAL_OVERRIDE;
72 // XServiceInfo
73 OUString SAL_CALL getImplementationName()
74 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
75 { return OUString("com.sun.star.form.OFormattedModel"); }
77 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
79 // XPersistObject
80 virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
81 virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
82 virtual OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
84 // XPropertySet
85 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
86 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
87 sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
88 throw(::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
89 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
91 // XLoadListener
92 virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 // XPropertyState
95 void setPropertyToDefaultByHandle(sal_Int32 nHandle) SAL_OVERRIDE;
96 ::com::sun::star::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const SAL_OVERRIDE;
98 void SAL_CALL setPropertyToDefault(const OUString& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 // OControlModel's property handling
102 virtual void describeFixedProperties(
103 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
104 ) const SAL_OVERRIDE;
105 virtual void describeAggregateProperties(
106 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
107 ) const SAL_OVERRIDE;
109 // XPropertyChangeListener
110 virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
112 // prevent method hiding
113 using OEditBaseModel::disposing;
114 using OEditBaseModel::getFastPropertyValue;
116 protected:
117 virtual sal_uInt16 getPersistenceFlags() const SAL_OVERRIDE;
118 // as we have an own version handling for persistence
120 // OBoundControlModel overridables
121 virtual ::com::sun::star::uno::Any
122 translateDbColumnToControlValue( ) SAL_OVERRIDE;
123 virtual bool commitControlValueToDbColumn( bool _bPostReset ) SAL_OVERRIDE;
125 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
126 getSupportedBindingTypes() SAL_OVERRIDE;
127 virtual ::com::sun::star::uno::Any
128 translateExternalValueToControlValue( const ::com::sun::star::uno::Any& _rExternalValue ) const SAL_OVERRIDE;
129 virtual ::com::sun::star::uno::Any
130 translateControlValueToExternalValue( ) const SAL_OVERRIDE;
131 virtual void onConnectedExternalValue( ) SAL_OVERRIDE;
133 virtual ::com::sun::star::uno::Any
134 getDefaultForReset() const SAL_OVERRIDE;
135 virtual void resetNoBroadcast() SAL_OVERRIDE;
137 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ) SAL_OVERRIDE;
138 virtual void onDisconnectedDbColumn() SAL_OVERRIDE;
140 private:
141 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 void implConstruct();
145 void updateFormatterNullDate();
148 typedef ::cppu::ImplHelper1< ::com::sun::star::awt::XKeyListener> OFormattedControl_BASE;
149 class OFormattedControl : public OBoundControl
150 ,public OFormattedControl_BASE
152 ImplSVEvent * m_nKeyEvent;
154 public:
155 OFormattedControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
156 virtual ~OFormattedControl();
158 DECLARE_UNO3_AGG_DEFAULTS(OFormattedControl, OBoundControl)
159 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
163 // ::com::sun::star::lang::XServiceInfo
164 OUString SAL_CALL getImplementationName()
165 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
166 { return OUString("com.sun.star.form.OFormattedControl"); }
168 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
170 // ::com::sun::star::lang::XEventListener
171 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 // ::com::sun::star::awt::XKeyListener
174 virtual void SAL_CALL keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
175 virtual void SAL_CALL keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 // ::com::sun::star::awt::XControl
178 virtual void SAL_CALL setDesignMode(sal_Bool bOn) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 // disambiguation
181 using OBoundControl::disposing;
183 private:
184 DECL_LINK( OnKeyPressed, void* );
187 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELD_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */