[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/ooxmlexport_setup.mk sw/source

Michael Stahl mstahl at redhat.com
Tue Jan 12 00:59:17 PST 2016


 sw/ooxmlexport_setup.mk             |    5 +++-
 sw/source/filter/ww8/docxexport.cxx |   38 ++++++++++++++++++++++++++----------
 2 files changed, 32 insertions(+), 11 deletions(-)

New commits:
commit a20c344627a71c079c6b9abc1fd629a636b37cc8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 18 20:48:52 2015 +0100

    sw: stop using SfxObjectShell in DocxExport::WriteOLEObject
    
    (cherry picked from commit 1a5104a6cd7c69b960d84ecb4f375b15d4bc042c)
    
    sw: add yet another stupid component for WNT
    (cherry picked from commit 3612634fee539c7ee4163ac553691f8d64291244)
    
    WIP: Fix build with --disable-atl on Windows
    This avoids finding emboleobj's component in such case.
    Reviewed-on: https://gerrit.libreoffice.org/21075
    Reviewed-by: Matúš Kukan <matus at libreoffice.org>
    Tested-by: Matúš Kukan <matus at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 3c42024f467ec9110be751e9af49d025ecc17182)
    
    Change-Id: I3ffa29c57bcb6d12208ef24cb6972364c2f50315
    Reviewed-on: https://gerrit.libreoffice.org/21348
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/ooxmlexport_setup.mk b/sw/ooxmlexport_setup.mk
index 7b33349..d78d276 100644
--- a/sw/ooxmlexport_setup.mk
+++ b/sw/ooxmlexport_setup.mk
@@ -33,7 +33,10 @@ define sw_ooxmlexport_components
 	dbaccess/util/dba \
 	drawinglayer/drawinglayer \
 	embeddedobj/util/embobj \
-	$(if $(filter-out WNT,$(OS)), \
+	$(if $(filter WNT,$(OS)), \
+		$(if $(DISABLE_ATL),, \
+			embeddedobj/source/msole/emboleobj.windows \
+		), \
 		embeddedobj/source/msole/emboleobj \
 	) \
 	filter/source/config/cache/filterconfig1 \
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index d2c05c4..cd01cd4 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())


More information about the Libreoffice-commits mailing list