[Libreoffice-commits] core.git: basic/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 23 16:15:55 UTC 2019


 basic/source/classes/sbunoobj.cxx |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 1efe1f82fabb3b8566c0beca2ba5df21c54fa6d5
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Oct 23 15:16:32 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Oct 23 18:14:37 2019 +0200

    In checkUnoObjectType, check for derived-from types too
    
    As discussed in the mail thread starting at
    <https://listarchives.libreoffice.org/global/users/msg54775.html>
    "[libreoffice-users] Experimental macro features: How to determine object
    types?", it is confusing if a variable dim'ed as
    com.sun.star.util.XSearchDescriptor cannot hold an object whose
    css.lang.XTypeProvider::getTypes only reports css.util.XReplaceDescriptor (which
    is derived from XSearchDescriptor) but not XSearchDescriptor itself.
    
    At least for now, keep the odd endsWithIgnoreAsciiCase check intact (instead of
    checking for strict equality).
    
    Change-Id: Idd8ae8cb11b0f2e9c6369842629fc5a21e1c5cc5
    Reviewed-on: https://gerrit.libreoffice.org/81386
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 0c938d6c475e..af5a3aab3da2 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -84,6 +84,7 @@
 #include <sbintern.hxx>
 #include <runtime.hxx>
 
+#include <algorithm>
 #include <math.h>
 #include <memory>
 #include <unordered_map>
@@ -1621,6 +1622,22 @@ OUString getBasicObjectTypeName( SbxObject* pObj )
     return OUString();
 }
 
+namespace {
+
+bool matchesBasicTypeName(
+    css::uno::Reference<css::reflection::XIdlClass> const & unoType, OUString const & basicTypeName)
+{
+    if (unoType->getName().endsWithIgnoreAsciiCase(basicTypeName)) {
+        return true;
+    }
+    auto const sups = unoType->getSuperclasses();
+    return std::any_of(
+        sups.begin(), sups.end(),
+        [&basicTypeName](auto const & t) { return matchesBasicTypeName(t, basicTypeName); });
+}
+
+}
+
 bool checkUnoObjectType(SbUnoObject& rUnoObj, const OUString& rClass)
 {
     Any aToInspectObj = rUnoObj.getUnoAny();
@@ -1697,8 +1714,7 @@ bool checkUnoObjectType(SbUnoObject& rUnoObj, const OUString& rClass)
                 break; // finished checking automation object
             }
 
-            // match interface name with passed class name
-            if ( aInterfaceName.endsWithIgnoreAsciiCase( aClassName ) )
+            if ( matchesBasicTypeName(xClass, aClassName) )
             {
                 bResult = true;
                 break;


More information about the Libreoffice-commits mailing list