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