diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx index bb9b397f1c81..5cc3f7ba10c7 100644 --- a/forms/source/component/DatabaseForm.hxx +++ b/forms/source/component/DatabaseForm.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DatabaseForm.hxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: fs $ $Date: 2002-03-04 14:01:11 $ + * last change: $Author: fs $ $Date: 2002-10-04 08:14:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -520,7 +520,7 @@ public: inline void submitNBC( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& Control, const ::com::sun::star::awt::MouseEvent& MouseEvt ); protected: - virtual void implInserted(const InterfaceRef& _rxObject); + virtual void implInserted( const ElementDescription* _pElement ); virtual void implRemoved(const InterfaceRef& _rxObject); // OPropertyChangeListener diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx index 63dd597fabbb..0a1c1f988f5d 100644 --- a/forms/source/component/Grid.cxx +++ b/forms/source/component/Grid.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Grid.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: fs $ $Date: 2001-11-08 11:24:52 $ + * last change: $Author: fs $ $Date: 2002-10-04 08:11:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -984,8 +984,8 @@ void SAL_CALL OGridControlModel::reloaded(const EventObject& rEvent) throw(Runti OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxIFace) const { OGridColumn* pImplementation = NULL; - Reference xUnoTunnel(_rxIFace, UNO_QUERY); - if (xUnoTunnel.is()) + Reference< XUnoTunnel > xUnoTunnel( _rxIFace, UNO_QUERY ); + if ( xUnoTunnel.is() ) pImplementation = reinterpret_cast(xUnoTunnel->getSomething(OGridColumn::getUnoTunnelImplementationId())); return pImplementation; @@ -1032,33 +1032,43 @@ void OGridControlModel::implRemoved(const InterfaceRef& _rxObject) } //------------------------------------------------------------------------------ -void OGridControlModel::implInserted(const InterfaceRef& _rxObject) +void OGridControlModel::implInserted( const ElementDescription* _pElement ) { - OInterfaceContainer::implInserted(_rxObject); + OInterfaceContainer::implInserted( _pElement ); - Reference< XSQLErrorBroadcaster > xBroadcaster( _rxObject, UNO_QUERY ); + Reference< XSQLErrorBroadcaster > xBroadcaster( _pElement->xInterface, UNO_QUERY ); if ( xBroadcaster.is() ) xBroadcaster->addSQLErrorListener( this ); - gotColumn(_rxObject); + gotColumn( _pElement->xInterface ); } //------------------------------------------------------------------------------ -void OGridControlModel::implReplaced(const InterfaceRef& _rxReplacedObject, const InterfaceRef& _rxNewObject) +void OGridControlModel::implReplaced( const InterfaceRef& _rxReplacedObject, const ElementDescription* _pElement ) { - OInterfaceContainer::implReplaced(_rxReplacedObject, _rxNewObject); - lostColumn(_rxReplacedObject); - gotColumn(_rxNewObject); + OInterfaceContainer::implReplaced( _rxReplacedObject, _pElement ); + lostColumn( _rxReplacedObject ); + gotColumn( _pElement->xInterface ); } //------------------------------------------------------------------------------ -InterfaceRef OGridControlModel::approveNewElement( const InterfaceRef& _rxObject ) +ElementDescription* OGridControlModel::createElementMetaData( ) +{ + return new ColumnDescription; +} + +//------------------------------------------------------------------------------ +void OGridControlModel::approveNewElement( const Reference< XPropertySet >& _rxObject, ElementDescription* _pElement ) { OGridColumn* pCol = getColumnImplementation( _rxObject ); if ( !pCol ) throw IllegalArgumentException(); - return OInterfaceContainer::approveNewElement( _rxObject ); + OInterfaceContainer::approveNewElement( _rxObject, _pElement ); + + // if we're here, the object passed all tests + if ( _pElement ) + static_cast< ColumnDescription* >( _pElement )->pColumn = pCol; } // XPersistObject @@ -1222,7 +1232,7 @@ void OGridControlModel::read(const Reference& _rxInStream) t } if ( xCol.is() ) - implInsert( i, xCol, sal_False, sal_False, sal_False ); + implInsert( i, xCol, sal_False, NULL, sal_False ); } } diff --git a/forms/source/component/Grid.hxx b/forms/source/component/Grid.hxx index 1e140566e043..da30c47b0e20 100644 --- a/forms/source/component/Grid.hxx +++ b/forms/source/component/Grid.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Grid.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: fs $ $Date: 2001-10-16 16:19:02 $ + * last change: $Author: fs $ $Date: 2002-10-04 08:11:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,6 +96,18 @@ namespace frm { //......................................................................... +class OGridColumn; + +//================================================================== +// ColumnDescription +//================================================================== + + struct ColumnDescription : public ElementDescription + { + public: + OGridColumn* pColumn; // not owned by this instance! only to prevent duplicate XUnoTunnel usage + }; + //================================================================== // OGridControlModel //================================================================== @@ -107,7 +119,6 @@ typedef ::cppu::ImplHelper6 < ::com::sun::star::awt::XControlModel , ::com::sun::star::sdb::XSQLErrorListener > OGridControlModel_BASE; -class OGridColumn; class OGridControlModel :public OControlModel ,public OInterfaceContainer ,public OErrorBroadcaster @@ -228,16 +239,21 @@ public: IMPLEMENT_INFO_SERVICE() protected: - virtual InterfaceRef approveNewElement( const InterfaceRef& _rxObject ); + virtual void approveNewElement( + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject, + ElementDescription* _pElement + ); ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> createColumn(sal_Int32 nTypeId) const; OGridColumn* getColumnImplementation(const InterfaceRef& _rxIFace) const; + virtual ElementDescription* createElementMetaData( ); + protected: virtual void implRemoved(const InterfaceRef& _rxObject); - virtual void implInserted(const InterfaceRef& _rxObject); - virtual void implReplaced(const InterfaceRef& _rxReplacedObject, const InterfaceRef& _rxNewObject); + virtual void implInserted( const ElementDescription* _pElement ); + virtual void implReplaced( const InterfaceRef& _rxReplacedObject, const ElementDescription* _pElement ); void gotColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn); void lostColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn); diff --git a/forms/source/inc/InterfaceContainer.hxx b/forms/source/inc/InterfaceContainer.hxx index 3d081b3c3ab1..232c1dac0e5b 100644 --- a/forms/source/inc/InterfaceContainer.hxx +++ b/forms/source/inc/InterfaceContainer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: InterfaceContainer.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: fs $ $Date: 2001-10-16 16:18:23 $ + * last change: $Author: fs $ $Date: 2002-10-04 08:08:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,6 +102,9 @@ #ifndef _COM_SUN_STAR_BEANS_PROPERTYCHANGEEVENT_HPP_ #include #endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_SCRIPT_XEVENTATTACHERMANAGER_HPP_ #include #endif @@ -146,15 +149,30 @@ namespace frm //......................................................................... +//================================================================== + struct ElementDescription + { + public: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInterface; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > xChild; + ::com::sun::star::uno::Any aElementTypeInterface; + + public: + ElementDescription( ); + virtual ~ElementDescription(); + + private: + ElementDescription( const ElementDescription& ); // never implemented + ElementDescription& operator=( const ElementDescription& ); // never implemented + }; + typedef ::std::vector OInterfaceArray; typedef ::std::hash_multimap< ::rtl::OUString, InterfaceRef, ::comphelper::UStringHash, ::comphelper::UStringEqual> OInterfaceMap; //================================================================== -// FmForms -// Implementiert den UNO-Container fuer Formulare -// enthaelt alle zugeordneten Forms -// dieses Container kann selbst den Context fuer Formulare darstellen -// oder außen einen Context uebergeben bekommen +// OInterfaceContainer +// implements a container for form components //================================================================== typedef ::cppu::ImplHelper7< ::com::sun::star::container::XNameContainer, ::com::sun::star::container::XIndexContainer, @@ -250,23 +268,44 @@ protected: virtual void SAL_CALL disposing(); virtual void removeElementsNoEvents(sal_Int32 nIndex); - /// to be overridden if elements which are to be inserted into the container shall be checked - virtual InterfaceRef approveNewElement( const ::com::sun::star::uno::Any& _rObject ); - virtual InterfaceRef approveNewElement( const InterfaceRef& _rxObject ); + /** to be overridden if elements which are to be inserted into the container shall be checked + +

