Tag: cws_src680_qiq User: fs Date: 06/05/31 04:08:54 Modified: /dba/dbaccess/source/core/dataaccess/ definitioncontainer.cxx
Log: #i51143# XContainerApproveListener return XVeto now, instead of throwing - need to translate this File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: definitioncontainer.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/definitioncontainer.cxx?r1=1.21.4.2&r2=1.21.4.3 Delta lines: +48 -5 -------------------- --- definitioncontainer.cxx 24 May 2006 14:55:16 -0000 1.21.4.2 +++ definitioncontainer.cxx 31 May 2006 11:08:51 -0000 1.21.4.3 @@ -4,9 +4,9 @@ * * $RCSfile: definitioncontainer.cxx,v $ * - * $Revision: 1.21.4.2 $ + * $Revision: 1.21.4.3 $ * - * last change: $Author: fs $ $Date: 2006/05/24 14:55:16 $ + * last change: $Author: fs $ $Date: 2006/05/31 11:08:51 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -236,6 +236,46 @@ // and dispose it disposeComponent(xOldElement); } + +// ----------------------------------------------------------------------------- +namespace +{ + typedef Reference< XVeto > ( SAL_CALL XContainerApproveListener::*ContainerApprovalMethod )( const ContainerEvent& ); + + struct RaiseExceptionFromVeto + { + private: + ContainerApprovalMethod m_pMethod; + const ContainerEvent& m_rEvent; + + public: + RaiseExceptionFromVeto( ContainerApprovalMethod _pMethod, const ContainerEvent& _rEvent ) + :m_pMethod( _pMethod ) + ,m_rEvent( _rEvent ) + { + } + + void operator()( const Reference< XContainerApproveListener >& _Listener ) const + { + Reference< XVeto > xVeto = (_Listener.get()->*m_pMethod)( m_rEvent ); + if ( !xVeto.is() ) + return; + + Any eVetoDetails = xVeto->getDetails(); + + IllegalArgumentException aIllegalArgumentError; + if ( eVetoDetails >>= aIllegalArgumentError ) + throw aIllegalArgumentError; + + WrappedTargetException aWrappedError; + if ( eVetoDetails >>= aWrappedError ) + throw aWrappedError; + + throw WrappedTargetException( xVeto->getReason(), _Listener.get(), eVetoDetails ); + } + }; +} + // ----------------------------------------------------------------------------- void ODefinitionContainer::notifyByName( ResettableMutexGuard& _rGuard, const ::rtl::OUString& _rName, const Reference< XContent >& _xNewElement, const Reference< XContent >& _xOldElement, @@ -254,19 +294,22 @@ { case E_INSERTED: if ( bApprove ) - rContainer.notifyEach( &XContainerApproveListener::approveInsertElement, aEvent ); + rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >( + RaiseExceptionFromVeto( &XContainerApproveListener::approveInsertElement, aEvent ) ); else rContainer.notifyEach( &XContainerListener::elementInserted, aEvent ); break; case E_REPLACED: if ( bApprove ) - rContainer.notifyEach( &XContainerApproveListener::approveReplaceElement, aEvent ); + rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >( + RaiseExceptionFromVeto( &XContainerApproveListener::approveReplaceElement, aEvent ) ); else rContainer.notifyEach( &XContainerListener::elementReplaced, aEvent ); break; case E_REMOVED: if ( bApprove ) - rContainer.notifyEach( &XContainerApproveListener::approveRemoveElement, aEvent ); + rContainer.forEach< XContainerApproveListener, RaiseExceptionFromVeto >( + RaiseExceptionFromVeto( &XContainerApproveListener::approveRemoveElement, aEvent ) ); else rContainer.notifyEach( &XContainerListener::elementRemoved, aEvent ); break; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
