i18npool/source/characterclassification/cclass_unicode_parser.cxx |   18 ++
 offapi/com/sun/star/i18n/KParseTokens.idl                         |    7 
 sc/source/core/tool/compiler.cxx                                  |    8 -
 sw/qa/extras/uiwriter/uiwriter2.cxx                               |   73 
++++++++++
 sw/source/core/bastyp/calc.cxx                                    |    2 
 sw/source/core/doc/DocumentContentOperationsManager.cxx           |   10 -
 sw/source/core/docnode/node2lay.cxx                               |    7 
 sw/source/core/undo/untblk.cxx                                    |    4 
 sw/source/ui/misc/bookmark.cxx                                    |    2 
 9 files changed, 112 insertions(+), 19 deletions(-)

New commits:
commit b2c1ace2e9721f0752540c8503b897a4792455d8
Author:     Michael Stahl <[email protected]>
AuthorDate: Thu Jan 30 18:36:42 2025 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed Feb 5 11:42:16 2025 +0100

    tdf#158221 sw: fix performance disaster in SwInsertBookmarkDlg
    
    Moving the shell cursor without Start/EndAction results in formatting
    and repainting for every bookmark :(
    
    (regression from commit aa6ec3f79607478213272283b7eb17ec2116173c)
    
    Change-Id: I2eb77a7a6aa48a1f218957245d75399bddb594ff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180965
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit 163ddd7a841fc4ee2b4a79a5ec5e5635bcc0cbc2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180983
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>
    (cherry picked from commit 5e85d816db0e6c4bf31bdfa84faf0507f277e617)

diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx
index 4133b28a8914..b7d2c22c2c96 100644
--- a/sw/source/ui/misc/bookmark.cxx
+++ b/sw/source/ui/misc/bookmark.cxx
@@ -346,6 +346,7 @@ void SwInsertBookmarkDlg::PopulateTable()
     aTableBookmarks.clear();
     m_xBookmarksBox->clear();
 
+    rSh.StartAllAction();
     IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
     for (IDocumentMarkAccess::const_iterator_t ppBookmark = 
pMarkAccess->getBookmarksBegin();
          ppBookmark != pMarkAccess->getBookmarksEnd(); ++ppBookmark)
@@ -356,6 +357,7 @@ void SwInsertBookmarkDlg::PopulateTable()
             aTableBookmarks.emplace_back(*ppBookmark, 
(*ppBookmark)->GetName());
         }
     }
+    rSh.EndAllAction();
     m_nLastBookmarksCount = pMarkAccess->getBookmarksCount();
 }
 
commit 2a13f49297dc927d90afd39c3cfd03ad8e37a21c
Author:     Michael Stahl <[email protected]>
AuthorDate: Thu Jan 30 15:06:34 2025 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed Feb 5 11:25:26 2025 +0100

    (tdf#159377 related) sw: fix undo of table pasted in middle of paragraph
    
    The problem is that the !bCanMoveBack path doesn't work if the insert
    position's content index isn't 0.
    
    (regression from commit fcd4222d36e1864452163e5c94976eea353bbaf0)
    
    Change-Id: I746db2187ab8f2e24eb694dc94d7eea9f50e2d9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180948
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit 3227660e55416254463234f35a43268b9b4c2c9e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180964
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>
    (cherry picked from commit d7a0bc8c8d2d2e4fa4c6e2e29e2de09ea9bb56a6)

diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index c1f2f909f11e..ad1e963b75c2 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -3420,4 +3420,38 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf159377)
     CPPUNIT_ASSERT_EQUAL(SwNodeOffset(28), pDoc->GetNodes().Count());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testPasteTableInMiddleOfParagraph)
