sw/source/core/docnode/ndtbl.cxx |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit 6c155583c83eb19c3520084c90df51eca725da00
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Mar 22 14:27:01 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Mar 22 17:48:23 2024 +0100

    tdf#157241 sw: assert when importing ToX in table in rhbz589883-2.docx
    
    ndtbl.cxx:1417: SwNodes::TextToTable(): Assertion `!rNode.IsSectionNode()' 
failed.
    
    (regression from commit 62cb3b8b8d6106c6aeb073b12d84973a107182ef)
    
    Change-Id: Iec12282573cb914d1924f4da4a28e26e01b866df
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165164
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit df6fdb0041f8bfd251a4b03030b8bc47f0614c36)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165173
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index d052ed7eda4b..f3b3a07d63b5 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1413,16 +1413,19 @@ SwTableNode* SwNodes::TextToTable( const 
SwNodes::TableRanges_t & rTableNodes,
     // delete frames of all contained content nodes
     for( nLines = 0; aNodeIndex <= rTableNodes.rbegin()->rbegin()->aEnd; 
++aNodeIndex,++nLines )
     {
-        SwNode& rNode = aNodeIndex.GetNode();
-        assert(!rNode.IsSectionNode()); // not possible in writerfilter import
-        if (rNode.IsTableNode())
+        SwNode* pNode(&aNodeIndex.GetNode());
+        while (pNode->IsSectionNode()) // could be ToX field in table
         {
-            lcl_RemoveBreaksTable(static_cast<SwTableNode&>(rNode),
+            pNode = pNode->GetNodes()[pNode->GetIndex()+1];
+        }
+        if (pNode->IsTableNode())
+        {
+            lcl_RemoveBreaksTable(static_cast<SwTableNode&>(*pNode),
                     (0 == nLines) ? pTableFormat : nullptr);
         }
-        else if (rNode.IsContentNode())
+        else if (pNode->IsContentNode())
         {
-            lcl_RemoveBreaks(static_cast<SwContentNode&>(rNode),
+            lcl_RemoveBreaks(static_cast<SwContentNode&>(*pNode),
                     (0 == nLines) ? pTableFormat : nullptr);
         }
     }

Reply via email to