summaryrefslogtreecommitdiff
path: root/svx/qa
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2018-12-15 17:51:25 +0100
committerRegina Henschel <rb.henschel@t-online.de>2018-12-23 22:42:11 +0100
commita4c46ceec433edf0c5de03ea8d36857a455cafd2 (patch)
treef91219d16a75f38f27c3910e0e0aeaa52c04e796 /svx/qa
parent721bc6dafbed2185a9aedae35a34d3395eaed0bc (diff)
tdf#121761, tdf#121952 Accurate ellipsequadrant in custom shape
The current solution uses one, bad valued Bezier curve and does not toggle direction. The patch uses the more accurate solution from basegfx and simplifies the decision tree. In addition it extracts the calculation in double from GetPoint, so they can be used directly instead of double->long->double conversion. Change-Id: I298f49415d1b7624b36ca561647f2e58af5eb5c6 Reviewed-on: https://gerrit.libreoffice.org/65203 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'svx/qa')
-rw-r--r--svx/qa/unit/customshapes.cxx65
-rw-r--r--svx/qa/unit/data/tdf121761_Accuracy_command_X.odpbin0 -> 11177 bytes
-rw-r--r--svx/qa/unit/data/tdf121952_Toggle_direction_command_X.odpbin0 -> 12029 bytes
3 files changed, 65 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index b5aeea670ae2..d3f63dffe2a9 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -48,9 +48,13 @@ public:
}
void testViewBoxLeftTop();
+ void testAccuracyCommandX();
+ void testToggleCommandXY();
CPPUNIT_TEST_SUITE(CustomshapesTest);
CPPUNIT_TEST(testViewBoxLeftTop);
+ CPPUNIT_TEST(testAccuracyCommandX);
+ CPPUNIT_TEST(testToggleCommandXY);
CPPUNIT_TEST_SUITE_END();
};
@@ -96,6 +100,67 @@ void CustomshapesTest::testViewBoxLeftTop()
CPPUNIT_ASSERT_LESS(static_cast<long>(3), labs(aFrameRectTB.Y - aBoundRectTB.Y));
}
+void CustomshapesTest::testAccuracyCommandX()
+{
+ // 121761 Increase accuracy of quarter circles drawn by command X or Y
+ // The loaded document has a quarter circle with radius 10000 (unit 1/100 mm)
+ // which is rotated by 45deg. The test considers the segment.
+ OUString aURL
+ = m_directories.getURLFromSrc(sDataDirectory) + "tdf121761_Accuracy_command_X.odp";
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument");
+ CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is());
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
+ uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
+ uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
+
+ // Get the shape "arc_45deg_rotated". Error was, that a Bezier curve with bad parameters
+ // was used, thus the segment height was obviously smaller than for a true circle.
+ // Math: segment height approx 10000 * ( 1 - sqrt(0.5)) + line width
+ uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("Could not get the shape", xShape.is());
+ 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;
+ double fHeight = static_cast<double>(aBoundRect.Height);
+ // The tolerance is a guess, might be smaller.
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("segment height out of tolerance", 2942.0, fHeight, 8.0);
+}
+
+void CustomshapesTest::testToggleCommandXY()
+{
+ // 121952 Toggle x- and y-direction if command X has several parameters
+ // The loaded document has a shape with command X and two parameter placed on a diagonal.
+ // The radius of the quarter circles are both 10000 (unit 1/100 mm).
+ // The shape is rotated by 45deg, so you get two segments, one up and one down.
+ OUString aURL
+ = m_directories.getURLFromSrc(sDataDirectory) + "tdf121952_Toggle_direction_command_X.odp";
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument");
+ CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is());
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
+ uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
+ uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
+
+ // Error was, that the second segment was drawn with same direction as first one. If drawn
+ // correctly, the bounding box height of the segments together is about twice the single
+ // segment height. Math: segment height approx 10000 * ( 1 - sqrt(0.5)) + line width
+ uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("Could not get the shape", xShape.is());
+ 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;
+ double fHeight = static_cast<double>(aBoundRect.Height);
+ // The tolerance is a guess, might be smaller.
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("segment height out of tolerance", 5871.0, fHeight, 16.0);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(CustomshapesTest);
}
diff --git a/svx/qa/unit/data/tdf121761_Accuracy_command_X.odp b/svx/qa/unit/data/tdf121761_Accuracy_command_X.odp
new file mode 100644
index 000000000000..1de391758e4c
--- /dev/null
+++ b/svx/qa/unit/data/tdf121761_Accuracy_command_X.odp
Binary files differ
diff --git a/svx/qa/unit/data/tdf121952_Toggle_direction_command_X.odp b/svx/qa/unit/data/tdf121952_Toggle_direction_command_X.odp
new file mode 100644
index 000000000000..fbe1b7d4032e
--- /dev/null
+++ b/svx/qa/unit/data/tdf121952_Toggle_direction_command_X.odp
Binary files differ