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
This commit is contained in:
Frank Schoenheit [fs] 2010-01-15 15:21:15 +01:00
parent 216cc35f85
commit d0e9f1f751
4 changed files with 41 additions and 17 deletions

View file

@ -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
{

View file

@ -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

View file

@ -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;

View file

@ -35,6 +35,7 @@
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/embed/XVisualObject.hpp>
#include <com/sun/star/embed/XEmbedPersist.hpp>
@ -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 );