sw/qa/extras/layout/layout5.cxx | 52 ++++++++++++++++++++++++----------- sw/source/core/doc/textboxhelper.cxx | 8 ++--- xmloff/qa/unit/draw.cxx | 2 - 3 files changed, 41 insertions(+), 21 deletions(-)
New commits: commit da7414e63578c17adb7f5f3345fa2143f0bc769c Author: Michael Stahl <[email protected]> AuthorDate: Mon Jan 19 16:16:15 2026 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Wed Jan 21 14:05:27 2026 +0100 sw: fix setting mbIsTextBox on shapes' text boxes SetTextBoxes(true) is never called because it checks the shape's SdrObject, while previously this code was in SwFrameFormat::SetOtherTextBoxFormat() where it would be called a second time for the text box SwFrameFormat which has the SwFlyDrawObj. SwTextBoxHelper::getCount() can't ignore the text boxes if the flag is never set; this ends up confusing ShapeGroupContext::popGroupAndPostProcess() (and causes tests like testTdf84695 to fail with the fixes in the next commit). Because shapes with text boxes are sorted again with this, testTdf146272 and testTextBoxLoss need adapting. (regression from commit 504d78acb866495fd954fcd6db22ea68f174a5ab) Change-Id: I80c375d900a10f1956cd112d60c3f25332c485ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197594 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit 327e92c78603e011e7ddf8b57749dfd9e690addf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197727 Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/layout/layout5.cxx b/sw/qa/extras/layout/layout5.cxx index b1b6c9cc9d23..0fcf72b12bf0 100644 --- a/sw/qa/extras/layout/layout5.cxx +++ b/sw/qa/extras/layout/layout5.cxx @@ -66,21 +66,43 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf146272) { createSwDoc("tdf146272.odt"); - uno::Reference<beans::XPropertySet> xPicture(getShape(2), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xDrawing(getShape(1), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xFrame(xDrawing->getPropertyValue(u"TextBoxContent"_ustr), - uno::UNO_QUERY); - - CPPUNIT_ASSERT(xPicture); - CPPUNIT_ASSERT(xDrawing); - CPPUNIT_ASSERT(xFrame); - - const sal_uInt64 nPitureZorder = xPicture->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); - const sal_uInt64 nDrawingZorder = xDrawing->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); - const sal_uInt64 nFrameZorder = xFrame->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); - - CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nDrawingZorder < nFrameZorder); - CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nFrameZorder < nPitureZorder); + uno::Reference<beans::XPropertySet> xPicture1(getShapeByName(u"graphics1"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xDrawing1(getShapeByName(u"Shape2"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xFrame1(xDrawing1->getPropertyValue(u"TextBoxContent"_ustr), + uno::UNO_QUERY); + + CPPUNIT_ASSERT(xPicture1); + CPPUNIT_ASSERT(xDrawing1); + CPPUNIT_ASSERT(xFrame1); + + const sal_uInt64 nPicture1Zorder + = xPicture1->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); + const sal_uInt64 nDrawing1Zorder + = xDrawing1->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); + const sal_uInt64 nFrame1Zorder = xFrame1->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); + + CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nDrawing1Zorder < nFrame1Zorder); + CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nFrame1Zorder < nPicture1Zorder); + + uno::Reference<beans::XPropertySet> xPicture2(getShapeByName(u"Image423"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xDrawing2(getShapeByName(u"Shape3"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xFrame2(xDrawing2->getPropertyValue(u"TextBoxContent"_ustr), + uno::UNO_QUERY); + + CPPUNIT_ASSERT(xPicture2); + CPPUNIT_ASSERT(xDrawing2); + CPPUNIT_ASSERT(xFrame2); + + const sal_uInt64 nPicture2Zorder + = xPicture2->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); + const sal_uInt64 nDrawing2Zorder + = xDrawing2->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); + const sal_uInt64 nFrame2Zorder = xFrame2->getPropertyValue(u"ZOrder"_ustr).get<sal_uInt64>(); + + CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nDrawing2Zorder < nFrame2Zorder); + CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nFrame2Zorder < nPicture2Zorder); + CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nDrawing1Zorder < nDrawing2Zorder); + CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nDrawing2Zorder < nPicture1Zorder); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf138773) diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 59798f4f0afc..bc4f11515187 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1803,11 +1803,9 @@ void SwTextBoxNode::AddTextBox(SdrObject* pDrawObject, SwFrameFormat* pNewTextBo } } - auto pSwFlyDraw = dynamic_cast<SwFlyDrawObj*>(pDrawObject); - if (pSwFlyDraw) - { - pSwFlyDraw->SetTextBox(true); - } + SdrObject* const pFlyObject{ pNewTextBox->FindSdrObject() }; + assert(dynamic_cast<SwFlyDrawObj*>(pFlyObject)); + static_cast<SwFlyDrawObj*>(pFlyObject)->SetTextBox(true); m_pTextBoxes.push_back(aElem); } diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index 92f810ef8bb7..7ef59337d4c8 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -98,7 +98,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextBoxLoss) // Make sure that the shape is still a textbox. uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); bool bTextBox = false; xShape->getPropertyValue(u"TextBox"_ustr) >>= bTextBox;
