LibreOffice Module vcl (master) 1
qt5/QtTransferable.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
14#include <com/sun/star/datatransfer/XTransferable.hpp>
15
16#include <QtCore/QMimeData>
17#include <QtCore/QStringList>
18#include <QtGui/QClipboard>
19
32class QtTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable>
33{
35
36 const QMimeData* m_pMimeData;
37 osl::Mutex m_aMutex;
39 css::uno::Sequence<css::datatransfer::DataFlavor> m_aMimeTypeSeq;
40
41public:
42 QtTransferable(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
69public:
70 explicit QtClipboardTransferable(const QClipboard::Mode aMode, const QMimeData* pMimeData);
71
72 // these are the same then QtTransferable, 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
102class QtMimeData 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#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
112 QVariant retrieveData(const QString& mimeType, QVariant::Type type) const override;
113#else
114 QVariant retrieveData(const QString& mimeType, QMetaType type) const override;
115#endif
116
117public:
118 explicit QtMimeData(const css::uno::Reference<css::datatransfer::XTransferable>& aContents);
119
120 bool hasFormat(const QString& mimeType) const override;
121 QStringList formats() const override;
122
123 bool deepCopy(QMimeData** const) const;
124
125 css::datatransfer::XTransferable* xTransferable() const { return m_aContents.get(); }
126};
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The QClipboard's QMimeData is volatile.
const QClipboard::Mode m_aMode
css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor &rFlavor) override
QtClipboardTransferable(const QClipboard::Mode aMode, const QMimeData *pMimeData)
bool hasInFlightChanged() const
sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor &rFlavor) override
css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override
A lazy loading QMimeData for XTransferable reads.
css::datatransfer::XTransferable * xTransferable() const
bool deepCopy(QMimeData **const) const
QStringList m_aMimeTypeList
QStringList formats() const override
const css::uno::Reference< css::datatransfer::XTransferable > m_aContents
QtMimeData(const css::uno::Reference< css::datatransfer::XTransferable > &aContents)
bool hasFormat(const QString &mimeType) const override
QVariant retrieveData(const QString &mimeType, QMetaType type) const override
QtTransferable classes are used to read QMimeData via the XTransferable interface.
css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override
const QMimeData * mimeData() const
css::uno::Sequence< css::datatransfer::DataFlavor > m_aMimeTypeSeq
QtTransferable(const QMimeData *pMimeData)
const QMimeData * m_pMimeData
css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor &rFlavor) override
sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor &rFlavor) override
QtTransferable(const QtTransferable &)=delete
bool m_bProvideUTF16FromOtherEncoding
QtTransferable QtDnDTransferable
Convenience typedef for better code readability.
unsigned char sal_Bool