oox/source/export/shapes.cxx | 5 +++++ sw/qa/extras/uiwriter/uiwriter4.cxx | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+)
New commits: commit 87db920b141fe9846cbd1b37fff3a9806a9b5c2d Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Tue Nov 30 11:59:55 2021 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Jan 3 13:37:29 2022 +0100 tdf#98736 OOXML export: keep CaptionShape as TextShape Caption shapes were lost during OOXML export. As a workaround, export them as text shapes, losing only the leader lines, but not their text shapes and text content. Change-Id: I372708fa4c9356c807a0a239c722691fd88ec1a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126123 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 35b7a4bd4c9d..997a6e949b76 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1668,6 +1668,11 @@ static const NameToConvertMapType& lcl_GetConverters() { static NameToConvertMapType const shape_converters { + // tdf#98736 export CaptionShape as TextShape, because it is non-ooxml shape and + // we can't export this shape as CustomShape + // TODO: WriteCaptionShape + { "com.sun.star.drawing.CaptionShape" , &ShapeExport::WriteTextShape }, + { "com.sun.star.drawing.ClosedBezierShape" , &ShapeExport::WriteClosedPolyPolygonShape }, { "com.sun.star.drawing.ConnectorShape" , &ShapeExport::WriteConnectorShape }, { "com.sun.star.drawing.CustomShape" , &ShapeExport::WriteCustomShape }, diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index fa9258949c07..0101e246a42d 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -290,6 +290,7 @@ public: void testInsertPdf(); void testTdf143760WrapContourToOff(); void testTdf127989(); + void testCaptionShape(); CPPUNIT_TEST_SUITE(SwUiWriterTest4); CPPUNIT_TEST(testTdf96515); @@ -413,6 +414,7 @@ public: CPPUNIT_TEST(testInsertPdf); CPPUNIT_TEST(testTdf143760WrapContourToOff); CPPUNIT_TEST(testTdf127989); + CPPUNIT_TEST(testCaptionShape); CPPUNIT_TEST_SUITE_END(); }; @@ -4067,6 +4069,27 @@ void SwUiWriterTest4::testTdf127989() CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), "FillBackground")); } +void SwUiWriterTest4::testCaptionShape() +{ + createSwDoc(); + + // Add a caption shape to the document. + uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape( + xFactory->createInstance("com.sun.star.drawing.CaptionShape"), uno::UNO_QUERY); + xShape->setSize(awt::Size(10000, 10000)); + xShape->setPosition(awt::Point(1000, 1000)); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + xDrawPage->add(xShape); + + // Save it as DOCX and load it again. + reload("Office Open XML Text", "captionshape.docx"); + + // Without fix in place, the shape was lost on export. + CPPUNIT_ASSERT_EQUAL(1, getShapes()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest4); CPPUNIT_PLUGIN_IMPLEMENT();