Tag: mws_ooh680 User: ihi Date: 2008-05-20 18:23:35+0000 Modified: dba/dbaccess/source/core/dataaccess/documentdefinition.cxx
Log: INTEGRATION: CWS dba241d (1.50.18.4.10); FILE MERGED 2008/05/05 13:08:53 fs 1.50.18.4.10.2: #i87741# when loading a form, allow user interaction for the macro execution mode adjustment - just in case the form is not loaded after the database document had been plugged into a frame (which is where the user interaction would normally happen) 2008/05/05 10:18:17 fs 1.50.18.4.10.1: #i88977# do not reset MacroExecution to NEVER if the document was already loaded 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.50.18.4&r2=1.50.18.5 Delta lines: +79 -45 --------------------- --- documentdefinition.cxx 2008-03-12 08:38:33+0000 1.50.18.4 +++ documentdefinition.cxx 2008-05-20 18:23:33+0000 1.50.18.5 @@ -283,6 +283,10 @@ //........................................................................ namespace dbaccess { +//........................................................................ + + typedef ::boost::optional< bool > optional_bool; + //================================================================== // OEmbedObjectHolder //================================================================== @@ -898,9 +902,17 @@ } // our database document's macro execution mode - // Note that we don't pass an interaction handler here. If the user has not been asked/notified - // by now (i.e. during loading the whole DB document), then this won't happen anymore. - bool bExecuteDBDocMacros = m_pImpl->m_pDataSource->adjustMacroMode_AutoReject(); + bool bExecuteDBDocMacros = m_pImpl->m_pDataSource->checkMacrosOnLoading(); + // Note that this call implies the user might be asked for the macro execution mode. + // Normally, this would happen when the database document is loaded, and subsequent calls + // will simply use the user's decision from this point in time. + // However, it is possible to programmatically load forms/reports, without actually + // loading the database document into a frame. In this case, the user will be asked + // here and now. + // Note also that this call here might imply false alarm: If the form does not contain macros, + // but, another one does, then the user will still be bothered with a query whether or + // not to use macros. However, this is negligible + // #i87741# / 2008-05-05 / [EMAIL PROTECTED] // allow the command arguments to downgrade the macro execution mode, but not to upgrade // it @@ -1425,10 +1437,12 @@ namespace { // ......................................................................... - void lcl_putLoadArgs( ::comphelper::NamedValueCollection& _io_rArgs, const bool _bSuppressMacros, const bool _bReadOnly, + void lcl_putLoadArgs( ::comphelper::NamedValueCollection& _io_rArgs, const optional_bool _bSuppressMacros, const optional_bool _bReadOnly, const ::rtl::OUString& _rDocTitle ) { - if ( _bSuppressMacros ) + if ( !!_bSuppressMacros ) + { + if ( *_bSuppressMacros ) { // if we're to suppress macros, do exactly this _io_rArgs.put( "MacroExecutionMode", MacroExecMode::NEVER_EXECUTE ); @@ -1441,8 +1455,10 @@ _io_rArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); } } + } - _io_rArgs.put( "ReadOnly", _bReadOnly ); + if ( !!_bReadOnly ) + _io_rArgs.put( "ReadOnly", *_bReadOnly ); if ( _rDocTitle.getLength() ) { @@ -1467,7 +1483,7 @@ aMediaDesc.put( "ComponentData", aDocumentContext ); } - lcl_putLoadArgs( aMediaDesc, _bSuppressMacros, _bReadOnly, m_pImpl->m_aProps.aTitle ); + lcl_putLoadArgs( aMediaDesc, optional_bool( _bSuppressMacros ), optional_bool( _bReadOnly ), m_pImpl->m_aProps.aTitle ); if ( m_pInterceptor ) { @@ -1599,7 +1615,10 @@ } } } - else if ( m_xEmbeddedObject->getCurrentState() == EmbedStates::LOADED ) + else + { + sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState(); + if ( nCurrentState == EmbedStates::LOADED ) { if ( !m_pClientHelper ) { @@ -1619,11 +1638,37 @@ xCommon->reload( aLoadArgs, aEmbeddedObjectDescriptor ); m_xEmbeddedObject->changeState(EmbedStates::RUNNING); } + else + { + OSL_ENSURE( ( nCurrentState == EmbedStates::RUNNING ) || ( nCurrentState == EmbedStates::ACTIVE ), + "ODocumentDefinition::loadEmbeddedObject: unexpected state!" ); + + // if the document was already loaded (which means the embedded object is in state RUNNING or ACTIVE), + // then just re-set some model parameters + try + { + Reference< XModel > xModel( getComponent(), UNO_QUERY_THROW ); + Sequence< PropertyValue > aArgs = xModel->getArgs(); + + ::comphelper::NamedValueCollection aMediaDesc( aArgs ); + lcl_putLoadArgs( aMediaDesc, optional_bool(), optional_bool(), m_pImpl->m_aProps.aTitle ); + // don't put _bSuppressMacros and _bReadOnly here - if the document was already + // loaded, we should not tamper with its settings. + // #i88977# / 2008-05-05 / [EMAIL PROTECTED] + + aMediaDesc >>= aArgs; + xModel->attachResource( xModel->getURL(), aArgs ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } - Reference<XModel> xModel(getComponent(),UNO_QUERY); // set the OfficeDatabaseDocument instance as parent of the embedded document // #i40358# / 2005-01-19 / [EMAIL PROTECTED] - Reference< XChild > xDepdendDocAsChild( xModel, UNO_QUERY ); + Reference< XChild > xDepdendDocAsChild( getComponent(), UNO_QUERY ); if ( xDepdendDocAsChild.is() ) { try @@ -1638,17 +1683,6 @@ DBG_UNHANDLED_EXCEPTION(); } } - - if ( xModel.is() ) - { - Sequence<PropertyValue> aArgs = xModel->getArgs(); - - ::comphelper::NamedValueCollection aMediaDesc( aArgs ); - lcl_putLoadArgs( aMediaDesc, _bSuppressMacros, _bReadOnly, m_pImpl->m_aProps.aTitle ); - - aMediaDesc >>= aArgs; - xModel->attachResource( xModel->getURL(), aArgs ); - } } // ----------------------------------------------------------------------------- void ODocumentDefinition::onCommandPreview(Any& _rImage) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
