summaryrefslogtreecommitdiff
path: root/svx/qa
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2019-01-25 00:30:57 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-01-29 01:16:51 +0100
commit76c7a6c39d769cb9bdb9b951d9f95507c0139372 (patch)
treee718b89423f52c71d3f94afa12a738edfff21639 /svx/qa
parentecc855aa1c86d88a99c3be06c70ed382180be688 (diff)
Improve ODF enhanced-path command moveTo to follow spec
ODF 1.2 section 19.145 says 'If a moveto is followed by multiple pairs of coordinates, they are treated as lineto.' The patch does this on import. Change-Id: Ib493ca49288cdb2d34b7ee801bd052281617d2e8 Reviewed-on: https://gerrit.libreoffice.org/66888 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'svx/qa')
-rwxr-xr-x[-rw-r--r--]svx/qa/unit/customshapes.cxx29
-rw-r--r--svx/qa/unit/data/tdf122964_MultipleMoveTo.odgbin0 -> 9666 bytes
2 files changed, 29 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index d3f63dffe2a9..a0c256b5d6e0 100644..100755
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -50,11 +50,13 @@ public:
void testViewBoxLeftTop();
void testAccuracyCommandX();
void testToggleCommandXY();
+ void testMultipleMoveTo();
CPPUNIT_TEST_SUITE(CustomshapesTest);
CPPUNIT_TEST(testViewBoxLeftTop);
CPPUNIT_TEST(testAccuracyCommandX);
CPPUNIT_TEST(testToggleCommandXY);
+ CPPUNIT_TEST(testMultipleMoveTo);
CPPUNIT_TEST_SUITE_END();
};
@@ -161,6 +163,33 @@ void CustomshapesTest::testToggleCommandXY()
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("segment height out of tolerance", 5871.0, fHeight, 16.0);
}
+void CustomshapesTest::testMultipleMoveTo()
+{
+ // tdf122964 Multiple moveTo has to be treated as lineTo in draw:enhanced-path
+ // Load a document with path "M 0 0 5 10 10 0 N"
+ OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf122964_MultipleMoveTo.odg";
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.drawing.DrawingDocument");
+ 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 and further parameter pairs were treated as moveTo,
+ // and so the generated path was empty, resulting in zero width and height of the
+ // bounding box. It has to be treated same as "M 0 0 L 5 10 10 0 N".
+ 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;
+ bool bIsZero(aBoundRect.Height == 0 && aBoundRect.Width == 0);
+ CPPUNIT_ASSERT_MESSAGE("Path is empty", !bIsZero);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(CustomshapesTest);
}
diff --git a/svx/qa/unit/data/tdf122964_MultipleMoveTo.odg b/svx/qa/unit/data/tdf122964_MultipleMoveTo.odg
new file mode 100644
index 000000000000..63d80fd06736
--- /dev/null
+++ b/svx/qa/unit/data/tdf122964_MultipleMoveTo.odg
Binary files differ