desktop/source/lib/init.cxx |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 620cf04907360ce39a03dc2b9f97ac437cdf9a8e
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Jun 2 12:16:29 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Thu Jun 2 13:07:37 2022 +0200

    fix handling of XTransferable2 if the type is only XTransferable
    
    Apparently some selections provide only XTransferable and not
    XTransferable2, making this entire call think that there's no
    selection at all. Handle that properly, and if XTransferable2
    is not provided, then presumably it's not important to check
    for isComplex().
    
    Change-Id: I3bbafe46a6b9ac8552c62e524137e1691b54895a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135300
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e5b0412d7cef..c833bc817c0d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4667,14 +4667,15 @@ static int doc_getSelectionType(LibreOfficeKitDocument* 
pThis)
         return LOK_SELTYPE_NONE;
     }
 
-    css::uno::Reference<css::datatransfer::XTransferable2> 
xTransferable(pDoc->getSelection(), css::uno::UNO_QUERY);
+    css::uno::Reference<css::datatransfer::XTransferable> xTransferable = 
pDoc->getSelection();
     if (!xTransferable)
     {
         SetLastExceptionMsg("No selection available");
         return LOK_SELTYPE_NONE;
     }
 
-    if (xTransferable->isComplex())
+    css::uno::Reference<css::datatransfer::XTransferable2> 
xTransferable2(xTransferable, css::uno::UNO_QUERY);
+    if (xTransferable2.is() && xTransferable2->isComplex())
         return LOK_SELTYPE_COMPLEX;
 
     OString aRet;
@@ -4704,14 +4705,15 @@ static int 
doc_getSelectionTypeAndText(LibreOfficeKitDocument* pThis, const char
         return LOK_SELTYPE_NONE;
     }
 
-    css::uno::Reference<css::datatransfer::XTransferable2> 
xTransferable(pDoc->getSelection(), css::uno::UNO_QUERY);
+    css::uno::Reference<css::datatransfer::XTransferable> xTransferable = 
pDoc->getSelection();
     if (!xTransferable)
     {
         SetLastExceptionMsg("No selection available");
         return LOK_SELTYPE_NONE;
     }
 
-    if (xTransferable->isComplex())
+    css::uno::Reference<css::datatransfer::XTransferable2> 
xTransferable2(xTransferable, css::uno::UNO_QUERY);
+    if (xTransferable2.is() && xTransferable2->isComplex())
         return LOK_SELTYPE_COMPLEX;
 
     const char *pType = pMimeType;

Reply via email to