summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndras Timar <andras.timar@collabora.com>2016-01-29 16:42:31 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-02-05 10:49:43 +0000
commitc756fb14769373b700fd41d4f64e8e902480645b (patch)
tree4b745ebe3a04fb5836668bede41089706ab53b1d
parent30ae51934cd844a1d145130f35815de8edef6c5a (diff)
tdf#92077 Improve DrawingML export of rotated/flipped customshapes
When we export the customshape as polypolygon, we need to take into account, that the polypolygon of the shape already has flipped coordinates, but coordinates has to be relative to the rotated bounding rectangle. Reviewed-on: https://gerrit.libreoffice.org/21905 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com> (cherry picked from commit bd36889b2caa4a74d647e18fc52e455f83529be9) Change-Id: I4f3b015e439d3d6041adc67eddd460f5bd4dfca1 Reviewed-on: https://gerrit.libreoffice.org/22103 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--oox/source/export/shapes.cxx18
-rw-r--r--sw/qa/extras/ooxmlexport/data/flip_and_rotate.odtbin0 -> 9403 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport7.cxx19
3 files changed, 33 insertions, 4 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index c3b8b8e9353e..c20d69dcdbb8 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -713,9 +713,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
// moon is flipped in MSO, and mso-spt89 (right up arrow) is mapped to leftUpArrow
if ( sShapeType == "moon" || sShapeType == "mso-spt89" )
- WriteShapeTransformation( xShape, XML_a, !bFlipH, bFlipV );
- else
- WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV );
+ bFlipH = !bFlipH;
// we export non-primitive shapes to custom geometry
// we also export non-ooxml shapes which have handles/equations to custom geometry, because
@@ -736,14 +734,26 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
if (bHasHandles && bCustGeom && pShape)
{
- WritePolyPolygon( tools::PolyPolygon( pShape->GetLineGeometry(true) ) );
+ WriteShapeTransformation( xShape, XML_a ); // 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.
+ uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
+ if (xPropertySetInfo->hasPropertyByName("RotateAngle"))
+ xPropertySet->getPropertyValue("RotateAngle") >>= nRotation;
+ if (nRotation != 0)
+ aPolyPolygon.Rotate(Point(0,0), static_cast<sal_uInt16>(3600-nRotation/10));
+ WritePolyPolygon( aPolyPolygon );
}
else if (bCustGeom)
{
+ WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV );
WriteCustomGeometry( xShape );
}
else // preset geometry
{
+ WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV );
if( nAdjustmentValuesIndex != -1 )
{
sal_Int32 nAdjustmentsWhichNeedsToBeConverted = 0;
diff --git a/sw/qa/extras/ooxmlexport/data/flip_and_rotate.odt b/sw/qa/extras/ooxmlexport/data/flip_and_rotate.odt
new file mode 100644
index 000000000000..4805bfa80004
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/flip_and_rotate.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index cfa1ddb4637e..6463c8096184 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -1103,6 +1103,25 @@ DECLARE_OOXMLEXPORT_TEST(testTDF93675, "no-numlevel-but-indented.odt")
assertXPath(pXmlDoc, "//w:ind", "start", "1418");
}
+DECLARE_OOXMLEXPORT_TEST(testFlipAndRotateCustomShape, "flip_and_rotate.odt")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ // there should be no flipH and flipV attributes in this case
+ assertXPathNoAttribute(pXmlDoc, "//a:xfrm", "flipH");
+ assertXPathNoAttribute(pXmlDoc, "//a:xfrm", "flipV");
+ // check rotation angle
+ assertXPath(pXmlDoc, "//a:xfrm", "rot", "13500000");
+ // check the first few coordinates of the polygon
+ assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "x", "2351");
+ assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "y", "3171");
+ assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[2]/a:pt", "x", "1695");
+ assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[2]/a:pt", "y", "3171");
+ assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[3]/a:pt", "x", "1695");
+ assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[3]/a:pt", "y", "1701");
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();