oox/qa/unit/data/graphic-stroke.pptx         |binary
 oox/qa/unit/vml.cxx                          |   32 +++++++++++++++++++++++++++
 oox/source/drawingml/graphicshapecontext.cxx |    2 +
 oox/source/vml/vmlshape.cxx                  |   15 ++++++++++++
 4 files changed, 49 insertions(+)

New commits:
commit 166395a0913bf6d98b5d1cda982b64ec4f8c7335
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Aug 18 17:43:57 2020 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Aug 19 10:32:27 2020 +0200

    tdf#132555 PPTX VML import: handle stroke properties of image shapes
    
    ComplexShape::implConvertAndInsert() returns early in the graphic object
    shape case, so stroke model is not applied at all.
    
    Also fix a problem in ShapeBase::finalizeFragmentImport(), where the
    shape type had no stroke, but the shape itself had, and the later should
    win.
    
    The warning in OleObjectGraphicDataContext::onCreateContext() now points
    out that <mc:AlternateContent> is ignored as a child of <a:graphicData>,
    which probably should be addressed at some stage, but it's not required
    to fix the missing stroke.
    
    (cherry picked from commit b2d834d6727626f070bb4dde3e1c65da1169f729)
    
    Conflicts:
            oox/qa/unit/vml.cxx
            oox/source/vml/vmlshape.cxx
    
    Change-Id: I4ab43b4c6d40d9f43caad22b85f5b885fa8b4ef1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100972
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/oox/qa/unit/data/graphic-stroke.pptx 
b/oox/qa/unit/data/graphic-stroke.pptx
new file mode 100644
index 000000000000..f4465476fcc6
Binary files /dev/null and b/oox/qa/unit/data/graphic-stroke.pptx differ
diff --git a/oox/qa/unit/vml.cxx b/oox/qa/unit/vml.cxx
index b83334eeadc6..36a120dbc938 100644
--- a/oox/qa/unit/vml.cxx
+++ b/oox/qa/unit/vml.cxx
@@ -11,10 +11,12 @@
 #include <unotest/macros_test.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
 
 #include <comphelper/embeddedobjectcontainer.hxx>
@@ -121,6 +123,36 @@ CPPUNIT_TEST_FIXTURE(OoxVmlTest, 
testShapeNonAutosizeWithText)
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5398), 
xShape->getSize().Width);
 }
 
+CPPUNIT_TEST_FIXTURE(OoxVmlTest, testGraphicStroke)
+{
+    load("graphic-stroke.pptx");
+    uno::Reference<drawing::XDrawPagesSupplier> 
xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+    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;
+        }
+
+        xShape.set(xInfo, uno::UNO_QUERY);
+        break;
+    }
+    CPPUNIT_ASSERT(xShape.is());
+
+    drawing::LineStyle eLineStyle{};
+    xShape->getPropertyValue("LineStyle") >>= eLineStyle;
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 1
+    // - Actual  : 0
+    // i.e. line style was NONE, not SOLID.
+    CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, eLineStyle);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/graphicshapecontext.cxx 
b/oox/source/drawingml/graphicshapecontext.cxx
index 527c43f9be3d..1c22a33b9ca1 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -235,6 +235,8 @@ ContextHandlerRef 
OleObjectGraphicDataContext::onCreateContext( sal_Int32 nEleme
             return new GraphicShapeContext( *this, mpMasterShapePtr, 
mpShapePtr );
         break;
     }
+    SAL_WARN("oox", "OleObjectGraphicDataContext::onCreateContext: unhandled 
element: "
+                        << getBaseToken(nElement));
     return nullptr;
 }
 
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index e1c857f5528e..2d18c4f21a98 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -303,7 +303,15 @@ void ShapeBase::finalizeFragmentImport()
         if (aType[ 0 ] == '#')
             aType = aType.copy(1);
         if( const ShapeType* pShapeType = 
mrDrawing.getShapes().getShapeTypeById( aType ) )
+        {
+            // Make sure that the stroke props from maTypeModel have priority 
over the stroke props from
+            // the shape type.
+            StrokeModel aMergedStrokeModel;
+            
aMergedStrokeModel.assignUsed(pShapeType->getTypeModel().maStrokeModel);
+            aMergedStrokeModel.assignUsed(maTypeModel.maStrokeModel);
             maTypeModel.assignUsed( pShapeType->getTypeModel() );
+            maTypeModel.maStrokeModel = aMergedStrokeModel;
+        }
         else {
             // Temporary fix, shapetype not found if referenced from different 
substream
             // FIXME: extend scope of ShapeContainer to store all shapetypes 
from the document
@@ -1353,6 +1361,13 @@ Reference< XShape > ComplexShape::implConvertAndInsert( 
const Reference< XShapes
         // AS_CHARACTER shape: vertical orientation default is bottom, MSO 
default is top.
         if ( maTypeModel.maPosition != "absolute" && maTypeModel.maPosition != 
"relative" )
             PropertySet( xShape ).setAnyProperty( PROP_VertOrient, 
makeAny(text::VertOrientation::TOP));
+
+        // Apply stroke props from the type model.
+        oox::drawingml::ShapePropertyMap 
aPropMap(mrDrawing.getFilter().getModelObjectHelper());
+        const GraphicHelper& rGraphicHelper = 
mrDrawing.getFilter().getGraphicHelper();
+        maTypeModel.maStrokeModel.pushToPropMap(aPropMap, rGraphicHelper);
+        PropertySet(xShape).setProperties(aPropMap);
+
         return xShape;
     }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to