diff --git a/vcl/qt5/QtClipboard.cxx b/vcl/qt5/QtClipboard.cxx index a8cabc7664d8..ffb9425eb447 100644 --- a/vcl/qt5/QtClipboard.cxx +++ b/vcl/qt5/QtClipboard.cxx @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -24,6 +25,10 @@ #include #include +#if defined EMSCRIPTEN && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif + QtClipboard::QtClipboard(OUString aModeString, const QClipboard::Mode aMode) : cppu::WeakComponentImplHelper::get() }; + if (xTrans->isDataFlavorSupported(flav)) + { + try + { + xTrans->getTransferData(flav) >>= textContents; + } + catch (css::io::IOException) + { + TOOLS_WARN_EXCEPTION("vcl.qt", ""); + } + } + MAIN_THREAD_EM_ASM( + { + // clang-format off + try { + //TODO: Support embedded NULs: + navigator.clipboard.writeText(Module.UTF16ToString($0, 2 * $1)); + } catch (e) { + console.warn("clipboard.writeText failed:", e); + } + // clang-format on + }, + textContents.getStr(), textContents.getLength()); +#endif + // we have to notify only an owner change, since handleChanged can't // access the previous owner anymore and can just handle lost ownership. if (xOldOwner.is() && xOldOwner != xClipboardOwner)