summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-12-18 20:48:52 +0100
committerMichael Stahl <mstahl@redhat.com>2015-12-20 00:56:05 +0100
commit1a5104a6cd7c69b960d84ecb4f375b15d4bc042c (patch)
treeb1b1b71edd21b9c80b1d529237fade35a7851bfc /sw/source/filter
parentbbbce5e04643a625e8b348f5064b062c013d4953 (diff)
sw: stop using SfxObjectShell in DocxExport::WriteOLEObject
Change-Id: I3ffa29c57bcb6d12208ef24cb6972364c2f50315
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/ww8/docxexport.cxx38
1 files changed, 28 insertions, 10 deletions
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index d2c05c44953d..cd01cd43c9af 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -24,8 +24,10 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/embed/EmbedStates.hpp>
+#include <com/sun/star/embed/XEmbedPersist.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/XStorable.hpp>
@@ -548,24 +550,40 @@ static uno::Reference<io::XInputStream> lcl_StoreOwnAsOOXML(
OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID)
{
uno::Reference <embed::XEmbeddedObject> xObj( rObject.GetOleRef() );
- comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer();
- uno::Reference< io::XInputStream > xInStream = aContainer->GetObjectStream( xObj );
+ uno::Reference<io::XInputStream> xInStream;
OUString sMediaType;
OUString sRelationType;
OUString sSuffix;
const char * pProgID(nullptr);
- if (xInStream.is())
+ try
{
- lcl_ConvertProgID(io_rProgID, sMediaType, sRelationType, sSuffix);
+ uno::Reference<document::XStorageBasedDocument> const xParent(
+ uno::Reference<container::XChild>(xObj, uno::UNO_QUERY)->getParent(),
+ uno::UNO_QUERY);
+ uno::Reference<embed::XStorage> const xParentStorage(xParent->getDocumentStorage());
+ OUString const entryName(
+ uno::Reference<embed::XEmbedPersist>(xObj, uno::UNO_QUERY)->getEntryName());
+
+ if (xParentStorage->isStreamElement(entryName))
+ {
+ lcl_ConvertProgID(io_rProgID, sMediaType, sRelationType, sSuffix);
+
+ xInStream = xParentStorage->cloneStreamElement(entryName)->getInputStream();
+ // TODO: is it possible to take the sMediaType from the stream?
+ }
+ else // the object is ODF - either the whole document is
+ { // ODF, or the OLE was edited so it was converted to ODF
+ uno::Reference<uno::XComponentContext> const xContext(
+ GetFilter().getComponentContext());
+ xInStream = lcl_StoreOwnAsOOXML(xContext, xObj,
+ pProgID, sMediaType, sRelationType, sSuffix);
+ }
}
- else // the object is ODF - either the whole document is
- { // ODF, or the OLE was edited so it was converted to ODF
- uno::Reference<uno::XComponentContext> const xContext(
- GetFilter().getComponentContext());
- xInStream = lcl_StoreOwnAsOOXML(xContext, xObj,
- pProgID, sMediaType, sRelationType, sSuffix);
+ catch (uno::Exception const& e)
+ {
+ SAL_WARN("sw.ww8", "DocxExport::WriteOLEObject: exception: " << e.Message);
}
if (!xInStream.is())