summaryrefslogtreecommitdiff
path: root/svx/qa
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2019-09-28 00:34:35 +0200
committerRegina Henschel <rb.henschel@t-online.de>2019-09-28 20:00:51 +0200
commit7830a9d42926a9c5265230d42fce4a4858b303c1 (patch)
tree63bebe7a9ffebdb39df04132c74a411b03aad79b /svx/qa
parent4ea413542ebb142dcdec81f43b1b5e565dbe7316 (diff)
tdf#127785 correct calculation of text rectangle in flipped shape
The calculation had used a wrong corner. That resulted in negative width or height. Thus the entire shape frame was used as fallback instead of the smaller text rectangle. Change-Id: Ia18d9630dc83c0556115609575f26dcfa71bdb13 Reviewed-on: https://gerrit.libreoffice.org/79774 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'svx/qa')
-rw-r--r--svx/qa/unit/customshapes.cxx45
-rw-r--r--svx/qa/unit/data/tdf127785_Mirror.odpbin0 -> 13742 bytes
2 files changed, 45 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 5d1d4c3f44fe..5f5983776e15 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -460,6 +460,51 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf126512_OOXML_handle_in_ODP)
}
CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
}
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_Mirror)
+{
+ // The document contains two shapes, one with horizontal flip, the other with vertical
+ // flip. They are diamonds, so their text frame is symmetric to the center of the shape.
+ // The shapes have not stroke and no fill, so that the bounding box sourrounds the text
+ // and therefore equals approximately the text frame.
+ // Error was, that because of wrong calculation, the flipped shapes do not use the
+ // text frame but the frame rectangle for their text.
+ const OUString sFileName("tdf127785_Mirror.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> xShapeV(getShape(0));
+ uno::Reference<beans::XPropertySet> xShapeVProps(xShapeV, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeVProps.is());
+ awt::Rectangle aBoundRectV;
+ xShapeVProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectV;
+ const sal_Int32 nHeightV = aBoundRectV.Height;
+ const sal_Int32 nWidthV = aBoundRectV.Width;
+ const sal_Int32 nLeftV = aBoundRectV.X;
+ const sal_Int32 nTopV = aBoundRectV.Y;
+ if (abs(nHeightV - 4149) > 5 || abs(nWidthV - 3819) > 5)
+ sErrors += "Flip vertical wrong size.";
+ if (abs(nLeftV - 3155) > 5 || abs(nTopV - 3736) > 5)
+ sErrors += " Flip vertical wrong position.";
+
+ uno::Reference<drawing::XShape> xShapeH(getShape(1));
+ uno::Reference<beans::XPropertySet> xShapeHProps(xShapeH, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeHProps.is());
+ awt::Rectangle aBoundRectH;
+ xShapeHProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectH;
+ const sal_Int32 nHeightH = aBoundRectH.Height;
+ const sal_Int32 nWidthH = aBoundRectH.Width;
+ const sal_Int32 nLeftH = aBoundRectH.X;
+ const sal_Int32 nTopH = aBoundRectH.Y;
+ if (abs(nHeightH - 4149) > 5 || abs(nWidthH - 3819) > 5)
+ sErrors += " Flip horizontal wrong size.";
+ if (abs(nLeftH - 15026) > 5 || abs(nTopH - 4115) > 5)
+ sErrors += " Flip horizontal wrong position.";
+
+ CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf127785_Mirror.odp b/svx/qa/unit/data/tdf127785_Mirror.odp
new file mode 100644
index 000000000000..ff867839f4ac
--- /dev/null
+++ b/svx/qa/unit/data/tdf127785_Mirror.odp
Binary files differ