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/embedobj.cxx | 2 +- embeddedobj/source/commonembedding/miscobj.cxx | 3 +- embeddedobj/source/commonembedding/persistence.cxx | 44 +++++++++++++++------- embeddedobj/source/inc/commonembobj.hxx | 9 ++++- 4 files changed, 41 insertions(+), 17 deletions(-) (limited to 'embeddedobj/source') diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 85f9b8b0b2c9..1884b1b84a9e 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -192,7 +192,7 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) if ( !m_xObjectStorage.is() ) throw io::IOException(); //TODO: access denied - m_pDocHolder->SetComponent( LoadDocumentFromStorage_Impl( m_xObjectStorage ), m_bReadOnly ); + m_pDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly ); } else { diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx index db515570fe98..f666cfc4912a 100644 --- a/embeddedobj/source/commonembedding/miscobj.cxx +++ b/embeddedobj/source/commonembedding/miscobj.cxx @@ -646,7 +646,8 @@ void SAL_CALL OCommonEmbeddedObject::close( sal_Bool bDeliverOwnership ) } catch ( uno::Exception& ) {} } - m_xObjectStorage = uno::Reference< embed::XStorage >(); + m_xObjectStorage.clear(); + m_xObjectLoadStorage.clear(); } m_bClosed = sal_True; // the closing succeeded 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; diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx index 68c00500ff58..69cdb3d4c7a3 100644 --- a/embeddedobj/source/inc/commonembobj.hxx +++ b/embeddedobj/source/inc/commonembobj.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -150,6 +151,7 @@ protected: ::rtl::OUString m_aEntryName; ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xParentStorage; ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xObjectStorage; + ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xObjectLoadStorage; // link related stuff ::rtl::OUString m_aLinkURL; @@ -200,8 +202,7 @@ private: ::com::sun::star::uno::Sequence< sal_Int32 > GetIntermediateStatesSequence_Impl( sal_Int32 nNewState ); ::rtl::OUString GetFilterName( sal_Int32 nVersion ); - ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > LoadDocumentFromStorage_Impl( - const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); + ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > LoadDocumentFromStorage_Impl(); ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > LoadLink_Impl(); @@ -213,6 +214,10 @@ private: const ::rtl::OUString& aHierarchName, sal_Bool bAttachToStorage ); + void SwitchDocToStorage_Impl( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageBasedDocument >& xDoc, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); + ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > CreateDocFromMediaDescr_Impl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMedDescr ); -- cgit