diff options
-rw-r--r-- | desktop/source/lib/init.cxx | 14 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 4 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 10 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitGtk.h | 3 | ||||
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 15 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 5 |
6 files changed, 51 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index ee986c515722..eff82b64a78f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -27,6 +27,7 @@ #include <rtl/strbuf.hxx> #include <rtl/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx> +#include <comphelper/dispatchcommand.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -213,6 +214,8 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis, int nX, int nY, int nCount); +static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, + const char* pCommand); static void doc_setTextSelection (LibreOfficeKitDocument* pThis, int nType, int nX, @@ -251,6 +254,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument m_pDocumentClass->registerCallback = doc_registerCallback; m_pDocumentClass->postKeyEvent = doc_postKeyEvent; m_pDocumentClass->postMouseEvent = doc_postMouseEvent; + m_pDocumentClass->postUnoCommand = doc_postUnoCommand; m_pDocumentClass->setTextSelection = doc_setTextSelection; m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection; m_pDocumentClass->resetSelection = doc_resetSelection; @@ -723,6 +727,16 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* /*pThis*/, int nType, int n #endif } +static void doc_postUnoCommand(LibreOfficeKitDocument* /*pThis*/, const char* pCommand) +{ + OUString aCommand(pCommand, strlen(pCommand), RTL_TEXTENCODING_UTF8); + + if (!comphelper::dispatchCommand(aCommand)) + { + gImpl->maLastExceptionMsg = "Failed to dispatch the .uno: command"; + } +} + static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY, int nCount) { ITiledRenderable* pDoc = getTiledRenderable(pThis); diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index e2ad1930108d..7f9a515c3487 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -132,6 +132,10 @@ struct _LibreOfficeKitDocumentClass int nX, int nY, int nCount); + /// @see lok::Document::postUnoCommand + void (*postUnoCommand)(LibreOfficeKitDocument* pThis, + const char* pCommand); + /// @see lok::Document::setTextSelection void (*setTextSelection)(LibreOfficeKitDocument* pThis, int nType, diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index c19aa504cbac..1d7d7096c149 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -131,6 +131,16 @@ public: } /** + * Posts an UNO command to the document. + * + * @param pCommand uno command to be posted to the document, like ".uno:Bold" + */ + inline void postUnoCommand(const char* pCommand) + { + mpDoc->pClass->postUnoCommand(mpDoc, pCommand); + } + + /** * Sets the start or end of a text selection. * * @param nType @see LibreOfficeKitSetTextSelectionType diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index 77e9118f60bd..f088f494806e 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -121,6 +121,9 @@ void lok_docview_set_edit (LOKDocView* pDocView, gboolean bEdit); /// Gets if the viewer is actually an editor or not. gboolean lok_docview_get_edit (LOKDocView* pDocView); + +/// Posts the .uno: command to the LibreOfficeKit. +void lok_docview_post_command (LOKDocView* pDocView, const char* pCommand); #ifdef __cplusplus } #endif diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 32a107ee9fca..92ffdd489ea0 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -35,6 +35,7 @@ static int help() static GtkWidget* pDocView; static GtkToolItem* pEnableEditing; +static GtkToolItem* pBold; static GtkWidget* pDocViewQuad; static GtkWidget* pVBox; // GtkComboBox requires gtk 2.24 or later @@ -124,6 +125,14 @@ static void signalEdit(LOKDocView* pLOKDocView, gboolean bWasEdit, gpointer /*pD gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pEnableEditing), bEdit); } +/// User clicked on the 'Bold' button -> inform LOKDocView. +void toggleBold(GtkWidget* /*pButton*/, gpointer /*pItem*/) +{ + LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView); + + lok_docview_post_command(pLOKDocView, ".uno:Bold"); +} + void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ ) { if ( pDocView ) @@ -364,6 +373,12 @@ int main( int argc, char* argv[] ) gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pEnableEditing, -1); g_signal_connect(G_OBJECT(pEnableEditing), "toggled", G_CALLBACK(toggleEditing), NULL); + gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1); + pBold = gtk_toggle_tool_button_new(); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(pBold), "Bold"); + gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pBold, -1); + g_signal_connect(G_OBJECT(pBold), "toggled", G_CALLBACK(toggleBold), NULL); + gtk_box_pack_start( GTK_BOX(pVBox), pToolbar, FALSE, FALSE, 0 ); // Adds to top. // Docview diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 8349256256a9..e3fd1cba34d0 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -971,4 +971,9 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_get_edit(LOKDocView* pDocView) return pDocView->m_bEdit; } +SAL_DLLPUBLIC_EXPORT void lok_docview_post_command(LOKDocView* pDocView, const char* pCommand) +{ + pDocView->pDocument->pClass->postUnoCommand(pDocView->pDocument, pCommand); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |