summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h7
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx24
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx25
-rw-r--r--sc/source/ui/app/inputhdl.cxx8
4 files changed, 63 insertions, 1 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 37837ea49b86..7b23fcbab1c3 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -209,7 +209,12 @@ typedef enum
*
* Payload is a css mouse pointer style.
*/
- LOK_CALLBACK_MOUSE_POINTER
+ LOK_CALLBACK_MOUSE_POINTER,
+
+ /**
+ * The text content of the formula bar in Calc.
+ */
+ LOK_CALLBACK_CELL_FORMULA
}
LibreOfficeKitCallbackType;
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*
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 070c94a25fc7..4138bad3b57b 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -52,6 +52,7 @@
#include <tools/urlobj.hxx>
#include <comphelper/string.hxx>
#include <formula/formulahelper.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include "inputwin.hxx"
#include "tabvwsh.hxx"
@@ -2131,6 +2132,11 @@ void ScInputHandler::DataChanged( bool bFromTopNotify, bool bSetModified )
if ( pInputWin )
pInputWin->SetTextString( aText );
+
+ ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell();
+ ScDocument& rDoc = pDocSh->GetDocument();
+ if ( rDoc.GetDrawLayer()->isTiledRendering() )
+ rDoc.GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_CELL_FORMULA, aText.toUtf8().getStr());
}
// If the cursor is before the end of a paragraph, parts are being pushed to
@@ -3466,6 +3472,8 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
if ( pInputWin )
pInputWin->SetTextString(aString);
+ else if ( rDoc.GetDrawLayer()->isTiledRendering() )
+ rDoc.GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_CELL_FORMULA, aString.toUtf8().getStr());
}
if ( pInputWin ) // Named range input