From af7c6403dc669c0565be7530d50fef3445ad5e39 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 6 Jan 2010 21:34:53 +0100 Subject: autorecovery: allow creating SFX-based documents which do not support the XDocumentRecovery interface For this purpose, the SFX document factory methods got an additional parameter respectively flag ("DocumentRecoverySupport" resp. SFXMODEL_DISABLE_DOCUMENT_RECOVERY). This flag is used by database documents to remove the interface from sub documents (aka forms/reports). In this course, some of the functionality around those SFXMODELL_* flags, previously duplicated in all applications, has been consolidated into a new SfxObjectShell constructor. --- embeddedobj/source/commonembedding/persistence.cxx | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'embeddedobj/source/commonembedding/persistence.cxx') diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 47b16bf961af..9af3cf91c359 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -63,6 +63,7 @@ #include #include #include +#include #include @@ -199,22 +200,17 @@ uno::Reference< io::XInputStream > createTempInpStreamFromStor( //------------------------------------------------------ static uno::Reference< util::XCloseable > CreateDocument( const uno::Reference< lang::XMultiServiceFactory >& _rxFactory, - const ::rtl::OUString& _rDocumentServiceName, bool _bEmbeddedScriptSupport ) + const ::rtl::OUString& _rDocumentServiceName, bool _bEmbeddedScriptSupport, const bool i_bDocumentRecoverySupport ) { - uno::Sequence< uno::Any > aArguments(2); - aArguments[0] <<= beans::NamedValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EmbeddedObject" ) ), - uno::makeAny( (sal_Bool)sal_True ) - ); - aArguments[1] <<= beans::NamedValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EmbeddedScriptSupport" ) ), - uno::makeAny( (sal_Bool)_bEmbeddedScriptSupport ) - ); + ::comphelper::NamedValueCollection aArguments; + aArguments.put( "EmbeddedObject", (sal_Bool)sal_True ); + aArguments.put( "EmbeddedScriptSupport", (sal_Bool)_bEmbeddedScriptSupport ); + aArguments.put( "DocumentRecoverySupport", (sal_Bool)i_bDocumentRecoverySupport ); uno::Reference< uno::XInterface > xDocument; try { - xDocument = _rxFactory->createInstanceWithArguments( _rDocumentServiceName, aArguments ); + xDocument = _rxFactory->createInstanceWithArguments( _rDocumentServiceName, aArguments.getWrappedPropertyValues() ); } catch( const uno::Exception& ) { @@ -308,7 +304,7 @@ void OCommonEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::X uno::Reference< util::XCloseable > OCommonEmbeddedObject::InitNewDocument_Impl() { uno::Reference< util::XCloseable > xDocument( CreateDocument( m_xFactory, GetDocumentServiceName(), - m_bEmbeddedScriptSupport ) ); + m_bEmbeddedScriptSupport, m_bDocumentRecoverySupport ) ); uno::Reference< frame::XModel > xModel( xDocument, uno::UNO_QUERY ); uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY ); @@ -359,7 +355,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::InitNewDocument_Impl() uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadLink_Impl() { uno::Reference< util::XCloseable > xDocument( CreateDocument( m_xFactory, GetDocumentServiceName(), - m_bEmbeddedScriptSupport ) ); + m_bEmbeddedScriptSupport, m_bDocumentRecoverySupport ) ); uno::Reference< frame::XLoadable > xLoadable( xDocument, uno::UNO_QUERY ); if ( !xLoadable.is() ) @@ -462,7 +458,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag OSL_ENSURE( xStorage.is(), "The storage can not be empty!" ); uno::Reference< util::XCloseable > xDocument( CreateDocument( m_xFactory, GetDocumentServiceName(), - m_bEmbeddedScriptSupport ) ); + m_bEmbeddedScriptSupport, m_bDocumentRecoverySupport ) ); //#i103460# ODF: take the size given from the parent frame as default uno::Reference< chart2::XChartDocument > xChart( xDocument, uno::UNO_QUERY ); @@ -804,7 +800,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::CreateDocFromMediaDesc const uno::Sequence< beans::PropertyValue >& aMedDescr ) { uno::Reference< util::XCloseable > xDocument( CreateDocument( m_xFactory, GetDocumentServiceName(), - m_bEmbeddedScriptSupport ) ); + m_bEmbeddedScriptSupport, m_bDocumentRecoverySupport ) ); uno::Reference< frame::XLoadable > xLoadable( xDocument, uno::UNO_QUERY ); if ( !xLoadable.is() ) @@ -1063,6 +1059,10 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry( { OSL_VERIFY( lObjArgs[nObjInd].Value >>= m_bEmbeddedScriptSupport ); } + else if ( lObjArgs[nObjInd].Name.equalsAscii( "DocumentRecoverySupport" ) ) + { + OSL_VERIFY( lObjArgs[nObjInd].Value >>= m_bDocumentRecoverySupport ); + } sal_Int32 nStorageMode = m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE; -- cgit From d0e9f1f751ecd16597d6a06276a40dfb4ae00fb8 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 15 Jan 2010 15:21:15 +0100 Subject: autorecovery: save/recover forms and reports Still some lose ends. Most notably, the current code contains cases for other sub component types, but has no real implementation - attempting to save/recover those other types will yield multiple assertions only. Also, recovery of SRB-reports has not been tested, yet, chances are good there's some work ahead here. Other known open issues: - recovering sub components immediately shows them, instead of initially hiding them, and showing only when the main document window is shown - the implementation currently is no real session save, which would require saving information about *unmodified* open sub components (though not their actual content), and restoring them upon recovery. - doing an implicit "connect" at the controller of the to-be-recovered database document is a requirement to actually load the sub components, but might yield problems in case this requires interaction (e.g. a login). Need to investigate - the "recovery" storage is not removed from the database document storage after un/successful recovery - cancelling the recovery of a "modified" database document always suggests to store this doc somewhere --- embeddedobj/source/commonembedding/persistence.cxx | 44 +++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'embeddedobj/source/commonembedding/persistence.cxx') diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 9af3cf91c359..a2c3d2bcef64 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -272,7 +272,7 @@ void OCommonEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::X { uno::Reference< document::XStorageBasedDocument > xDoc( m_pDocHolder->GetComponent(), uno::UNO_QUERY ); if ( xDoc.is() ) - xDoc->switchToStorage( m_xObjectStorage ); + SwitchDocToStorage_Impl( xDoc, m_xObjectStorage ); } #endif @@ -452,10 +452,9 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadLink_Impl() } //------------------------------------------------------ -uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorage_Impl( - const uno::Reference< embed::XStorage >& xStorage ) +uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorage_Impl() { - OSL_ENSURE( xStorage.is(), "The storage can not be empty!" ); + OSL_ENSURE( m_xObjectStorage.is(), "The storage can not be empty!" ); uno::Reference< util::XCloseable > xDocument( CreateDocument( m_xFactory, GetDocumentServiceName(), m_bEmbeddedScriptSupport, m_bDocumentRecoverySupport ) ); @@ -478,7 +477,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag if ( !xDoc.is() && !xLoadable.is() ) ///BUG: This should be || instead of && ? throw uno::RuntimeException(); - ::rtl::OUString aFilterName = GetFilterName( ::comphelper::OStorageHelper::GetXStorageFormat( xStorage ) ); + ::rtl::OUString aFilterName = GetFilterName( ::comphelper::OStorageHelper::GetXStorageFormat( m_xObjectStorage ) ); OSL_ENSURE( aFilterName.getLength(), "Wrong document service name!" ); if ( !aFilterName.getLength() ) @@ -499,7 +498,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag uno::Reference< io::XInputStream > xTempInpStream; if ( !xDoc.is() ) { - xTempInpStream = createTempInpStreamFromStor( xStorage, m_xFactory ); + xTempInpStream = createTempInpStreamFromStor( m_xObjectStorage, m_xFactory ); if ( !xTempInpStream.is() ) throw uno::RuntimeException(); @@ -550,7 +549,15 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag } if ( xDoc.is() ) - xDoc->loadFromStorage( xStorage, aArgs ); + { + if ( m_xObjectLoadStorage.is() ) + { + xDoc->loadFromStorage( m_xObjectLoadStorage, aArgs ); + SwitchDocToStorage_Impl( xDoc, m_xObjectStorage ); + } + else + xDoc->loadFromStorage( m_xObjectStorage, aArgs ); + } else xLoadable->load( aArgs ); } @@ -725,6 +732,18 @@ void OCommonEmbeddedObject::SaveObject_Impl() } +//------------------------------------------------------ +void OCommonEmbeddedObject::SwitchDocToStorage_Impl( const uno::Reference< document::XStorageBasedDocument >& xDoc, const uno::Reference< embed::XStorage >& xStorage ) +{ + xDoc->switchToStorage( xStorage ); + uno::Reference< util::XModifiable > xModif( xDoc, uno::UNO_QUERY ); + if ( xModif.is() ) + xModif->setModified( sal_False ); + + if ( m_xObjectLoadStorage.is() ) + m_xObjectLoadStorage.clear(); +} + //------------------------------------------------------ void OCommonEmbeddedObject::StoreDocToStorage_Impl( const uno::Reference< embed::XStorage >& xStorage, sal_Int32 nStorageFormat, @@ -763,12 +782,7 @@ void OCommonEmbeddedObject::StoreDocToStorage_Impl( const uno::Reference< embed: xDoc->storeToStorage( xStorage, aArgs ); if ( bAttachToTheStorage ) - { - xDoc->switchToStorage( xStorage ); - uno::Reference< util::XModifiable > xModif( m_pDocHolder->GetComponent(), uno::UNO_QUERY ); - if ( xModif.is() ) - xModif->setModified( sal_False ); - } + SwitchDocToStorage_Impl( xDoc, xStorage ); } else #endif @@ -1063,6 +1077,10 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry( { OSL_VERIFY( lObjArgs[nObjInd].Value >>= m_bDocumentRecoverySupport ); } + else if ( lObjArgs[nObjInd].Name.equalsAscii( "RecoverFromStorage" ) ) + { + OSL_VERIFY( lObjArgs[nObjInd].Value >>= m_xObjectLoadStorage ); + } sal_Int32 nStorageMode = m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE; -- cgit From 6d315e9820439bd8566491da9fcd5fcb28174db7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 26 Jan 2010 13:19:11 +0100 Subject: autorecovery: mav sanctioned the approach of the (now so-called) RecoveryStorage --- embeddedobj/source/commonembedding/persistence.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'embeddedobj/source/commonembedding/persistence.cxx') diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index a2c3d2bcef64..e9aa0edd0ec8 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -550,9 +550,9 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag if ( xDoc.is() ) { - if ( m_xObjectLoadStorage.is() ) + if ( m_xRecoveryStorage.is() ) { - xDoc->loadFromStorage( m_xObjectLoadStorage, aArgs ); + xDoc->loadFromStorage( m_xRecoveryStorage, aArgs ); SwitchDocToStorage_Impl( xDoc, m_xObjectStorage ); } else @@ -736,12 +736,13 @@ void OCommonEmbeddedObject::SaveObject_Impl() void OCommonEmbeddedObject::SwitchDocToStorage_Impl( const uno::Reference< document::XStorageBasedDocument >& xDoc, const uno::Reference< embed::XStorage >& xStorage ) { xDoc->switchToStorage( xStorage ); + uno::Reference< util::XModifiable > xModif( xDoc, uno::UNO_QUERY ); if ( xModif.is() ) xModif->setModified( sal_False ); - if ( m_xObjectLoadStorage.is() ) - m_xObjectLoadStorage.clear(); + if ( m_xRecoveryStorage.is() ) + m_xRecoveryStorage.clear(); } //------------------------------------------------------ @@ -1077,9 +1078,9 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry( { OSL_VERIFY( lObjArgs[nObjInd].Value >>= m_bDocumentRecoverySupport ); } - else if ( lObjArgs[nObjInd].Name.equalsAscii( "RecoverFromStorage" ) ) + else if ( lObjArgs[nObjInd].Name.equalsAscii( "RecoveryStorage" ) ) { - OSL_VERIFY( lObjArgs[nObjInd].Value >>= m_xObjectLoadStorage ); + OSL_VERIFY( lObjArgs[nObjInd].Value >>= m_xRecoveryStorage ); } -- cgit From 8ae0efd7d8888ae6f3444e1633d8a6afc92519ea Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 27 Jan 2010 10:53:30 +0100 Subject: autorecovery: when creating a new document, also respect the RecoveryStorage parameter --- embeddedobj/source/commonembedding/persistence.cxx | 180 +++++++++++---------- 1 file changed, 93 insertions(+), 87 deletions(-) (limited to 'embeddedobj/source/commonembedding/persistence.cxx') diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index e9aa0edd0ec8..55170093c43e 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -67,6 +67,8 @@ #include +#include + #define USE_STORAGEBASED_DOCUMENT using namespace ::com::sun::star; @@ -198,6 +200,22 @@ uno::Reference< io::XInputStream > createTempInpStreamFromStor( } +//------------------------------------------------------ +static void TransferMediaType( const uno::Reference< embed::XStorage >& i_rSource, const uno::Reference< embed::XStorage >& i_rTarget ) +{ + try + { + const uno::Reference< beans::XPropertySet > xSourceProps( i_rSource, uno::UNO_QUERY_THROW ); + const uno::Reference< beans::XPropertySet > xTargetProps( i_rTarget, uno::UNO_QUERY_THROW ); + const ::rtl::OUString sMediaTypePropName( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ); + xTargetProps->setPropertyValue( sMediaTypePropName, xSourceProps->getPropertyValue( sMediaTypePropName ) ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + //------------------------------------------------------ static uno::Reference< util::XCloseable > CreateDocument( const uno::Reference< lang::XMultiServiceFactory >& _rxFactory, const ::rtl::OUString& _rDocumentServiceName, bool _bEmbeddedScriptSupport, const bool i_bDocumentRecoverySupport ) @@ -300,6 +318,23 @@ void OCommonEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::X SwitchOwnPersistence( xNewParentStorage, xNewOwnStorage, aNewName ); } +//------------------------------------------------------ +void OCommonEmbeddedObject::EmbedAndReparentDoc_Impl( const uno::Reference< util::XCloseable >& i_rxDocument ) const +{ + SetDocToEmbedded( uno::Reference< frame::XModel >( i_rxDocument, uno::UNO_QUERY ), m_aModuleName ); + + try + { + uno::Reference < container::XChild > xChild( i_rxDocument, uno::UNO_QUERY ); + if ( xChild.is() ) + xChild->setParent( m_xParent ); + } + catch( const lang::NoSupportException & ) + { + OSL_ENSURE( false, "OCommonEmbeddedObject::EmbedAndReparentDoc: cannot set parent at document!" ); + } +} + //------------------------------------------------------ uno::Reference< util::XCloseable > OCommonEmbeddedObject::InitNewDocument_Impl() { @@ -314,22 +349,31 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::InitNewDocument_Impl() try { // set the document mode to embedded as the first action on document!!! - SetDocToEmbedded( xModel, m_aModuleName ); + EmbedAndReparentDoc_Impl( xDocument ); - try + // if we have a storage to recover the document from, do not use initNew, but instead load from that storage + bool bInitNew = true; + if ( m_xRecoveryStorage.is() ) { - uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY ); - if ( xChild.is() ) - xChild->setParent( m_xParent ); + uno::Reference< document::XStorageBasedDocument > xDoc( xLoadable, uno::UNO_QUERY ); + OSL_ENSURE( xDoc.is(), "OCommonEmbeddedObject::InitNewDocument_Impl: cannot recover from a storage when the document is not storage based!" ); + if ( xDoc.is() ) + { + ::comphelper::NamedValueCollection aLoadArgs; + FillDefaultLoadArgs_Impl( m_xRecoveryStorage, aLoadArgs ); + + xDoc->loadFromStorage( m_xRecoveryStorage, aLoadArgs.getPropertyValues() ); + SwitchDocToStorage_Impl( xDoc, m_xObjectStorage ); + bInitNew = false; + } } - catch( const lang::NoSupportException & ) + + if ( bInitNew ) { - OSL_ENSURE( false, "Cannot set parent at document" ); + // init document as a new + xLoadable->initNew(); + xModel->attachResource( xModel->getURL(), m_aDocMediaDescriptor ); } - - // init document as a new - xLoadable->initNew(); - xModel->attachResource( xModel->getURL(),m_aDocMediaDescriptor); } catch( uno::Exception& ) { @@ -384,18 +428,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadLink_Impl() try { // the document is not really an embedded one, it is a link - SetDocToEmbedded( uno::Reference < frame::XModel >( xDocument, uno::UNO_QUERY ), m_aModuleName ); - - try - { - uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY ); - if ( xChild.is() ) - xChild->setParent( m_xParent ); - } - catch( const lang::NoSupportException & ) - { - OSL_ENSURE( false, "Cannot set parent at document" ); - } + EmbedAndReparentDoc_Impl( xDocument ); // load the document xLoadable->load( aArgs ); @@ -436,7 +469,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadLink_Impl() } //------------------------------------------------------ -::rtl::OUString OCommonEmbeddedObject::GetFilterName( sal_Int32 nVersion ) +::rtl::OUString OCommonEmbeddedObject::GetFilterName( sal_Int32 nVersion ) const { ::rtl::OUString aFilterName = GetPresetFilterName(); if ( !aFilterName.getLength() ) @@ -451,10 +484,28 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadLink_Impl() return aFilterName; } +//------------------------------------------------------ +void OCommonEmbeddedObject::FillDefaultLoadArgs_Impl( const uno::Reference< embed::XStorage >& i_rxStorage, + ::comphelper::NamedValueCollection& o_rLoadArgs ) const +{ + o_rLoadArgs.put( "DocumentBaseURL", GetBaseURL_Impl() ); + o_rLoadArgs.put( "HierarchicalDocumentName", m_aEntryName ); + o_rLoadArgs.put( "ReadOnly", m_bReadOnly ); + + ::rtl::OUString aFilterName = GetFilterName( ::comphelper::OStorageHelper::GetXStorageFormat( i_rxStorage ) ); + OSL_ENSURE( aFilterName.getLength(), "OCommonEmbeddedObject::FillDefaultLoadArgs_Impl: Wrong document service name!" ); + if ( !aFilterName.getLength() ) + throw io::IOException(); // TODO: error message/code + + o_rLoadArgs.put( "FilterName", aFilterName ); +} + //------------------------------------------------------ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorage_Impl() { - OSL_ENSURE( m_xObjectStorage.is(), "The storage can not be empty!" ); + ENSURE_OR_THROW( m_xObjectStorage.is(), "no object storage" ); + + const uno::Reference< embed::XStorage > xSourceStorage( m_xRecoveryStorage.is() ? m_xRecoveryStorage : m_xObjectStorage ); uno::Reference< util::XCloseable > xDocument( CreateDocument( m_xFactory, GetDocumentServiceName(), m_bEmbeddedScriptSupport, m_bDocumentRecoverySupport ) ); @@ -477,28 +528,13 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag if ( !xDoc.is() && !xLoadable.is() ) ///BUG: This should be || instead of && ? throw uno::RuntimeException(); - ::rtl::OUString aFilterName = GetFilterName( ::comphelper::OStorageHelper::GetXStorageFormat( m_xObjectStorage ) ); - - OSL_ENSURE( aFilterName.getLength(), "Wrong document service name!" ); - if ( !aFilterName.getLength() ) - throw io::IOException(); - - sal_Int32 nLen = xDoc.is() ? 4 : 6; - uno::Sequence< beans::PropertyValue > aArgs( nLen ); - - aArgs[0].Name = ::rtl::OUString::createFromAscii( "DocumentBaseURL" ); - aArgs[0].Value <<= GetBaseURL_Impl(); - aArgs[1].Name = ::rtl::OUString::createFromAscii( "HierarchicalDocumentName" ); - aArgs[1].Value <<= m_aEntryName; - aArgs[2].Name = ::rtl::OUString::createFromAscii( "ReadOnly" ); - aArgs[2].Value <<= m_bReadOnly; - aArgs[3].Name = ::rtl::OUString::createFromAscii( "FilterName" ); - aArgs[3].Value <<= aFilterName; + ::comphelper::NamedValueCollection aLoadArgs; + FillDefaultLoadArgs_Impl( xSourceStorage, aLoadArgs ); uno::Reference< io::XInputStream > xTempInpStream; if ( !xDoc.is() ) { - xTempInpStream = createTempInpStreamFromStor( m_xObjectStorage, m_xFactory ); + xTempInpStream = createTempInpStreamFromStor( xSourceStorage, m_xFactory ); if ( !xTempInpStream.is() ) throw uno::RuntimeException(); @@ -516,50 +552,27 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag OSL_ENSURE( aTempFileURL.getLength(), "Coudn't retrieve temporary file URL!\n" ); - aArgs[4].Name = ::rtl::OUString::createFromAscii( "URL" ); - aArgs[4].Value <<= aTempFileURL; // ::rtl::OUString::createFromAscii( "private:stream" ); - aArgs[5].Name = ::rtl::OUString::createFromAscii( "InputStream" ); - aArgs[5].Value <<= xTempInpStream; + aLoadArgs.put( "URL", aTempFileURL ); + aLoadArgs.put( "InputStream", xTempInpStream ); } - // aArgs[4].Name = ::rtl::OUString::createFromAscii( "AsTemplate" ); - // aArgs[4].Value <<= sal_True; + // aLoadArgs.put( "AsTemplate", sal_True ); - aArgs.realloc( m_aDocMediaDescriptor.getLength() + nLen ); - for ( sal_Int32 nInd = 0; nInd < m_aDocMediaDescriptor.getLength(); nInd++ ) - { - aArgs[nInd+nLen].Name = m_aDocMediaDescriptor[nInd].Name; - aArgs[nInd+nLen].Value = m_aDocMediaDescriptor[nInd].Value; - } + aLoadArgs.merge( m_aDocMediaDescriptor, true ); try { // set the document mode to embedded as the first step!!! - SetDocToEmbedded( uno::Reference < frame::XModel >( xDocument, uno::UNO_QUERY ), m_aModuleName ); - - try - { - uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY ); - if ( xChild.is() ) - xChild->setParent( m_xParent ); - } - catch( const lang::NoSupportException & ) - { - OSL_ENSURE( false, "Cannot set parent at document" ); - } + EmbedAndReparentDoc_Impl( xDocument ); if ( xDoc.is() ) { - if ( m_xRecoveryStorage.is() ) - { - xDoc->loadFromStorage( m_xRecoveryStorage, aArgs ); + xDoc->loadFromStorage( xSourceStorage, aLoadArgs.getPropertyValues() ); + if ( xSourceStorage != m_xObjectStorage ) SwitchDocToStorage_Impl( xDoc, m_xObjectStorage ); - } - else - xDoc->loadFromStorage( m_xObjectStorage, aArgs ); } else - xLoadable->load( aArgs ); + xLoadable->load( aLoadArgs.getPropertyValues() ); } catch( uno::Exception& ) { @@ -572,6 +585,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag } catch( uno::Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } @@ -661,7 +675,7 @@ void OCommonEmbeddedObject::SaveObject_Impl() } //------------------------------------------------------ -::rtl::OUString OCommonEmbeddedObject::GetBaseURL_Impl() +::rtl::OUString OCommonEmbeddedObject::GetBaseURL_Impl() const { ::rtl::OUString aBaseURL; sal_Int32 nInd = 0; @@ -824,18 +838,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::CreateDocFromMediaDesc try { // set the document mode to embedded as the first action on the document!!! - SetDocToEmbedded( uno::Reference < frame::XModel >( xDocument, uno::UNO_QUERY ), m_aModuleName ); - - try - { - uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY ); - if ( xChild.is() ) - xChild->setParent( m_xParent ); - } - catch( const lang::NoSupportException & ) - { - OSL_ENSURE( false, "Cannot set parent at document" ); - } + EmbedAndReparentDoc_Impl( xDocument ); xLoadable->load( addAsTemplate( aMedDescr ) ); } @@ -1117,6 +1120,9 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry( } else if ( nEntryConnectionMode == embed::EntryInitModes::TRUNCATE_INIT ) { + if ( m_xRecoveryStorage.is() ) + TransferMediaType( m_xRecoveryStorage, m_xObjectStorage ); + // TODO: m_pDocHolder->SetComponent( InitNewDocument_Impl(), m_bReadOnly ); -- cgit From bec6c2b0014b2b5f0d291914db4957c57eac4642 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 9 Feb 2010 23:10:16 +0100 Subject: autorecovery: even when loading a new document from a recovery storage, ensure that attachResource is called, for those (correct) implentations which do *not* implicitly do this in their loadFromStorage method --- embeddedobj/source/commonembedding/persistence.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'embeddedobj/source/commonembedding/persistence.cxx') diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 55170093c43e..2ef491cf73d4 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -372,8 +372,8 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::InitNewDocument_Impl() { // init document as a new xLoadable->initNew(); - xModel->attachResource( xModel->getURL(), m_aDocMediaDescriptor ); } + xModel->attachResource( xModel->getURL(), m_aDocMediaDescriptor ); } catch( uno::Exception& ) { -- cgit