diff options
author | Paul Trojahn <paul.trojahn@gmail.com> | 2017-08-17 20:04:27 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-09-06 15:47:12 +0200 |
commit | 9c0387ef602d84d0079828f0ad4b53ada7ab1d8a (patch) | |
tree | 69c75bb2c4b7b8d80bbc629be6b3ed9f5d7c9de0 | |
parent | cc47ba8a8ba72acce94ef9c612afd9f16e3e9e86 (diff) |
tdf#111798 Fix deformed export of flipped custom shapes to pptx
Shapes were deformed because flipping wasn't considered when removing
the rotation. Also WriteShapeTransformation needs information about
flipping to convert the angle correctly.
Change-Id: I7d485e93c00e02b9ec6c73ad6ae2876e5bc6360a
Reviewed-on: https://gerrit.libreoffice.org/41462
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/41996
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | include/oox/export/drawingml.hxx | 4 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 10 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 6 | ||||
-rw-r--r-- | sd/qa/unit/data/odp/tdf111798.odp | bin | 0 -> 11183 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 59 |
5 files changed, 74 insertions, 5 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 97d8dff58de6..a3ad66897e80 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -188,8 +188,8 @@ public: const OUString& rURL, bool bRelPathToMedia = false , const Graphic *pGraphic=nullptr ); void WriteBlipMode( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL ); - void WriteShapeTransformation( const css::uno::Reference< css::drawing::XShape >& rXShape, - sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false ); + void WriteShapeTransformation(const css::uno::Reference< css::drawing::XShape >& rXShape, + sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false, bool bSuppressFlipping = false ); void WriteTransformation( const Rectangle& rRectangle, sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0 ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index c8d148aeb1c2..cbf3abb513d7 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1165,7 +1165,7 @@ void DrawingML::WriteTransformation( const Rectangle& rRect, mpFS->endElementNS( nXmlNamespace, XML_xfrm ); } -void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, bool bSuppressRotation ) +void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, bool bSuppressRotation, bool bSuppressFlipping ) { SAL_INFO("oox.shape", "write shape transformation"); @@ -1202,6 +1202,14 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa if (xPropertySetInfo->hasPropertyByName("RotateAngle")) xPropertySet->getPropertyValue("RotateAngle") >>= nRotation; } + + // OOXML flips shapes before rotating them. + if(bFlipH != bFlipV) + nRotation = nRotation * -1 + 36000; + + if(bSuppressFlipping) + bFlipH = bFlipV = false; + WriteTransformation( Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), nXmlNamespace, bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation) ); } diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 7bd85a8cd39f..066a1ecf1021 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -827,7 +827,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape ) if (bHasHandles && bCustGeom && pShape) { - WriteShapeTransformation( xShape, XML_a ); // do not flip, polypolygon coordinates are flipped already + WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, false, true );// do not flip, polypolygon coordinates are flipped already tools::PolyPolygon aPolyPolygon( pShape->GetLineGeometry(true) ); sal_Int32 nRotation = 0; // The RotateAngle property's value is independent from any flipping, and that's exactly what we need here. @@ -835,8 +835,10 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape ) uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); if (xPropertySetInfo->hasPropertyByName("RotateAngle")) xPropertySet->getPropertyValue("RotateAngle") >>= nRotation; + // Remove rotation + bool bInvertRotation = bFlipH != bFlipV; if (nRotation != 0) - aPolyPolygon.Rotate(Point(0,0), static_cast<sal_uInt16>(3600-nRotation/10)); + aPolyPolygon.Rotate(Point(0,0), static_cast<sal_uInt16>(bInvertRotation ? nRotation/10 : 3600-nRotation/10)); WritePolyPolygon( aPolyPolygon ); } else if (bCustGeom) diff --git a/sd/qa/unit/data/odp/tdf111798.odp b/sd/qa/unit/data/odp/tdf111798.odp Binary files differnew file mode 100644 index 000000000000..f00c0bec7fd1 --- /dev/null +++ b/sd/qa/unit/data/odp/tdf111798.odp diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 817cad398a13..3150687c04cb 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -104,6 +104,7 @@ public: void testTdf92076(); void testTdf59046(); void testTdf105739(); + void testTdf111798(); void testTdf111518(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -132,6 +133,7 @@ public: CPPUNIT_TEST(testTdf92076); CPPUNIT_TEST(testTdf59046); CPPUNIT_TEST(testTdf105739); + CPPUNIT_TEST(testTdf111798); CPPUNIT_TEST(testTdf111518); CPPUNIT_TEST_SUITE_END(); @@ -792,6 +794,63 @@ void SdOOXMLExportTest2::testTdf105739() xShell->DoClose(); } +void SdOOXMLExportTest2::testTdf111798() +{ + sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf111798.odp"), ODP); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml"); + + const OUString data[][29] = + { + { + "2700000", "2458080", "2414880", "1439640", "1440000", + "moveTo", "0", "3000", + "lnTo[1]", "3000", "3000", + "lnTo[2]", "3000", "4000", + "lnTo[3]", "4000", "2000", + "lnTo[4]", "3000", "0", + "lnTo[5]", "3000", "1000", + "lnTo[6]", "0", "1000", + "lnTo[7]", "0", "3000" + }, + { + "2700000", "6778080", "2414880", "1439640", "1440000", + "moveTo", "3000", "0", + "lnTo[1]", "3000", "3000", + "lnTo[2]", "4000", "3000", + "lnTo[3]", "2000", "4000", + "lnTo[4]", "0", "3000", + "lnTo[5]", "1000", "3000", + "lnTo[6]", "1000", "0", + "lnTo[7]", "3000", "0" + } + }; + + for (size_t nShapeIndex = 0; nShapeIndex < SAL_N_ELEMENTS(data); nShapeIndex++) + { + size_t nDataIndex = 0; + + const OString sSpPr = "/p:sld/p:cSld/p:spTree/p:sp[" + OString::number(nShapeIndex + 1) + "]/p:spPr"; + const OString sXfrm = sSpPr + "/a:xfrm"; + assertXPath(pXmlDoc, sXfrm, "rot", data[nShapeIndex][nDataIndex++]); + const OString sOff = sXfrm + "/a:off"; + assertXPath(pXmlDoc, sOff, "x", data[nShapeIndex][nDataIndex++]); + assertXPath(pXmlDoc, sOff, "y", data[nShapeIndex][nDataIndex++]); + const OString sExt = sXfrm + "/a:ext"; + assertXPath(pXmlDoc, sExt, "cx", data[nShapeIndex][nDataIndex++]); + assertXPath(pXmlDoc, sExt, "cy", data[nShapeIndex][nDataIndex++]); + + while (nDataIndex < SAL_N_ELEMENTS(data[nShapeIndex])) + { + const OString sPt = sSpPr + "/a:custGeom/a:pathLst/a:path/a:" + data[nShapeIndex][nDataIndex++].toUtf8() + "/a:pt"; + assertXPath(pXmlDoc, sPt, "x", data[nShapeIndex][nDataIndex++]); + assertXPath(pXmlDoc, sPt, "y", data[nShapeIndex][nDataIndex++]); + } + } +} + void SdOOXMLExportTest2::testTdf111518() { sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf111518.pptx"), PPTX); |