From 2975955db0512b8ba6ac4a543cedcf8e2fe1879c Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Tue, 13 Apr 2010 15:25:33 +0200 Subject: fwk140: #i108978# copy sheets from stream only if a SFX event was notified before saving --- sc/source/filter/xml/sheetdata.cxx | 13 ++++++++++++- sc/source/filter/xml/xmlwrap.cxx | 27 ++++++++++++++++++--------- 2 files changed, 30 insertions(+), 10 deletions(-) (limited to 'sc/source/filter/xml') diff --git a/sc/source/filter/xml/sheetdata.cxx b/sc/source/filter/xml/sheetdata.cxx index 66b1c2579dd4..947c1370fa4b 100644 --- a/sc/source/filter/xml/sheetdata.cxx +++ b/sc/source/filter/xml/sheetdata.cxx @@ -43,7 +43,8 @@ ScSheetSaveData::ScSheetSaveData() : mnStartTab( -1 ), mnStartOffset( -1 ), - maPreviousNote( rtl::OUString(), rtl::OUString(), ScAddress(ScAddress::INITIALIZE_INVALID) ) + maPreviousNote( rtl::OUString(), rtl::OUString(), ScAddress(ScAddress::INITIALIZE_INVALID) ), + mbInSupportedSave( false ) { } @@ -270,3 +271,13 @@ bool ScSheetSaveData::AddLoadedNamespaces( SvXMLNamespaceMap& rNamespaces ) cons return true; // success } +bool ScSheetSaveData::IsInSupportedSave() const +{ + return mbInSupportedSave; +} + +void ScSheetSaveData::SetInSupportedSave( bool bSet ) +{ + mbInSupportedSave = bSet; +} + diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx index fde7f00bb05a..a8176cc7d955 100644 --- a/sc/source/filter/xml/xmlwrap.cxx +++ b/sc/source/filter/xml/xmlwrap.cxx @@ -78,6 +78,8 @@ #include "globstr.hrc" #include "scerrors.hxx" #include "XMLExportSharedData.hxx" +#include "docuno.hxx" +#include "sheetdata.hxx" #define MAP_LEN(x) x, sizeof(x) - 1 @@ -738,16 +740,23 @@ sal_Bool ScXMLImportWrapper::ExportToComponent(uno::Reference xTmpStorage = rDoc.GetDocumentShell()->GetStorage(); uno::Reference xSrcStream; uno::Reference xSrcInput; - try - { - if (xTmpStorage.is()) - xSrcStream = xTmpStorage->openStreamElement( sName, embed::ElementModes::READ ); - if (xSrcStream.is()) - xSrcInput = xSrcStream->getInputStream(); - } - catch (uno::Exception&) + + // #i108978# If an embedded object is saved and no events are notified, don't use the stream + // because without the ...DONE events, stream positions aren't updated. + ScSheetSaveData* pSheetData = ScModelObj::getImplementation(xModel)->GetSheetSaveData(); + if (pSheetData && pSheetData->IsInSupportedSave()) { - // stream not available (for example, password protected) - save normally (xSrcInput is null) + try + { + if (xTmpStorage.is()) + xSrcStream = xTmpStorage->openStreamElement( sName, embed::ElementModes::READ ); + if (xSrcStream.is()) + xSrcInput = xSrcStream->getInputStream(); + } + catch (uno::Exception&) + { + // stream not available (for example, password protected) - save normally (xSrcInput is null) + } } pExport->SetSourceStream( xSrcInput ); -- cgit