summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMihai Varga <mihai.varga@collabora.com>2015-11-13 09:48:14 +0200
committerMihai Varga <mihai.mv13@gmail.com>2015-11-13 10:00:13 +0200
commit5b1e22e9ba941305a7f138adcef75a464161a145 (patch)
tree28cd17b06803468cd32c3e0a6b35f2d4aae00760 /libreofficekit
parent96cd2abd748ed24e5aba50cc4c300cf06e512db3 (diff)
LOK: calc formula callback + formula bar implementation in gtk
We need the callback to be able implement the formula bar Change-Id: I1c78ab0b9ed9304c0465a9993a7101f8efb91052 Conflicts: include/LibreOfficeKit/LibreOfficeKitEnums.h libreofficekit/source/gtk/lokdocview.cxx
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx24
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx25
2 files changed, 49 insertions, 0 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 5935b3562c6a..b751feca5a9c 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -101,6 +101,7 @@ public:
GtkToolItem* m_pCenterpara;
GtkToolItem* m_pRightpara;
GtkToolItem* m_pJustifypara;
+ GtkWidget* m_pFormulabarEntry;
GtkWidget* m_pScrolledWindow;
std::map<GtkToolItem*, std::string> m_aToolItemCommandNames;
std::map<std::string, GtkToolItem*> m_aCommandNameToolItems;
@@ -135,6 +136,7 @@ public:
m_pCenterpara(nullptr),
m_pRightpara(nullptr),
m_pJustifypara(nullptr),
+ m_pFormulabarEntry(nullptr),
m_pScrolledWindow(nullptr),
m_bToolItemBroadcast(true),
m_pVBox(nullptr),
@@ -632,6 +634,14 @@ static gboolean signalFindbar(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer
return FALSE;
}
+/// Handles the key-press-event of the formula entry widget.
+static gboolean signalFormulabar(GtkWidget* /*pWidget*/, GdkEventKey* /*pEvent*/, gpointer /*pData*/)
+{
+ // for now it just displays the callback
+ // TODO - submit the edited formula
+ return TRUE;
+}
+
/// LOKDocView changed edit state -> inform the tool button.
static void signalEdit(LOKDocView* pLOKDocView, gboolean bWasEdit, gpointer /*pData*/)
{
@@ -768,6 +778,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 formula has changed
+static void formulaChanged(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pData*/)
+{
+ TiledWindow& rWindow = lcl_getTiledWindow(GTK_WIDGET(pLOKDocView));
+ gtk_entry_set_text((GtkEntry*)rWindow.m_pFormulabarEntry, pPayload);
+}
+
static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
{
TiledWindow& rWindow = lcl_getTiledWindow(pWidget);
@@ -1076,6 +1093,12 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
gtk_toolbar_insert(GTK_TOOLBAR(pLowerToolbar), rWindow.m_pJustifypara, -1);
g_signal_connect(G_OBJECT(rWindow.m_pJustifypara), "toggled", G_CALLBACK(toggleToolItem), NULL);
lcl_registerToolItem(rWindow, rWindow.m_pJustifypara, ".uno:JustifyPara");
+ // Formula bar
+ GtkToolItem* pFormulaEntryContainer = gtk_tool_item_new();
+ rWindow.m_pFormulabarEntry = gtk_entry_new();
+ gtk_container_add(GTK_CONTAINER(pFormulaEntryContainer), rWindow.m_pFormulabarEntry);
+ g_signal_connect(rWindow.m_pFormulabarEntry, "key-press-event", G_CALLBACK(signalFormulabar), 0);
+ gtk_toolbar_insert(GTK_TOOLBAR(pLowerToolbar), pFormulaEntryContainer, -1);
gtk_box_pack_start(GTK_BOX(rWindow.m_pVBox), pLowerToolbar, FALSE, FALSE, 0 ); // Adds to top.
// Findbar
@@ -1189,6 +1212,7 @@ static void setupDocView(GtkWidget* pDocView)
g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
g_signal_connect(pDocView, "cursor-changed", G_CALLBACK(cursorChanged), NULL);
+ g_signal_connect(pDocView, "formula-changed", G_CALLBACK(formulaChanged), NULL);
}
int main( int argc, char* argv[] )
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index f52ba6176b31..0a7e8b8dda56 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -184,6 +184,7 @@ enum
CURSOR_CHANGED,
SEARCH_RESULT_COUNT,
COMMAND_RESULT,
+ FORMULA_CHANGED,
LAST_SIGNAL
};
@@ -495,6 +496,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 formulaChanged(LOKDocView* pDocView, const std::string& rString)
+{
+ g_signal_emit(pDocView, doc_view_signals[FORMULA_CHANGED], 0, rString.c_str());
+}
+
static void
setPart(LOKDocView* pDocView, const std::string& rString)
{
@@ -809,6 +815,11 @@ callback (gpointer pData)
commandResult(pDocView, pCallback->m_aPayload);
}
break;
+ case LOK_CALLBACK_CELL_FORMULA:
+ {
+ formulaChanged(pDocView, pCallback->m_aPayload);
+ }
+ break;
default:
g_assert(false);
break;
@@ -2248,6 +2259,20 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
G_TYPE_NONE, 1,
G_TYPE_STRING);
+ /**
+ * LOKDocView::formula-changed:
+ * @pDocView: the #LOKDocView on which the signal is emitted
+ * @aCommand: formula text content
+ */
+ doc_view_signals[FORMULA_CHANGED] =
+ g_signal_new("formula-changed",
+ 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*