sw/source/core/doc/textboxhelper.cxx | 70 +++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 32 deletions(-)
New commits: commit f08fdf3e81e63469609eaafaf790cb3fea6b27c4 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jul 22 12:27:08 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jul 22 14:22:04 2024 +0200 crashtesting tdf135164-3.docx ./instdir/program/soffice --headless --convert-to odt ~/Downloads/tdf135164-3.docx fails after commit f98f684d22e6323185104ca9c082241c53dfc2b3 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Sat Jul 13 18:50:34 2024 +0200 remove RecalcObjOrdNums in DoTextBoxZOrderCorrection add a check to catch this case and flatten the method to make it more readable Change-Id: I7827807c77f51b28f16b1042b77b8211ab5416ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170839 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 084caf0af2aa..70badac75810 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1513,42 +1513,48 @@ bool SwTextBoxHelper::DoTextBoxZOrderCorrection(SwFrameFormat* pShape, const Sdr pShpObj = pShape->FindRealSdrObject(); - if (pShpObj) + if (!pShpObj) { - auto pTextBox = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT, pObj); - if (!pTextBox) - return false; - SdrObject* pFrmObj = pTextBox->FindRealSdrObject(); - if (!pFrmObj) - { - // During loading there is no ready SdrObj for z-ordering, so create and cache it here - pFrmObj - = SwXTextFrame::GetOrCreateSdrObject(*dynamic_cast<SwFlyFrameFormat*>(pTextBox)); - } - if (pFrmObj) - { - // Get the draw model from the doc - SwDrawModel* pDrawModel - = pShape->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel(); - if (pDrawModel) - { - // Not really sure this will work on all pages, but it seems it will. - // If the shape is behind the frame, is good, but if there are some objects - // between of them that is wrong so put the frame exactly one level higher - // than the shape. - pFrmObj->ensureSortedImmediatelyAfter(*pShpObj); - return true; // Success - } - SAL_WARN("sw.core", "SwTextBoxHelper::DoTextBoxZOrderCorrection(): " - "No Valid Draw model for SdrObject for the shape!"); - } SAL_WARN("sw.core", "SwTextBoxHelper::DoTextBoxZOrderCorrection(): " - "No Valid SdrObject for the frame!"); + "No Valid SdrObject for the shape!"); + return false; } - SAL_WARN("sw.core", "SwTextBoxHelper::DoTextBoxZOrderCorrection(): " - "No Valid SdrObject for the shape!"); - return false; + auto pTextBox = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT, pObj); + if (!pTextBox) + return false; + SdrObject* pFrmObj = pTextBox->FindRealSdrObject(); + if (!pFrmObj) + { + // During loading there is no ready SdrObj for z-ordering, so create and cache it here + pFrmObj = SwXTextFrame::GetOrCreateSdrObject(*dynamic_cast<SwFlyFrameFormat*>(pTextBox)); + } + if (!pFrmObj) + { + SAL_WARN("sw.core", "SwTextBoxHelper::DoTextBoxZOrderCorrection(): " + "No Valid SdrObject for the frame!"); + return false; + } + // Get the draw model from the doc + SwDrawModel* pDrawModel = pShape->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel(); + if (!pDrawModel) + { + SAL_WARN("sw.core", "SwTextBoxHelper::DoTextBoxZOrderCorrection(): " + "No Valid Draw model for SdrObject for the shape!"); + return false; + } + if (!pFrmObj->getParentSdrObjListFromSdrObject()) + { + SAL_WARN("sw.core", "SwTextBoxHelper::DoTextBoxZOrderCorrection(): " + "Frame object is not inserted into any parent"); + return false; + } + // Not really sure this will work on all pages, but it seems it will. + // If the shape is behind the frame, is good, but if there are some objects + // between of them that is wrong so put the frame exactly one level higher + // than the shape. + pFrmObj->ensureSortedImmediatelyAfter(*pShpObj); + return true; // Success } void SwTextBoxHelper::synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat*, SdrObject*),