+{
+    SwDoc* pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0);
+    pWrtShell->InsertTable(aTableOptions, /*nRows=*/2, /*nCols=*/2);
+    pWrtShell->MoveTable(GotoPrevTable, fnTableStart);
+
+    lcl_dispatchCommand(mxComponent, ".uno:SelectTable", {});
+    lcl_dispatchCommand(mxComponent, ".uno:Copy", {});
+
+    pWrtShell->Undo();
+
+    pWrtShell->Insert("AB");
+
+    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+
+    lcl_dispatchCommand(mxComponent, ".uno:Paste", {});
+
+    pWrtShell->Undo();
+
+    // the problem was that the A was missing
+    CPPUNIT_ASSERT_EQUAL(
+        OUString("AB"),
+        
pWrtShell->GetCursor()->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
+
+    pWrtShell->Redo();
+    pWrtShell->Undo();
+    CPPUNIT_ASSERT_EQUAL(
+        OUString("AB"),
+        
pWrtShell->GetCursor()->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index b0974bc3db3b..db87e6f11df7 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4790,7 +4790,9 @@ bool 
DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
     // Note this doesn't just check IsStartNode() because SwDoc::AppendDoc()
     // intentionally sets it to the body start node, perhaps it should just
     // call SplitNode instead?
-    if (!pStt->nNode.GetNode().IsSectionNode() && 
!pStt->nNode.GetNode().IsTableNode())
+    if ((!pStt->nNode.GetNode().IsSectionNode() && 
!pStt->nNode.GetNode().IsTableNode())
+        || (pCopyPam->GetPoint()->nContent.GetIndex() != 0 // also if node 
will split
+            && pCopyPam->GetPoint()->nContent.GetIndex() != 
pCopyPam->GetPoint()->nNode.GetNode().GetContentNode()->Len()))
     {
         bCanMoveBack = pCopyPam->Move(fnMoveBackward, GoInContent);
     }
@@ -4988,7 +4990,7 @@ bool 
DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
                     aRg.aEnd--;
                 }
             }
-            assert(!bCanMoveBack);
+            assert((nDeleteTextNodes != 0) == bCanMoveBack);
         }
 
         pDestTextNd = aInsPos.GetNode().GetTextNode();
commit 7ba2ed33d03ebf376f57768e435eb57331eba6c2
Author:     Michael Stahl <[email protected]>
AuthorDate: Thu Jan 30 14:47:01 2025 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed Feb 5 11:25:25 2025 +0100

    tdf#159377 sw: fix undo of paste table into footnote
    
    Tables aren't allowed in footnotes, hence pasting a table into a
    footnote will paste only the text nodes in the cells but not the table
    nodes.
    
    This code isn't prepared for this situation, so the adjustment of the
    position doesn't happen.
    
            if (pCopyPam->GetPoint()->GetNode().IsStartNode())
                pCopyPam->GetPoint()->Adjust(SwNodeOffset(-1));
    
    But then the corresponding adjustment in SwUndoInserts::SetInsertRange()
    does happen and the stored start node index is wrong.
    
    It looks like both of these adjustments can simply be removed.
    
    (regression from commit fcd4222d36e1864452163e5c94976eea353bbaf0)
    
    Change-Id: Ib419b29da552cf1df7150178924c45e3743cd7d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180947
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 3bbbe366e455f1b165f2f913fffd27f3a0e03a2d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180958
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>
    (cherry picked from commit 4f8ba5de916e18e7ae8daf67c7f72fa69d394ad0)

diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index f6748fc1200b..c1f2f909f11e 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -3381,4 +3381,43 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf129655)
     assertXPath(pXmlDoc, "//fly/txt[@WritingMode='Vertical']", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf159377)
+{
+    typedef sal_uLong SwNodeOffset;
+    SwDoc* pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0);
+    pWrtShell->InsertTable(aTableOptions, /*nRows=*/2, /*nCols=*/2);
+    pWrtShell->MoveTable(GotoPrevTable, fnTableStart);
+
+    lcl_dispatchCommand(mxComponent, ".uno:SelectTable", {});
+    lcl_dispatchCommand(mxComponent, ".uno:Copy", {});
+
+    pWrtShell->InsertFootnote("");
+    CPPUNIT_ASSERT(pWrtShell->IsCursorInFootnote());
+
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(28), pDoc->GetNodes().Count());
+
+    lcl_dispatchCommand(mxComponent, ".uno:Paste", {});
+
+    // this pasted the 4 text nodes in the table, but no table nodes
+    // as currently tables aren't allowed in footnotes
+
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(32), pDoc->GetNodes().Count());
+
+    pWrtShell->Undo();
+
+    // problem was that this was 29 with an extra text node in the footnote
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(28), pDoc->GetNodes().Count());
+
+    pWrtShell->Redo();
+
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(32), pDoc->GetNodes().Count());
+
+    pWrtShell->Undo();
+
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(28), pDoc->GetNodes().Count());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 8318cc5d5ba8..b0974bc3db3b 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -5175,10 +5175,6 @@ bool 
DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
 
         // Reset the offset to 0 as it was before the insertion
         
