diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-08 09:41:37 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-12 15:21:24 +0200 |
commit | 3f29d2cb7ccb7150d5ecd8f6e2bdc2f0de9efb1d (patch) | |
tree | 750d5763ee1e6d3399087e3db2826d9ee2167e05 /vcl | |
parent | b752a93acff31c824bcec4233a8dd9bee014ca7d (diff) |
Support HTML paste from qt5 clipboard
Change-Id: I23b615bf0720fdcdb1849e7890956c1d9f1a79c1
Reviewed-on: https://gerrit.libreoffice.org/61516
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/Qt5Clipboard.cxx | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx index 52c43a2541b1..6a777cc1af3e 100644 --- a/vcl/qt5/Qt5Clipboard.cxx +++ b/vcl/qt5/Qt5Clipboard.cxx @@ -15,6 +15,7 @@ #include <QtWidgets/QApplication> #include <QtGui/QClipboard> +#include <QtCore/QMimeData> #include <Qt5Clipboard.hxx> #include <Qt5Tools.hxx> @@ -23,11 +24,23 @@ std::vector<css::datatransfer::DataFlavor> Qt5Transferable::getTransferDataFlavo { std::vector<css::datatransfer::DataFlavor> aVector; - // FIXME: this is fake + const QClipboard* clipboard = QApplication::clipboard(); + const QMimeData* mimeData = clipboard->mimeData(); css::datatransfer::DataFlavor aFlavor; - aFlavor.MimeType = "text/plain;charset=utf-16"; - aFlavor.DataType = cppu::UnoType<OUString>::get(); - aVector.push_back(aFlavor); + + if (mimeData->hasHtml()) + { + aFlavor.MimeType = "text/html"; + aFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get(); + aVector.push_back(aFlavor); + } + + if (mimeData->hasText()) + { + aFlavor.MimeType = "text/plain;charset=utf-16"; + aFlavor.DataType = cppu::UnoType<OUString>::get(); + aVector.push_back(aFlavor); + } return aVector; } @@ -53,15 +66,23 @@ css::uno::Any SAL_CALL Qt5Transferable::getTransferData(const css::datatransfer::DataFlavor& rFlavor) { css::uno::Any aRet; + const QClipboard* clipboard = QApplication::clipboard(); + const QMimeData* mimeData = clipboard->mimeData(); if (rFlavor.MimeType == "text/plain;charset=utf-16") { - const QClipboard* clipboard = QApplication::clipboard(); - QString clipboardContent = clipboard->text(); + QString clipboardContent = mimeData->text(); OUString sContent = toOUString(clipboardContent); aRet <<= sContent.replaceAll("\r\n", "\n"); } + else if (rFlavor.MimeType == "text/html") + { + QString clipboardContent = mimeData->html(); + std::string aStr = clipboardContent.toStdString(); + Sequence<sal_Int8> aSeq(reinterpret_cast<const sal_Int8*>(aStr.c_str()), aStr.length()); + aRet <<= aSeq; + } return aRet; } |