summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-05-08 00:26:08 +0200
committerpranavk <pranavk@collabora.co.uk>2017-05-11 17:56:09 +0200
commit9cc9300bc20e9367728aa4b7ec3a789fdd274aff (patch)
treeddde949f86a4b68e7864e22f293ba2da412abf31 /libreofficekit
parentb973b184a0870ad70e2db4e0e3842cf208b87abf (diff)
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@collabora.co.uk> Tested-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx52
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx28
2 files changed, 80 insertions, 0 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index ed1d7f10a694..14bb2c1a2b6d 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;
@@ -590,6 +591,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);
}
@@ -1402,6 +1404,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*/)
{
@@ -1593,6 +1628,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*/)
{
@@ -2088,6 +2130,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();
@@ -2188,6 +2238,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);
@@ -2214,6 +2265,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 fd367052ddca..a59d72bcc374 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());
@@ -1301,6 +1309,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);
@@ -3072,6 +3085,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