diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2023-11-24 01:18:22 +0100 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2023-11-24 15:15:41 +0100 |
commit | 63ecd577f5fe95feda0d1d8577a7d3b493999d78 (patch) | |
tree | b69b842f35a6fbd2400f1d6066eede375e2b00d3 /oox | |
parent | b1a866caccb322ec6e88eac67710310160e72b58 (diff) |
tdf#158339 setFullWPGSupport to group shape in wpc
otherwise the group will create no wps shapes but draw shapes and those
cannot be connected to text frames. The text frames were then located
separate outside the drawing canvas instead of being bound to the shape.
Change-Id: I525fac157c08c60d43ff9420775e2cbb9d891d23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159885
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/qa/unit/data/WPC_tdf158339_shape_text_in_group.docx | bin | 0 -> 20454 bytes | |||
-rw-r--r-- | oox/qa/unit/wpc_drawing_canvas.cxx | 24 | ||||
-rw-r--r-- | oox/source/shape/WordprocessingCanvasContext.cxx | 6 |
3 files changed, 29 insertions, 1 deletions
diff --git a/oox/qa/unit/data/WPC_tdf158339_shape_text_in_group.docx b/oox/qa/unit/data/WPC_tdf158339_shape_text_in_group.docx Binary files differnew file mode 100644 index 000000000000..b34071cd99d2 --- /dev/null +++ b/oox/qa/unit/data/WPC_tdf158339_shape_text_in_group.docx diff --git a/oox/qa/unit/wpc_drawing_canvas.cxx b/oox/qa/unit/wpc_drawing_canvas.cxx index 0857eb8099cf..1d00123e14a1 100644 --- a/oox/qa/unit/wpc_drawing_canvas.cxx +++ b/oox/qa/unit/wpc_drawing_canvas.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/util/XComplexColor.hpp> @@ -252,6 +253,29 @@ CPPUNIT_TEST_FIXTURE(TestWPC, WPC_Shadow) xShapeProps->getPropertyValue(UNO_NAME_SHADOWCOLOR) >>= nColor; CPPUNIT_ASSERT_EQUAL(Color(0x808080), nColor); } + +CPPUNIT_TEST_FIXTURE(TestWPC, WPC_tdf158339_shape_text_in_group) +{ + // The document has a group of two shapes with text. This group is child of a drawing canvas. + // Without fix the text of the shapes were imported as separate text boxes. + loadFromURL(u"WPC_tdf158339_shape_text_in_group.docx"); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + // Make sure there is only one object on that page. Without fix there were three objects. + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); + // Get the group which represents the drawing canvas and the group object inside. + uno::Reference<drawing::XShapes> xCanvas(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xGroup(xCanvas->getByIndex(1), uno::UNO_QUERY); + // Get the properties of the second shape inside the group + uno::Reference<beans::XPropertySet> xShapeProps(xGroup->getByIndex(1), uno::UNO_QUERY); + // and make sure the shape has text. + uno::Reference<css::text::XTextFrame> xTextFrame; + xShapeProps->getPropertyValue(u"TextBoxContent"_ustr) >>= xTextFrame; + CPPUNIT_ASSERT(xTextFrame.is()); + CPPUNIT_ASSERT_EQUAL(OUString("Group"), xTextFrame->getText()->getString()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/oox/source/shape/WordprocessingCanvasContext.cxx b/oox/source/shape/WordprocessingCanvasContext.cxx index 7273a8d23ea6..9365e387f5e3 100644 --- a/oox/source/shape/WordprocessingCanvasContext.cxx +++ b/oox/source/shape/WordprocessingCanvasContext.cxx @@ -88,7 +88,11 @@ WordprocessingCanvasContext::onCreateContext(sal_Int32 nElementToken, << getBaseToken(nElementToken)); break; case XML_wgp: // CT_WordprocessingGroup - return new oox::shape::WpgContext(*this, mpShapePtr); + { + rtl::Reference<WpgContext> pWPGContext = new oox::shape::WpgContext(*this, mpShapePtr); + pWPGContext->setFullWPGSupport(m_bFullWPGSupport); + return pWPGContext; + } default: // includes case XML_contentPart // Word uses this for Ink, as <w14:contentPart r:id="rId4"> for example. Thereby rId4 is |