oox/qa/unit/vml.cxx                          |   15 +++++----------
 oox/source/drawingml/graphicshapecontext.cxx |    3 ++-
 oox/source/drawingml/shape.cxx               |   17 +++++++++++++++++
 sd/qa/unit/data/pptx/ole.pptx                |binary
 sd/qa/unit/export-tests-ooxml3.cxx           |   21 +++++++++++++++++++++
 5 files changed, 45 insertions(+), 11 deletions(-)

New commits:
commit 7f91933023a844f53b498439fb0e2752d46b01d5
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Tue Sep 13 10:29:03 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Nov 1 11:13:34 2022 +0100

    tdf#124333 PPTX import: fix Z-order of embedded OLE objects
    
    Choose mc:Choice in a:graphicData element
    if the selected p:oleObj element has a shape id
    to avoid of shape duplication which created also
    bad layout/overlapping because of the different Z-order
    of the duplicated shape.
    
    Change-Id: Idecff4903c2d637bc82353f13352cac72413cec1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140041
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141938
    Tested-by: Jenkins

diff --git a/oox/qa/unit/vml.cxx b/oox/qa/unit/vml.cxx
index 9dcaaef83cc4..61730c744220 100644
--- a/oox/qa/unit/vml.cxx
+++ b/oox/qa/unit/vml.cxx
@@ -192,18 +192,13 @@ CPPUNIT_TEST_FIXTURE(OoxVmlTest, testGraphicStroke)
     uno::Reference<drawing::XDrawPage> 
xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
                                                  uno::UNO_QUERY);
 
-    uno::Reference<beans::XPropertySet> xShape;
-    for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i)
-    {
-        uno::Reference<lang::XServiceInfo> xInfo(xDrawPage->getByIndex(i), 
uno::UNO_QUERY);
-        if (!xInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
-        {
-            continue;
-        }
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
 
+    uno::Reference<beans::XPropertySet> xShape;
+    uno::Reference<lang::XServiceInfo> xInfo(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
+    if (xInfo->supportsService("com.sun.star.drawing.OLE2Shape"))
         xShape.set(xInfo, uno::UNO_QUERY);
-        break;
-    }
+
     CPPUNIT_ASSERT(xShape.is());
 
     drawing::LineStyle eLineStyle{};
diff --git a/oox/source/drawingml/graphicshapecontext.cxx 
b/oox/source/drawingml/graphicshapecontext.cxx
index d90980a87824..2e5ce5dc47a8 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -256,7 +256,8 @@ void OleObjectGraphicDataContext::onEndElement()
 {
     if( getCurrentElement() == PPT_TOKEN( oleObj ) && !isMCEStateEmpty() )
     {
-        if( getMCEState() == MCE_STATE::FoundChoice && 
!mrOleObjectInfo.mbHasPicture )
+        if (getMCEState() == MCE_STATE::FoundChoice && 
!mrOleObjectInfo.mbHasPicture
+            && mrOleObjectInfo.maShapeId.isEmpty())
             setMCEState( MCE_STATE::Started );
     }
 }
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 50bc2f8bc9c4..12b3303054e4 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1860,6 +1860,23 @@ Reference< XShape > const & Shape::createAndInsert(
             propertySet->setPropertyValue(
                 "SoftEdgeRadius", 
Any(convertEmuToHmm(aEffectProperties.maSoftEdge.moRad.get())));
         }
+
+        // Set the stroke and fill-color properties of the OLE shape
+        if (aServiceName == "com.sun.star.drawing.OLE2Shape" && mxOleObjectInfo
+            && !mxOleObjectInfo->maShapeId.isEmpty())
+            if (::oox::vml::Drawing* pVmlDrawing = rFilterBase.getVmlDrawing())
+                if (const ::oox::vml::ShapeBase* pVmlShape
+                    = 
pVmlDrawing->getShapes().getShapeById(mxOleObjectInfo->maShapeId))
+                {
+                    // Apply stroke props from the type model of the related 
VML shape.
+                    ShapePropertyMap 
aPropMap(rFilterBase.getModelObjectHelper());
+                    pVmlShape->getTypeModel().maStrokeModel.pushToPropMap(
+                        aPropMap, rFilterBase.getGraphicHelper());
+                    // And, fill-color properties as well...
+                    pVmlShape->getTypeModel().maFillModel.pushToPropMap(
+                        aPropMap, rFilterBase.getGraphicHelper());
+                    PropertySet(xSet).setProperties(aPropMap);
+                }
     }
 
     if (mxShape.is())
diff --git a/sd/qa/unit/data/pptx/ole.pptx b/sd/qa/unit/data/pptx/ole.pptx
new file mode 100644
index 000000000000..b998e79e0d66
Binary files /dev/null and b/sd/qa/unit/data/pptx/ole.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 45453f8e2b42..499491d084f9 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -119,6 +119,7 @@ public:
     void testTdf109169_DiamondBevel();
     void testTdf144092_emptyShapeTextProps();
     void testTdf94122_autoColor();
+    void testTdf124333();
     void testAutofittedTextboxIndent();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
@@ -205,6 +206,7 @@ public:
     CPPUNIT_TEST(testTdf109169_DiamondBevel);
     CPPUNIT_TEST(testTdf144092_emptyShapeTextProps);
     CPPUNIT_TEST(testTdf94122_autoColor);
+    CPPUNIT_TEST(testTdf124333);
     CPPUNIT_TEST(testAutofittedTextboxIndent);
     CPPUNIT_TEST_SUITE_END();
 
@@ -2179,6 +2181,25 @@ void SdOOXMLExportTest3::testTdf94122_autoColor()
                 "val", "000000");
 }
 
+void SdOOXMLExportTest3::testTdf124333()
+{
+    // Document contains one rectangle and one embedded OLE object.
+    ::sd::DrawDocShellRef xDocShRef
+        = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/ole.pptx"), PPTX);
+
+    // Without the fix in place, the number of shapes was 3.
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("number of shapes is incorrect", sal_Int32(2),
+                                 getPage(0, xDocShRef)->getCount());
+
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
+
+    // Check number of shapes after export.
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("number of shapes is incorrect after export", 
sal_Int32(2),
+                                 getPage(0, xDocShRef)->getCount());
+
+    xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest3::testAutofittedTextboxIndent()
 {
     ::sd::DrawDocShellRef xDocShRef = loadURL(

Reply via email to