diff options
-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; } |