oox/qa/unit/data/WPC_tdf158348_shape_text_in_table_cell.docx |binary
oox/qa/unit/wpc_drawing_canvas.cxx | 32 ++-
writerfilter/source/ooxml/OOXMLFastContextHandler.cxx|4 -
3 files changed, 33 insertions(+), 3 deletions(-)
New commits:
commit bf6350ef7f9856abc4d6a085bd2d2f95d6b0c84e
Author: Regina Henschel
AuthorDate: Mon Nov 27 02:22:29 2023 +0100
Commit: Regina Henschel
CommitDate: Tue Nov 28 14:07:30 2023 +0100
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
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
new file mode 100644
index ..e8f2cf73d3d5
Binary files /dev/null and
b/oox/qa/unit/data/WPC_tdf158348_shape_text_in_table_cell.docx differ
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
#include
#include
+#include
#include
+#include
+#include
#include
-#include
#include
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
xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
+uno::Reference
xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+
+// Get the shape and make sure it has text.
+uno::Reference xCanvas(xDrawPage->getByIndex(0),
uno::UNO_QUERY);
+uno::Reference xShapeProps(xCanvas->getByIndex(1),
uno::UNO_QUERY);
+uno::Reference 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 xTablesSupplier(mxComponent,
uno::UNO_QUERY);
+uno::Reference xTextTable(
+xTablesSupplier->getTextTables()->getByName(u"Table1"_ustr),
uno::UNO_QUERY);
+uno::Reference 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();
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 30ed3a70e63c..cbc75c14070a 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1840,8 +1840,8 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t
Element )
bool OOXMLFastContextHandlerShape::isDMLGroupShape() const
{
-return (mrShapeContext->getFullWPGSupport()
- && (mrShapeContext->isWordProcessingGroupShape() ||
mrShapeContext->isWordprocessingCanvas()));
+return (mrShapeContext->getFullWPGSupport() &&
mrShapeContext->isWordProcessingGroupShape())
+|| mrShapeContext->isWordprocessingCanvas();
};
void OOXMLFastContextHandlerShape::lcl_endFastElement