diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-10-26 14:20:26 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-10-27 10:14:51 +0100 |
commit | 5a2184ff317906b1b4b2c5b8b608c92aa18399ed (patch) | |
tree | af68740dfff88e5ab5068cd740054779402d48a3 /desktop | |
parent | 2c6a58d71ca74ea3147dcfd18097142806eaf6ed (diff) |
lok clipboard: support rich text paste
Change-Id: Ida5028969782be792b32b952d3adba0c30dd8bae
(cherry picked from commit faa316e670414363dcfb6db6001fdb209f4a48c1)
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 | ||||
-rw-r--r-- | desktop/source/lib/lokclipboard.cxx | 11 | ||||
-rw-r--r-- | desktop/source/lib/lokclipboard.hxx | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 26b96ecbaa14..71f50ec7a49b 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -338,7 +338,10 @@ void DesktopLOKTest::testPasteWriter() CPPUNIT_ASSERT_EQUAL(OString("hello"), OString(pText)); free(pText); + // textt/plain should be rejected. CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, "textt/plain;charset=utf-8", aText.getStr(), aText.getLength())); + // Writer is expected to support text/html. + CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aText.getStr(), aText.getLength())); comphelper::LibreOfficeKit::setActive(false); } diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx index a81902b15b6b..50d570577e27 100644 --- a/desktop/source/lib/lokclipboard.cxx +++ b/desktop/source/lib/lokclipboard.cxx @@ -32,7 +32,7 @@ OUString SAL_CALL LOKClipboard::getName() throw (uno::RuntimeException, std::exc LOKTransferable::LOKTransferable(const char* pMimeType, const char* pData, size_t nSize) : m_aMimeType(pMimeType), - m_aText(pData, nSize) + m_aSequence(reinterpret_cast<const sal_Int8*>(pData), nSize) { } @@ -40,8 +40,13 @@ uno::Any SAL_CALL LOKTransferable::getTransferData(const datatransfer::DataFlavo throw(datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException, std::exception) { uno::Any aRet; - if (m_aMimeType == "text/plain;charset=utf-8" && rFlavor.MimeType == "text/plain;charset=utf-16") - aRet <<= OStringToOUString(m_aText, RTL_TEXTENCODING_UTF8); + 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); + } + else + aRet <<= m_aSequence; return aRet; } diff --git a/desktop/source/lib/lokclipboard.hxx b/desktop/source/lib/lokclipboard.hxx index b982e1c734ee..a0ab6451e0c0 100644 --- a/desktop/source/lib/lokclipboard.hxx +++ b/desktop/source/lib/lokclipboard.hxx @@ -35,7 +35,7 @@ public: class LOKTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable> { OString m_aMimeType; - OString m_aText; + css::uno::Sequence<sal_Int8> m_aSequence; /// Provides a list of flavors, used by getTransferDataFlavors() and isDataFlavorSupported(). std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector(); |