diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-09 15:33:12 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-12 15:24:12 +0200 |
commit | f2c4b6eeb62e9ceb102cccf56c823309df8c6a4a (patch) | |
tree | 60845c787046c874e2d3c83e4a82451bd3e0ec75 /vcl | |
parent | 3f29d2cb7ccb7150d5ecd8f6e2bdc2f0de9efb1d (diff) |
Support image paste from qt5 clipboard
Change-Id: Ie1894d9549227c73c6da6688b0540c85d4593a2b
Reviewed-on: https://gerrit.libreoffice.org/61589
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/Qt5Clipboard.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx index 6a777cc1af3e..14e98d4b6ed3 100644 --- a/vcl/qt5/Qt5Clipboard.cxx +++ b/vcl/qt5/Qt5Clipboard.cxx @@ -15,6 +15,7 @@ #include <QtWidgets/QApplication> #include <QtGui/QClipboard> +#include <QtCore/QBuffer> #include <QtCore/QMimeData> #include <Qt5Clipboard.hxx> @@ -42,6 +43,13 @@ std::vector<css::datatransfer::DataFlavor> Qt5Transferable::getTransferDataFlavo aVector.push_back(aFlavor); } + if (mimeData->hasImage()) + { + aFlavor.MimeType = "image/png"; + aFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get(); + aVector.push_back(aFlavor); + } + return aVector; } @@ -83,6 +91,20 @@ Qt5Transferable::getTransferData(const css::datatransfer::DataFlavor& rFlavor) Sequence<sal_Int8> aSeq(reinterpret_cast<const sal_Int8*>(aStr.c_str()), aStr.length()); aRet <<= aSeq; } + else if (rFlavor.MimeType.startsWith("image") && mimeData->hasImage()) + { + QImage image = qvariant_cast<QImage>(mimeData->imageData()); + QByteArray ba; + QBuffer buffer(&ba); + sal_Int32 nIndex = rFlavor.MimeType.indexOf('/'); + OUString sFormat(nIndex != -1 ? rFlavor.MimeType.copy(nIndex + 1) : "png"); + + buffer.open(QIODevice::WriteOnly); + image.save(&buffer, sFormat.toUtf8().getStr()); + + Sequence<sal_Int8> aSeq(reinterpret_cast<const sal_Int8*>(ba.data()), ba.size()); + aRet <<= aSeq; + } return aRet; } |