From 5c39b6b997ddc85e6848efc230a427a124b97264 Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Mon, 3 Feb 2014 02:46:30 +0100 Subject: drawingML export: custom geometry with cubic bezier curves When the custom shape is not a preset shape then construct a PolyPolygon and use DrawingML::WritePolyPolygon() to export it. Change-Id: I6598976a475bfcb92305338af9016e09df4c9456 --- .../data/dml-customgeometry-cubicbezier.docx | Bin 0 -> 17348 bytes sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 64 +++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/dml-customgeometry-cubicbezier.docx (limited to 'sw') diff --git a/sw/qa/extras/ooxmlexport/data/dml-customgeometry-cubicbezier.docx b/sw/qa/extras/ooxmlexport/data/dml-customgeometry-cubicbezier.docx new file mode 100644 index 000000000000..baa47f43c102 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/dml-customgeometry-cubicbezier.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 8f1982d26de0..239bb0286c03 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -46,6 +46,9 @@ #include #include #include +#include +#include +#include #include #include @@ -2717,6 +2720,67 @@ DECLARE_OOXMLEXPORT_TEST(testDMLSolidfillAlpha, "dml-solidfill-alpha.docx") xShape.set(getShape(2), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty(xShape, "FillTransparence")); } + +DECLARE_OOXMLEXPORT_TEST(testDMLCustomGeometry, "dml-customgeometry-cubicbezier.docx") +{ + + // The problem was that a custom shape was not exported. + uno::Sequence aProps = getProperty< uno::Sequence >(getShape(1), "CustomShapeGeometry"); + uno::Sequence aPathProps; + for (int i = 0; i < aProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aProps[i]; + if (rProp.Name == "Path") + rProp.Value >>= aPathProps; + } + uno::Sequence aPairs; + uno::Sequence aSegments; + for (int i = 0; i < aPathProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aPathProps[i]; + if (rProp.Name == "Coordinates") + rProp.Value >>= aPairs; + else if (rProp.Name == "Segments") + rProp.Value >>= aSegments; + } + + // (a:moveTo) + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments[0].Count); + CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::MOVETO), aSegments[0].Command ); + + // (a:cubicBezTo) + CPPUNIT_ASSERT_EQUAL(sal_Int16(5), aSegments[1].Count); + CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::CURVETO), aSegments[1].Command ); + + // Coordinates + sal_Int32 nLength = 16; + CPPUNIT_ASSERT_EQUAL(nLength, aPairs.getLength()); + std::pair aCoordinates[] = + { + std::pair(607, 0), + std::pair(450, 44), + std::pair(300, 57), + std::pair(176, 57), + std::pair(109, 57), + std::pair(49, 53), + std::pair(0, 48), + std::pair(66, 58), + std::pair(152, 66), + std::pair(251, 66), + std::pair(358, 66), + std::pair(480, 56), + std::pair(607, 27), + std::pair(607, 0), + std::pair(607, 0), + std::pair(607, 0) + }; + + for( int i = 0; i < nLength; ++i ) + { + CPPUNIT_ASSERT_EQUAL(aCoordinates[i].first, aPairs[i].First.Value.get()); + CPPUNIT_ASSERT_EQUAL(aCoordinates[i].second, aPairs[i].Second.Value.get()); + } +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit