f325b2
From cb62457c638e4bd4d951bcf664040326c840824c Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Mon, 26 Oct 2015 14:20:26 +0100
f325b2
Subject: [PATCH 233/398] lok clipboard: support rich text paste
f325b2
f325b2
Change-Id: Ida5028969782be792b32b952d3adba0c30dd8bae
f325b2
(cherry picked from commit faa316e670414363dcfb6db6001fdb209f4a48c1)
f325b2
---
f325b2
 desktop/qa/desktop_lib/test_desktop_lib.cxx |  3 +++
f325b2
 desktop/source/lib/lokclipboard.cxx         | 11 ++++++++---
f325b2
 desktop/source/lib/lokclipboard.hxx         |  2 +-
f325b2
 3 files changed, 12 insertions(+), 4 deletions(-)
f325b2
f325b2
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
index 12831318dde3..d4135b66d1d8 100644
f325b2
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
@@ -338,7 +338,10 @@ void DesktopLOKTest::testPasteWriter()
f325b2
     CPPUNIT_ASSERT_EQUAL(OString("hello"), OString(pText));
f325b2
     free(pText);
f325b2
 
f325b2
+    // textt/plain should be rejected.
f325b2
     CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, "textt/plain;charset=utf-8", aText.getStr(), aText.getLength()));
f325b2
+    // Writer is expected to support text/html.
f325b2
+    CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aText.getStr(), aText.getLength()));
f325b2
 
f325b2
     comphelper::LibreOfficeKit::setActive(false);
f325b2
 }
f325b2
diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx
f325b2
index a81902b15b6b..50d570577e27 100644
f325b2
--- a/desktop/source/lib/lokclipboard.cxx
f325b2
+++ b/desktop/source/lib/lokclipboard.cxx
f325b2
@@ -32,7 +32,7 @@ OUString SAL_CALL LOKClipboard::getName() throw (uno::RuntimeException, std::exc
f325b2
 
f325b2
 LOKTransferable::LOKTransferable(const char* pMimeType, const char* pData, size_t nSize)
f325b2
     : m_aMimeType(pMimeType),
f325b2
-      m_aText(pData, nSize)
f325b2
+      m_aSequence(reinterpret_cast<const sal_Int8*>(pData), nSize)
f325b2
 {
f325b2
 }
f325b2
 
f325b2
@@ -40,8 +40,13 @@ uno::Any SAL_CALL LOKTransferable::getTransferData(const datatransfer::DataFlavo
f325b2
 throw(datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException, std::exception)
f325b2
 {
f325b2
     uno::Any aRet;
f325b2
-    if (m_aMimeType == "text/plain;charset=utf-8" && rFlavor.MimeType == "text/plain;charset=utf-16")
f325b2
-        aRet <<= OStringToOUString(m_aText, RTL_TEXTENCODING_UTF8);
f325b2
+    if (rFlavor.DataType == cppu::UnoType<OUString>::get())
f325b2
+    {
f325b2
+        sal_Char* pText = reinterpret_cast<sal_Char*>(m_aSequence.getArray());
f325b2
+        aRet <<= OUString(pText, rtl_str_getLength(pText), RTL_TEXTENCODING_UTF8);
f325b2
+    }
f325b2
+    else
f325b2
+        aRet <<= m_aSequence;
f325b2
     return aRet;
f325b2
 }
f325b2
 
f325b2
diff --git a/desktop/source/lib/lokclipboard.hxx b/desktop/source/lib/lokclipboard.hxx
f325b2
index b982e1c734ee..a0ab6451e0c0 100644
f325b2
--- a/desktop/source/lib/lokclipboard.hxx
f325b2
+++ b/desktop/source/lib/lokclipboard.hxx
f325b2
@@ -35,7 +35,7 @@ public:
f325b2
 class LOKTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable>
f325b2
 {
f325b2
     OString m_aMimeType;
f325b2
-    OString m_aText;
f325b2
+    css::uno::Sequence<sal_Int8> m_aSequence;
f325b2
 
f325b2
     /// Provides a list of flavors, used by getTransferDataFlavors() and isDataFlavorSupported().
f325b2
     std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector();
f325b2
-- 
f325b2
2.12.0
f325b2