summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-01-15 15:21:15 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-01-15 15:21:15 +0100
commit98955e2af1901eeb341686d7d5ae7c39a3e3c781 (patch)
tree872b4610ee2338aac2df5669750bae256fffc16f /embeddedobj
parent46f6a9943ed207e7ab975bd8dc955daa77fd3829 (diff)
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
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/source/commonembedding/embedobj.cxx2
-rw-r--r--embeddedobj/source/commonembedding/miscobj.cxx3
-rw-r--r--embeddedobj/source/commonembedding/persistence.cxx44
-rw-r--r--embeddedobj/source/inc/commonembobj.hxx9
4 files changed, 41 insertions, 17 deletions
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx
index 799e8654e9..62aa5aa7c9 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 884116978c..5b4b96e3be 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 dd0c84915b..d8dac0e093 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 );
}
@@ -726,6 +733,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,
const ::rtl::OUString& aBaseURL,
@@ -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 310a4e72f2..a610dfcfa8 100644
--- a/embeddedobj/source/inc/commonembobj.hxx
+++ b/embeddedobj/source/inc/commonembobj.hxx
@@ -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 );