the ElementDescription given can be used to cache information about the object - it will be passed + later on to implInserted/implReplaced.

+ */ + virtual void approveNewElement( + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject, + ElementDescription* _pElement + ); + + virtual ElementDescription* createElementMetaData( ); + + /** inserts an object into our internal structures + + @param _nIndex + the index at which position it should be inserted + @param _bEvents + if , event knittings will be done + @param _pApprovalResult + must contain the result of an approveNewElement call. Can be , in this case, the approval + is done within implInsert. + @param _bFire + if , a notification about the insertion will be fired + */ void implInsert( sal_Int32 _nIndex, - const InterfaceRef& _rxObject, - sal_Bool _bEvents = sal_True, - sal_Bool _bApprove = sal_True, - sal_Bool _bFire = sal_True + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject, + sal_Bool _bEvents /* = sal_True */, + ElementDescription* _pApprovalResult /* = NULL */ , + sal_Bool _bFire /* = sal_True */ ) throw(::com::sun::star::lang::IllegalArgumentException); // called after the object is inserted, but before the "real listeners" are notified - virtual void implInserted(const InterfaceRef& _rxObject) { } + virtual void implInserted( const ElementDescription* _pElement ) { } // called after the object is removed, but before the "real listeners" are notified virtual void implRemoved(const InterfaceRef& _rxObject) { } // called after an object was replaced, but before the "real listeners" are notified - virtual void implReplaced(const InterfaceRef& _rxReplacedObject, const InterfaceRef& _rxNewObject) { } + virtual void implReplaced( const InterfaceRef& _rxReplacedObject, const ElementDescription* _pElement ) { } void SAL_CALL writeEvents(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream); void SAL_CALL readEvents(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream);