Tag: cws_src680_custommeta User: mst Date: 2008-02-01 10:34:34+0000 Removed: dba/dbaccess/source/inc/dba_reghelper.hxx dba/dbaccess/source/shared/dba_reghelper.cxx
Modified: dba/dbaccess/source/core/dataaccess/documentdefinition.cxx dba/dbaccess/source/core/dataaccess/documentdefinition.hxx dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx dba/dbaccess/source/ui/misc/HtmlReader.cxx dba/dbaccess/source/ui/misc/TokenWriter.cxx Log: RESYNC: (1.50-1.53); 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.50.26.1&r2=1.50.26.2 Delta lines: +199 -37 ---------------------- --- documentdefinition.cxx 2008-01-29 13:14:59+0000 1.50.26.1 +++ documentdefinition.cxx 2008-02-01 10:33:41+0000 1.50.26.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() ) @@ -1056,6 +1096,13 @@ dispose(); } + 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); } @@ -1268,6 +1315,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 { @@ -1386,12 +1539,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; @@ -1649,7 +1802,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 @@ -1658,6 +1819,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.26.1&r2=1.24.26.2 Delta lines: +5 -6 ------------------- --- documentdefinition.hxx 2008-01-29 13:14:59+0000 1.24.26.1 +++ documentdefinition.hxx 2008-02-01 10:33:44+0000 1.24.26.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(); + inline sal_Bool isNewReport() const { return !m_bForm && !m_pImpl->m_aProps.bAsTemplate; } /** prepares closing the document component Directory: /dba/dbaccess/source/inc/ ==================================== File [removed]: dba_reghelper.hxx Directory: /dba/dbaccess/source/shared/ ======================================= File [removed]: dba_reghelper.cxx Directory: /dba/dbaccess/source/ui/app/ ======================================= File [changed]: AppDetailPageHelper.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx?r1=1.27.68.1&r2=1.27.68.2 Delta lines: +5 -3 ------------------- --- AppDetailPageHelper.cxx 2008-01-29 13:14:58+0000 1.27.68.1 +++ AppDetailPageHelper.cxx 2008-02-01 10:33:53+0000 1.27.68.2 @@ -1388,3 +1388,5 @@ SetBackground( rStyleSettings.GetFieldColor() ); } // ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: HtmlReader.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/HtmlReader.cxx?r1=1.31.28.1&r2=1.31.28.2 Delta lines: +9 -9 ------------------- --- HtmlReader.cxx 2008-01-16 17:15:33+0000 1.31.28.1 +++ HtmlReader.cxx 2008-02-01 10:33:57+0000 1.31.28.2 @@ -180,8 +180,8 @@ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM, const TColumnVector* pList, const OTypeInfoMap* _pInfoMap) - : HTMLParser(rIn) - ,ODatabaseExport(_rxConnection,_rxNumberF,_rM,pList,_pInfoMap) + :HTMLParser(rIn) + ,ODatabaseExport( _rxConnection, _rxNumberF, _rM, pList, _pInfoMap, rIn ) ,m_nTableCount(0) ,m_nColumnWidth(87) ,m_bMetaOptions(sal_False) @@ -201,8 +201,8 @@ const TColumnVector* pList, const OTypeInfoMap* _pInfoMap, sal_Bool _bAutoIncrementEnabled) - : HTMLParser(rIn) - ,ODatabaseExport(nRows,_rColumnPositions,_rxNumberF,_rM,pList,_pInfoMap,_bAutoIncrementEnabled) + :HTMLParser(rIn) + ,ODatabaseExport( nRows, _rColumnPositions, _rxNumberF, _rM, pList, _pInfoMap, _bAutoIncrementEnabled, rIn ) ,m_nTableCount(0) ,m_nColumnWidth(87) ,m_bMetaOptions(sal_False) @@ -666,10 +666,10 @@ ReleaseRef(); } // ----------------------------------------------------------------------------- -OWizTypeSelect* OHTMLReader::createPage(Window* _pParent) +TypeSelectionPageFactory OHTMLReader::getTypeSelectionPageFactory() { DBG_CHKTHIS(OHTMLReader,NULL); - return new OWizHTMLExtend(_pParent,rInput); + return &OWizHTMLExtend::Create; } // ----------------------------------------------------------------------------- Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: TokenWriter.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/TokenWriter.cxx?r1=1.34.68.1&r2=1.34.68.2 Delta lines: +5 -5 ------------------- --- TokenWriter.cxx 2008-01-16 17:15:33+0000 1.34.68.1 +++ TokenWriter.cxx 2008-02-01 10:34:00+0000 1.34.68.2 @@ -363,8 +363,8 @@ Reference<XPropertySet > xProp(m_xResultSet,UNO_QUERY); if(xProp.is()) { - xProp->setPropertyValue( PROPERTY_ACTIVECONNECTION, makeAny( m_xConnection.getTyped() ) ); - xProp->setPropertyValue(PROPERTY_COMMANDTYPE,makeAny(m_nCommandType)); + xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) ); + xProp->setPropertyValue(PROPERTY_COMMAND_TYPE,makeAny(m_nCommandType)); xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(m_sName)); Reference<XRowSet> xRowSet(xProp,UNO_QUERY); xRowSet->execute(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
