Filter out text/uri-list with empty list

...as seen at least with the Qt6 Wasm implementation (see the code comment for
details), and where, at least when trying to paste some plain text into Writer,
the LO code would then favor that faux text/uri-list over text/plain, and would
get into the

>     else if( bMsg )

branch in SwTransferable::PasteFileList (sw/source/uibase/dochdl/swdtflvr.cxx)
and try to synchronously show a message box, which for now causes an abort in
the Emscripten build

Change-Id: I64e7cf66717f29b3609c04aea3c6124279ab55de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179699
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Stephan Bergmann
2025-01-03 13:12:21 +01:00
parent fd32e497bb
commit 9c855f5e59
+13
View File
@@ -75,6 +75,19 @@ css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL QtTransferable::getTr
if (rMimeType == QStringLiteral("text/plain;charset=unicode"))
continue;
// At least the Qt6 Wasm implementation may announce text/uri-list even though the actual
// list of URLs is empty (presumably since
// <https://github.com/qt/qtbase/commit/0ffe8050bd5b55d64da37f5177a7e20dd9d14232> "wasm:
// implement async drag-and-drop" unconditionally calls setUrls in
// DataTransfer::toMimeDataWithFile's MimeContext::deref):
if (rMimeType == QStringLiteral("text/uri-list"))
{
if (m_pMimeData->urls().empty())
{
continue;
}
}
// LO doesn't like 'text/plain', so we have to provide UTF-16
bool bIsNoCharset = false, bIsUTF16 = false, bIsUTF8 = false;
if (lcl_textMimeInfo(toOUString(rMimeType), bIsNoCharset, bIsUTF16, bIsUTF8))