diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-10-23 15:16:32 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-10-23 18:14:37 +0200 |
commit | 1efe1f82fabb3b8566c0beca2ba5df21c54fa6d5 (patch) | |
tree | 81127fe6e74d0370d0ff7d59a1b61b0f05884bc1 /basic | |
parent | 00af5c36e16c233fe365b3da770cf420cd415c24 (diff) |
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@redhat.com>
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/sbunoobj.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
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; |