diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-02-03 02:46:30 +0100 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-02-03 02:46:30 +0100 |
commit | 5c39b6b997ddc85e6848efc230a427a124b97264 (patch) | |
tree | 0a4faac2c991f3134a3f5963f5258e28d1931c3b /sw | |
parent | 72b2fafebfc44fa90f08cc198e2fa5fc26154c5b (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/dml-customgeometry-cubicbezier.docx | bin | 0 -> 17348 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 64 |
2 files changed, 64 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/dml-customgeometry-cubicbezier.docx b/sw/qa/extras/ooxmlexport/data/dml-customgeometry-cubicbezier.docx Binary files differnew file mode 100644 index 000000000000..baa47f43c102 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/dml-customgeometry-cubicbezier.docx 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 <rtl/strbuf.hxx> #include <comphelper/sequenceashashmap.hxx> #include <com/sun/star/text/XDocumentIndex.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> #include <libxml/xpathInternals.h> #include <libxml/parserInternals.h> @@ -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<sal_Int16>(xShape, "FillTransparence")); } + +DECLARE_OOXMLEXPORT_TEST(testDMLCustomGeometry, "dml-customgeometry-cubicbezier.docx") +{ + + // The problem was that a custom shape was not exported. + uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(getShape(1), "CustomShapeGeometry"); + uno::Sequence<beans::PropertyValue> aPathProps; + for (int i = 0; i < aProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aProps[i]; + if (rProp.Name == "Path") + rProp.Value >>= aPathProps; + } + uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs; + uno::Sequence<drawing::EnhancedCustomShapeSegment> 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<sal_Int32,sal_Int32> aCoordinates[] = + { + std::pair<sal_Int32,sal_Int32>(607, 0), + std::pair<sal_Int32,sal_Int32>(450, 44), + std::pair<sal_Int32,sal_Int32>(300, 57), + std::pair<sal_Int32,sal_Int32>(176, 57), + std::pair<sal_Int32,sal_Int32>(109, 57), + std::pair<sal_Int32,sal_Int32>(49, 53), + std::pair<sal_Int32,sal_Int32>(0, 48), + std::pair<sal_Int32,sal_Int32>(66, 58), + std::pair<sal_Int32,sal_Int32>(152, 66), + std::pair<sal_Int32,sal_Int32>(251, 66), + std::pair<sal_Int32,sal_Int32>(358, 66), + std::pair<sal_Int32,sal_Int32>(480, 56), + std::pair<sal_Int32,sal_Int32>(607, 27), + std::pair<sal_Int32,sal_Int32>(607, 0), + std::pair<sal_Int32,sal_Int32>(607, 0), + std::pair<sal_Int32,sal_Int32>(607, 0) + }; + + for( int i = 0; i < nLength; ++i ) + { + CPPUNIT_ASSERT_EQUAL(aCoordinates[i].first, aPairs[i].First.Value.get<sal_Int32>()); + CPPUNIT_ASSERT_EQUAL(aCoordinates[i].second, aPairs[i].Second.Value.get<sal_Int32>()); + } +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); |