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_COMBOBOX_HXX_ 25 #define _FORMS_COMBOBOX_HXX_ 26 27 #include "FormComponent.hxx" 28 #include "errorbroadcaster.hxx" 29 #include "entrylisthelper.hxx" 30 #include "cachedrowset.hxx" 31 32 /** === begin UNO includes === **/ 33 #include <com/sun/star/util/XNumberFormatter.hpp> 34 #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> 35 #include <com/sun/star/form/ListSourceType.hpp> 36 #include <com/sun/star/awt/XItemListener.hpp> 37 #include <com/sun/star/awt/XFocusListener.hpp> 38 /** === end UNO includes === **/ 39 40 #include <connectivity/formattedcolumnvalue.hxx> 41 42 #include <cppuhelper/interfacecontainer.hxx> 43 44 #include <vcl/timer.hxx> 45 46 #include <tools/date.hxx> 47 48 //......................................................................... 49 namespace frm 50 { 51 52 //================================================================== 53 // OComboBoxModel 54 //================================================================== 55 class OComboBoxModel 56 :public OBoundControlModel 57 ,public OEntryListHelper 58 ,public OErrorBroadcaster 59 { 60 CachedRowSet m_aListRowSet; // the row set to fill the list 61 ::com::sun::star::uno::Any m_aBoundColumn; // obsolet 62 ::rtl::OUString m_aListSource; // 63 ::rtl::OUString m_aDefaultText; // DefaultText 64 ::com::sun::star::uno::Any m_aLastKnownValue; 65 66 StringSequence m_aDesignModeStringItems; 67 // upon loading, in some cases we reset fill our string item list ourself. We don't want 68 // to lose the user's items then, so we remember them here. 69 70 71 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter> m_xFormatter; 72 73 ::com::sun::star::form::ListSourceType m_eListSourceType; // type der list source 74 sal_Bool m_bEmptyIsNull; // LeerString wird als NULL interpretiert 75 76 ::std::auto_ptr< ::dbtools::FormattedColumnValue > 77 m_pValueFormatter; 78 79 80 81 protected: 82 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 83 84 public: 85 DECLARE_DEFAULT_LEAF_XTOR( OComboBoxModel ); 86 87 virtual void SAL_CALL disposing(); 88 89 // OPropertySetHelper 90 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const; 91 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) 92 throw (::com::sun::star::uno::Exception); 93 virtual sal_Bool SAL_CALL convertFastPropertyValue( 94 ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) 95 throw (::com::sun::star::lang::IllegalArgumentException); 96 97 // XLoadListener 98 virtual void SAL_CALL reloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); 99 100 // XServiceInfo 101 IMPLEMENTATION_NAME(OComboBoxModel); 102 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); 103 104 // UNO 105 DECLARE_UNO3_AGG_DEFAULTS(OComboBoxModel, OBoundControlModel); 106 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); 107 108 // XPersistObject 109 virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); 110 virtual void SAL_CALL 111 write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 112 virtual void SAL_CALL 113 read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 114 115 // OControlModel's property handling 116 virtual void describeFixedProperties( 117 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps 118 ) const; 119 virtual void describeAggregateProperties( 120 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps 121 ) const; 122 123 // XEventListener 124 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException); 125 126 // prevent method hiding 127 using OBoundControlModel::getFastPropertyValue; 128 129 protected: 130 // OBoundControlModel overridables 131 virtual ::com::sun::star::uno::Any 132 translateDbColumnToControlValue( ); 133 virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset ); 134 135 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ); 136 virtual void onDisconnectedDbColumn(); 137 138 virtual ::com::sun::star::uno::Any 139 getDefaultForReset() const; 140 141 virtual void resetNoBroadcast(); 142 143 // OEntryListHelper overriables 144 virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ); 145 virtual void connectedExternalListSource( ); 146 virtual void disconnectedExternalListSource( ); 147 virtual void refreshInternalEntryList(); 148 149 protected: 150 void loadData( bool _bForce ); 151 152 DECLARE_XCLONEABLE(); 153 }; 154 155 //================================================================== 156 // OComboBoxControl 157 //================================================================== 158 159 class OComboBoxControl : public OBoundControl 160 { 161 public: 162 OComboBoxControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); 163 164 // XServiceInfo 165 IMPLEMENTATION_NAME(OComboBoxControl); 166 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); 167 }; 168 169 //......................................................................... 170 } 171 //......................................................................... 172 173 #endif // _FORMS_COMBOBOX_HXX_ 174 175