include/sfx2/lokhelper.hxx      |    2 ++
 sc/source/ui/docshell/docsh.cxx |    1 +
 sc/source/ui/inc/docsh.hxx      |    4 +++-
 sc/source/ui/unoobj/docuno.cxx  |   18 ++++++++++++++++++
 sfx2/source/view/lokhelper.cxx  |   14 ++++++++++++++
 5 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit f06c66035bf83be10753a543078ea08e219ff256
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Mon Sep 5 15:01:34 2022 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Nov 10 11:44:27 2022 +0100

    lok: Notify about last used row and column in Calc
    
    We use HelperNotifyChanges::NotifyIfChangesListeners
    notifier so we know which cell was modified and we
    can correctly target only affected users.
    
    Change-Id: Iaeb68e350e85e4ed1492a7d350a790e68f2d63af
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139473
    Reviewed-by: Dennis Francis <dennis.fran...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index b8d584ac8ecc..341febc7882a 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -115,6 +115,8 @@ public:
     static void notifyDocumentSizeChanged(SfxViewShell const* pThisView, const 
OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true);
     /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same 
document - if @bInvalidateAll - first invalidates all parts
     static void notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, 
bool bInvalidateAll = true);
+    /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same 
document with the same part
+    static void notifyPartSizeChangedAllViews(vcl::ITiledRenderable* pDoc, int 
nPart);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to 
setOptionalFeatures() if needed.
     static void notifyInvalidation(SfxViewShell const* pThisView, 
tools::Rectangle const *);
     /// Notifies all views with the given type and payload.
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index c6574c7d7405..6089544c768c 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -44,6 +44,7 @@
 #include <sfx2/docfile.hxx>
 #include <sfx2/event.hxx>
 #include <sfx2/docfilt.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <svl/documentlockfile.hxx>
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 20f326a9c4f7..0cbc52750dfe 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -24,6 +24,7 @@
 #include <sfx2/sfxmodelfactory.hxx>
 #include <sfx2/viewsh.hxx>
 #include <o3tl/deleter.hxx>
+#include <comphelper/lok.hxx>
 #include <comphelper/servicehelper.hxx>
 
 #include <scdllapi.h>
@@ -475,7 +476,8 @@ namespace HelperNotifyChanges
     inline ScModelObj* getMustPropagateChangesModel(const ScDocShell 
&rDocShell)
     {
         ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel<ScModelObj>(rDocShell.GetModel());
-        if (pModelObj && pModelObj->HasChangesListeners())
+        const bool isLOK = comphelper::LibreOfficeKit::isActive(); // for 
LOK_CALLBACK_DOCUMENT_SIZE_CHANGED
+        if (pModelObj && (pModelObj->HasChangesListeners() || isLOK))
             return pModelObj;
         return nullptr;
     }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 4e102f159d14..deb0f55fddb4 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -3248,6 +3248,24 @@ void ScModelObj::NotifyChanges( const OUString& 
rOperation, const ScRangeList& r
         }
     }
 
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        size_t nRangeCount = rRanges.size();
+        for ( size_t nIndex = 0; nIndex < nRangeCount; ++nIndex )
+        {
+            ScRange const & rRange = rRanges[ nIndex ];
+            ScAddress const & rEnd = rRange.aEnd;
+            const Size aCurrentDataArea = getDataArea(rEnd.Tab());
+
+            SCCOL nLastCol = aCurrentDataArea.Width();
+            SCROW nLastRow = aCurrentDataArea.Height();
+
+            // is equal -> probably we just edited last col/row
+            if (rEnd.Col() >= nLastCol || rEnd.Row() >= nLastRow)
+                SfxLokHelper::notifyPartSizeChangedAllViews(this, rEnd.Tab());
+        }
+    }
+
     // handle sheet events
     //! separate method with ScMarkData? Then change HasChangesListeners back.
     if ( !(rOperation == "cell-change" && pDocShell) )
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 6ddbae1d169b..ba60402c2601 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -593,6 +593,20 @@ void 
SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc
     }
 }
 
+void SfxLokHelper::notifyPartSizeChangedAllViews(vcl::ITiledRenderable* pDoc, 
int nPart)
+{
+    if (DisableCallbacks::disabled())
+        return;
+
+    SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+    while (pViewShell)
+    {
+        if (pViewShell->getPart() == nPart)
+            SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pDoc, 
false);
+        pViewShell = SfxViewShell::GetNext(*pViewShell);
+    }
+}
+
 OString SfxLokHelper::makeVisCursorInvalidation(int nViewId, const OString& 
rRectangle,
     bool bMispelledWord, const OString& rHyperlink)
 {

Reply via email to