sw/source/core/crsr/trvltbl.cxx  |    8 +++++++-
 sw/source/core/docnode/ndtbl.cxx |   10 ++++------
 2 files changed, 11 insertions(+), 7 deletions(-)

New commits:
commit ff81c8285103f588bf94ddac533362c8b34e7bd8
Author:     Oliver Specht <[email protected]>
AuthorDate: Thu Jan 9 13:17:15 2025 +0100
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Wed Mar 26 15:24:49 2025 +0100

    tdf#158709 Update cell formula if cells change from value to text
    
    Modification of cells that are part of formulas notify
    also if numeric content is changed to text - even if they have
     multiple paragraphs.
    
    Change-Id: Ifb6a35f4c162388d4fadd73e5207a6d3719a9a04
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180013
    Tested-by: Gabor Kelemen <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <[email protected]>

diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx
index c7390b7de1b8..8ef66d9fae58 100644
--- a/sw/source/core/crsr/trvltbl.cxx
+++ b/sw/source/core/crsr/trvltbl.cxx
@@ -825,8 +825,14 @@ bool SwCursorShell::CheckTableBoxContent( const 
SwPosition* pPos )
     }
 
     // box has more than one paragraph
-    if( pChkBox && pSttNd->GetIndex() + SwNodeOffset(2) != 
pSttNd->EndOfSectionIndex() )
+    if (pChkBox && pSttNd->GetIndex() + SwNodeOffset(2) != 
pSttNd->EndOfSectionIndex())
+    {
+        ClearTableBoxContent();
+        StartAction();
+        GetDoc()->ChkBoxNumFormat( *pChkBox, true );
+        EndAction();
         pChkBox = nullptr;
+    }
 
     // destroy pointer before next action starts
     if( !pPos && !pChkBox )
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index f26438d4ebd8..2c755a4371e9 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4093,7 +4093,7 @@ void SwDoc::ChkBoxNumFormat( SwTableBox& rBox, bool 
bCallUpdate )
     // Optimization: If the Box says it's Text, it remains Text
     const SwTableBoxNumFormat* pNumFormatItem = 
rBox.GetFrameFormat()->GetItemIfSet( RES_BOXATR_FORMAT,
         false );
-    if( pNumFormatItem && 
GetNumberFormatter()->IsTextFormat(pNumFormatItem->GetValue()) )
+    if (pNumFormatItem && 
GetNumberFormatter()->IsTextFormat(pNumFormatItem->GetValue()))
         return ;
 
     std::unique_ptr<SwUndoTableNumFormat> pUndo;
@@ -4202,10 +4202,7 @@ void SwDoc::ChkBoxNumFormat( SwTableBox& rBox, bool 
bCallUpdate )
             bChgd = false;
     }
 
-    if( !bChgd )
-        return;
-
-    if( pUndo )
+    if( bChgd && pUndo )
     {
         pUndo->SetBox( rBox );
         GetIDocumentUndoRedo().AppendUndo(std::move(pUndo));
@@ -4222,7 +4219,8 @@ void SwDoc::ChkBoxNumFormat( SwTableBox& rBox, bool 
bCallUpdate )
         if (AUTOUPD_FIELD_AND_CHARTS == 
GetDocumentSettingManager().getFieldUpdateFlags(true))
             pTableNd->GetTable().UpdateCharts();
     }
-    getIDocumentState().SetModified();
+    if( bChgd )
+        getIDocumentState().SetModified();
 }
 
 void SwDoc::SetTableBoxFormulaAttrs( SwTableBox& rBox, const SfxItemSet& rSet )

Reply via email to