[Libreoffice-commits] core.git: vcl/qt5
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Jan 21 09:47:56 UTC 2019
vcl/qt5/Qt5Clipboard.cxx | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
New commits:
commit 3fa4674615b747e219afe5bf0a9b689df3840439
Author: Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Wed Dec 12 10:03:49 2018 +0100
Commit: Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Mon Jan 21 10:47:34 2019 +0100
Related tdf#120625: improve querying supported data flavours
Change-Id: Ia46b136f64c2750ed466d86967de9dfe90b4ce65
Reviewed-on: https://gerrit.libreoffice.org/65003
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 a9134506896f..742dc8a8d851 100644
--- a/vcl/qt5/Qt5Clipboard.cxx
+++ b/vcl/qt5/Qt5Clipboard.cxx
@@ -45,25 +45,27 @@ std::vector<css::datatransfer::DataFlavor> Qt5Transferable::getTransferDataFlavo
const QMimeData* mimeData = clipboard->mimeData();
css::datatransfer::DataFlavor aFlavor;
- if (mimeData->hasHtml())
+ if (mimeData)
{
- 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);
- }
+ for (QString& rMimeType : mimeData->formats())
+ {
+ // filter out non-MIME types such as TARGETS, MULTIPLE, TIMESTAMP
+ if (rMimeType.indexOf('/') == -1)
+ continue;
- if (mimeData->hasImage())
- {
- aFlavor.MimeType = "image/png";
- aFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get();
- aVector.push_back(aFlavor);
+ if (rMimeType.startsWith("text/plain"))
+ {
+ aFlavor.MimeType = "text/plain;charset=utf-16";
+ aFlavor.DataType = cppu::UnoType<OUString>::get();
+ aVector.push_back(aFlavor);
+ }
+ else
+ {
+ aFlavor.MimeType = toOUString(rMimeType);
+ aFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get();
+ aVector.push_back(aFlavor);
+ }
+ }
}
return aVector;
@@ -75,11 +77,13 @@ css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL Qt5Transferable::getT
}
sal_Bool SAL_CALL
-Qt5Transferable::isDataFlavorSupported(const css::datatransfer::DataFlavor& /*rFlavor*/)
+Qt5Transferable::isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor)
{
const std::vector<css::datatransfer::DataFlavor> aAll = getTransferDataFlavorsAsVector();
- return !aAll.empty(); //FIXME
+ return std::any_of(aAll.begin(), aAll.end(), [&](const css::datatransfer::DataFlavor& aFlavor) {
+ return rFlavor.MimeType == aFlavor.MimeType;
+ }); //FIXME
}
/*
More information about the Libreoffice-commits
mailing list