pCopyPam->GetPoint()->nContent.Assign(pCopyPam->GetPoint()->nNode.GetNode().GetContentNode(),
 0);
-        // If the next node is a start node, then step back: SetInsertRange()
-        // will add 1 in this case, but that is too much...
-        if (pCopyPam->GetPoint()->nNode.GetNode().IsStartNode())
-            pCopyPam->GetPoint()->nNode--;
     }
     oInsContentIndex.reset();
     pCopyPam->Exchange();
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index 8258498b9181..dfce21d3984b 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -126,10 +126,6 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, 
bool bScanFlys,
         m_nSttContent = pTmpPos->nContent.GetIndex();
 
         m_nDeleteTextNodes = nDeleteTextNodes;
-        if (m_nDeleteTextNodes == 0) // if a table selection is added...
-        {
-            ++m_nSttNode;         // ... then the CopyPam is not fully correct
-        }
     }
 
     // Fill m_FlyUndos with flys anchored to first and last paragraphs
commit 543f0bc322db6fa88c14157fabc3b3698155adc7
Author:     Michael Stahl <[email protected]>
AuthorDate: Wed Jan 29 19:54:14 2025 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Feb 4 19:12:35 2025 +0100

    tdf#158867 offapi,i18npool,starmath: fix "," in Math again
    
    This is essentially the same bug that was fixed in commit
    2caa9d7ddcff3f6e380c306b737e9b5e9cdaf4c2 "Resolves: tdf#127873 accept
    ',' comma group separator in number entities again".
    
    The problem is that sw wants to recognize group separators only if there
    are 3 digits following so it really looks like a number (see bug
    tdf#42518), but starmath really wants to recognize either comma or dot
    as a decimal separator and uses the GROUP_SEPARATOR_IN_NUMBER as a hack
    to get this behaviour, so the same parser can work in any locale.
    
    Introduce new constant GROUP_SEPARATOR_IN_NUMBER_3 so that sw and
    starmath can request different parsing.
    
    sc/source/core/tool/compiler.cxx also uses GROUP_SEPARATOR_IN_NUMBER and
    it's unclear to me what is desired there, but there are no known
    regression reports so leave the behaviour there unchanged.
    
    (regression from commit 1bd9a51b826015746069fcc0d02a30a2ddc7e7f5)
    
    Change-Id: Icb7662f26d89677cf84ccad07a2ea4c380587ab4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180920
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit ff16c4e3f27efc0fc9ed734b19ae778482566cdb)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180956
    Reviewed-by: Eike Rathke <[email protected]>
    (cherry picked from commit 055b637ed9bdd02cd857664813a66afde51dfd0a)

diff --git a/i18npool/source/characterclassification/cclass_unicode_parser.cxx 
b/i18npool/source/characterclassification/cclass_unicode_parser.cxx
index 4287cd2e57fc..475269819116 100644
--- a/i18npool/source/characterclassification/cclass_unicode_parser.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode_parser.cxx
@@ -23,6 +23,7 @@
 #include <rtl/character.hxx>
 #include <rtl/math.hxx>
 #include <rtl/ustring.hxx>
+#include <sal/log.hxx>
 #include <com/sun/star/i18n/KParseTokens.hpp>
 #include <com/sun/star/i18n/KParseType.hpp>
 #include <com/sun/star/i18n/LocaleData2.hpp>
@@ -441,7 +442,11 @@ void cclass_Unicode::initParserTable( const Locale& 
rLocale, sal_Int32 startChar
         cDecimalSepAlt = aItem.decimalSeparatorAlternative.toChar();
     }
 
