Tag: cws_src680_rptwizard01 User: lla Date: 2008-02-15 07:38:02+0000 Removed: dba/dbaccess/source/inc/dba_reghelper.hxx dba/dbaccess/source/shared/dba_reghelper.cxx
Modified: dba/dbaccess/source/core/dataaccess/documentcontainer.cxx dba/dbaccess/source/core/dataaccess/documentdefinition.cxx dba/dbaccess/source/core/dataaccess/documentdefinition.hxx dba/dbaccess/source/core/dataaccess/intercept.cxx Log: RESYNC: (1.26-1.27); FILE MERGED File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: documentcontainer.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentcontainer.cxx?r1=1.26.48.1&r2=1.26.48.2 Delta lines: +4 -4 ------------------- --- documentcontainer.cxx 2008-02-14 13:20:23+0000 1.26.48.1 +++ documentcontainer.cxx 2008-02-15 07:37:11+0000 1.26.48.2 @@ -234,7 +234,7 @@ { aValue.Value >>= sURL; } - else if ( aValue.Name.equalsAscii(PROPERTY_ACTIVECONNECTION) ) + else if ( aValue.Name.equalsAscii(PROPERTY_ACTIVE_CONNECTION) ) { xConnection.set(aValue.Value,UNO_QUERY); } 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.46.1&r2=1.50.46.2 Delta lines: +199 -37 ---------------------- --- documentdefinition.cxx 2008-02-14 13:20:23+0000 1.50.46.1 +++ documentdefinition.cxx 2008-02-15 07:37:16+0000 1.50.46.2 @@ -292,7 +292,8 @@ { Reference< XEmbeddedObject > m_xBroadCaster; ODocumentDefinition* m_pDefinition; - sal_Bool m_bInStateChange; + bool m_bInStateChange; + bool m_bInChangingState; protected: virtual void SAL_CALL disposing(); public: @@ -300,7 +301,8 @@ : TEmbedObjectHolder(m_aMutex) ,m_xBroadCaster(_xBroadCaster) ,m_pDefinition(_pDefinition) - ,m_bInStateChange(sal_False) + ,m_bInStateChange(false) + ,m_bInChangingState(false) { osl_incrementInterlockedCount( &m_refCount ); { @@ -323,22 +325,28 @@ m_pDefinition = NULL; } //------------------------------------------------------------------ - void SAL_CALL OEmbedObjectHolder::changingState( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 /*nOldState*/, ::sal_Int32 /*nNewState*/ ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException) + void SAL_CALL OEmbedObjectHolder::changingState( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException) { + if ( !m_bInChangingState && nNewState == EmbedStates::RUNNING && nOldState == EmbedStates::ACTIVE && m_pDefinition ) + { + m_bInChangingState = true; + //m_pDefinition->save(sal_False); + m_bInChangingState = false; + } } //------------------------------------------------------------------ void SAL_CALL OEmbedObjectHolder::stateChanged( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException) { if ( !m_bInStateChange && nNewState == EmbedStates::RUNNING && nOldState == EmbedStates::ACTIVE && m_pDefinition ) { - m_bInStateChange = sal_True; + m_bInStateChange = true; Reference<XInterface> xInt(static_cast< ::cppu::OWeakObject* >(m_pDefinition),UNO_QUERY); { Reference<XEmbeddedObject> xEmbeddedObject(aEvent.Source,UNO_QUERY); if ( xEmbeddedObject.is() ) xEmbeddedObject->changeState(EmbedStates::LOADED); } - m_bInStateChange = sal_False; + m_bInStateChange = false; } } //------------------------------------------------------------------ @@ -848,12 +856,6 @@ Reference< XConnection > xConnection; sal_Int32 nOpenMode = OpenMode::DOCUMENT; - // our own 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 bExecuteOwnMacros = m_pImpl->m_pDataSource->adjustMacroMode_AutoReject(); - sal_Int16 nDocumentMacroMode = MacroExecMode::ALWAYS_EXECUTE_NO_WARN; - ::comphelper::NamedValueCollection aDocumentArgs; // for the document, default to the interaction handler as used for loading the DB doc @@ -861,6 +863,8 @@ ::comphelper::NamedValueCollection aDBDocArgs( m_pImpl->m_pDataSource->m_aArgs ); aDocumentArgs.put( "InteractionHandler", aDBDocArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) ); + ::boost::optional< sal_Int16 > aDocumentMacroMode; + if ( !lcl_extractOpenMode( _rOpenArgument, nOpenMode ) ) { Sequence< PropertyValue > aArguments; @@ -870,7 +874,7 @@ const PropertyValue* pEnd = pIter + aArguments.getLength(); for ( ;pIter != pEnd; ++pIter ) { - if ( pIter->Name == PROPERTY_ACTIVECONNECTION ) + if ( pIter->Name == PROPERTY_ACTIVE_CONNECTION ) { xConnection.set( pIter->Value, UNO_QUERY ); continue; @@ -881,7 +885,9 @@ if ( pIter->Name.equalsAscii( "MacroExecutionMode" ) ) { - OSL_VERIFY( pIter->Value >>= nDocumentMacroMode ); + sal_Int16 nMacroExecMode( *aDocumentMacroMode ); + OSL_VERIFY( pIter->Value >>= nMacroExecMode ); + aDocumentMacroMode.reset( nMacroExecMode ); continue; } @@ -891,20 +897,54 @@ } } + // 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(); + // allow the command arguments to downgrade the macro execution mode, but not to upgrade // it - if ( !bExecuteOwnMacros ) + if ( ( m_pImpl->m_pDataSource->getImposedMacroExecMode() == MacroExecMode::USE_CONFIG ) + && bExecuteDBDocMacros + ) { - // no macros per DB doc -> no macros in the embedded doc - nDocumentMacroMode = MacroExecMode::NEVER_EXECUTE; + // while loading the whole database document, USE_CONFIG, or *no* macro exec mode was passed. + // Additionally, *by now* executing macros from the DB doc is allowed (this is what bExecuteDBDocMacros + // indicates). This means either one of: + // 1. The DB doc or one of the sub docs contained macros and + // 1a. the user explicitly allowed executing them + // 1b. the configuration allows executing them without asking the user + // 2. Neither the DB doc nor the sub docs contained macros, thus macro + // execution was silently enabled, assuming that any macro will be a + // user-created macro + // + // 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 + // 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, + // regardless of the global security settings - which would be a security issue, of + // course. + if ( !m_pImpl->m_pDataSource->hasAnyObjectWithMacros() ) + { + // this is case 2. from above (not *exactly*, but sufficiently) + // So, pass a USE_CONFIG to the to-be-loaded document. This means that + // the user will be prompted with a security message upon opening this + // sub document, in case the settings require this, *and* the document + // contains scripts in the content.xml. But this is better than the security + // issue we had before ... + aDocumentMacroMode.reset( MacroExecMode::USE_CONFIG ); } - else - { - // DB doc allows macros -> allow macros in the embedded doc, unless explicitly prohibited - if ( nDocumentMacroMode != MacroExecMode::NEVER_EXECUTE ) - nDocumentMacroMode = MacroExecMode::ALWAYS_EXECUTE_NO_WARN; } - aDocumentArgs.put( "MacroExecutionMode", nDocumentMacroMode ); + + if ( !aDocumentMacroMode ) + { + // nobody so far felt responsible for setting it + // => use the DBDoc-wide macro exec mode for the document, too + aDocumentMacroMode.reset( bExecuteDBDocMacros ? MacroExecMode::ALWAYS_EXECUTE_NO_WARN : MacroExecMode::NEVER_EXECUTE ); + } + aDocumentArgs.put( "MacroExecutionMode", *aDocumentMacroMode ); if ( xConnection.is() ) @@ -1068,6 +1108,13 @@ notifyDataSourceModified(); } } + else if ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) + { + bool bClose = prepareClose(); + if ( bClose && m_xEmbeddedObject.is() ) + m_xEmbeddedObject->changeState(EmbedStates::LOADED); + aRet <<= bClose; + } else { aRet = OContentHelper::execute(aCommand,CommandId,Environment); @@ -1282,6 +1329,112 @@ } return sal_True; } +// ----------------------------------------------------------------------------- +sal_Bool ODocumentDefinition::saveAs() +{ + // default handling: instantiate an interaction handler and let it handle the parameter request + if ( !m_bOpenInDesign ) + return sal_False; + try + { + { + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + + // the request + Reference<XNameAccess> xName(m_xParentContainer,UNO_QUERY); + DocumentSaveRequest aRequest; + aRequest.Name = m_pImpl->m_aProps.aTitle; + if ( !aRequest.Name.getLength() ) + { + if ( m_bForm ) + aRequest.Name = DBACORE_RESSTRING( RID_STR_FORM ); + else + aRequest.Name = DBACORE_RESSTRING( RID_STR_REPORT ); + aRequest.Name = ::dbtools::createUniqueName(xName,aRequest.Name); + } + + aRequest.Content.set(m_xParentContainer,UNO_QUERY); + OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest)); + Reference< XInteractionRequest > xRequest(pRequest); + // some knittings + // two continuations allowed: OK and Cancel + ODocumentSaveContinuation* pDocuSave = new ODocumentSaveContinuation; + pRequest->addContinuation(pDocuSave); + OInteraction< XInteractionDisapprove >* pDisApprove = new OInteraction< XInteractionDisapprove >; + pRequest->addContinuation(pDisApprove); + OInteractionAbort* pAbort = new OInteractionAbort; + pRequest->addContinuation(pAbort); + + // create the handler, let it handle the request + Reference< XInteractionHandler > xHandler(m_aContext.createComponent(::rtl::OUString(SERVICE_SDB_INTERACTION_HANDLER)), UNO_QUERY); + if ( xHandler.is() ) + xHandler->handle(xRequest); + + if ( pAbort->wasSelected() ) + return sal_False; + if ( pDisApprove->wasSelected() ) + return sal_True; + if ( pDocuSave->wasSelected() ) + { + ::osl::MutexGuard aGuard(m_aMutex); + Reference<XNameContainer> xNC(pDocuSave->getContent(),UNO_QUERY); + if ( xNC.is() ) + { + try + { + Reference< XStorage> xStorage = getStorage(); + const static ::rtl::OUString sBaseName(RTL_CONSTASCII_USTRINGPARAM("Obj")); + // ----------------------------------------------------------------------------- + Reference<XNameAccess> xElements(xStorage,UNO_QUERY_THROW); + ::rtl::OUString sPersistentName = ::dbtools::createUniqueName(xElements,sBaseName); + xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xStorage,sPersistentName); + + ::rtl::OUString sOldName = m_pImpl->m_aProps.aTitle; + rename(pDocuSave->getName()); + updateDocumentTitle(); + + Sequence< Any > aArguments(3); + PropertyValue aValue; + // set as folder + aValue.Name = PROPERTY_NAME; + aValue.Value <<= sOldName; + aArguments[0] <<= aValue; + + aValue.Name = PROPERTY_PERSISTENT_NAME; + aValue.Value <<= sPersistentName; + aArguments[1] <<= aValue; + + aValue.Name = PROPERTY_AS_TEMPLATE; + aValue.Value <<= m_pImpl->m_aProps.bAsTemplate; + aArguments[2] <<= aValue; + + Reference< XMultiServiceFactory > xORB( m_xParentContainer, UNO_QUERY_THROW ); + Reference< XInterface > xComponent( xORB->createInstanceWithArguments( SERVICE_SDB_DOCUMENTDEFINITION, aArguments ) ); + Reference< XNameContainer > xNameContainer( m_xParentContainer, UNO_QUERY_THROW ); + xNameContainer->insertByName( sOldName, makeAny( xComponent ) ); + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + } + + ::osl::MutexGuard aGuard(m_aMutex); + Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY); + if ( xPersist.is() ) + { + xPersist->storeOwn(); + notifyDataSourceModified(); + } + } + catch(Exception&) + { + OSL_ENSURE(0,"ODocumentDefinition::save: caught an Exception (tried to let the InteractionHandler handle it)!"); + } + return sal_True; +} namespace { @@ -1400,12 +1553,12 @@ sDocumentService = GetDocumentServiceFromMediaType( xStorage, m_pImpl->m_aProps.sPersistentName, m_aContext.getLegacyServiceFactory(), aClassID ); // check if we are not a form and // the com.sun.star.report.pentaho.SOReportJobFactory is not present. - if (m_bForm == 0 /* MAGIC! */ && !sDocumentService.equalsAscii("com.sun.star.text.TextDocument")) + if ( !m_bForm && !sDocumentService.equalsAscii("com.sun.star.text.TextDocument")) { // we seems to be a new report, check if report extension is present. Reference< XContentEnumerationAccess > xEnumAccess( m_aContext.getLegacyServiceFactory(), UNO_QUERY ); - static ::rtl::OUString s_sReportDesign(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory")); - Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(s_sReportDesign); + const ::rtl::OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_aContext.getLegacyServiceFactory()); + Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName); if ( !xEnumDrivers.is() || !xEnumDrivers->hasMoreElements() ) { com::sun::star::io::WrongFormatException aWFE; @@ -1662,7 +1815,15 @@ // controller vetoed the closing return false; - if ( isModified() && !save( sal_True ) ) + if ( isModified() ) + { + Reference< XFrame > xFrame( xController->getFrame() ); + if ( xFrame.is() ) + { + Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW ); + xTopWindow->toFront(); + } + if ( !save( sal_True ) ) { if ( bCouldSuspend ) // revert suspension @@ -1671,6 +1832,7 @@ return false; } } + } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: documentdefinition.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.hxx?r1=1.24.46.1&r2=1.24.46.2 Delta lines: +6 -7 ------------------- --- documentdefinition.hxx 2008-02-14 13:20:24+0000 1.24.46.1 +++ documentdefinition.hxx 2008-02-15 07:37:19+0000 1.24.46.2 @@ -42,9 +42,6 @@ #ifndef _CPPUHELPER_IMPLBASE1_HXX_ #include <cppuhelper/implbase1.hxx> #endif -#ifndef _DBA_REGHELPER_HXX_ -#include "dba_reghelper.hxx" -#endif #ifndef DBA_CONTENTHELPER_HXX #include "ContentHelper.hxx" #endif @@ -146,9 +143,11 @@ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> getStorage() const; sal_Bool save(sal_Bool _bApprove); + sal_Bool saveAs(); void closeObject(); sal_Bool isModified(); - void fillReportData(::osl::ClearableMutexGuard & _aGuard); + void fillReportData(); + inline sal_Bool isNewReport() const { return !m_bForm && !m_pImpl->m_aProps.bAsTemplate; } /** prepares closing the document component Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: intercept.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/intercept.cxx?r1=1.8.228.1&r2=1.8.228.2 Delta lines: +44 -33 --------------------- --- intercept.cxx 2008-02-14 13:20:24+0000 1.8.228.1 +++ intercept.cxx 2008-02-15 07:37:22+0000 1.8.228.2 @@ -160,6 +160,12 @@ } else if( _URL.Complete == m_aInterceptedURL[DISPATCH_SAVEAS] ) { + if ( m_pContentHolder->isNewReport() ) + { + m_pContentHolder->saveAs(); + } + else + { Sequence< PropertyValue > aNewArgs = Arguments; sal_Int32 nInd = 0; @@ -185,6 +191,7 @@ if ( xDispatch.is() ) xDispatch->dispatch( _URL, aNewArgs ); } + } else if ( _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEDOC] || _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEWIN] || _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEFRAME] @@ -221,6 +228,9 @@ if ( m_pContentHolder && _URL.Complete == m_aInterceptedURL[DISPATCH_SAVEAS] ) { // SaveAs + + if ( !m_pContentHolder->isNewReport() ) + { FeatureStateEvent aStateEvent; aStateEvent.FeatureURL.Complete = m_aInterceptedURL[DISPATCH_SAVEAS]; aStateEvent.FeatureDescriptor = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SaveCopyTo")); @@ -228,6 +238,7 @@ aStateEvent.Requery = sal_False; aStateEvent.State <<= (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("($3)"))); Control->statusChanged(aStateEvent); + } { osl::MutexGuard aGuard(m_aMutex); Directory: /dba/dbaccess/source/inc/ ==================================== File [removed]: dba_reghelper.hxx Directory: /dba/dbaccess/source/shared/ ======================================= File [removed]: dba_reghelper.cxx --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
