[Libreoffice-commits] core.git: Branch 'distro/collabora/cd-5.3' - include/sfx2 sc/source sfx2/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu Jan 4 11:42:08 UTC 2018


 include/sfx2/lokhelper.hxx     |    2 ++
 sc/source/ui/inc/inputhdl.hxx  |    1 +
 sc/source/ui/view/tabvwsha.cxx |   18 ++++++++++++++++++
 sfx2/source/view/lokhelper.cxx |   11 +++++++++++
 4 files changed, 32 insertions(+)

New commits:
commit 530f163eee03fffe60f2c2a6413441693f682496
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu Jan 4 00:06:58 2018 -0500

    lok: send modified status when applying cell-formula before saving
    
    Without this, the modified status resulting from applying
    the cell-formula immediately before saving is lost, since
    it is clobbered after the save.
    
    Change-Id: Ie402812d0fc0528020161fffe57e8220c5abfeb5
    Reviewed-on: https://gerrit.libreoffice.org/47368
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index f76977e6b25d..b11d07a108f2 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -42,6 +42,8 @@ public:
     static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell* pOtherView, int nType, const OString& rKey, const OString& rPayload);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
     static void notifyInvalidation(SfxViewShell* pThisView, const OString& rPayload);
+    /// Notifies all views with the given type and payload.
+    static void notifyAllViews(int nType, const OString& rPayload);
     /// A special value to signify 'infinity'.
     /// This value is chosen such that sal_Int32 will not overflow when manipulated.
     static const long MaxTwips = 1e9;
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index 68dc71930cac..4326928e035b 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -224,6 +224,7 @@ public:
 
     bool            TakesReturn() const     { return ( nTipVisible != 0 ); }
 
+    bool            GetModified() const { return bModified; }
     void            SetModified()       { bModified = true; }
 
     bool            GetSelIsRef() const     { return bSelIsRef; }
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index a5672100d1b4..5946a6054b8f 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -56,6 +56,9 @@
 #include "markdata.hxx"
 #include "cellvalue.hxx"
 #include "tokenarray.hxx"
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
+#include <sfx2/lokhelper.hxx>
 
 #include <com/sun/star/table/BorderLineStyle.hpp>
 
@@ -723,7 +726,22 @@ void ScTabViewShell::ExecuteSave( SfxRequest& rReq )
 
     // Finish entering unless 'DontTerminateEdit' is specified, even if a formula is being processed
     if (bCommitChanges)
+    {
+        if (comphelper::LibreOfficeKit::isActive())
+        {
+            // Normally this isn't needed, but in Calc when editing a cell formula
+            // and manually saving (without changing cells or hitting enter), while
+            // InputEnterHandler will mark the doc as modified (when it is), because
+            // we will save the doc immediately afterwards, the modified state event
+            // is clobbered. To avoid that, we notify all views immediately of the
+            // modified state, apply the modification, then save the document.
+            ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+            if (pHdl != nullptr && pHdl->GetModified())
+                SfxLokHelper::notifyAllViews(LOK_CALLBACK_STATE_CHANGED, ".uno:ModifiedStatus=true");
+        }
+
         SC_MOD()->InputEnterHandler();
+    }
 
     if ( GetViewData().GetDocShell()->IsDocShared() )
     {
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index bfcd000eba01..e44ad146bea7 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -142,4 +142,15 @@ void SfxLokHelper::notifyInvalidation(SfxViewShell* pThisView, const OString& rP
     pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, aPayload.getStr());
 }
 
+void SfxLokHelper::notifyAllViews(int nType, const OString& rPayload)
+{
+    const auto payload = rPayload.getStr();
+    SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+    while (pViewShell)
+    {
+        pViewShell->libreOfficeKitViewCallback(nType, payload);
+        pViewShell = SfxViewShell::GetNext(*pViewShell);
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list