diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2022-03-18 18:31:05 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-25 14:00:23 +0100 |
commit | 2029b2f6dd0109c5892e5ac5640022b31fe42fd2 (patch) | |
tree | cdb2b2776ea497f8bed2ffdcdaf100b2c2a4b64f /sd/qa | |
parent | c4cb1d1dd581a5f120d9cf8b1d4274ec38f3eabe (diff) |
tdf#147978 export subpaths individually in custGeom
...and implement export of all missing commands,
use existing viewBox if suitable,
use one EnhancedCustomShape2d
move WriteCustomGeometryPoint to protected,
make GetCustomGeometryPointValue local
The fix solves tdf#100390 too.
Without the fix the entire enhanced-path was exported as one element
<a:path>. The command F was applied to the whole drawing but should
affect only the subpath. The implementation is changed so that each
subpath gets its own element <a:path> and command F acts only on its
subpath.
Support for export of handles and equations is still a long way off.
Thus there is no reason to tread shapes with and without handles
different. Shapes with handles had used method WritePolyPolygon, but
that is not able to handle subpaths. So have desided to use method
WriteCustomGeometry for all cases.
To get shapes exported regardless of path commands I have added the
export for the missing commands.
I have removed the no longer used method WritePolyPolygon.
The special treatment of shapes "moon" and "mso-spt89" (right up arrow)
in export is no longer needed. Related code parts are removed. The
unit test testFlipAndRotateCustomShape is adapted.
In case the method WriteCustomGeometry fails, the enhanced-path is
invalid. In that case an minimal custGeom is written in case of docx.
Shapes whose drawing does not touch all edges of the snap rectangle
were exported with wrong position and size of the drawing inside the
snap rectangle. That is fixed by using an existing ViewBox for the
OOXML path size. The old way of creating a path size from point
coordinates is only used if the shape has no suitable ViewBox.
The point values in unit test SdOOXMLExportTest2::testTdf111798 are
adapted to path size 21600 x 21600 and traverse direction of the points
is corrected. The resulting shape outline is still the same as before.
The expected xml is updated for file tdf92001.odp in
SdImportTest::testDocumentLayout. The resulting shape outline is the
same, because the shape touches the edges of the snap rectangle.
The case, that the shape outline does not touch a edge of the snap
rectangle is tested in SdOOXMLExportTest3::testEnhancedPathViewBox.
Still missing is the case, that ViewBox has other left,top than 0,0.
In that case all coordinates would have to be shifted because the path
size in OOXML has only width and height but not left,top. That will
not be included in this patch.
Change-Id: Ib1736d6a08371f4d98411d2769275f0580cd0030
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131837
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/data/odp/tdf147978_enhancedPath_viewBox.odp | bin | 0 -> 12728 bytes | |||
-rw-r--r-- | sd/qa/unit/data/xml/tdf92001_0.xml | 42 | ||||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 32 | ||||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml3.cxx | 16 |
4 files changed, 70 insertions, 20 deletions
diff --git a/sd/qa/unit/data/odp/tdf147978_enhancedPath_viewBox.odp b/sd/qa/unit/data/odp/tdf147978_enhancedPath_viewBox.odp Binary files differnew file mode 100644 index 000000000000..15d7046811c8 --- /dev/null +++ b/sd/qa/unit/data/odp/tdf147978_enhancedPath_viewBox.odp diff --git a/sd/qa/unit/data/xml/tdf92001_0.xml b/sd/qa/unit/data/xml/tdf92001_0.xml index afc1fd6ef10a..1bacf2f2559c 100644 --- a/sd/qa/unit/data/xml/tdf92001_0.xml +++ b/sd/qa/unit/data/xml/tdf92001_0.xml @@ -24,16 +24,52 @@ <PropertyValue name="Path"> <Path> <PropertyValue name="Coordinates"> - <Coordinates/> + <Coordinates> + <EnhancedCustomShapeParameterPair> + <First value="0" type="0"/> + <Second value="5677" type="0"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="8631" type="0"/> + <Second value="5677" type="0"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="8631" type="0"/> + <Second value="0" type="0"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="21600" type="0"/> + <Second value="10800" type="0"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="8631" type="0"/> + <Second value="21600" type="0"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="8631" type="0"/> + <Second value="15923" type="0"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="0" type="0"/> + <Second value="15923" type="0"/> + </EnhancedCustomShapeParameterPair> + </Coordinates> </PropertyValue> <PropertyValue name="Segments"> - <Segments/> + <Segments> + <EnhancedCustomShapeSegment command="1" count="1"/> + <EnhancedCustomShapeSegment command="2" count="6"/> + <EnhancedCustomShapeSegment command="4" count="0"/> + <EnhancedCustomShapeSegment command="5" count="0"/> + </Segments> </PropertyValue> + <PropertyValue name="SubViewSize" handle="0" propertyState="DIRECT_VALUE"/> + <PropertyValue name="TextFrames" handle="0" propertyState="DIRECT_VALUE"/> </Path> </PropertyValue> <PropertyValue name="Type" value="ooxml-non-primitive" handle="0" propertyState="DIRECT_VALUE"/> <PropertyValue name="ViewBox"> - <ViewBox x="0" y="0" width="7040880" height="4663440"/> + <ViewBox x="0" y="0" width="0" height="0"/> </PropertyValue> </CustomShapeGeometry> </XShape> diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 1cff1e9f4617..e99ac6168dd5 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -1047,29 +1047,27 @@ void SdOOXMLExportTest2::testTdf111798() xDocShRef->DoClose(); xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml"); - const OUString data[][29] = + const OUString data[][26] = { { "2700000", "2458080", "2414880", "1439640", "1440000", - "moveTo", "0", "3000", - "lnTo[1]", "3000", "3000", - "lnTo[2]", "3000", "4000", - "lnTo[3]", "4000", "2000", - "lnTo[4]", "3000", "0", - "lnTo[5]", "3000", "1000", - "lnTo[6]", "0", "1000", - "lnTo[7]", "0", "3000" + "moveTo", "0", "5400", + "lnTo[1]", "16200", "5400", + "lnTo[2]", "16200", "0", + "lnTo[3]", "21600", "10800", + "lnTo[4]", "16200", "21600", + "lnTo[5]", "16200", "16200", + "lnTo[6]", "0", "16200" }, { "2700000", "6778080", "2414880", "1439640", "1440000", - "moveTo", "3000", "0", - "lnTo[1]", "3000", "3000", - "lnTo[2]", "4000", "3000", - "lnTo[3]", "2000", "4000", - "lnTo[4]", "0", "3000", - "lnTo[5]", "1000", "3000", - "lnTo[6]", "1000", "0", - "lnTo[7]", "3000", "0" + "moveTo", "5400", "0", + "lnTo[1]", "5400", "16200", + "lnTo[2]", "0", "16200", + "lnTo[3]", "10800", "21600", + "lnTo[4]", "21600", "16200", + "lnTo[5]", "16200", "16200", + "lnTo[6]", "16200", "0" } }; diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx index 58b4d3680da9..776d436b7edf 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -105,6 +105,7 @@ public: void testTdf143315(); void testTdf147121(); void testTdf140912_PicturePlaceholder(); + void testEnhancedPathViewBox(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest3); @@ -180,6 +181,7 @@ public: CPPUNIT_TEST(testTdf143315); CPPUNIT_TEST(testTdf147121); CPPUNIT_TEST(testTdf140912_PicturePlaceholder); + CPPUNIT_TEST(testEnhancedPathViewBox); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -1877,6 +1879,20 @@ void SdOOXMLExportTest3::testTdf140912_PicturePlaceholder() xDocShRef->DoClose(); } +void SdOOXMLExportTest3::testEnhancedPathViewBox() +{ + auto xDocShRef = loadURL( + m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf147978_enhancedPath_viewBox.odp"), + ODP); + xDocShRef = saveAndReload(xDocShRef.get(), PPTX); + auto xShapeProps(getShapeFromPage(0, 0, xDocShRef)); + awt::Rectangle aBoundRectangle; + xShapeProps->getPropertyValue("BoundRect") >>= aBoundRectangle; + // The shape has a Bézier curve which does not touch the right edge. Prior to the fix the curve + // was stretched to touch the edge, resulting in 5098 curve width instead of 2045. + CPPUNIT_ASSERT_EQUAL(sal_Int32(2045), aBoundRectangle.Width); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3); CPPUNIT_PLUGIN_IMPLEMENT(); |