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 /sw | |
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 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf147978_enhancedPath_commandABVW.odt | bin | 0 -> 11581 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 16 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 24 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 20 |
4 files changed, 31 insertions, 29 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf147978_enhancedPath_commandABVW.odt b/sw/qa/extras/ooxmlexport/data/tdf147978_enhancedPath_commandABVW.odt Binary files differnew file mode 100644 index 000000000000..d9ef07db5920 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf147978_enhancedPath_commandABVW.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index bbc5ec25da07..aff5fb3b336c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -376,6 +376,22 @@ DECLARE_OOXMLEXPORT_TEST(testTdf144668, "tdf144668.odt") CPPUNIT_ASSERT_EQUAL(OUString("[001]"), getProperty<OUString>(xPara2, "ListLabelString")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf147978enhancedPathABVW) +{ + load(DATA_DIRECTORY, "tdf147978_enhancedPath_commandABVW.odt"); + CPPUNIT_ASSERT(mxComponent); + save("Office Open XML Text", maTempFile); + mxComponent->dispose(); + mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument"); + // Make sure the new implemented export for commands A,B,V and W use the correct arc between + // the given two points, here the short one. + for (sal_Int16 i = 1 ; i <= 4; ++i) + { + uno::Reference<drawing::XShape> xShape = getShape(i); + CPPUNIT_ASSERT_EQUAL(sal_Int32(506), getProperty<awt::Rectangle>(xShape, "BoundRect").Height); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index e985e66e5f54..23cdbc2c53b6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -1131,24 +1131,30 @@ CPPUNIT_TEST_FIXTURE(Test, testFlipAndRotateCustomShape) CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); - // there should be no flipH and flipV attributes in this case + // there should be no flipH assertXPathNoAttribute(pXmlDoc, "//a:xfrm", "flipH"); - assertXPathNoAttribute(pXmlDoc, "//a:xfrm", "flipV"); + // flipV should be there + assertXPath(pXmlDoc, "//a:xfrm", "flipV", "1"); // check rotation angle - assertXPath(pXmlDoc, "//a:xfrm", "rot", "13500000"); + assertXPath(pXmlDoc, "//a:xfrm", "rot", "8100000"); + // point values depend on path size, values as of March 2022 + assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path", "w", "21600"); + assertXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path", "h", "21600"); // check the first few coordinates of the polygon CPPUNIT_ASSERT_DOUBLES_EQUAL( - 2351, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "x").toInt32(), 1); + 0, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:moveTo/a:pt", "x").toInt32(), 1); CPPUNIT_ASSERT_DOUBLES_EQUAL( - 3171, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "y").toInt32(), 1); + 15831, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:moveTo/a:pt", "y").toInt32(), 1); CPPUNIT_ASSERT_DOUBLES_EQUAL( - 1695, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[2]/a:pt", "x").toInt32(), 1); + 6098, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "x").toInt32(), 1); CPPUNIT_ASSERT_DOUBLES_EQUAL( - 3171, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[2]/a:pt", "y").toInt32(), 1); + 10062, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "y").toInt32(), 1); CPPUNIT_ASSERT_DOUBLES_EQUAL( - 1695, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[3]/a:pt", "x").toInt32(), 1); + 13284, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[4]/a:pt", "x").toInt32(), 1); CPPUNIT_ASSERT_DOUBLES_EQUAL( - 1701, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[3]/a:pt", "y").toInt32(), 1); + 6098, getXPath(pXmlDoc, "//a:custGeom/a:pathLst/a:path/a:lnTo[4]/a:pt", "y").toInt32(), 1); + // check path is closed + assertXPath(pXmlDoc, "//a:close", 1); } CPPUNIT_TEST_FIXTURE(Test, testTdf92335) diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 4541714fdf00..7f8f86ac48ee 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -346,26 +346,6 @@ tools::Polygon lcl_CreateContourPolygon(SdrObject* pSdrObj) basegfx::B2DHomMatrix aScale(basegfx::utils::createScaleB2DHomMatrix(fScaleX, fScaleY)); aPolyPolygon.transform(aScale); - // ToDo: In some cases (see ShapeExport::WriteCustomShape()) flip is suppressed when - // calling WriteShapeTransformation(), because the path in custGeom contains already - // flipped coordinates. In such cases the wrap polygon needs to contain flipped - // coordinates too. That is missing here. - - // "moon" and "msp-spt89" (up-right-arrow) are currently mirrored horizontally. But - // that is removed on export in shapes.cxx. So need to remove it in wrap polygon too. - uno::Reference<drawing::XShape> xShape(pSdrObj->getUnoShape(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY); - comphelper::SequenceAsHashMap aCustomShapeGeometry( - xProps->getPropertyValue("CustomShapeGeometry")); - auto it = aCustomShapeGeometry.find("Type"); - if (it != aCustomShapeGeometry.end() - && (aCustomShapeGeometry["Type"].get<OUString>() == "moon" - || aCustomShapeGeometry["Type"].get<OUString>() == "mso-spt89")) - { - basegfx::B2DHomMatrix aFlipH(basegfx::utils::createScaleB2DHomMatrix(-1.0, 1.0)); - aPolyPolygon.transform(aFlipH); - } - basegfx::B2DHomMatrix aTranslateToCenter( basegfx::utils::createTranslateB2DHomMatrix(10800.0, 10800.0)); aPolyPolygon.transform(aTranslateToCenter); |