summaryrefslogtreecommitdiffstats
path: root/vcl/inc/qt5/QtTransferable.hxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 11:47:06 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 11:47:06 +0000
commit8ceff95c69cf9bd9ff5ab3a4b5689925b8bd6a59 (patch)
treeca2b0cc4fba88107f5f6e740285184a061011866 /vcl/inc/qt5/QtTransferable.hxx
parentAdding debian version 4:24.2.3-2. (diff)
downloadlibreoffice-8ceff95c69cf9bd9ff5ab3a4b5689925b8bd6a59.tar.xz
libreoffice-8ceff95c69cf9bd9ff5ab3a4b5689925b8bd6a59.zip
Merging upstream version 4:24.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/inc/qt5/QtTransferable.hxx')
-rw-r--r--vcl/inc/qt5/QtTransferable.hxx31
1 files changed, 22 insertions, 9 deletions
diff --git a/vcl/inc/qt5/QtTransferable.hxx b/vcl/inc/qt5/QtTransferable.hxx
index 5f1533dd59..5687fa06df 100644
--- a/vcl/inc/qt5/QtTransferable.hxx
+++ b/vcl/inc/qt5/QtTransferable.hxx
@@ -34,13 +34,23 @@ class QtTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransfera
QtTransferable(const QtTransferable&) = delete;
const QMimeData* m_pMimeData;
- osl::Mutex m_aMutex;
- bool m_bProvideUTF16FromOtherEncoding;
- css::uno::Sequence<css::datatransfer::DataFlavor> m_aMimeTypeSeq;
+
+protected:
+ /** Sets new mime data.
+ * Since data flavors supported by this class depend on the mime data,
+ * results from previous calls to the public methods of this
+ * class are no longer valid after setting new mime data using this method.
+ *
+ * Subclasses that set new mime data must ensure that no data race exists
+ * on m_pMimeData.
+ * (For the current only subclass doing so, QtClipboardTransferable, all access
+ * to m_pMimeData happens with the SolarMutex held.)
+ */
+ void setMimeData(const QMimeData* pMimeData) { m_pMimeData = pMimeData; }
+ const QMimeData* mimeData() const { return m_pMimeData; }
public:
QtTransferable(const QMimeData* pMimeData);
- const QMimeData* mimeData() const { return m_pMimeData; }
css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors() override;
sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor) override;
@@ -54,21 +64,24 @@ public:
* the QClipboard's object thread, which is the QApplication's thread, so all of
* the access has to go through RunInMainThread().
*
- * If we detect a QMimeData change, we simply drop reporting any content. In theory
- * we can recover in the case where there hadn't been any calls of the XTransferable
- * interface, but currently we don't. But we ensure to never report mixed content,
- * so we'll just cease operation on QMimeData change.
+ * If we detect a QMimeData change, the mime data is updated with the new one from
+ * the system clipboard. Note however that this means that results of any previous
+ * calls of the XTransferable interface will be out of sync with the newly set mime
+ * data, so this scenario should generally be avoided.
**/
class QtClipboardTransferable final : public QtTransferable
{
// to detect in-flight QMimeData changes
const QClipboard::Mode m_aMode;
- bool hasInFlightChanged() const;
+ void ensureConsistencyWithSystemClipboard();
public:
explicit QtClipboardTransferable(const QClipboard::Mode aMode, const QMimeData* pMimeData);
+ // whether pMimeData are the current mime data
+ bool hasMimeData(const QMimeData* pMimeData) const;
+
// these are the same then QtTransferable, except they go through RunInMainThread
css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors() override;
sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor) override;