1*2d785d7eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2d785d7eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2d785d7eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2d785d7eSAndrew Rist * distributed with this work for additional information 6*2d785d7eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2d785d7eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2d785d7eSAndrew Rist * "License"); you may not use this file except in compliance 9*2d785d7eSAndrew Rist * with the License. You may obtain a copy of the License at 10*2d785d7eSAndrew Rist * 11*2d785d7eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2d785d7eSAndrew Rist * 13*2d785d7eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2d785d7eSAndrew Rist * software distributed under the License is distributed on an 15*2d785d7eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2d785d7eSAndrew Rist * KIND, either express or implied. See the License for the 17*2d785d7eSAndrew Rist * specific language governing permissions and limitations 18*2d785d7eSAndrew Rist * under the License. 19*2d785d7eSAndrew Rist * 20*2d785d7eSAndrew Rist *************************************************************/ 21*2d785d7eSAndrew Rist 22*2d785d7eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef FORMS_ENTRYLISTHELPER_HXX 25cdf0e10cSrcweir #define FORMS_ENTRYLISTHELPER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir /** === begin UNO includes === **/ 28cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntrySink.hpp> 29cdf0e10cSrcweir #include <com/sun/star/util/XRefreshable.hpp> 30cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntryListener.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 32cdf0e10cSrcweir /** === end UNO includes === **/ 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 35cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir //......................................................................... 38cdf0e10cSrcweir namespace frm 39cdf0e10cSrcweir { 40cdf0e10cSrcweir //......................................................................... 41cdf0e10cSrcweir 42cdf0e10cSrcweir class OControlModel; 43cdf0e10cSrcweir class ControlModelLock; 44cdf0e10cSrcweir 45cdf0e10cSrcweir //===================================================================== 46cdf0e10cSrcweir //= OEntryListHelper 47cdf0e10cSrcweir //===================================================================== 48cdf0e10cSrcweir typedef ::cppu::ImplHelper3 < ::com::sun::star::form::binding::XListEntrySink 49cdf0e10cSrcweir , ::com::sun::star::form::binding::XListEntryListener 50cdf0e10cSrcweir , ::com::sun::star::util::XRefreshable 51cdf0e10cSrcweir > OEntryListHelper_BASE; 52cdf0e10cSrcweir 53cdf0e10cSrcweir class OEntryListHelper : public OEntryListHelper_BASE 54cdf0e10cSrcweir { 55cdf0e10cSrcweir private: 56cdf0e10cSrcweir OControlModel& m_rControlModel; 57cdf0e10cSrcweir 58cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource > 59cdf0e10cSrcweir m_xListSource; /// our external list source 60cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > 61cdf0e10cSrcweir m_aStringItems; /// "overridden" StringItemList property value 62cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper 63cdf0e10cSrcweir m_aRefreshListeners; 64cdf0e10cSrcweir 65cdf0e10cSrcweir 66cdf0e10cSrcweir protected: 67cdf0e10cSrcweir OEntryListHelper( OControlModel& _rControlModel ); 68cdf0e10cSrcweir OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel ); 69cdf0e10cSrcweir virtual ~OEntryListHelper( ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir /// returns the current string item list 72cdf0e10cSrcweir inline const ::com::sun::star::uno::Sequence< ::rtl::OUString >& getStringItemList() const73cdf0e10cSrcweir getStringItemList() const { return m_aStringItems; } 74cdf0e10cSrcweir inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& getExternalListEntrySource() const75cdf0e10cSrcweir getExternalListEntrySource() const { return m_xListSource; } 76cdf0e10cSrcweir 77cdf0e10cSrcweir /// determines whether we actually have an external list source hasExternalListSource() const78cdf0e10cSrcweir inline bool hasExternalListSource( ) const { return m_xListSource.is(); } 79cdf0e10cSrcweir 80cdf0e10cSrcweir /** handling the XEventListener::disposing call for the case where 81cdf0e10cSrcweir our list source is being disposed 82cdf0e10cSrcweir @return 83cdf0e10cSrcweir <TRUE/> if and only if the disposed object was our list source, and so the 84cdf0e10cSrcweir event was handled 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir bool handleDisposing( const ::com::sun::star::lang::EventObject& _rEvent ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** to be called by derived classes' instances when they're being disposed 89cdf0e10cSrcweir */ 90cdf0e10cSrcweir void disposing( ); 91cdf0e10cSrcweir 92cdf0e10cSrcweir // prevent method hiding 93cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException) = 0; 94cdf0e10cSrcweir 95cdf0e10cSrcweir /** helper for implementing convertFastPropertyValue( StringItemList ) 96cdf0e10cSrcweir 97cdf0e10cSrcweir <p>The signature of this method and the return type have the same semantics 98cdf0e10cSrcweir as convertFastPropertyValue.</p> 99cdf0e10cSrcweir */ 100cdf0e10cSrcweir sal_Bool convertNewListSourceProperty( 101cdf0e10cSrcweir ::com::sun::star::uno::Any& _rConvertedValue, 102cdf0e10cSrcweir ::com::sun::star::uno::Any& _rOldValue, 103cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rValue 104cdf0e10cSrcweir ) 105cdf0e10cSrcweir SAL_THROW( ( ::com::sun::star::lang::IllegalArgumentException ) ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir /** helper for implementing setFastPropertyValueNoBroadcast 108cdf0e10cSrcweir 109cdf0e10cSrcweir <p>Will internally call stringItemListChanged after the new item list 110cdf0e10cSrcweir has been set.</p> 111cdf0e10cSrcweir 112cdf0e10cSrcweir @precond 113cdf0e10cSrcweir not to be called when we have an external list source 114cdf0e10cSrcweir @see hasExternalListSource 115cdf0e10cSrcweir */ 116cdf0e10cSrcweir void setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ControlModelLock& _rInstanceLock ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir /** announces that the list of entries has changed. 119cdf0e10cSrcweir 120cdf0e10cSrcweir <p>Derived classes have to override this. Most probably, they'll set the new 121cdf0e10cSrcweir as model property.</p> 122cdf0e10cSrcweir 123cdf0e10cSrcweir @pure 124cdf0e10cSrcweir @see getStringItemList 125cdf0e10cSrcweir */ 126cdf0e10cSrcweir virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) = 0; 127cdf0e10cSrcweir 128cdf0e10cSrcweir /** called whenever a connection to a new external list source has been established 129cdf0e10cSrcweir */ 130cdf0e10cSrcweir virtual void connectedExternalListSource( ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir /** called whenever a connection to a new external list source has been revoked 133cdf0e10cSrcweir */ 134cdf0e10cSrcweir virtual void disconnectedExternalListSource( ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir /** called when XRefreshable::refresh has been called, and we do *not* have an external 137cdf0e10cSrcweir list source 138cdf0e10cSrcweir */ 139cdf0e10cSrcweir virtual void refreshInternalEntryList() = 0; 140cdf0e10cSrcweir 141cdf0e10cSrcweir private: 142cdf0e10cSrcweir // XListEntrySink 143cdf0e10cSrcweir virtual void SAL_CALL setListEntrySource( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource ) throw (::com::sun::star::uno::RuntimeException); 144cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource > SAL_CALL getListEntrySource( ) throw (::com::sun::star::uno::RuntimeException); 145cdf0e10cSrcweir 146cdf0e10cSrcweir // XListEntryListener 147cdf0e10cSrcweir virtual void SAL_CALL entryChanged( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException); 148cdf0e10cSrcweir virtual void SAL_CALL entryRangeInserted( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException); 149cdf0e10cSrcweir virtual void SAL_CALL entryRangeRemoved( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException); 150cdf0e10cSrcweir virtual void SAL_CALL allEntriesChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); 151cdf0e10cSrcweir 152cdf0e10cSrcweir // XRefreshable 153cdf0e10cSrcweir virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException); 154cdf0e10cSrcweir virtual void SAL_CALL addRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); 155cdf0e10cSrcweir virtual void SAL_CALL removeRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); 156cdf0e10cSrcweir 157cdf0e10cSrcweir private: 158cdf0e10cSrcweir /** disconnects from the active external list source, if present 159cdf0e10cSrcweir @see connectExternalListSource 160cdf0e10cSrcweir */ 161cdf0e10cSrcweir void disconnectExternalListSource( ); 162cdf0e10cSrcweir 163cdf0e10cSrcweir /** connects to a new external list source 164cdf0e10cSrcweir @param _rxSource 165cdf0e10cSrcweir the new list source. Must not be <NULL/> 166cdf0e10cSrcweir @see disconnectExternalListSource 167cdf0e10cSrcweir */ 168cdf0e10cSrcweir void connectExternalListSource( 169cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource, 170cdf0e10cSrcweir ControlModelLock& _rInstanceLock 171cdf0e10cSrcweir ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir /** refreshes our list entries 174cdf0e10cSrcweir 175cdf0e10cSrcweir In case we have an external list source, its used to obtain the new entries, and then 176cdf0e10cSrcweir stringItemListChanged is called to give the derived class the possibility to 177cdf0e10cSrcweir react on this. 178cdf0e10cSrcweir 179cdf0e10cSrcweir In case we do not have an external list source, refreshInternalEntryList is called. 180cdf0e10cSrcweir */ 181cdf0e10cSrcweir void impl_lock_refreshList( ControlModelLock& _rInstanceLock ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir private: 184cdf0e10cSrcweir OEntryListHelper(); // never implemented 185cdf0e10cSrcweir OEntryListHelper( const OEntryListHelper& ); // never implemented 186cdf0e10cSrcweir OEntryListHelper& operator=( const OEntryListHelper& ); // never implemented 187cdf0e10cSrcweir }; 188cdf0e10cSrcweir 189cdf0e10cSrcweir //......................................................................... 190cdf0e10cSrcweir } // namespace frm 191cdf0e10cSrcweir //......................................................................... 192cdf0e10cSrcweir 193cdf0e10cSrcweir 194cdf0e10cSrcweir #endif // FORMS_ENTRYLISTHELPER_HXX 195