From 63cd67e5e18f01aca303131e148c80398a181a41 Mon Sep 17 00:00:00 2001 From: "Attila Bakos (NISZ)" Date: Fri, 14 May 2021 13:53:32 +0200 Subject: tdf#92525 tdf#142398: fix export of simple custom shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of the custom shapes were exported with DrawingML custom geometry instead of DOCX preset shapes, losing their preset type, adjust handles and text position. Add a preset exporter class to handle all possible preset shapes later, and fix the export of the following shapes now: "bevel", "blockArc", "bracePair", "bracketPair", "hexagon", "octagon", "parallelogram", "plus", "roundRect" and "triangle". tdf#92525: keep text position in triangles with different adjustments, too. tdf#142398: part 1: export simple shapes as preset shapes. Change-Id: I6aee74f7670bea8c1fe5909cbf307778ea728669 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115606 Tested-by: László Németh Reviewed-by: László Németh --- .../data/testCustomShapePresetExport.odt | Bin 0 -> 86157 bytes sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 31 +++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/testCustomShapePresetExport.odt (limited to 'sw') diff --git a/sw/qa/extras/ooxmlexport/data/testCustomShapePresetExport.odt b/sw/qa/extras/ooxmlexport/data/testCustomShapePresetExport.odt new file mode 100644 index 000000000000..4f132e760460 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/testCustomShapePresetExport.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 5d567543bcec..dcaa4e6e5e54 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -129,6 +129,37 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testGutterTop, "gutter-top.docx") assertXPath(pXmlSettings, "/w:settings/w:gutterAtTop", 1); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testCustomShapePresetExport, "testCustomShapePresetExport.odt") +{ + // Check if the load failed. + CPPUNIT_ASSERT(getPages()); + + // Check all shapes of the file + int nCount = 0; + for (int i = 1; i <= getShapes(); i++) + { + uno::Reference xProperties(getShape(i), uno::UNO_QUERY); + if (!xProperties->getPropertySetInfo()->hasPropertyByName("CustomShapeGeometry")) + continue; + // Get the custom shape property + auto aCustomShapeGeometry = xProperties->getPropertyValue("CustomShapeGeometry") + .get>(); + // Find for shape type + for (const auto& aCustomGeometryIterator : std::as_const(aCustomShapeGeometry)) + { + if (aCustomGeometryIterator.Name == "Type") + CPPUNIT_ASSERT_MESSAGE( + "This is an ooxml preset shape with custom geometry! Shape type lost!", + aCustomGeometryIterator.Value.get() != "ooxml-non-primitive"); + // Without the fix, all shapes have ooxml-non-primitive type, and lost their + // real type (like triangle) with the textbox padding. + } + nCount++; + } + // Without the fix the count does not match. + CPPUNIT_ASSERT_EQUAL(17, nCount); +} + DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf69635, "tdf69635.docx") { xmlDocUniquePtr pXmlHeader1 = parseExport("word/header1.xml"); -- cgit