[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - 2 commits - vcl/qt5

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 13 14:45:53 UTC 2019


 vcl/qt5/Qt5Clipboard.cxx |   37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

New commits:
commit d0b03870b7eb67a5a4f4981c1e104ca03bd6e993
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed May 15 16:29:31 2019 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Thu Jun 13 16:45:23 2019 +0200

    Revert "tdf#120836 KDE5: Clipboard: don't put images to clipboard"
    
    My previous commit has disabled setting non-text for selection, so
    this workaround is no longer needed (and it very much looks like
    a workaround, I see no good reason for never putting images
    in the clipboard).
    
    This reverts commit c8b0c382c6330865df50ae7cf7360c8a2c08ebe6.
    
    Change-Id: I0206211e3ff0adcb89f8ca5410831a428e71fb51
    Reviewed-on: https://gerrit.libreoffice.org/72370
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
    (cherry picked from commit 0d58f51d7672c569c93c6e814dbfffa586eebfb7)
    Reviewed-on: https://gerrit.libreoffice.org/73929
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx
index d4df05504b8e..6d333d498ff2 100644
--- a/vcl/qt5/Qt5Clipboard.cxx
+++ b/vcl/qt5/Qt5Clipboard.cxx
@@ -287,6 +287,36 @@ void VclQt5Clipboard::setContents(
             }
         }
 
+        // Add image data if present
+        if (bHasImage)
+        {
+            css::datatransfer::DataFlavor aFlavor;
+            //FIXME: other image formats?
+            aFlavor.MimeType = "image/png";
+            aFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get();
+
+            Any aValue;
+            try
+            {
+                aValue = xTrans->getTransferData(aFlavor);
+            }
+            catch (...)
+            {
+            }
+
+            if (aValue.getValueType() == cppu::UnoType<Sequence<sal_Int8>>::get())
+            {
+                Sequence<sal_Int8> aData;
+                aValue >>= aData;
+
+                QImage image;
+                image.loadFromData(reinterpret_cast<const uchar*>(aData.getConstArray()),
+                                   aData.getLength());
+
+                pMimeData->setImageData(image);
+            }
+        }
+
         // Add text data
         // TODO: consider checking if text of suitable type is present
         {
commit efef02cc463f73bd575237ce702f735b9b494733
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed May 15 16:26:59 2019 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Thu Jun 13 16:45:17 2019 +0200

    do not add non-text to PRIMARY selection in VclQt5Clipboard
    
    E.g. tdf#80853 repeatedly sets the selection, which results
    in the entire document getting converted to html.
    
    Other VCL backends seem to be even faster, it looks like they convert
    the data only on-demand, but this at least makes things bearable.
    
    Change-Id: Ib08423bd89d7c7065ad0522338979f1ce66701c7
    Reviewed-on: https://gerrit.libreoffice.org/72369
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    (cherry picked from commit 294d4ed6aab4ae6dbf859626545cf6d75194bacd)
    Reviewed-on: https://gerrit.libreoffice.org/73928
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx
index 5fdbc47dfd2c..d4df05504b8e 100644
--- a/vcl/qt5/Qt5Clipboard.cxx
+++ b/vcl/qt5/Qt5Clipboard.cxx
@@ -249,8 +249,13 @@ void VclQt5Clipboard::setContents(
     {
         css::uno::Sequence<css::datatransfer::DataFlavor> aFormats
             = xTrans->getTransferDataFlavors();
+        // Do not add non-text formats for the selection buffer,
+        // I don't think that one is ever used for anything else
+        // besides text and this gets called whenever something
+        // in LO gets selected (which may be e.g. an entire Calc sheet).
         bool bHasHtml = false, bHasImage = false;
-        lcl_peekFormats(aFormats, bHasHtml, bHasImage);
+        if (m_aClipboardMode != QClipboard::Selection)
+            lcl_peekFormats(aFormats, bHasHtml, bHasImage);
 
         std::unique_ptr<QMimeData> pMimeData(new QMimeData);
 


More information about the Libreoffice-commits mailing list