Tag: cws_src680_oj14 User: oj Date: 06/03/20 05:50:12 Modified: /dba/dbaccess/source/core/dataaccess/ documentdefinition.cxx
Log: RESYNC: (1.33-1.35); FILE MERGED File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: documentdefinition.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.cxx?r1=1.29.4.2&r2=1.29.4.3 Delta lines: +102 -36 ---------------------- --- documentdefinition.cxx 3 Jan 2006 13:16:39 -0000 1.29.4.2 +++ documentdefinition.cxx 20 Mar 2006 13:50:08 -0000 1.29.4.3 @@ -45,6 +45,9 @@ #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif #ifndef _COMPHELPER_PROPERTY_HXX_ #include <comphelper/property.hxx> #endif @@ -165,6 +168,18 @@ #ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_ #include <com/sun/star/document/MacroExecMode.hpp> #endif +#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_ +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_ +#include <com/sun/star/container/XIndexContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_ +#include <com/sun/star/form/XFormsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_ +#include <com/sun/star/form/XForm.hpp> +#endif #ifndef _COMPHELPER_INTERACTION_HXX_ #include <comphelper/interaction.hxx> #endif @@ -233,6 +248,8 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::datatransfer; using namespace ::com::sun::star::task; +using namespace ::com::sun::star::form; +using namespace ::com::sun::star::drawing; using namespace ::osl; using namespace ::comphelper; using namespace ::cppu; @@ -531,7 +548,7 @@ ::osl::MutexGuard aGuard(m_aMutex); closeObject(); ::comphelper::disposeComponent(m_xListener); - m_xFrameLoader = NULL; + m_xDesktop = NULL; } // ----------------------------------------------------------------------------- IMPLEMENT_TYPEPROVIDER3(ODocumentDefinition,OContentHelper,OPropertyStateContainer,ODocumentDefinition_Base); @@ -598,6 +615,16 @@ } // ----------------------------------------------------------------------------- +void ODocumentDefinition::impl_removeFrameFromDesktop_throw( const Reference< XFrame >& _rxFrame ) +{ + if ( !m_xDesktop.is() ) + m_xDesktop.set( m_xORB->createInstance( SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); + + Reference< XFrames > xFrames( m_xDesktop->getFrames(), UNO_QUERY_THROW ); + xFrames->remove( _rxFrame ); +} + +// ----------------------------------------------------------------------------- void ODocumentDefinition::impl_onActivateEmbeddedObject( bool _bOpenedInDesignMode ) { try @@ -606,51 +633,34 @@ Reference< XController > xController( xModel.is() ? xModel->getCurrentController() : Reference< XController >() ); if ( !xController.is() ) return; - Reference< XFrame > xFrame( xController->getFrame() ); - if ( m_xListener.is() ) - { - // simply raise the window to top + if ( !m_xListener.is() ) + // it's the first time the embedded object has been activated + // create an OEmbedObjectHolder + m_xListener = new OEmbedObjectHolder(m_xEmbeddedObject,this); + + Reference< XFrame > xFrame( xController->getFrame() ); + // raise the window to top (especially necessary if this is not the first activation) if ( xFrame.is() ) { Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW ); xTopWindow->toFront(); } - } - else - { - // it's the first time the embedded object has been activated - - // - if ( !m_xFrameLoader.is() ) - m_xFrameLoader.set( m_xORB->createInstance( SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); -/* - // remove the frame from the desktop's frame collection because we need full control of it. - Reference< XFramesSupplier > xSup( m_xFrameLoader, UNO_QUERY_THROW ); - Reference< XFrames > xFrames( xSup->getFrames(), UNO_QUERY_THROW ); - xFrames->remove( xFrame ); -*/ - // create an OEmbedObjectHolder - m_xListener = new OEmbedObjectHolder(m_xEmbeddedObject,this); // ensure that we ourself are kept alive as long as the embedded object's frame is // opened LifetimeCoupler::couple( *this, Reference< XComponent >( xFrame, UNO_QUERY_THROW ) ); - } + // init the edit view if ( _bOpenedInDesignMode ) impl_initObjectEditView( xController ); + + // remove the frame from the desktop's frame collection because we need full control of it. + impl_removeFrameFromDesktop_throw( xFrame ); } - catch( const RuntimeException& e ) + catch( const RuntimeException& ) { - #if OSL_DEBUG_LEVEL > 0 - ::rtl::OString sMessage( "ODocumentDefinition::impl_onActivateEmbeddedObject: caught an exception!\n" ); - sMessage += "message:\n"; - sMessage += ::rtl::OString( e.Message.getStr(), e.Message.getLength(), osl_getThreadTextEncoding() ); - OSL_ENSURE( false, sMessage ); - #else - e; // make compiler happy - #endif + DBG_UNHANDLED_EXCEPTION(); } } @@ -941,6 +951,58 @@ return aRet; } // ----------------------------------------------------------------------------- +namespace +{ + void lcl_resetChildFormsToEmptyDataSource( const Reference< XIndexAccess>& _rxFormsContainer ) + { + OSL_PRECOND( _rxFormsContainer.is(), "lcl_resetChildFormsToEmptyDataSource: illegal call!" ); + sal_Int32 count = _rxFormsContainer->getCount(); + for ( sal_Int32 i = 0; i < count; ++i ) + { + Reference< XForm > xForm( _rxFormsContainer->getByIndex( i ), UNO_QUERY ); + if ( !xForm.is() ) + continue; + + // if the element is a form, reset its DataSourceName property to an empty string + try + { + Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW ); + xFormProps->setPropertyValue( PROPERTY_DATASOURCENAME, makeAny( ::rtl::OUString() ) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + // if the element is a container itself, step down the component hierarchy + Reference< XIndexAccess > xContainer( xForm, UNO_QUERY ); + if ( xContainer.is() ) + lcl_resetChildFormsToEmptyDataSource( xContainer ); + } + } + + void lcl_resetFormsToEmptyDataSource( const Reference< XEmbeddedObject>& _rxEmbeddedObject ) + { + try + { + Reference< XComponentSupplier > xCompProv( _rxEmbeddedObject, UNO_QUERY_THROW ); + Reference< XDrawPageSupplier > xSuppPage( xCompProv->getComponent(), UNO_QUERY_THROW ); + // if this interface does not exist, then either getComponent returned NULL, + // or the document is a multi-page document. The latter is allowed, but currently + // simply not handled by this code, as it would not normally happen. + + Reference< XFormsSupplier > xSuppForms( xSuppPage->getDrawPage(), UNO_QUERY_THROW ); + Reference< XIndexAccess > xForms( xSuppForms->getForms(), UNO_QUERY_THROW ); + lcl_resetChildFormsToEmptyDataSource( xForms ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + } +} +// ----------------------------------------------------------------------------- void ODocumentDefinition::insert(const ::rtl::OUString& _sURL, const Reference< XCommandEnvironment >& Environment) throw( Exception ) { @@ -978,6 +1040,10 @@ ,m_pImpl->m_aProps.sPersistentName ,aMediaDesc ,aEmpty),UNO_QUERY); + + lcl_resetFormsToEmptyDataSource( m_xEmbeddedObject ); + // #i57669# / 2005-12-01 / [EMAIL PROTECTED] + Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY); if ( xPersist.is() ) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
