merge the formfield patch from ooo-build
[ooovba.git] / forms / source / component / FormattedField.hxx
blob43716ca1fb0d2220c6a004aa1a7ae69e5591db9f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FormattedField.hxx,v $
10 * $Revision: 1.20 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FORMS_FORMATTEDFIELD_HXX_
32 #define _FORMS_FORMATTEDFIELD_HXX_
34 #include "EditBase.hxx"
35 #include <comphelper/propmultiplex.hxx>
36 #include <cppuhelper/implbase1.hxx>
37 #include "errorbroadcaster.hxx"
39 //.........................................................................
40 namespace frm
43 //==================================================================
44 //= OFormattedModel
45 //==================================================================
47 class OFormattedModel
48 :public OEditBaseModel
49 ,public OErrorBroadcaster
51 // das Original, falls ich die Format-Properties meines aggregierten Models gefaket, d.h. von dem Feld, an das
52 // ich gebunden bin, weitergereicht habe (nur gueltig wenn loaded)
53 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> m_xOriginalFormatter;
54 ::com::sun::star::util::Date m_aNullDate;
55 ::com::sun::star::uno::Any m_aSaveValue;
57 sal_Int32 m_nFieldType;
58 sal_Int16 m_nKeyType;
59 sal_Bool m_bOriginalNumeric : 1,
60 m_bNumeric : 1; // analog fuer TreatAsNumeric-Property
62 protected:
63 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcDefaultFormatsSupplier() const;
64 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcFormFormatsSupplier() const;
65 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcFormatsSupplier() const;
67 DECLARE_DEFAULT_LEAF_XTOR( OFormattedModel );
69 friend class OFormattedFieldWrapper;
71 protected:
72 // XInterface
73 DECLARE_UNO3_AGG_DEFAULTS( OFormattedModel, OEditBaseModel );
75 // XTypeProvider
76 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
78 // XAggregation
79 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
81 // OComponentHelper
82 virtual void SAL_CALL disposing();
84 // XServiceInfo
85 IMPLEMENTATION_NAME(OFormattedModel);
86 virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
88 // XPersistObject
89 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);
90 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);
91 virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
93 // XPropertySet
94 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
95 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
96 sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
97 throw(::com::sun::star::lang::IllegalArgumentException);
98 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception);
100 // XLoadListener
101 virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw ( ::com::sun::star::uno::RuntimeException);
103 // XPropertyState
104 void setPropertyToDefaultByHandle(sal_Int32 nHandle);
105 ::com::sun::star::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const;
107 void SAL_CALL setPropertyToDefault(const ::rtl::OUString& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
108 ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
110 // OControlModel's property handling
111 virtual void describeFixedProperties(
112 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
113 ) const;
114 virtual void describeAggregateProperties(
115 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
116 ) const;
118 // XPropertyChangeListener
119 virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
121 // prevent method hiding
122 using OEditBaseModel::disposing;
123 using OEditBaseModel::getFastPropertyValue;
125 protected:
126 virtual sal_uInt16 getPersistenceFlags() const;
127 // as we have an own version handling for persistence
129 // OBoundControlModel overridables
130 virtual ::com::sun::star::uno::Any
131 translateDbColumnToControlValue( );
132 virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset );
134 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
135 getSupportedBindingTypes();
136 virtual ::com::sun::star::uno::Any
137 translateExternalValueToControlValue( const ::com::sun::star::uno::Any& _rExternalValue ) const;
138 virtual ::com::sun::star::uno::Any
139 translateControlValueToExternalValue( ) const;
140 virtual void onConnectedExternalValue( );
142 virtual ::com::sun::star::uno::Any
143 getDefaultForReset() const;
145 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
146 virtual void onDisconnectedDbColumn();
148 private:
149 DECLARE_XCLONEABLE();
151 void implConstruct();
153 void updateFormatterNullDate();
156 //==================================================================
157 //= OFormattedControl
158 //==================================================================
159 typedef ::cppu::ImplHelper1< ::com::sun::star::awt::XKeyListener> OFormattedControl_BASE;
160 class OFormattedControl : public OBoundControl
161 ,public OFormattedControl_BASE
163 sal_uInt32 m_nKeyEvent;
165 public:
166 OFormattedControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
167 virtual ~OFormattedControl();
169 DECLARE_UNO3_AGG_DEFAULTS(OFormattedControl, OBoundControl);
170 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
172 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
174 // ::com::sun::star::lang::XServiceInfo
175 IMPLEMENTATION_NAME(OFormattedControl);
176 virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
178 // ::com::sun::star::lang::XEventListener
179 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
181 // ::com::sun::star::awt::XKeyListener
182 virtual void SAL_CALL keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
183 virtual void SAL_CALL keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
185 // ::com::sun::star::awt::XControl
186 virtual void SAL_CALL setDesignMode(sal_Bool bOn) throw ( ::com::sun::star::uno::RuntimeException);
188 // disambiguation
189 using OBoundControl::disposing;
191 private:
192 DECL_LINK( OnKeyPressed, void* );
195 //.........................................................................
197 //.........................................................................
199 #endif // _FORMS_FORMATTEDFIELD_HXX_