summaryrefslogtreecommitdiff
path: root/svx/qa
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2019-10-05 22:52:42 +0200
committerRegina Henschel <rb.henschel@t-online.de>2019-10-09 20:43:38 +0200
commit5e68f0e2a13cc21f95a875cf694e926e01642050 (patch)
tree38a0ac1af49d81db9c0c4b2d8c628870169496f0 /svx/qa
parent7d361e96c9ea822790db21806e9fc05279423833 (diff)
tdf#127785 Apply 180deg compensation for flipV to text range
If a shape is vertically flipped, then the text is rotated by 180deg around the shape center. The rotation is done by SdrTextObj, where text rectangle and shape rectangle are the same, so the rotated text rectangle has the correct position despite flipping. But the text rectangle for SdrObjCustomShape is set by the shape author in the TextFrames attribute and might have an asymmetric position. The patch compensates the flip-rotation by pre-rotate the text rectangle. This replaces commit caaa8fe7c4bb88185b5b11591ee8a619cff0eced. The error in the old patch was, that it has uses a translation instead of a rotation, and has used a wrong place. The result was, that a text box, which has an own TextRotateAngle, had got a wrong position. Change-Id: Id38e8c1839afa5091cd251fc5237315ba7944263 Reviewed-on: https://gerrit.libreoffice.org/80310 Reviewed-by: Regina Henschel <rb.henschel@t-online.de> Tested-by: Regina Henschel <rb.henschel@t-online.de> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'svx/qa')
-rw-r--r--svx/qa/unit/customshapes.cxx34
-rw-r--r--svx/qa/unit/data/tdf127785_TextRotateAngle.odpbin0 -> 12841 bytes
2 files changed, 34 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index c1090f87109d..4a1f3cb39c46 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -539,6 +539,40 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_Asymmetric)
CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
}
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_TextRotateAngle)
+{
+ // The document contains a shapes with vertical flip and a text frame with own
+ // rotate angle. The shape has not stroke and no fill, so that the bounding box
+ // surrounds the text and therefore equals approximately the text frame.
+ // Error was, that the compensation for the 180° rotation added for vertical
+ // flip were not made to the text box position but to the text matrix.
+ const OUString sFileName("tdf127785_TextRotateAngle.odp");
+ OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + sFileName;
+ mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument");
+ CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is());
+ OUString sErrors; // sErrors collects the errors and should be empty in case all is OK.
+
+ uno::Reference<drawing::XShape> xShape(getShape(0));
+ uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is());
+ awt::Rectangle aBoundRect;
+ xShapeProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRect;
+ const sal_Int32 nLeft = aBoundRect.X;
+ const sal_Int32 nTop = aBoundRect.Y;
+ const sal_Int32 nRight = aBoundRect.X + aBoundRect.Width - 1;
+ const sal_Int32 nBottom = aBoundRect.Y + aBoundRect.Height - 1;
+ if (abs(nLeft - 5054) > 5)
+ sErrors += "wrong left";
+ if (abs(nRight - 6374) > 5)
+ sErrors += " wrong right";
+ if (abs(nTop - 4516) > 5)
+ sErrors += " wrong top";
+ if (abs(nBottom - 8930) > 5)
+ sErrors += " wrong bottom";
+
+ CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf127785_TextRotateAngle.odp b/svx/qa/unit/data/tdf127785_TextRotateAngle.odp
new file mode 100644
index 000000000000..742f12d4d941
--- /dev/null
+++ b/svx/qa/unit/data/tdf127785_TextRotateAngle.odp
Binary files differ