[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - 2 commits - desktop/source include/LibreOfficeKit include/sfx2 libreofficekit/qa libreofficekit/source sc/source sfx2/source

Marco Cecchetti marco.cecchetti at collabora.com
Tue May 16 09:27:05 UTC 2017


 desktop/source/lib/init.cxx                         |    3 +
 include/LibreOfficeKit/LibreOfficeKitEnums.h        |    7 ++
 include/sfx2/viewsh.hxx                             |    2 
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   52 ++++++++++++++++++++
 libreofficekit/source/gtk/lokdocview.cxx            |   28 ++++++++++
 sc/source/ui/app/inputhdl.cxx                       |   21 +++++---
 sc/source/ui/inc/tabvwsh.hxx                        |    2 
 sc/source/ui/view/tabvwshc.cxx                      |    5 +
 sfx2/source/view/viewsh.cxx                         |    6 ++
 9 files changed, 118 insertions(+), 8 deletions(-)

New commits:
commit 708600e84cb3b20cbbc1f6eea5f7f039cba034a1
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon May 8 00:28:37 2017 +0200

    lok: sc: address and formula text field empty on creating a new view
    
    When the client starts the address and formula text field were empty
    because the updating callbacks occurred before the view callback
    handler had been registered.
    So a new method `afterCallbackRegistered` has been added in order to
    perform any needed updating/initialization soon after the view
    callback handler has been registered.
    
    Change-Id: Ia47234e32796f7e4bc1a8408736102054b4666e2

diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 14466922f461..2c93dd17bcd1 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -339,6 +339,8 @@ public:
     void NotifyOtherView(OutlinerViewShell* pOtherShell, int nType, const OString& rKey, const OString& rPayload) override;
     /// Ask this view to send its cursor position to pViewShell.
     virtual void NotifyCursor(SfxViewShell* /*pViewShell*/) const;
+    /// Where a new view can perform some update/initialization soon after the callback has been registered.
+    virtual void afterCallbackRegistered();
 };
 
 
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 0722b4980af7..eb759055817d 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -392,6 +392,8 @@ public:
     void SetForceFocusOnCurCell(bool bFlag) { bForceFocusOnCurCell=bFlag; }
     /// See SfxViewShell::getPart().
     int getPart() const override;
+    /// See SfxViewShell::afterCallbackRegistered().
+    void afterCallbackRegistered() override;
     /// See SfxViewShell::NotifyCursor().
     void NotifyCursor(SfxViewShell* pViewShell) const override;
 };
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index cdc2ee864676..a9e35896ca6e 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -516,6 +516,11 @@ int ScTabViewShell::getPart() const
     return GetViewData().GetTabNo();
 }
 
+void ScTabViewShell::afterCallbackRegistered()
+{
+    UpdateInputHandler(true, false);
+}
+
 void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const
 {
     ScDrawView* pDrView = const_cast<ScTabViewShell*>(this)->GetScDrawView();
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 4d55babc23ee..dbc6bc3a8c4c 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1460,6 +1460,8 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa
     pImpl->m_pLibreOfficeKitViewCallback = pCallback;
     pImpl->m_pLibreOfficeKitViewData = pData;
 
+    afterCallbackRegistered();
+
     // Ask other views to tell us about their cursors.
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     while (pViewShell)
@@ -1492,6 +1494,10 @@ void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) c
         pImpl->m_pLibreOfficeKitViewCallback(nType, pPayload, pImpl->m_pLibreOfficeKitViewData);
 }
 
+void SfxViewShell::afterCallbackRegistered()
+{
+}
+
 void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const
 {
 }
commit 838725b62320c6f9aebdeb45558620952abb5bec
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon May 8 00:26:08 2017 +0200

    lok: sc: notify cell cursor position to address control in client
    
    A new callback has been introduced for notifying the client:
    LOK_CALLBACK_CELL_ADDRESS
    
    Change-Id: I40b38a3cb8fb658c3f00332d56cfcbaf98e13771
    Reviewed-on: https://gerrit.libreoffice.org/37357
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 9cc9300bc20e9367728aa4b7ec3a789fdd274aff)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 971d43548611..58d47e5c590e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -681,6 +681,7 @@ CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, Li
     m_states.emplace(LOK_CALLBACK_MOUSE_POINTER, "NIL");
     m_states.emplace(LOK_CALLBACK_CELL_CURSOR, "NIL");
     m_states.emplace(LOK_CALLBACK_CELL_FORMULA, "NIL");
+    m_states.emplace(LOK_CALLBACK_CELL_ADDRESS, "NIL");
     m_states.emplace(LOK_CALLBACK_CURSOR_VISIBLE, "NIL");
     m_states.emplace(LOK_CALLBACK_SET_PART, "NIL");
 
@@ -760,6 +761,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
         case LOK_CALLBACK_CELL_CURSOR:
         case LOK_CALLBACK_CELL_VIEW_CURSOR:
         case LOK_CALLBACK_CELL_FORMULA:
+        case LOK_CALLBACK_CELL_ADDRESS:
         case LOK_CALLBACK_CURSOR_VISIBLE:
         case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
         case LOK_CALLBACK_SET_PART:
@@ -820,6 +822,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
             case LOK_CALLBACK_MOUSE_POINTER:
             case LOK_CALLBACK_CELL_CURSOR:
             case LOK_CALLBACK_CELL_FORMULA:
+            case LOK_CALLBACK_CELL_ADDRESS:
             case LOK_CALLBACK_CURSOR_VISIBLE:
             case LOK_CALLBACK_SET_PART:
             case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index dffc728eb641..300b71bb01ff 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -500,7 +500,12 @@ typedef enum
      *
      * The payload says if we are invalidating a row or column header.
      */
-    LOK_CALLBACK_INVALIDATE_HEADER = 33
+    LOK_CALLBACK_INVALIDATE_HEADER = 33,
+    /**
+     * The text content of the address field in Calc.
+     */
+    LOK_CALLBACK_CELL_ADDRESS = 34
+
 }
 LibreOfficeKitCallbackType;
 
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index b6c93528dc2b..1881edf7d98a 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -138,6 +138,7 @@ public:
     GtkToolItem* m_pInsertAnnotation;
     GtkToolItem* m_pDeleteComment;
     GtkToolItem* m_pTrackChanges;
+    GtkWidget* m_pAddressbarEntry;
     GtkWidget* m_pFormulabarEntry;
     GtkWidget* m_pScrolledWindow;
     std::map<GtkToolItem*, std::string> m_aToolItemCommandNames;
@@ -589,6 +590,7 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
         }
         gtk_widget_show(rWindow.m_pColumnBar->m_pDrawingArea);
         gtk_widget_queue_draw(rWindow.m_pColumnBar->m_pDrawingArea);
+        gtk_widget_show(rWindow.m_pAddressbarEntry);
         gtk_widget_show(rWindow.m_pFormulabarEntry);
 
     }
@@ -1399,6 +1401,39 @@ static gboolean signalFindbar(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer
     return FALSE;
 }
 
+/// Handles the key-press-event of the address entry widget.
+static gboolean signalAddressbar(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer /*pData*/)
+{
+    TiledWindow& rWindow = lcl_getTiledWindow(pWidget);
+    switch(pEvent->keyval)
+    {
+        case GDK_KEY_Return:
+        {
+            GtkEntry* pEntry = GTK_ENTRY(rWindow.m_pAddressbarEntry);
+            const char* pText = gtk_entry_get_text(pEntry);
+
+            boost::property_tree::ptree aTree;
+            aTree.put(boost::property_tree::ptree::path_type("ToPoint/type", '/'), "string");
+            aTree.put(boost::property_tree::ptree::path_type("ToPoint/value", '/'), pText);
+            std::stringstream aStream;
+            boost::property_tree::write_json(aStream, aTree);
+            std::string aArguments = aStream.str();
+
+            lok_doc_view_post_command(LOK_DOC_VIEW(rWindow.m_pDocView), ".uno:GoToCell", aArguments.c_str(), false);
+            gtk_widget_grab_focus(rWindow.m_pDocView);
+            return TRUE;
+        }
+        case GDK_KEY_Escape:
+        {
+            std::string aArguments;
+            lok_doc_view_post_command(LOK_DOC_VIEW(rWindow.m_pDocView), ".uno:Cancel", aArguments.c_str(), false);
+            gtk_widget_grab_focus(rWindow.m_pDocView);
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
 /// Handles the key-press-event of the formula entry widget.
 static gboolean signalFormulabar(GtkWidget* /*pWidget*/, GdkEventKey* /*pEvent*/, gpointer /*pData*/)
 {
@@ -1583,6 +1618,13 @@ static void cursorChanged(LOKDocView* pDocView, gint nX, gint nY,
         gtk_adjustment_set_value(hadj, lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), x));
 }
 
+/// LOKDocView the address has changed
+static void addressChanged(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pData*/)
+{
+    TiledWindow& rWindow = lcl_getTiledWindow(GTK_WIDGET(pLOKDocView));
+    gtk_entry_set_text(GTK_ENTRY(rWindow.m_pAddressbarEntry), pPayload);
+}
+
 /// LOKDocView the formula has changed
 static void formulaChanged(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pData*/)
 {
@@ -2078,6 +2120,14 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
     lcl_registerToolItem(rWindow, rWindow.m_pTrackChanges, ".uno:TrackChanges");
     gtk_widget_set_sensitive(GTK_WIDGET(rWindow.m_pTrackChanges), false);
 
+    // Address bar
+    GtkToolItem* pAddressEntryContainer = gtk_tool_item_new();
+    rWindow.m_pAddressbarEntry = gtk_entry_new();
+    gtk_container_add(GTK_CONTAINER(pAddressEntryContainer), rWindow.m_pAddressbarEntry);
+    g_signal_connect(rWindow.m_pAddressbarEntry, "key-press-event", G_CALLBACK(signalAddressbar), 0);
+    gtk_toolbar_insert(GTK_TOOLBAR(pLowerToolbar), pAddressEntryContainer, -1);
+    gtk_box_pack_start(GTK_BOX(rWindow.m_pVBox), pLowerToolbar, FALSE, FALSE, 0 ); // Adds to top.
+
     // Formula bar
     GtkToolItem* pFormulaEntryContainer = gtk_tool_item_new();
     rWindow.m_pFormulabarEntry = gtk_entry_new();
@@ -2178,6 +2228,7 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
     gtk_widget_hide(rWindow.m_pCornerButton->m_pDrawingArea);
     gtk_widget_hide(rWindow.m_pRowBar->m_pDrawingArea);
     gtk_widget_hide(rWindow.m_pColumnBar->m_pDrawingArea);
+    gtk_widget_hide(rWindow.m_pAddressbarEntry);
     gtk_widget_hide(rWindow.m_pFormulabarEntry);
     // Hide the non-progressbar children of the status bar by default.
     gtk_widget_hide(rWindow.m_pStatusbarLabel);
@@ -2204,6 +2255,7 @@ static void setupDocView(GtkWidget* pDocView)
     g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), nullptr);
     g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), nullptr);
     g_signal_connect(pDocView, "cursor-changed", G_CALLBACK(cursorChanged), nullptr);
+    g_signal_connect(pDocView, "address-changed", G_CALLBACK(addressChanged), nullptr);
     g_signal_connect(pDocView, "formula-changed", G_CALLBACK(formulaChanged), nullptr);
     g_signal_connect(pDocView, "password-required", G_CALLBACK(passwordRequired), nullptr);
     g_signal_connect(pDocView, "comment", G_CALLBACK(commentCallback), nullptr);
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 17ce275a1247..1d87f5bd17b0 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -273,6 +273,7 @@ enum
     CURSOR_CHANGED,
     SEARCH_RESULT_COUNT,
     COMMAND_RESULT,
+    ADDRESS_CHANGED,
     FORMULA_CHANGED,
     TEXT_SELECTION,
     PASSWORD_REQUIRED,
@@ -416,6 +417,8 @@ callbackTypeToString (int nType)
         return "LOK_CALLBACK_TEXT_VIEW_SELECTION";
     case LOK_CALLBACK_CELL_VIEW_CURSOR:
         return "LOK_CALLBACK_CELL_VIEW_CURSOR";
