1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _FORMS_FORMATTEDFIELD_HXX_ 25 #define _FORMS_FORMATTEDFIELD_HXX_ 26 27 #include "EditBase.hxx" 28 #include <comphelper/propmultiplex.hxx> 29 #include <cppuhelper/implbase1.hxx> 30 #include "errorbroadcaster.hxx" 31 32 //......................................................................... 33 namespace frm 34 { 35 36 //================================================================== 37 //= OFormattedModel 38 //================================================================== 39 40 class OFormattedModel 41 :public OEditBaseModel 42 ,public OErrorBroadcaster 43 { 44 // das Original, falls ich die Format-Properties meines aggregierten Models gefaket, d.h. von dem Feld, an das 45 // ich gebunden bin, weitergereicht habe (nur gueltig wenn loaded) 46 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> m_xOriginalFormatter; 47 ::com::sun::star::util::Date m_aNullDate; 48 ::com::sun::star::uno::Any m_aSaveValue; 49 50 sal_Int32 m_nFieldType; 51 sal_Int16 m_nKeyType; 52 sal_Bool m_bOriginalNumeric : 1, 53 m_bNumeric : 1; // analog fuer TreatAsNumeric-Property 54 55 protected: 56 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcDefaultFormatsSupplier() const; 57 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcFormFormatsSupplier() const; 58 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> calcFormatsSupplier() const; 59 60 DECLARE_DEFAULT_LEAF_XTOR( OFormattedModel ); 61 62 friend class OFormattedFieldWrapper; 63 64 protected: 65 // XInterface 66 DECLARE_UNO3_AGG_DEFAULTS( OFormattedModel, OEditBaseModel ); 67 68 // XTypeProvider 69 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 70 71 // XAggregation 72 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException); 73 74 // OComponentHelper 75 virtual void SAL_CALL disposing(); 76 77 // XServiceInfo 78 IMPLEMENTATION_NAME(OFormattedModel); 79 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(); 80 81 // XPersistObject 82 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); 83 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); 84 virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException); 85 86 // XPropertySet 87 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 88 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue, 89 sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) 90 throw(::com::sun::star::lang::IllegalArgumentException); 91 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception); 92 93 // XLoadListener 94 virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw ( ::com::sun::star::uno::RuntimeException); 95 96 // XPropertyState 97 void setPropertyToDefaultByHandle(sal_Int32 nHandle); 98 ::com::sun::star::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const; 99 100 void SAL_CALL setPropertyToDefault(const ::rtl::OUString& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 101 ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 102 103 // OControlModel's property handling 104 virtual void describeFixedProperties( 105 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps 106 ) const; 107 virtual void describeAggregateProperties( 108 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps 109 ) const; 110 111 // XPropertyChangeListener 112 virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException); 113 114 // prevent method hiding 115 using OEditBaseModel::disposing; 116 using OEditBaseModel::getFastPropertyValue; 117 118 protected: 119 virtual sal_uInt16 getPersistenceFlags() const; 120 // as we have an own version handling for persistence 121 122 // OBoundControlModel overridables 123 virtual ::com::sun::star::uno::Any 124 translateDbColumnToControlValue( ); 125 virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset ); 126 127 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > 128 getSupportedBindingTypes(); 129 virtual ::com::sun::star::uno::Any 130 translateExternalValueToControlValue( const ::com::sun::star::uno::Any& _rExternalValue ) const; 131 virtual ::com::sun::star::uno::Any 132 translateControlValueToExternalValue( ) const; 133 virtual void onConnectedExternalValue( ); 134 135 virtual ::com::sun::star::uno::Any 136 getDefaultForReset() const; 137 virtual void resetNoBroadcast(); 138 139 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ); 140 virtual void onDisconnectedDbColumn(); 141 142 private: 143 DECLARE_XCLONEABLE(); 144 145 void implConstruct(); 146 147 void updateFormatterNullDate(); 148 }; 149 150 //================================================================== 151 //= OFormattedControl 152 //================================================================== 153 typedef ::cppu::ImplHelper1< ::com::sun::star::awt::XKeyListener> OFormattedControl_BASE; 154 class OFormattedControl : public OBoundControl 155 ,public OFormattedControl_BASE 156 { 157 sal_uInt32 m_nKeyEvent; 158 159 public: 160 OFormattedControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); 161 virtual ~OFormattedControl(); 162 163 DECLARE_UNO3_AGG_DEFAULTS(OFormattedControl, OBoundControl); 164 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException); 165 166 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 167 168 // ::com::sun::star::lang::XServiceInfo 169 IMPLEMENTATION_NAME(OFormattedControl); 170 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(); 171 172 // ::com::sun::star::lang::XEventListener 173 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); 174 175 // ::com::sun::star::awt::XKeyListener 176 virtual void SAL_CALL keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException); 177 virtual void SAL_CALL keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException); 178 179 // ::com::sun::star::awt::XControl 180 virtual void SAL_CALL setDesignMode(sal_Bool bOn) throw ( ::com::sun::star::uno::RuntimeException); 181 182 // disambiguation 183 using OBoundControl::disposing; 184 185 private: 186 DECL_LINK( OnKeyPressed, void* ); 187 }; 188 189 //......................................................................... 190 } 191 //......................................................................... 192 193 #endif // _FORMS_FORMATTEDFIELD_HXX_ 194 195