[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit include/sfx2 sc/source sfx2/source

Marco Cecchetti marco.cecchetti at collabora.com
Fri Apr 21 13:35:48 UTC 2017


 desktop/source/lib/init.cxx                  |    1 +
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   10 +++++++++-
 include/sfx2/lokhelper.hxx                   |    3 ++-
 sc/source/ui/view/viewfunc.cxx               |   26 ++++++++++++++++++++++++--
 sfx2/source/view/lokhelper.cxx               |   11 +++++++++++
 5 files changed, 47 insertions(+), 4 deletions(-)

New commits:
commit 5751291e8cefea4d07b701c51051fc06ce14486e
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Thu Apr 20 12:48:59 2017 +0200

    LOK - Calc: changed the way header is updated on row/col insert/remove
    
    This patch introduce a new LOK callback for informing the client that
    the row/col header is no more valid and needs to be updated.
    
    Change-Id: I21a3a41d69bd1a3c11c9ffaf1d7d53dbc3b9681d
    Reviewed-on: https://gerrit.libreoffice.org/36733
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5c3bcd0a4526..8e5e89d0dbad 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -756,6 +756,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
         case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
         case LOK_CALLBACK_SET_PART:
         case LOK_CALLBACK_TEXT_VIEW_SELECTION:
+        case LOK_CALLBACK_INVALIDATE_HEADER:
         {
             const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(),
                     [type] (const queue_type::value_type& elem) { return (elem.first == type); });
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 8a59b4cc8ad1..dffc728eb641 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -492,7 +492,15 @@ typedef enum
      * - 'action' can be 'Add', 'Remove' or 'Modify' depending on whether
      *    comment has been added, removed or modified.
      */
-    LOK_CALLBACK_COMMENT = 32
+    LOK_CALLBACK_COMMENT = 32,
+
+    /**
+     * The column/row header is no more valid because of a column/row insertion
+     * or a similar event. Clients must query a new column/row header set.
+     *
+     * The payload says if we are invalidating a row or column header.
+     */
+    LOK_CALLBACK_INVALIDATE_HEADER = 33
 }
 LibreOfficeKitCallbackType;
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 9cc7492f70ae..4dc088d64d59 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -42,7 +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);
-
+    /// Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views.
+    static void notifyAllViewsHeaderInvalidation(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/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 7d4720bbbad7..9c3ff1118dbd 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -78,6 +78,7 @@
 #include "tokenarray.hxx"
 #include <rowheightcontext.hxx>
 #include <docfuncutil.hxx>
+#include <sfx2/lokhelper.hxx>
 
 #include <memory>
 
@@ -1458,17 +1459,26 @@ bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool bRecord, bool bPartOfPaste )
         bool bSuccess = pDocSh->GetDocFunc().InsertCells( aRange, &rMark, eCmd, bRecord, false, bPartOfPaste );
         if (bSuccess)
         {
+            bool bInsertCols = ( eCmd == INS_INSCOLS_BEFORE || eCmd == INS_INSCOLS_AFTER);
+            bool bInsertRows = ( eCmd == INS_INSROWS_BEFORE || eCmd == INS_INSROWS_AFTER );
+
             pDocSh->UpdateOle(&GetViewData());
             CellContentChanged();
             ResetAutoSpell();
 
-            if ( eCmd == INS_INSROWS_BEFORE || eCmd == INS_INSCOLS_BEFORE || eCmd == INS_INSROWS_AFTER || eCmd == INS_INSCOLS_AFTER )
+            if ( bInsertCols || bInsertRows )
             {
-                OUString aOperation = ( eCmd == INS_INSROWS_BEFORE || eCmd == INS_INSROWS_AFTER ) ?
+                OUString aOperation = bInsertRows ?
                     OUString("insert-rows"):
                     OUString("insert-columns");
                 HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, aRange, aOperation);
             }
+
+            if (bInsertCols)
+                SfxLokHelper::notifyAllViewsHeaderInvalidation("column");
+
+            if (bInsertRows)
+                SfxLokHelper::notifyAllViewsHeaderInvalidation("row");
         }
         return bSuccess;
     }
@@ -1535,6 +1545,12 @@ void ScViewFunc::DeleteCells( DelCellCmd eCmd )
         else
             nCurY = aRange.aStart.Row();
         SetCursor( nCurX, nCurY );
+
+        if (eCmd == DEL_DELCOLS)
+            SfxLokHelper::notifyAllViewsHeaderInvalidation("column");
+
+        if (eCmd == DEL_DELROWS)
+            SfxLokHelper::notifyAllViewsHeaderInvalidation("row");
     }
     else
     {
@@ -2128,6 +2144,12 @@ void ScViewFunc::SetWidthOrHeight(
             HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "column-resize");
         }
     }
+
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        OString aPayload = bWidth ? "column" : "row";
+        SfxLokHelper::notifyAllViewsHeaderInvalidation(aPayload);
+    }
 }
 
 //  column width/row height (via marked range)
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 2420b0903578..caa57c62f783 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -154,4 +154,15 @@ void SfxLokHelper::notifyInvalidation(SfxViewShell* pThisView, const OString& rP
     pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, aPayload.getStr());
 }
 
+void SfxLokHelper::notifyAllViewsHeaderInvalidation(const OString& rPayload)
+{
+    SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+    while (pViewShell)
+    {
+        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_HEADER, rPayload.getStr());
+
+        pViewShell = SfxViewShell::GetNext(*pViewShell);
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list