From 7d7fad258dfde500c5ee99b5f1691172724383bd Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Wed, 9 Dec 2015 21:45:21 +0530 Subject: tdf#96317: Add API for copy/paste from/to the widget Change-Id: Iac869ddb65cbdd2227f96d047d83159ca7819f11 Reviewed-on: https://gerrit.libreoffice.org/20534 Reviewed-by: David Tardon Tested-by: David Tardon --- libreofficekit/source/gtk/lokdocview.cxx | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'libreofficekit/source') diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 3bf4d44c2835..741760214be4 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -343,7 +343,7 @@ doSearch(LOKDocView* pDocView, const char* pText, bool bBackwards, bool highligh cairo_region_get_rectangle(cairoVisRegion, 0, &cairoVisRect); x = pixelToTwip (cairoVisRect.x, priv->m_fZoom); y = pixelToTwip (cairoVisRect.y, priv->m_fZoom); - + aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/type", '/'), "string"); aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/value", '/'), pText); aTree.put(boost::property_tree::ptree::path_type("SearchItem.Backward/type", '/'), "boolean"); @@ -2668,6 +2668,37 @@ lok_doc_view_highlight_all (LOKDocView* pDocView, doSearch(pDocView, pText, false, true); } +SAL_DLLPUBLIC_EXPORT gchar* +lok_doc_view_copy_selection (LOKDocView* pDocView, + const gchar* pMimeType, + gchar** pUsedMimeType) +{ + LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pDocView); + return pDocument->pClass->getTextSelection(pDocument, pMimeType, pUsedMimeType); +} + +SAL_DLLPUBLIC_EXPORT gboolean +lok_doc_view_paste (LOKDocView* pDocView, + const gchar* pMimeType, + const gchar* pData, + gsize nSize) +{ + LOKDocViewPrivate& priv = getPrivate(pDocView); + LibreOfficeKitDocument* pDocument = priv->m_pDocument; + gboolean ret = 0; + + if (!priv->m_bEdit) + { + g_info ("ignoring paste in view-only mode"); + return ret; + } + + if (pData) + ret = pDocument->pClass->paste(pDocument, pMimeType, pData, nSize); + + return ret; +} + SAL_DLLPUBLIC_EXPORT float lok_doc_view_pixel_to_twip (LOKDocView* pDocView, float fInput) { -- cgit