diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2023-11-27 02:22:29 +0100 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2023-11-28 14:07:30 +0100 |
commit | bf6350ef7f9856abc4d6a085bd2d2f95d6b0c84e (patch) | |
tree | a54baa6f9e8da6c03e99741468c7a3f942563ee7 /oox | |
parent | 7b96db51608e237155a37c7b5d31ef408a19019b (diff) |
tdf#158348 Treat wordprocessing canvas like group shape
getFullWPGSupport() is always false for mrShapeContext in case of a
shape on wordprocessing canvas in table cell. On the other hand we do
not need the test, because a wordprocessing canvas only occurs in docx
and thus the replacement group always has FullWPGSupport.
Change-Id: I0e7a9cf1c1c91a893ad7411fda7607947f053e05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159979
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/qa/unit/data/WPC_tdf158348_shape_text_in_table_cell.docx | bin | 0 -> 19725 bytes | |||
-rw-r--r-- | oox/qa/unit/wpc_drawing_canvas.cxx | 32 |
2 files changed, 31 insertions, 1 deletions
diff --git a/oox/qa/unit/data/WPC_tdf158348_shape_text_in_table_cell.docx b/oox/qa/unit/data/WPC_tdf158348_shape_text_in_table_cell.docx Binary files differnew file mode 100644 index 000000000000..e8f2cf73d3d5 --- /dev/null +++ b/oox/qa/unit/data/WPC_tdf158348_shape_text_in_table_cell.docx diff --git a/oox/qa/unit/wpc_drawing_canvas.cxx b/oox/qa/unit/wpc_drawing_canvas.cxx index 1d00123e14a1..d1fde534034c 100644 --- a/oox/qa/unit/wpc_drawing_canvas.cxx +++ b/oox/qa/unit/wpc_drawing_canvas.cxx @@ -20,9 +20,11 @@ #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/XTextDocument.hpp> #include <com/sun/star/text/XTextFrame.hpp> +#include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> -#include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/util/XComplexColor.hpp> using namespace ::com::sun::star; @@ -276,6 +278,34 @@ CPPUNIT_TEST_FIXTURE(TestWPC, WPC_tdf158339_shape_text_in_group) CPPUNIT_ASSERT(xTextFrame.is()); CPPUNIT_ASSERT_EQUAL(OUString("Group"), xTextFrame->getText()->getString()); } + +CPPUNIT_TEST_FIXTURE(TestWPC, WPC_tdf158348_shape_text_in_table_cell) +{ + // The document has a shape with text on a drawing canvas in a table cell. + // Without fix the text of the shape becomes part of the paragraph of the table cell. + loadFromURL(u"WPC_tdf158348_shape_text_in_table_cell.docx"); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + + // Get the shape and make sure it has text. + uno::Reference<drawing::XShapes> xCanvas(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProps(xCanvas->getByIndex(1), uno::UNO_QUERY); + uno::Reference<css::text::XTextFrame> xTextFrame; + xShapeProps->getPropertyValue(u"TextBoxContent"_ustr) >>= xTextFrame; + CPPUNIT_ASSERT(xTextFrame.is()); + // The string was empty without fix. + CPPUNIT_ASSERT_EQUAL(u"Inside shape"_ustr, xTextFrame->getText()->getString()); + + // Get the table and make sure the cell has only its own text. + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTextTable( + xTablesSupplier->getTextTables()->getByName(u"Table1"_ustr), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCellA1(xTextTable->getCellByName("A1"), uno::UNO_QUERY); + // The string had started with "Inside shape" without fix. + CPPUNIT_ASSERT(xCellA1->getString().startsWith("Inside table")); +} } CPPUNIT_PLUGIN_IMPLEMENT(); |