Kaydet (Commit) 5a2184ff authored tarafından Miklos Vajna's avatar Miklos Vajna

lok clipboard: support rich text paste

Change-Id: Ida5028969782be792b32b952d3adba0c30dd8bae
(cherry picked from commit faa316e6)
üst 2c6a58d7
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment