[Libreoffice-commits] core.git: 4 commits - desktop/source include/LibreOfficeKit libreofficekit/qa libreofficekit/source sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Oct 5 03:07:44 PDT 2015


 desktop/source/lib/init.cxx                         |    2 +
 include/LibreOfficeKit/LibreOfficeKitEnums.h        |    4 +-
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   31 +++++++++++++++++++-
 libreofficekit/source/gtk/lokdocview.cxx            |   28 ++++++++++++++++++
 sw/source/uibase/uiview/viewsrch.cxx                |    8 ++++-
 5 files changed, 70 insertions(+), 3 deletions(-)

New commits:
commit aa3f607f80a2269ca2e1f8a5805d2e0b4cd36d7e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Oct 5 11:39:11 2015 +0200

    gtktiledviewer: make it possible to trigger SearchItem.Command
    
    Change-Id: I210da07802bae1f2f2948976bc0faf90e93152b4

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 2145c99..408dd91 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -53,6 +53,7 @@ public:
     GtkWidget* m_pFindbar;
     GtkWidget* m_pFindbarEntry;
     GtkWidget* m_pFindbarLabel;
+    bool m_bFindAll;
 
     TiledWindow()
         : m_pDocView(0),
@@ -70,7 +71,8 @@ public:
         m_bPartSelectorBroadcast(true),
         m_pFindbar(0),
         m_pFindbarEntry(0),
-        m_pFindbarLabel(0)
+        m_pFindbarLabel(0),
+        m_bFindAll(false)
     {
     }
 };
@@ -178,6 +180,13 @@ static void toggleEditing(GtkWidget* pButton, gpointer /*pItem*/)
         lok_doc_view_set_edit(pLOKDocView, bActive);
 }
 
+/// Toggles if search should find all results or only the first one.
+static void toggleFindAll(GtkWidget* pButton, gpointer /*pItem*/)
+{
+    TiledWindow& rWindow = lcl_getTiledWindow(pButton);
+    rWindow.m_bFindAll = !rWindow.m_bFindAll;
+}
+
 /// Toggle the visibility of the findbar.
 static void toggleFindbar(GtkWidget* pButton, gpointer /*pItem*/)
 {
@@ -285,6 +294,12 @@ static void doSearch(GtkWidget* pButton, bool bBackwards)
     aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/value", '/'), pText);
     aTree.put(boost::property_tree::ptree::path_type("SearchItem.Backward/type", '/'), "boolean");
     aTree.put(boost::property_tree::ptree::path_type("SearchItem.Backward/value", '/'), bBackwards);
+    if (rWindow.m_bFindAll)
+    {
+        aTree.put(boost::property_tree::ptree::path_type("SearchItem.Command/type", '/'), "unsigned short");
+        // SvxSearchCmd::FIND_ALL
+        aTree.put(boost::property_tree::ptree::path_type("SearchItem.Command/value", '/'), "1");
+    }
 
     LOKDocView* pLOKDocView = LOK_DOC_VIEW(rWindow.m_pDocView);
     GdkRectangle aArea;
@@ -730,6 +745,11 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
     gtk_toolbar_insert(GTK_TOOLBAR(rWindow.m_pFindbar), pFindbarPrev, -1);
     g_signal_connect(G_OBJECT(pFindbarPrev), "clicked", G_CALLBACK(signalSearchPrev), NULL);
 
+    GtkToolItem* pFindAll = gtk_toggle_tool_button_new();
+    gtk_tool_button_set_label(GTK_TOOL_BUTTON(pFindAll), "Highlight All");
+    gtk_toolbar_insert(GTK_TOOLBAR(rWindow.m_pFindbar), pFindAll, -1);
+    g_signal_connect(G_OBJECT(pFindAll), "toggled", G_CALLBACK(toggleFindAll), NULL);
+
     GtkToolItem* pFindbarLabelContainer = gtk_tool_item_new();
     rWindow.m_pFindbarLabel = gtk_label_new("");
     gtk_container_add(GTK_CONTAINER(pFindbarLabelContainer), rWindow.m_pFindbarLabel);
commit 22d342a82f225381057b5b8b941be8583de87a63
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Oct 5 11:30:15 2015 +0200

    lokdocview: handle LOK_CALLBACK_SEARCH_RESULT_COUNT
    
    Change-Id: I0d1b641654e0de65169e19bb5843ea11b43a90a3

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 8686b00..2145c99 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -387,6 +387,14 @@ static void signalSearch(LOKDocView* pLOKDocView, char* /*pPayload*/, gpointer /
     gtk_label_set_text(GTK_LABEL(rWindow.m_pFindbarLabel), "Search key not found");
 }
 
+/// LOKDocView found some search matches -> set the search label accordingly.
+static void signalSearchResultCount(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pData*/)
+{
+    TiledWindow& rWindow = lcl_getTiledWindow(GTK_WIDGET(pLOKDocView));
+    std::stringstream ss;
+    ss << pPayload << " match(es)";
+    gtk_label_set_text(GTK_LABEL(rWindow.m_pFindbarLabel), ss.str().c_str());
+}
 
 static void signalPart(LOKDocView* pLOKDocView, int nPart, gpointer /*pData*/)
 {
@@ -764,6 +772,7 @@ static void setupDocView(GtkWidget* pDocView)
     g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL);
     g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
     g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
+    g_signal_connect(pDocView, "search-result-count", G_CALLBACK(signalSearchResultCount), NULL);
     g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
     g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
     g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 8b85c45..2270231 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -121,6 +121,7 @@ enum
     SIZE_CHANGED,
     HYPERLINK_CLICKED,
     CURSOR_CHANGED,
+    SEARCH_RESULT_COUNT,
 
     LAST_SIGNAL
 };
@@ -221,6 +222,8 @@ callbackTypeToString (int nType)
         return "LOK_CALLBACK_STATUS_INDICATOR_FINISH";
     case LOK_CALLBACK_SEARCH_NOT_FOUND:
         return "LOK_CALLBACK_SEARCH_NOT_FOUND";
+    case LOK_CALLBACK_SEARCH_RESULT_COUNT:
+        return "LOK_CALLBACK_SEARCH_RESULT_COUNT";
     case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
         return "LOK_CALLBACK_DOCUMENT_SIZE_CHANGED";
     case LOK_CALLBACK_SET_PART:
@@ -363,6 +366,11 @@ searchNotFound(LOKDocView* pDocView, const std::string& rString)
     g_signal_emit(pDocView, doc_view_signals[SEARCH_NOT_FOUND], 0, rString.c_str());
 }
 
+static void searchResultCount(LOKDocView* pDocView, const std::string& rString)
+{
+    g_signal_emit(pDocView, doc_view_signals[SEARCH_RESULT_COUNT], 0, rString.c_str());
+}
+
 static void
 setPart(LOKDocView* pDocView, const std::string& rString)
 {
@@ -645,6 +653,11 @@ callback (gpointer pData)
         setPart(pDocView, pCallback->m_aPayload);
     }
     break;
+    case LOK_CALLBACK_SEARCH_RESULT_COUNT:
+    {
+        searchResultCount(pDocView, pCallback->m_aPayload);
+    }
+    break;
     default:
         g_assert(false);
         break;
@@ -1841,6 +1854,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                      G_TYPE_NONE, 4,
                      G_TYPE_INT, G_TYPE_INT,
                      G_TYPE_INT, G_TYPE_INT);
+    /**
+     * LOKDocView::search-result-count:
+     * @pDocView: the #LOKDocView on which the signal is emitted
+     * @aCommand: number of matches.
+     */
+    doc_view_signals[SEARCH_RESULT_COUNT] =
+        g_signal_new("search-result_count",
+                     G_TYPE_FROM_CLASS(pGObjectClass),
+                     G_SIGNAL_RUN_FIRST,
+                     0,
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__STRING,
+                     G_TYPE_NONE, 1,
+                     G_TYPE_STRING);
+
 }
 
 SAL_DLLPUBLIC_EXPORT GtkWidget*
commit 6c040ad18bd7b5a2d1d11130f4dbfd1c9d90055d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Oct 5 11:29:28 2015 +0200

    LOK: add CALLBACK_SEARCH_RESULT_COUNT and implement in sw
    
    Change-Id: I616b3f6d2881aaa479f6498d3121540980256c15

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 7038e5f..dc3e0f9 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -155,7 +155,9 @@ typedef enum
      *
      * Payload is a single 0-based integer.
      */
-    LOK_CALLBACK_SET_PART
+    LOK_CALLBACK_SET_PART,
+    /// Number of search results, in case something is found.
+    LOK_CALLBACK_SEARCH_RESULT_COUNT
 }
 LibreOfficeKitCallbackType;
 
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index b9c54fc..dcb4452 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -209,7 +209,8 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage)
             break;
             case SvxSearchCmd::FIND_ALL:
             {
-                bool bRet = SearchAll();
+                sal_uInt16 nFound = 0;
+                bool bRet = SearchAll(&nFound);
                 if( !bRet )
                 {
 #if HAVE_FEATURE_DESKTOP
@@ -222,6 +223,11 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage)
 #endif
                     m_bFound = false;
                 }
+                else
+                {
+                    OString aPayload = OString::number(nFound);
+                    m_pWrtShell->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_COUNT, aPayload.getStr());
+                }
                 rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
 #if HAVE_FEATURE_DESKTOP
                 {
commit 44838c669b6bd02e14c394aebd9d19bcbf5ff409
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Oct 5 11:29:02 2015 +0200

    desktop: handle sal_uInt16 in jsonToPropertyValues()
    
    Change-Id: Ic0059404b7ccbc922703705e7818404d4904f324

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e902df0..7eb54d3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -903,6 +903,8 @@ static void jsonToPropertyValues(const char* pJSON, uno::Sequence<beans::Propert
                 aValue.Value <<= OString(rValue.c_str()).toFloat();
             else if (rType == "long")
                 aValue.Value <<= OString(rValue.c_str()).toInt32();
+            else if (rType == "unsigned short")
+                aValue.Value <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32());
             else
                 SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<<rType<<"'");
             aArguments.push_back(aValue);


More information about the Libreoffice-commits mailing list