+    case LOK_CALLBACK_CELL_ADDRESS:
+        return "LOK_CALLBACK_CELL_ADDRESS";
     case LOK_CALLBACK_CELL_FORMULA:
         return "LOK_CALLBACK_CELL_FORMULA";
     case LOK_CALLBACK_UNO_COMMAND_RESULT:
@@ -882,6 +885,11 @@ static void commandResult(LOKDocView* pDocView, const std::string& rString)
     g_signal_emit(pDocView, doc_view_signals[COMMAND_RESULT], 0, rString.c_str());
 }
 
+static void addressChanged(LOKDocView* pDocView, const std::string& rString)
+{
+    g_signal_emit(pDocView, doc_view_signals[ADDRESS_CHANGED], 0, rString.c_str());
+}
+
 static void formulaChanged(LOKDocView* pDocView, const std::string& rString)
 {
     g_signal_emit(pDocView, doc_view_signals[FORMULA_CHANGED], 0, rString.c_str());
@@ -1302,6 +1310,11 @@ callback (gpointer pData)
         commandResult(pDocView, pCallback->m_aPayload);
     }
     break;
+    case LOK_CALLBACK_CELL_ADDRESS:
+    {
+        addressChanged(pDocView, pCallback->m_aPayload);
+    }
+    break;
     case LOK_CALLBACK_CELL_FORMULA:
     {
         formulaChanged(pDocView, pCallback->m_aPayload);
@@ -3048,6 +3061,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                      G_TYPE_STRING);
 
     /**
+     * LOKDocView::address-changed:
+     * @pDocView: the #LOKDocView on which the signal is emitted
+     * @aCommand: formula text content
+     */
+    doc_view_signals[ADDRESS_CHANGED] =
+        g_signal_new("address-changed",
+                     G_TYPE_FROM_CLASS(pGObjectClass),
+                     G_SIGNAL_RUN_FIRST,
+                     0,
+                     nullptr, nullptr,
+                     g_cclosure_marshal_VOID__STRING,
+                     G_TYPE_NONE, 1,
+                     G_TYPE_STRING);
+
+    /**
      * LOKDocView::formula-changed:
      * @pDocView: the #LOKDocView on which the signal is emitted
      * @aCommand: formula text content
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 241d866c365c..5006d3787f7d 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3660,7 +3660,7 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
                         }
                     }
 
-                    if ( pInputWin )                        // Named range input
+                    if ( pInputWin || comphelper::LibreOfficeKit::isActive())                        // Named range input
                     {
                         OUString aPosStr;
                         const ScAddress::Details aAddrDetails( &rDoc, aCursorPos );
@@ -3686,12 +3686,19 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
                                 aPosStr = aCursorPos.Format(ScRefFlags::VALID | nFlags, &rDoc, aAddrDetails);
                         }
 
-                        // Disable the accessible VALUE_CHANGE event
-                        bool bIsSuppressed = pInputWin->IsAccessibilityEventsSuppressed(false);
-                        pInputWin->SetAccessibilityEventsSuppressed(true);
-                        pInputWin->SetPosString(aPosStr);
-                        pInputWin->SetAccessibilityEventsSuppressed(bIsSuppressed);
-                        pInputWin->SetSumAssignMode();
+                        if (pInputWin)
+                        {
+                            // Disable the accessible VALUE_CHANGE event
+                            bool bIsSuppressed = pInputWin->IsAccessibilityEventsSuppressed(false);
+                            pInputWin->SetAccessibilityEventsSuppressed(true);
+                            pInputWin->SetPosString(aPosStr);
+                            pInputWin->SetAccessibilityEventsSuppressed(bIsSuppressed);
+                            pInputWin->SetSumAssignMode();
+                        }
+                        else if (pActiveViewSh)
+                        {
+                            pActiveViewSh->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_ADDRESS, aPosStr.toUtf8().getStr());
+                        }
                     }
 
                     if (bStopEditing)


More information about the Libreoffice-commits mailing list