diff options
-rw-r--r-- | desktop/source/lib/lokclipboard.cxx | 2 | ||||
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx index 50d570577e27..376bcd72d238 100644 --- a/desktop/source/lib/lokclipboard.cxx +++ b/desktop/source/lib/lokclipboard.cxx @@ -43,7 +43,7 @@ throw(datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeExc if (rFlavor.DataType == cppu::UnoType<OUString>::get()) { sal_Char* pText = reinterpret_cast<sal_Char*>(m_aSequence.getArray()); - aRet <<= OUString(pText, rtl_str_getLength(pText), RTL_TEXTENCODING_UTF8); + aRet <<= OUString(pText, m_aSequence.getLength(), RTL_TEXTENCODING_UTF8); } else aRet <<= m_aSequence; diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index f7c4d5c8d743..8b81c73fbec2 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -15,6 +15,7 @@ #include <iostream> #include <boost/property_tree/json_parser.hpp> +#include <boost/optional.hpp> #include <gdk/gdkkeysyms.h> #define LOK_USE_UNSTABLE_API @@ -288,6 +289,33 @@ static void doPaste(GtkWidget* pButton, gpointer /*pItem*/) LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView); GtkClipboard* pClipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(rWindow.m_pDocView), GDK_SELECTION_CLIPBOARD); + + GdkAtom* pTargets; + gint nTargets; + boost::optional<GdkAtom> oTarget; + if (gtk_clipboard_wait_for_targets(pClipboard, &pTargets, &nTargets)) + { + for (gint i = 0; i < nTargets; ++i) + { + gchar* pName = gdk_atom_name(pTargets[i]); + if (std::string(pName) == "text/html") + oTarget = pTargets[i]; + g_free(pName); + } + g_free(pTargets); + } + + if (oTarget) + { + GtkSelectionData* pSelectionData = gtk_clipboard_wait_for_contents(pClipboard, *oTarget); + gint nLength; + const guchar* pData = gtk_selection_data_get_data_with_length(pSelectionData, &nLength); + bool bSuccess = pDocument->pClass->paste(pDocument, "text/html", reinterpret_cast<const char*>(pData), nLength); + gtk_selection_data_free(pSelectionData); + if (bSuccess) + return; + } + gchar* pText = gtk_clipboard_wait_for_text(pClipboard); if (pText) pDocument->pClass->paste(pDocument, "text/plain;charset=utf-8", pText, strlen(pText)); |