[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - include/oox oox/source sd/qa

Bartosz Kosiorek (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 12 11:11:09 UTC 2019


 include/oox/export/drawingml.hxx      |    2 +-
 oox/source/export/drawingml.cxx       |    4 +++-
 oox/source/export/shapes.cxx          |    8 ++++----
 sd/qa/unit/data/odp/closed-shapes.odp |binary
 sd/qa/unit/export-tests-ooxml2.cxx    |   14 ++++++++++++++
 5 files changed, 22 insertions(+), 6 deletions(-)

New commits:
commit f4a660c38471daa35db2dcfa69fb3ebe56d599b9
Author:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Fri Aug 9 01:20:37 2019 +0200
Commit:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Mon Aug 12 13:10:21 2019 +0200

    tdf#126746 Fix exporting closed Polylines to PPTX
    
    In previous implementation the closed shapes was
    imported as a polylines without closing joint.
    As a result the joint style was not applied.
    
    This patch fixes that, and allow proper PPTX export.
    
    TODO The same issue needs to be fixed for PPT export
    
    Change-Id: I557daac1ba02330d8923f7eda3476e67d8711384
    Reviewed-on: https://gerrit.libreoffice.org/77179
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Regina Henschel <rb.henschel at t-online.de>
    (cherry picked from commit 3feaff84fafc23c26ff9c6a716709f17a6c8330b)
    Reviewed-on: https://gerrit.libreoffice.org/77229
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 55279e2de69f..c11664bb2738 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -265,7 +265,7 @@ public:
     static sal_Int32 GetCustomGeometryPointValue(
         const css::drawing::EnhancedCustomShapeParameter& rParam,
         const SdrObjCustomShape& rSdrObjCustomShape);
-    void WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon );
+    void WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon, const bool bClosed );
     void WriteFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
     void WriteShapeStyle( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
     void WriteShapeEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 38320242c3ce..b49ccfce21d2 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3127,7 +3127,7 @@ sal_Int32 DrawingML::GetCustomGeometryPointValue(
     return nValue;
 }
 
-void DrawingML::WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon )
+void DrawingML::WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon, const bool bClosed )
 {
     // In case of Writer, the parent element is <wps:spPr>, and there the
     // <a:custGeom> element is not optional.
@@ -3197,6 +3197,8 @@ void DrawingML::WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon )
             }
         }
     }
+    if (bClosed)
+        mpFS->singleElementNS( XML_a, XML_close);
     mpFS->endElementNS( XML_a, XML_path );
 
     mpFS->endElementNS( XML_a, XML_pathLst );
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index b36ebb26f67f..80de09f97a76 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -418,7 +418,7 @@ bool ShapeExport::NonEmptyText( const Reference< XInterface >& xIface )
     return false;
 }
 
-ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xShape, bool bClosed )
+ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xShape, const bool bClosed )
 {
     SAL_INFO("oox.shape", "write polypolygon shape");
 
@@ -452,7 +452,7 @@ ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xSha
     // visual shape properties
     pFS->startElementNS(mnXmlNamespace, XML_spPr);
     WriteTransformation( aRect, XML_a );
-    WritePolyPolygon( aPolyPolygon );
+    WritePolyPolygon( aPolyPolygon, bClosed );
     Reference< XPropertySet > xProps( xShape, UNO_QUERY );
     if( xProps.is() ) {
         if( bClosed )
@@ -840,7 +840,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
         bool bInvertRotation = bFlipH != bFlipV;
         if (nRotation != 0)
             aPolyPolygon.Rotate(Point(0,0), static_cast<sal_uInt16>(bInvertRotation ? nRotation/10 : 3600-nRotation/10));
-        WritePolyPolygon( aPolyPolygon );
+        WritePolyPolygon( aPolyPolygon, false );
     }
     else if (bCustGeom)
     {
@@ -1437,7 +1437,7 @@ static const NameToConvertMapType& lcl_GetConverters()
         { "com.sun.star.drawing.LineShape"                 , &ShapeExport::WriteLineShape },
         { "com.sun.star.drawing.OpenBezierShape"           , &ShapeExport::WriteOpenPolyPolygonShape },
         { "com.sun.star.drawing.PolyPolygonShape"          , &ShapeExport::WriteClosedPolyPolygonShape },
-        { "com.sun.star.drawing.PolyLineShape"             , &ShapeExport::WriteClosedPolyPolygonShape },
+        { "com.sun.star.drawing.PolyLineShape"             , &ShapeExport::WriteOpenPolyPolygonShape },
         { "com.sun.star.drawing.RectangleShape"            , &ShapeExport::WriteRectangleShape },
         { "com.sun.star.drawing.OLE2Shape"                 , &ShapeExport::WriteOLE2Shape },
         { "com.sun.star.drawing.TableShape"                , &ShapeExport::WriteTableShape },
diff --git a/sd/qa/unit/data/odp/closed-shapes.odp b/sd/qa/unit/data/odp/closed-shapes.odp
new file mode 100644
index 000000000000..23460c7dbae5
Binary files /dev/null and b/sd/qa/unit/data/odp/closed-shapes.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 9c6cc27aa804..f69d63208e6a 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -147,6 +147,7 @@ public:
     void testTdf111863();
     void testTdf111518();
     void testTdf100387();
+    void testClosingShapes();
     void testRotateFlip();
     void testTdf106867();
     void testTdf112280();
@@ -237,6 +238,7 @@ public:
     CPPUNIT_TEST(testTdf111863);
     CPPUNIT_TEST(testTdf111518);
     CPPUNIT_TEST(testTdf100387);
+    CPPUNIT_TEST(testClosingShapes);
     CPPUNIT_TEST(testRotateFlip);
     CPPUNIT_TEST(testTdf106867);
     CPPUNIT_TEST(testTdf112280);
@@ -1122,6 +1124,17 @@ void SdOOXMLExportTest2::testTdf100387()
                              "/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt/p:txEl/p:pRg", "end", "2");
 }
 
+void SdOOXMLExportTest2::testClosingShapes()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/closed-shapes.odp"), ODP);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+    xDocShRef->DoClose();
+    xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
+    assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 1);
+    assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 0);
+}
+
 void SdOOXMLExportTest2::testRotateFlip()
 {
     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/rotate_flip.odp"), ODP);
@@ -1164,6 +1177,7 @@ void SdOOXMLExportTest2::testRotateFlip()
             assertXPath(pXmlDocContent, sPt, "x", points[nPointIndex][0]);
             assertXPath(pXmlDocContent, sPt, "y", points[nPointIndex][1]);
         }
+        assertXPath(pXmlDocContent, sSpPr + "/a:custGeom/a:pathLst/a:path/a:close", 1);
     }
 }
 


More information about the Libreoffice-commits mailing list