[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - oox/source sw/qa

2016-02-05 Thread Andras Timar
 oox/source/export/shapes.cxx  |   18 ++
 sw/qa/extras/ooxmlexport/data/flip_and_rotate.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx |   19 +++
 3 files changed, 33 insertions(+), 4 deletions(-)

New commits:
commit c756fb14769373b700fd41d4f64e8e902480645b
Author: Andras Timar 
Date:   Fri Jan 29 16:42:31 2016 +0100

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 
Reviewed-by: Andras Timar 
(cherry picked from commit bd36889b2caa4a74d647e18fc52e455f83529be9)

Change-Id: I4f3b015e439d3d6041adc67eddd460f5bd4dfca1
Reviewed-on: https://gerrit.libreoffice.org/22103
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index c3b8b8e..c20d69d 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 xPropertySet(xShape, 
uno::UNO_QUERY);
+uno::Reference xPropertySetInfo = 
xPropertySet->getPropertySetInfo();
+if (xPropertySetInfo->hasPropertyByName("RotateAngle"))
+xPropertySet->getPropertyValue("RotateAngle") >>= nRotation;
+if (nRotation != 0)
+aPolyPolygon.Rotate(Point(0,0), 
static_cast(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 000..4805bfa
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/flip_and_rotate.odt 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index cfa1ddb..6463c80 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", "1350");
+// 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", 

[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - oox/source sw/qa

2016-01-08 Thread Miklos Vajna
 oox/source/drawingml/shape.cxx  |   13 -
 sw/qa/extras/ooxmlimport/data/tdf96674.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx|   10 ++
 3 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 9be39a75053be54214efd1fc4c2811913659c30e
Author: Miklos Vajna 
Date:   Tue Jan 5 09:08:21 2016 +0100

tdf#96674 drawingML import: fix handling of zero width/height lines

(cherry picked from commit 627c2469843c9461b665c4571f1214aca7fc36a4)

Change-Id: If3d9f6272031e08ab228cfa58963d60ceede2498
Reviewed-on: https://gerrit.libreoffice.org/21115
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 6f84759..2dc84e9 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -510,7 +510,18 @@ Reference< XShape > Shape::createAndInsert(
 bool bIsWriter = 
xModelInfo->supportsService("com.sun.star.text.TextDocument");
 for( i = 0; i < nNumPoints; ++i )
 {
-const ::basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
+basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
+
+// Guard against zero width or height.
+if (i)
+{
+const basegfx::B2DPoint& rPreviousPoint = aPoly.getB2DPoint(i 
- 1);
+if (aPoint.getX() - rPreviousPoint.getX() == 0)
+aPoint.setX(aPoint.getX() + 1);
+if (aPoint.getY() - rPreviousPoint.getX() == 0)
+aPoint.setY(aPoint.getY() + 1);
+}
+
 if (bIsWriter && bInGroup)
 // Writer's draw page is in twips, and these points get passed
 // to core without any unit conversion when Writer
diff --git a/sw/qa/extras/ooxmlimport/data/tdf96674.docx 
b/sw/qa/extras/ooxmlimport/data/tdf96674.docx
new file mode 100644
index 000..752479c
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf96674.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 40949b2..cfdbd7b5 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -3002,6 +3002,16 @@ DECLARE_OOXMLIMPORT_TEST(testTdf94043, "tdf94043.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(2), 
getProperty(xTextColumns, "SeparatorLineWidth"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf96674, "tdf96674.docx")
+{
+uno::Reference xShape(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShape.is());
+awt::Size aActualSize(xShape->getSize());
+// This was 3493: the vertical line was horizontal.
+CPPUNIT_ASSERT_EQUAL(static_cast(0), aActualSize.Width);
+CPPUNIT_ASSERT(aActualSize.Height > 0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits