summaryrefslogtreecommitdiff
path: root/svx/qa
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2019-10-01 18:20:53 +0200
committerRegina Henschel <rb.henschel@t-online.de>2019-10-02 13:36:17 +0200
commitcaaa8fe7c4bb88185b5b11591ee8a619cff0eced (patch)
tree540a0598db429ec1d98ece0cf52c2e0ccbd59417 /svx/qa
parent14ee9ffe01ecadaddc7e9b97dae00077dd051d7a (diff)
tdf#127785 compensate 180deg rotation for position of text box
If a shape is vertically flipped, then the text is rotated by 180deg around the shape center. The rotation is done by SdrTextObj. There text rectangle and shape rectangle are the same, so the rotated text rectangle has the correct position in regard to 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 translates the text rectangle so, that is will be at the correct position after the 180deg rotation. Change-Id: I42e552394cc4b0103530eab48750dd621c52cc5e Reviewed-on: https://gerrit.libreoffice.org/79984 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'svx/qa')
-rw-r--r--svx/qa/unit/customshapes.cxx34
-rw-r--r--svx/qa/unit/data/tdf127785_asymmetricTextBoxFlipV.odgbin0 -> 12166 bytes
2 files changed, 34 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 5ad16cc5ea53..c1090f87109d 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -505,6 +505,40 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_Mirror)
CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
}
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_Asymmetric)
+{
+ // The document contains a shapes with vertical flip and text frame asymmetrical
+ // to shape. 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 180deg text rotation was not compensated for the position of
+ // the flipped text box.
+ const OUString sFileName("tdf127785_asymmetricTextBoxFlipV.odg");
+ 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 - 10034) > 5)
+ sErrors += "wrong left";
+ if (abs(nRight - 12973) > 5)
+ sErrors += " wrong right";
+ if (abs(nTop - 7892) > 5)
+ sErrors += " wrong top";
+ if (abs(nBottom - 14884) > 5)
+ sErrors += " wrong bottom";
+
+ CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf127785_asymmetricTextBoxFlipV.odg b/svx/qa/unit/data/tdf127785_asymmetricTextBoxFlipV.odg
new file mode 100644
index 000000000000..ea700eaf7e49
--- /dev/null
+++ b/svx/qa/unit/data/tdf127785_asymmetricTextBoxFlipV.odg
Binary files differ