Tag: cws_src680_dba30 User: fs Date: 06/03/21 10:24:49 Modified: /dba/dbaccess/source/core/dataaccess/ documentdefinition.cxx
Log: RESYNC: (1.32-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.25.2.5&r2=1.25.2.6 Delta lines: +113 -76 ---------------------- --- documentdefinition.cxx 23 Nov 2005 10:15:56 -0000 1.25.2.5 +++ documentdefinition.cxx 21 Mar 2006 18:24:46 -0000 1.25.2.6 @@ -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 @@ -227,6 +242,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; @@ -315,28 +332,19 @@ virtual void SAL_CALL saveObject( ) throw (ObjectSaveVetoException, Exception, RuntimeException) { - if ( m_pClient ) - m_pClient->saveObject(); } virtual void SAL_CALL onShowWindow( sal_Bool bVisible ) throw (RuntimeException) { - if ( m_pClient ) - m_pClient->onShowWindow(bVisible); } // XComponentSupplier virtual Reference< ::com::sun::star::util::XCloseable > SAL_CALL getComponent( ) throw (RuntimeException) { - Reference< ::com::sun::star::util::XCloseable > xRet; - // if ( m_pClient ) - // xRet = m_pClient->getComponent(); - return xRet; + return Reference< css::util::XCloseable >(); } // XEmbeddedClient virtual void SAL_CALL visibilityChanged( ::sal_Bool bVisible ) throw (WrongStateException, RuntimeException) { - if ( m_pClient ) - m_pClient->visibilityChanged( bVisible ); } inline void resetClient(ODocumentDefinition* _pClient) { m_pClient = _pClient; } }; @@ -568,7 +576,7 @@ ::osl::MutexGuard aGuard(m_aMutex); closeObject(); ::comphelper::disposeComponent(m_xListener); - m_xFrameLoader = NULL; + m_xDesktop = NULL; } // ----------------------------------------------------------------------------- IMPLEMENT_TYPEPROVIDER3(ODocumentDefinition,OContentHelper,OPropertyStateContainer,ODocumentDefinition_Base); @@ -635,6 +643,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 @@ -643,51 +661,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(); } } @@ -978,6 +979,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 ) { @@ -1015,6 +1068,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() ) { @@ -1041,10 +1098,6 @@ // inserted(); } // ----------------------------------------------------------------------------- -void SAL_CALL ODocumentDefinition::saveObject( ) throw (ObjectSaveVetoException, Exception, RuntimeException) -{ -} -// ----------------------------------------------------------------------------- sal_Bool ODocumentDefinition::save(sal_Bool _bApprove) { // default handling: instantiate an interaction handler and let it handle the parameter request @@ -1180,6 +1233,12 @@ _rEmbeddedObjectDescriptor[nLen++].Value <<= xInterceptor; } // ----------------------------------------------------------------------------- +Sequence< sal_Int8 > ODocumentDefinition::getDefaultDocumentTypeClassId() +{ + return lcl_GetSequenceClassID( SO3_SW_CLASSID ); +} + +// ----------------------------------------------------------------------------- void ODocumentDefinition::loadEmbeddedObject(const Sequence< sal_Int8 >& _aClassID,const Reference<XConnection>& _xConnection,sal_Bool _bReadOnly) { if ( !m_xEmbeddedObject.is() ) @@ -1201,7 +1260,7 @@ } else { - aClassID = lcl_GetSequenceClassID(SO3_SW_CLASSID); + aClassID = getDefaultDocumentTypeClassId(); sDocumentService = lcl_GetDocumentServiceFromMediaType(xStorage,m_pImpl->m_aProps.sPersistentName); } @@ -1241,7 +1300,10 @@ else if ( m_xEmbeddedObject->getCurrentState() == EmbedStates::LOADED ) { if ( !m_pClientHelper ) + { m_pClientHelper = new OEmbeddedClientHelper(this); + m_pClientHelper->acquire(); + } Reference<XEmbeddedClient> xClient = m_pClientHelper; m_xEmbeddedObject->setClientSite(xClient); @@ -1295,11 +1357,6 @@ } } // ----------------------------------------------------------------------------- -void SAL_CALL ODocumentDefinition::onShowWindow( sal_Bool bVisible ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard(m_aMutex); -} -// ----------------------------------------------------------------------------- void ODocumentDefinition::generateNewImage(Any& _rImage) { loadEmbeddedObject( Sequence< sal_Int8 >(), Reference< XConnection >(), sal_True ); @@ -1371,26 +1428,6 @@ } } return xComp; -} -// ----------------------------------------------------------------------------- -void SAL_CALL ODocumentDefinition::visibilityChanged( ::sal_Bool bVisible ) throw (WrongStateException, RuntimeException) -{ -// ::osl::MutexGuard aGuard(m_aMutex); -// if ( m_xEmbeddedObject.is() && !bVisible ) -// { -// try -// { -// Reference< com::sun::star::util::XCloseable> xCloseable(m_xEmbeddedObject,UNO_QUERY); -// if ( xCloseable.is() ) -// xCloseable->close(sal_True); -// } -// catch(Exception) -// { -// } -// m_xEmbeddedObject = NULL; -// if ( m_pClientHelper ) -// m_pClientHelper->resetClient(NULL); -// } } // ----------------------------------------------------------------------------- void SAL_CALL ODocumentDefinition::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
