https://bugs.documentfoundation.org/show_bug.cgi?id=160944

--- Comment #13 from Julien Nabet <[email protected]> ---
For avoiding the crash during insertion, from bt I had provided, we may do
this:

diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx
b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 406b114d53cf..606e09f5ffb0 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -1119,7 +1119,17 @@ rtl::Reference<utl::AccessibleRelationSetHelper>
ScChildrenShapes::GetRelationSe
             sal_Int32 nColumn = pData->xRelationCell->Col();
             bool bPositionUnset = nRow == -1 && nColumn == -1;
             if (!bPositionUnset)
-                xAccessible = pSpreadsheet->getAccessibleCellAt(nRow,
nColumn);
+            {
+                try
+                {
+                    xAccessible = pSpreadsheet->getAccessibleCellAt(nRow,
nColumn);
+                }
+                catch (const lang::IndexOutOfBoundsException&)
+                {
+                    // The anchor may temporarily point outside the sheet,
+                    // e.g. when inserting rows at the last sheet row.
+                }
+            }
         }
         AccessibleRelation aRelation;
         aRelation.TargetSet = { xAccessible };

but there's another crash during the export and this patch helps (GPT 5.6 found
this part with some static analysis):
diff --git a/sc/source/filter/xml/xmlexprt.cxx
b/sc/source/filter/xml/xmlexprt.cxx
index 0f207b10a55d..595eef84a431 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -545,7 +545,9 @@ void ScXMLExport::CollectSharedData(SCTAB& nTableCount,
sal_Int32& nShapesCount)
                 continue;

             ScDrawObjData* pAnchor =
ScDrawLayer::GetNonRotatedObjData(pSdrObj);
-            if (pAnchor && pAnchor->maStart.IsValid())
+            if (pDoc && pAnchor
+                && ValidColRow(pAnchor->maStart.Col(), pAnchor->maStart.Row(),
+                               pDoc->MaxCol(), pDoc->MaxRow()))
             {
                 ScMyShape aMyShape;
                 aMyShape.aAddress = pAnchor->maStart;

indeed, IsValid isn't enough since it does:
return (nRow >= 0) && (nCol >= 0) && (nTab >= 0);
(see https://opengrok.libreoffice.org/xref/core/sc/inc/address.hxx#329)
so rather call ValidColRow
(an additional test on pDoc may be useful too).

Now the last part is how to avoid the Zombie-shape.

Regina: what do you think about these 2 changes? Ok for a patch on gerrit?

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to