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_EDIT_HXX_ 25 #define _FORMS_EDIT_HXX_ 26 27 #include "EditBase.hxx" 28 29 #include <cppuhelper/implbase3.hxx> 30 31 namespace dbtools { class FormattedColumnValue; } 32 33 //......................................................................... 34 namespace frm 35 { 36 37 //================================================================== 38 //= OEditModel 39 //================================================================== 40 class OEditModel 41 :public OEditBaseModel 42 { 43 ::std::auto_ptr< ::dbtools::FormattedColumnValue > 44 m_pValueFormatter; 45 sal_Bool m_bMaxTextLenModified : 1; // set to <TRUE/> when we change the MaxTextLen of the aggregate 46 47 sal_Bool m_bWritingFormattedFake : 1; 48 // are we writing something which should be interpreted as formatted upon reading? 49 50 protected: 51 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 52 53 DECLARE_DEFAULT_LEAF_XTOR( OEditModel ); 54 enableFormattedWriteFake()55 void enableFormattedWriteFake() { m_bWritingFormattedFake = sal_True; } disableFormattedWriteFake()56 void disableFormattedWriteFake() { m_bWritingFormattedFake = sal_False; } lastReadWasFormattedFake() const57 sal_Bool lastReadWasFormattedFake() const { return (getLastReadVersion() & PF_FAKE_FORMATTED_FIELD) != 0; } 58 59 friend InterfaceRef SAL_CALL OEditModel_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); 60 friend class OFormattedFieldWrapper; 61 friend class OFormattedModel; // temporary 62 63 public: 64 virtual void SAL_CALL disposing(); 65 66 // XPropertySet 67 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 68 69 // XPersistObject 70 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); 71 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); 72 virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException); 73 74 // XPropertySet 75 using OBoundControlModel::getFastPropertyValue; 76 77 // XReset 78 virtual void SAL_CALL reset( ) throw(::com::sun::star::uno::RuntimeException); 79 80 // XServiceInfo 81 IMPLEMENTATION_NAME(OEditModel); 82 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(); 83 84 // OControlModel's property handling 85 virtual void describeFixedProperties( 86 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps 87 ) const; 88 virtual void describeAggregateProperties( 89 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps 90 ) const; 91 92 // XEventListener 93 using OBoundControlModel::disposing; 94 95 protected: 96 // OControlModel overridables 97 virtual void writeAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream ) const; 98 virtual void readAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream ); 99 100 // OBoundControlModel overridables 101 virtual ::com::sun::star::uno::Any 102 translateDbColumnToControlValue( ); 103 virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset ); 104 105 virtual ::com::sun::star::uno::Any 106 getDefaultForReset() const; 107 108 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ); 109 virtual void onDisconnectedDbColumn(); 110 111 virtual sal_Bool approveDbColumnType( sal_Int32 _nColumnType ); 112 113 virtual void resetNoBroadcast(); 114 115 protected: 116 virtual sal_uInt16 getPersistenceFlags() const; 117 118 DECLARE_XCLONEABLE(); 119 120 private: 121 bool implActsAsRichText( ) const; 122 }; 123 124 //================================================================== 125 //= OEditControl 126 //================================================================== 127 typedef ::cppu::ImplHelper3< ::com::sun::star::awt::XFocusListener, 128 ::com::sun::star::awt::XKeyListener, 129 ::com::sun::star::form::XChangeBroadcaster > OEditControl_BASE; 130 131 class OEditControl : public OBoundControl 132 ,public OEditControl_BASE 133 { 134 ::cppu::OInterfaceContainerHelper 135 m_aChangeListeners; 136 137 ::rtl::OUString m_aHtmlChangeValue; 138 sal_uInt32 m_nKeyEvent; 139 140 public: 141 OEditControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); 142 virtual ~OEditControl(); 143 144 DECLARE_UNO3_AGG_DEFAULTS(OEditControl, OBoundControl); 145 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException); 146 147 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 148 149 // OComponentHelper 150 virtual void SAL_CALL disposing(); 151 152 // ::com::sun::star::lang::XEventListener 153 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); 154 155 // ::com::sun::star::lang::XServiceInfo 156 IMPLEMENTATION_NAME(OEditControl); 157 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(); 158 159 // ::com::sun::star::form::XChangeBroadcaster 160 virtual void SAL_CALL addChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException); 161 virtual void SAL_CALL removeChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException); 162 163 // ::com::sun::star::awt::XFocusListener 164 virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw ( ::com::sun::star::uno::RuntimeException); 165 virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw ( ::com::sun::star::uno::RuntimeException); 166 167 // ::com::sun::star::awt::XKeyListener 168 virtual void SAL_CALL keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException); 169 virtual void SAL_CALL keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException); 170 171 // XControl 172 virtual void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& _rxToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& _rxParent ) throw ( ::com::sun::star::uno::RuntimeException ); 173 174 private: 175 DECL_LINK( OnKeyPressed, void* ); 176 }; 177 178 //......................................................................... 179 } 180 //......................................................................... 181 182 #endif // _FORMS_EDIT_HXX_ 183 184