User: kz Date: 2008-03-06 18:00:16+0000 Modified: dba/dbaccess/source/core/dataaccess/documentdefinition.cxx
Log: INTEGRATION: CWS odbmacros2 (1.50.2); FILE MERGED 2008/03/04 12:00:29 fs 1.50.2.7: RESYNC: (1.53-1.54); FILE MERGED 2008/02/18 21:11:06 fs 1.50.2.6: pass the OutplaceFrameProperties as named values 2008/02/27 14:38:06 fs 1.50.2.5.2.4: when copying a document, load it with disabled macros, to prevent the macro security message 2008/02/26 14:13:46 fs 1.50.2.5.2.3: #i49133# support a 'Hidden' flag 2008/02/20 14:47:36 fs 1.50.2.5.2.2: 'resync' copy changes 1.50.2.5->1.5.2.6 onto branch odbmacros_2_5 2008/02/14 12:18:07 fs 1.50.2.5.2.1: #i49133# re-enable the macros in DBDocs, which had been temporarily disable to finalize CWS odbmacros2 2008/02/14 08:22:19 fs 1.50.2.5: temporarily disable scripting support for database documents, so we have an intermediate version of the CWS which we can integrate 2008/02/04 22:27:21 fs 1.50.2.4: #i10000 2008/02/04 13:07:23 fs 1.50.2.3: RESYNC: (1.50-1.53); FILE MERGED 2008/01/06 21:13:01 fs 1.50.2.2: #i49133# allow form/report-macros if and only if there already is *any* form/report which contains macros 2007/12/12 09:54:56 fs 1.50.2.1: #i49133# when loading an embedded object, prohibit it to have embedded scripts/macros (unless it already has some) 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.55&r2=1.56 Delta lines: +84 -49 --------------------- --- documentdefinition.cxx 2008-03-05 17:05:36+0000 1.55 +++ documentdefinition.cxx 2008-03-06 18:00:13+0000 1.56 @@ -885,7 +885,7 @@ if ( pIter->Name.equalsAscii( "MacroExecutionMode" ) ) { - sal_Int16 nMacroExecMode( *aDocumentMacroMode ); + sal_Int16 nMacroExecMode( !aDocumentMacroMode ? MacroExecMode::USE_CONFIG : *aDocumentMacroMode ); OSL_VERIFY( pIter->Value >>= nMacroExecMode ); aDocumentMacroMode.reset( nMacroExecMode ); continue; @@ -898,13 +898,15 @@ } // 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->adjustMacroMode_AutoReject(); // allow the command arguments to downgrade the macro execution mode, but not to upgrade // it - if ( ( m_pImpl->m_pDataSource->getImposedMacroExecMode() == MacroExecMode::USE_CONFIG ) + if ( ( nImposedMacroExecMode == MacroExecMode::USE_CONFIG ) && bExecuteDBDocMacros ) { @@ -920,7 +922,7 @@ // // The problem with this: If the to-be-opened sub document has macros embedded in // the content.xml (which is valid ODF, but normally not produced by OOo itself), - // then this has not been detecte while loading the database document - it would + // then this has not been detected while loading the database document - it would // be too expensive, as it effectively would require loading all forms/reports. // // So, in such a case, and with 2. above, we would silently execute those macros, @@ -1090,7 +1092,7 @@ // delete ////////////////////////////////////////////////////////////////// closeObject(); - Reference< XStorage> xStorage = getStorage(); + Reference< XStorage> xStorage = getContainerStorage(); if ( xStorage.is() ) xStorage->removeElement(m_pImpl->m_aProps.sPersistentName); @@ -1194,7 +1196,7 @@ if ( !m_xEmbeddedObject.is() ) { - Reference< XStorage> xStorage = getStorage(); + Reference< XStorage> xStorage = getContainerStorage(); if ( xStorage.is() ) { Reference< XEmbedObjectCreator> xEmbedFactory( m_aContext.createComponent( "com.sun.star.embed.EmbeddedObjectCreator" ), UNO_QUERY ); @@ -1377,7 +1379,7 @@ { try { - Reference< XStorage> xStorage = getStorage(); + Reference< XStorage> xStorage = getContainerStorage(); const static ::rtl::OUString sBaseName(RTL_CONSTASCII_USTRINGPARAM("Obj")); // ----------------------------------------------------------------------------- Reference<XNameAccess> xElements(xStorage,UNO_QUERY_THROW); @@ -1455,23 +1457,46 @@ } // ----------------------------------------------------------------------------- -Sequence< PropertyValue > ODocumentDefinition::fillLoadArgs( const Reference< XConnection>& _xConnection, const bool _bSuppressMacros, const bool _bReadOnly, - const Sequence< PropertyValue >& _rAdditionalArgs, Sequence< PropertyValue >& _out_rEmbeddedObjectDescriptor ) +namespace { - ::comphelper::NamedValueCollection aMediaDesc( _rAdditionalArgs ); + Reference< XFrame > lcl_getDatabaseDocumentFrame( ODatabaseModelImpl& _rImpl ) { - Sequence<PropertyValue> aDocumentContext(2); - aDocumentContext[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection")); - aDocumentContext[0].Value <<= _xConnection; + Reference< XModel > xDatabaseDocumentModel( _rImpl.getModel_noCreate() ); + + Reference< XController > xDatabaseDocumentController; + if ( xDatabaseDocumentModel.is() ) + xDatabaseDocumentController = xDatabaseDocumentModel->getCurrentController(); - aDocumentContext[1].Name = PROPERTY_APPLYFORMDESIGNMODE; - aDocumentContext[1].Value <<= !_bReadOnly; + Reference< XFrame > xFrame; + if ( xDatabaseDocumentController.is() ) + xFrame = xDatabaseDocumentController->getFrame(); - aMediaDesc.put( "ComponentData", aDocumentContext ); + return xFrame; } +} - lcl_putLoadArgs( aMediaDesc, _bSuppressMacros, _bReadOnly, m_pImpl->m_aProps.aTitle ); +// ----------------------------------------------------------------------------- +sal_Bool ODocumentDefinition::objectSupportsEmbeddedScripts() const +{ +// bool bAllowDocumentMacros = !m_pImpl->m_pDataSource || m_pImpl->m_pDataSource->hasAnyObjectWithMacros(); + // TODO: revert to the disabled code. The current version is just to be able + // to integrate an intermediate version of the CWS, which should behave as + // if no macros in DB docs are allowed + bool bAllowDocumentMacros = true; + // if *any* of the objects of the database document already has macros, we continue to allow it + // to have them, until the user did a migration. + // If there are no macros, yet, we don't allow to create them + + return bAllowDocumentMacros; +} + +// ----------------------------------------------------------------------------- +Sequence< PropertyValue > ODocumentDefinition::fillLoadArgs( const Reference< XConnection>& _xConnection, const bool _bSuppressMacros, const bool _bReadOnly, + const Sequence< PropertyValue >& _rAdditionalArgs, Sequence< PropertyValue >& _out_rEmbeddedObjectDescriptor ) +{ + // ......................................................................... + // (re-)create interceptor, and put it into the descriptor of the embedded object if ( m_pInterceptor ) { m_pInterceptor->dispose(); @@ -1483,38 +1508,48 @@ m_pInterceptor->acquire(); Reference<XDispatchProviderInterceptor> xInterceptor = m_pInterceptor; - _out_rEmbeddedObjectDescriptor.realloc(2); - sal_Int32 nLen = 0; - _out_rEmbeddedObjectDescriptor[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutplaceDispatchInterceptor")); - _out_rEmbeddedObjectDescriptor[nLen++].Value <<= xInterceptor; - - uno::Sequence< uno::Any > aOutFrameProps(2); - PropertyValue aProp; - aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TopWindow")); - aProp.Value <<= sal_True; - aOutFrameProps[0] <<= aProp; + ::comphelper::NamedValueCollection aEmbeddedDescriptor; + aEmbeddedDescriptor.put( "OutplaceDispatchInterceptor", xInterceptor ); + + // ......................................................................... + // create the OutplaceFrameProperties, and put them into the descriptor of the embedded object + ::comphelper::NamedValueCollection OutplaceFrameProperties; + OutplaceFrameProperties.put( "TopWindow", (sal_Bool)sal_True ); - Reference< XModel > xDatabaseDocumentModel; + Reference< XFrame > xParentFrame; if ( m_pImpl->m_pDataSource ) - xDatabaseDocumentModel = m_pImpl->m_pDataSource->getModel_noCreate(); + xParentFrame = lcl_getDatabaseDocumentFrame( *m_pImpl->m_pDataSource ); + OSL_ENSURE( xParentFrame.is(), "ODocumentDefinition::fillLoadArgs: no parent frame!" ); + if ( xParentFrame.is() ) + OutplaceFrameProperties.put( "ParentFrame", xParentFrame ); - Reference< XController > xDatabaseDocumentController; - if ( xDatabaseDocumentModel.is() ) - xDatabaseDocumentController = xDatabaseDocumentModel->getCurrentController(); + aEmbeddedDescriptor.put( "OutplaceFrameProperties", OutplaceFrameProperties.getNamedValues() ); - if ( xDatabaseDocumentController.is() ) + // ......................................................................... + // tell the embedded object to have (or not have) script support + aEmbeddedDescriptor.put( "EmbeddedScriptSupport", (sal_Bool)objectSupportsEmbeddedScripts() ); + + // ......................................................................... + // pass the descriptor of the embedded object to the caller + aEmbeddedDescriptor >>= _out_rEmbeddedObjectDescriptor; + + // ......................................................................... + ::comphelper::NamedValueCollection aMediaDesc( _rAdditionalArgs ); + + // ......................................................................... + // create the ComponentData, and put it into the document's media descriptor { - aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentFrame")); - aProp.Value <<= xDatabaseDocumentController->getFrame(); - aOutFrameProps[1] <<= aProp; + ::comphelper::NamedValueCollection aComponentData; + aComponentData.put( "ActiveConnection", _xConnection ); + aComponentData.put( "ApplyFormDesignMode", !_bReadOnly ); + aMediaDesc.put( "ComponentData", aComponentData.getPropertyValues() ); } - _out_rEmbeddedObjectDescriptor[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutplaceFrameProperties")); - _out_rEmbeddedObjectDescriptor[nLen++].Value <<= aOutFrameProps; + // ......................................................................... + // put the common load arguments into the document's media descriptor + lcl_putLoadArgs( aMediaDesc, _bSuppressMacros, _bReadOnly, m_pImpl->m_aProps.aTitle ); - Sequence< PropertyValue > aLoadArgs; - aMediaDesc >>= aLoadArgs; - return aLoadArgs; + return aMediaDesc.getPropertyValues(); } // ----------------------------------------------------------------------------- void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& _xConnection, const Sequence< sal_Int8 >& _aClassID, @@ -1522,7 +1557,7 @@ { if ( !m_xEmbeddedObject.is() ) { - Reference< XStorage> xStorage = getStorage(); + Reference< XStorage> xStorage = getContainerStorage(); if ( xStorage.is() ) { Reference< XEmbedObjectFactory> xEmbedFactory( m_aContext.createComponent( "com.sun.star.embed.OOoEmbeddedObjectFactory" ), UNO_QUERY ); @@ -1761,7 +1796,7 @@ } } // ----------------------------------------------------------------------------- -Reference< XStorage> ODocumentDefinition::getStorage() const +Reference< XStorage> ODocumentDefinition::getContainerStorage() const { return m_pImpl->m_pDataSource ? m_pImpl->m_pDataSource->getStorage( ODatabaseModelImpl::getObjectContainerStorageName( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) ) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
