[Libreoffice-commits] core.git: vcl/qt5
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Oct 12 13:24:36 UTC 2018
vcl/qt5/Qt5Clipboard.cxx | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
New commits:
commit f2c4b6eeb62e9ceb102cccf56c823309df8c6a4a
Author: Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Tue Oct 9 15:33:12 2018 +0200
Commit: Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Fri Oct 12 15:24:12 2018 +0200
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 at cib.de>
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;
}
More information about the Libreoffice-commits
mailing list