Tag: cws_dev300_dba30c User: fs Date: 2008-05-08 13:11:15+0000 Modified: dba/dbaccess/source/core/dataaccess/documentdefinition.cxx
Log: #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) 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.59&r2=1.59.4.1 Delta lines: +78 -47 --------------------- --- documentdefinition.cxx 2008-04-10 12:46:22+0000 1.59 +++ documentdefinition.cxx 2008-05-08 13:11:12+0000 1.59.4.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: documentdefinition.cxx,v $ - * $Revision: 1.59 $ + * $Revision: 1.59.4.1 $ * * This file is part of OpenOffice.org. * @@ -280,6 +280,10 @@ //........................................................................ namespace dbaccess { +//........................................................................ + + typedef ::boost::optional< bool > optional_bool; + //================================================================== // OEmbedObjectHolder //================================================================== @@ -897,9 +901,14 @@ // our database document's macro execution mode sal_Int16 nImposedMacroExecMode( m_pImpl->m_pDataSource->getImposedMacroExecMode() ); // (caching it, since adjustMacroMode will overwrite it) - bool bExecuteDBDocMacros = m_pImpl->m_pDataSource->adjustMacroMode_AutoReject(); - // 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->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. + // #i87741# / 2008-05-05 / [EMAIL PROTECTED] // allow the command arguments to downgrade the macro execution mode, but not to upgrade // it @@ -1431,9 +1440,11 @@ 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 ) { - if ( _bSuppressMacros ) + if ( !!_bSuppressMacros ) + { + if ( *_bSuppressMacros ) { // if we're to suppress macros, do exactly this _io_rArgs.put( "MacroExecutionMode", MacroExecMode::NEVER_EXECUTE ); @@ -1446,8 +1457,10 @@ _io_rArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); } } + } - _io_rArgs.put( "ReadOnly", _bReadOnly ); + if ( !!_bReadOnly ) + _io_rArgs.put( "ReadOnly", *_bReadOnly ); } } @@ -1541,7 +1554,7 @@ // ......................................................................... // put the common load arguments into the document's media descriptor - lcl_putLoadArgs( aMediaDesc, _bSuppressMacros, _bReadOnly ); + lcl_putLoadArgs( aMediaDesc, optional_bool( _bSuppressMacros ), optional_bool( _bReadOnly ) ); return aMediaDesc.getPropertyValues(); } @@ -1631,7 +1644,10 @@ } } } - else if ( m_xEmbeddedObject->getCurrentState() == EmbedStates::LOADED ) + else + { + sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState(); + if ( nCurrentState == EmbedStates::LOADED ) { if ( !m_pClientHelper ) { @@ -1651,11 +1667,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() ); + // 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 @@ -1670,17 +1712,6 @@ DBG_UNHANDLED_EXCEPTION(); } } - - if ( xModel.is() ) - { - Sequence<PropertyValue> aArgs = xModel->getArgs(); - - ::comphelper::NamedValueCollection aMediaDesc( aArgs ); - lcl_putLoadArgs( aMediaDesc, _bSuppressMacros, _bReadOnly); - - 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]