-    if (nContTypes & KParseTokens::GROUP_SEPARATOR_IN_NUMBER)
+    SAL_WARN_IF((nContTypes & KParseTokens::GROUP_SEPARATOR_IN_NUMBER)
+             && (nContTypes & KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3),
+        "i18npool", "only one GROUP_SEPARATOR_IN_NUMBER* should be used");
+    if (nContTypes & KParseTokens::GROUP_SEPARATOR_IN_NUMBER
+        || nContTypes & KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3)
     {
         if ( cGroupSep < nDefCnt )
             pTable[cGroupSep] |= ParserFlags::VALUE;
@@ -827,13 +832,20 @@ void cclass_Unicode::parseText( ParseResult& r, const 
OUString& rText, sal_Int32
                 {
                     if (current == cGroupSep)
                     {
-                        // accept only if it is followed by 3 digits
+                        // depending or requested nContTypes, accept only if
+                        // it is followed by 3 digits
                         sal_Int32 tempIndex(index);
                         sal_uInt32 const nextChar2((tempIndex < 
rText.getLength()) ? rText.iterateCodePoints(&tempIndex) : 0);
                         sal_uInt32 const nextChar3((tempIndex < 
rText.getLength()) ? rText.iterateCodePoints(&tempIndex) : 0);
-                        if (getFlags(nextChar) & ParserFlags::VALUE_DIGIT
+                        if ((nContTypes & 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3)
+                            && getFlags(nextChar) & ParserFlags::VALUE_DIGIT
                             && getFlags(nextChar2) & ParserFlags::VALUE_DIGIT
                             && getFlags(nextChar3) & ParserFlags::VALUE_DIGIT)
+                        {
+                            nParseTokensType |= 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3;
+                        }
+                        else if ((nContTypes & 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3) == 0
+                            && getFlags(nextChar) & ParserFlags::VALUE_DIGIT)
                         {
                             nParseTokensType |= 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER;
                         }
diff --git a/offapi/com/sun/star/i18n/KParseTokens.idl 
b/offapi/com/sun/star/i18n/KParseTokens.idl
index bc0f92c42c83..fffb476a8b8b 100644
--- a/offapi/com/sun/star/i18n/KParseTokens.idl
+++ b/offapi/com/sun/star/i18n/KParseTokens.idl
@@ -95,6 +95,13 @@ published constants KParseTokens
     /// Unicode (above 127) other number
     const long UNI_OTHER_NUMBER     = 0x00080000;
 
+    /** The same as GROUP_SEPARATOR_IN_NUMBER, but require <em>3</em>
+        digits following the group separator.
+
+        @since LibreOffice 25.2
+     */
+    const long GROUP_SEPARATOR_IN_NUMBER_3 = 0x04000000;
+
     /** If this bit is set in <em>nContCharFlags</em> parameters, the
         locale's group separator characters in numbers are accepted and
         ignored/skipped. Else a group separator in a number ends the
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 9fa5773d8346..0f7db65dc8b4 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -723,7 +723,7 @@ struct Convention_A1 : public ScCompiler::Convention
         static const OUString aAddAllowed("?#");
         return pCharClass->parseAnyToken( rFormula,
                 nSrcPos, nStartFlags, aAddAllowed,
-                (bGroupSeparator ? nContFlags | 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER : nContFlags),
+                (bGroupSeparator ? nContFlags | 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3 : nContFlags),
                 aAddAllowed );
     }
 
@@ -1344,7 +1344,7 @@ struct ConventionXL_A1 : public Convention_A1, public 
ConventionXL
         static const OUString aAddAllowed("?!");
         return pCharClass->parseAnyToken( rFormula,
                 nSrcPos, nStartFlags, aAddAllowed,
-                (bGroupSeparator ? nContFlags | 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER : nContFlags),
+                (bGroupSeparator ? nContFlags | 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3 : nContFlags),
                 aAddAllowed );
     }
 
@@ -1681,7 +1681,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, 
public ConventionXL
 
         return pCharClass->parseAnyToken( rFormula,
                 nSrcPos, nStartFlags, aAddAllowed,
-                (bGroupSeparator ? nContFlags | 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER : nContFlags),
+                (bGroupSeparator ? nContFlags | 
KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3 : nContFlags),
                 aAddAllowed );
     }
 
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index dc9fb62973f7..0328f3c18288 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -140,7 +140,7 @@ const sal_Int32 coStartFlags =
 
 // Continuing characters may be any alphanumeric, underscore, or dot.
 const sal_Int32 coContFlags =
-    (coStartFlags | i18n::KParseTokens::ASC_DOT | 
i18n::KParseTokens::GROUP_SEPARATOR_IN_NUMBER)
+    (coStartFlags | i18n::KParseTokens::ASC_DOT | 
i18n::KParseTokens::GROUP_SEPARATOR_IN_NUMBER_3)
         & ~i18n::KParseTokens::IGNORE_LEADING_WS;
 
 extern "C" {
commit a9f97dbf4c32e00ce6ae2f1e5c9a1fc12482e56c
Author:     Michael Stahl <[email protected]>
AuthorDate: Wed Jan 29 17:36:41 2025 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Feb 4 19:12:35 2025 +0100

    tdf#156348 sw: fix crash on converting text to table with SwSetExpField
    
    The problem is that the table node only gets a SwFrameFormat assigned at
    the end of the operation after all the nodes have been split etc., and
    moving a field into a newly split node calls
    sw::FindNeighbourFrameForNode() which needs to handle table node without
    SwFrameFormat now when going backwards (not when going forwards because
    the table node is always before the nodes in the table).
    
    (regression from commit 9dc6e2c9062725ef1f9d7e321cae5f4dbe8ca749)
    
    Change-Id: Ia0c1f7d7b14f525aa8de4a2b6492c39b59f31052
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180914
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit b5967157b37904219865fd847b20938b3ccfbd72)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180919
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>
    (cherry picked from commit 23d225dac8f717bea8e960e4c2130963db7f3920)

diff --git a/sw/source/core/docnode/node2lay.cxx 
b/sw/source/core/docnode/node2lay.cxx
index d9ec3aa1727f..9bbc8100f527 100644
--- a/sw/source/core/docnode/node2lay.cxx
+++ b/sw/source/core/docnode/node2lay.cxx
@@ -106,7 +106,12 @@ static SwNode* GoPreviousWithFrame(SwNodeIndex *pIdx)
             // frame as the caller's one
             bFound = SwIterator<SwFrame, SwContentNode, 
sw::IteratorMode::UnwrapMulti>(*static_cast<SwContentNode*>(pNd)).First();
         else if ( pNd->IsTableNode() )
-            bFound = 
SwIterator<SwFrame,SwFormat>(*static_cast<SwTableNode*>(pNd)->GetTable().GetFrameFormat()).First();
+        {
+            if (SwFrameFormat *const 
pFormat{static_cast<SwTableNode*>(pNd)->GetTable().GetFrameFormat()})
+            {
+                bFound = SwIterator<SwFrame,SwFormat>(*pFormat).First();
+            }
+        }
         else if( pNd->IsStartNode() && !pNd->IsSectionNode() )
         {
             pNd = nullptr;
commit 10c64af4118750ac3ce1ecb118b2c2ad6f6fd444
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Tue Oct 12 19:54:22 2021 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Feb 4 19:12:35 2025 +0100

    Remove useless check
    
    ...that was introduced with b14107dd0eaf9bfc276544e1900873d36075425e 
"tdf#133858
    reduce the double-ref range to data content", but which can only ever be 
either
    true or invoke undefined behavior (as gets reported as
    
    > sc/source/core/tool/compiler.cxx:6412:27: error: comparing the result of 
pointer addition 
‘(((ScCompiler*)this)->ScCompiler::<anonymous>.formula::FormulaCompiler::pCode 
+ -8)’ and NULL [-Werror=address]
    >  6412 |     if (!pCode || !(pCode -1) || !(*(pCode - 1)))
    >       |                    ~~~~~~~^~~
    
    with recent GCC 12 trunk)
    
    Change-Id: I72395f1874343a047afceaa5e342e9e67a51c44f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123531
    Reviewed-by: Dennis Francis <[email protected]>
    Reviewed-by: Stephan Bergmann <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit a60296694b3af2c18e7aa81eba8782e0ad03f7b8)

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index a994f5cf1ebf..9fa5773d8346 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -6261,7 +6261,7 @@ void ScCompiler::CorrectSumRange(const ScComplexRefData& 
rBaseRange,
 
 void ScCompiler::AnnotateTrimOnDoubleRefs()
 {
-    if (!pCode || !(pCode -1) || !(*(pCode - 1)))
+    if (!pCode || !(*(pCode - 1)))
         return;
 
     // OpCode of the "root" operator (which is already in RPN array).

Reply via email to