sc/source/ui/undo/undotab.cxx  |   51 ++++++++++++++++++++++++++++++++++++++++-
 sc/source/ui/view/viewfun2.cxx |    7 +++++
 2 files changed, 57 insertions(+), 1 deletion(-)

New commits:
commit 86e6d67220d6d3d93c5decf04195b7f5025984ae
Author:     Marco Cecchetti <[email protected]>
AuthorDate: Tue Feb 27 17:56:26 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Feb 29 21:18:37 2024 +0100

    lok: calc: sheet geometry not updated on undo a tab insert/delete/move
    
    Change-Id: I1e12ca71771e746155afe48215ba2df4b35634d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164165
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index dd00f1fa33c0..a33be3301231 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -61,6 +61,24 @@ using namespace com::sun::star;
 using ::std::unique_ptr;
 using ::std::vector;
 
+namespace
+{
+void lcl_OnTabsChanged(const ScTabViewShell* pViewShell, const ScDocument& 
rDoc, SCTAB nTab, bool bInvalidateTiles = false)
+{
+    for (SCTAB nTabIndex = nTab; nTabIndex < rDoc.GetTableCount(); ++nTabIndex)
+    {
+        if (!rDoc.IsVisible(nTabIndex))
+            continue;
+        if (bInvalidateTiles)
+            pViewShell->libreOfficeKitViewInvalidateTilesCallback(nullptr, 
nTabIndex, 0);
+        ScTabViewShell::notifyAllViewsSheetGeomInvalidation(
+            pViewShell,
+            true /* bColsAffected */, true /* bRowsAffected */,
+            true /* bSizes*/, true /* bHidden */, true /* bFiltered */,
+            true /* bGroups */, nTabIndex);
+    }
+}
+}
 
 ScUndoInsertTab::ScUndoInsertTab( ScDocShell* pNewDocShell,
                                   SCTAB nTabNum,
@@ -119,6 +137,12 @@ void ScUndoInsertTab::Undo()
     if ( pChangeTrack )
         pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
 
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        ScDocument& rDoc = pDocShell->GetDocument();
+        lcl_OnTabsChanged(pViewShell, rDoc, nTab);
+    }
+
     //  SetTabNo(...,sal_True) for all views to sync with drawing layer pages
     pDocShell->Broadcast( SfxHint( SfxHintId::ScForceSetTab ) );
 }
@@ -142,6 +166,12 @@ void ScUndoInsertTab::Redo()
     pDocShell->SetInUndo( false );              //! EndRedo
 
     SetChangeTrack();
+
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        ScDocument& rDoc = pDocShell->GetDocument();
+        lcl_OnTabsChanged(pViewShell, rDoc, nTab);
+    }
 }
 
 void ScUndoInsertTab::Repeat(SfxRepeatTarget& rTarget)
@@ -360,6 +390,12 @@ void ScUndoDeleteTab::Undo()
     if ( pChangeTrack )
         pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
 
+    ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+    if (comphelper::LibreOfficeKit::isActive() && !theTabs.empty())
+    {
+        lcl_OnTabsChanged(pViewShell, rDoc, theTabs[0]);
+    }
+
     for(SCTAB nTab: theTabs)
     {
         pDocShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab) );
@@ -373,7 +409,6 @@ void ScUndoDeleteTab::Undo()
     pDocShell->PostPaint(0,0,0, rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, 
PaintPartFlags::All );  // incl. extras
 
     // not ShowTable due to SetTabNo(..., sal_True):
-    ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     if (pViewShell)
         pViewShell->SetTabNo( lcl_GetVisibleTabBefore( rDoc, theTabs[0] ), 
true );
 }
@@ -393,6 +428,12 @@ void ScUndoDeleteTab::Redo()
 
     SetChangeTrack();
 
+    if (comphelper::LibreOfficeKit::isActive() && !theTabs.empty())
+    {
+        ScDocument& rDoc = pDocShell->GetDocument();
+        lcl_OnTabsChanged(pViewShell, rDoc, theTabs[0]);
+    }
+
     //  SetTabNo(...,sal_True) for all views to sync with drawing layer pages
     pDocShell->Broadcast( SfxHint( SfxHintId::ScForceSetTab ) );
 }
@@ -544,16 +585,10 @@ void ScUndoMoveTab::DoChange( bool bUndo ) const
 
     if (comphelper::LibreOfficeKit::isActive() && !mpNewTabs->empty())
     {
-        tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
         const auto newTabsMinIt = std::min_element(mpNewTabs->begin(), 
mpNewTabs->end());
         const auto oldTabsMinIt = std::min_element(mpOldTabs->begin(), 
mpOldTabs->end());
         SCTAB nTab = std::min(*newTabsMinIt, *oldTabsMinIt);
-        for (SCTAB nTabIndex = nTab; nTabIndex < rDoc.GetTableCount(); 
++nTabIndex)
-        {
-            if (!rDoc.IsVisible(nTabIndex))
-                continue;
-            pViewShell->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, 
nTabIndex, 0);
-        }
+        lcl_OnTabsChanged(pViewShell, rDoc, nTab, true /* bInvalidateTiles */);
     }
 
     SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );    // 
Navigator
commit cf4630887adcf3e9d8b7a2452f097bb2f564fc5c
Author:     Marco Cecchetti <[email protected]>
AuthorDate: Mon Feb 26 14:36:12 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Feb 29 21:18:29 2024 +0100

    lok: calc: tiles not invalidated on tab move
    
    This patch fixes a regression started from
    9f3ee2b2 "don't invalidate when switching tabs"
    
    Change-Id: Icd560c73cff836b026b1ba69432bb712e36c035a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164164
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 12d813c7da6c..dd00f1fa33c0 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -542,6 +542,20 @@ void ScUndoMoveTab::DoChange( bool bUndo ) const
         }
     }
 
+    if (comphelper::LibreOfficeKit::isActive() && !mpNewTabs->empty())
+    {
+        tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
+        const auto newTabsMinIt = std::min_element(mpNewTabs->begin(), 
mpNewTabs->end());
+        const auto oldTabsMinIt = std::min_element(mpOldTabs->begin(), 
mpOldTabs->end());
+        SCTAB nTab = std::min(*newTabsMinIt, *oldTabsMinIt);
+        for (SCTAB nTabIndex = nTab; nTabIndex < rDoc.GetTableCount(); 
++nTabIndex)
+        {
+            if (!rDoc.IsVisible(nTabIndex))
+                continue;
+            pViewShell->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, 
nTabIndex, 0);
+        }
+    }
+
     SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );    // 
Navigator
 
     pDocShell->PostPaintGridAll();
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 2f09d3b23fdc..b390364418c1 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -91,6 +91,7 @@
 #include <tools/json_writer.hxx>
 
 #include <officecfg/Office/Calc.hxx>
+#include <sfx2/lokhelper.hxx>
 
 using namespace com::sun::star;
 using ::editeng::SvxBorderLine;
@@ -3201,6 +3202,12 @@ void ScViewFunc::MoveTable(sal_uInt16 nDestDocNo, SCTAB 
nDestTab, bool bCopy,
 
         SCTAB nTab = GetViewData().GetTabNo();
 
+        if (comphelper::LibreOfficeKit::isActive() && !pSrcTabs->empty())
+        {
+            ScModelObj* pModel = 
comphelper::getFromUnoTunnel<ScModelObj>(pDocShell->GetModel());
+            SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel);
+        }
+
         if (bUndo)
         {
             if (bCopy)

Reply via email to