LibreOffice Module vcl (master)  1
Qt5Transferable.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  */
10 
11 #pragma once
12 
13 #include <cppuhelper/compbase.hxx>
14 #include <com/sun/star/datatransfer/XTransferable.hpp>
15 
16 #include <QtCore/QMimeData>
17 #include <QtCore/QStringList>
18 #include <QtGui/QClipboard>
19 
32 class Qt5Transferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable>
33 {
34  Qt5Transferable(const Qt5Transferable&) = delete;
35 
36  const QMimeData* m_pMimeData;
37  osl::Mutex m_aMutex;
39  css::uno::Sequence<css::datatransfer::DataFlavor> m_aMimeTypeSeq;
40 
41 public:
42  Qt5Transferable(const QMimeData* pMimeData);
43  const QMimeData* mimeData() const { return m_pMimeData; }
44 
45  css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors() override;
46  sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor) override;
47  css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor) override;
48 };
49 
63 {
64  // to detect in-flight QMimeData changes
65  const QClipboard::Mode m_aMode;
66 
67  bool hasInFlightChanged() const;
68 
69 public:
70  explicit Qt5ClipboardTransferable(const QClipboard::Mode aMode, const QMimeData* pMimeData);
71 
72  // these are the same then Qt5Transferable, except they go through RunInMainThread
73  css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors() override;
74  sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor) override;
75  css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor) override;
76 };
77 
84 
102 class Qt5MimeData final : public QMimeData
103 {
105 
106  const css::uno::Reference<css::datatransfer::XTransferable> m_aContents;
107  mutable bool m_bHaveNoCharset; // = uses the locale charset
108  mutable bool m_bHaveUTF8;
109  mutable QStringList m_aMimeTypeList;
110 
111  QVariant retrieveData(const QString& mimeType, QVariant::Type type) const override;
112 
113 public:
114  explicit Qt5MimeData(const css::uno::Reference<css::datatransfer::XTransferable>& aContents);
115 
116  bool hasFormat(const QString& mimeType) const override;
117  QStringList formats() const override;
118 
119  bool deepCopy(QMimeData** const) const;
120 
121  css::datatransfer::XTransferable* xTransferable() const { return m_aContents.get(); }
122 };
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::datatransfer::XTransferable * xTransferable() const
Qt5Transferable Qt5DnDTransferable
Convenience typedef for better code readability.
css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor &rFlavor) override
The QClipboard's QMimeData is volatile.
QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override
bool hasInFlightChanged() const
css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor &rFlavor) override
Qt5Transferable(const Qt5Transferable &)=delete
bool hasFormat(const QString &mimeType) const override
Qt5ClipboardTransferable(const QClipboard::Mode aMode, const QMimeData *pMimeData)
const QClipboard::Mode m_aMode
QStringList formats() const override
Qt5Transferable classes are used to read QMimeData via the XTransferable interface.
unsigned char sal_Bool
QStringList m_aMimeTypeList
const css::uno::Reference< css::datatransfer::XTransferable > m_aContents
Qt5MimeData(const css::uno::Reference< css::datatransfer::XTransferable > &aContents)
A lazy loading QMimeData for XTransferable reads.
const QMimeData * m_pMimeData
sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor &rFlavor) override
bool deepCopy(QMimeData **const) const
sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor &rFlavor) override
css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override
const QMimeData * mimeData() const
css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override
css::uno::Sequence< css::datatransfer::DataFlavor > m_aMimeTypeSeq