sfx2/source/devtools/ObjectInspectorTreeHandler.cxx |   46 +++++++++-----------
 1 file changed, 21 insertions(+), 25 deletions(-)

New commits:
commit 9f72f662d7ac2fbd5131ecf65be93aa001b720c9
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Mar 5 19:53:28 2021 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Mar 12 16:03:12 2021 +0100

    devtools: use XInvocation2 to get the available properties
    
    XIntrospection is not needed as XInvocation can provide a list of
    available properties by itself and we need XInvocation to get the
    property value. So this change removes XIntrospection and
    simplifies the code a bit.
    
    Change-Id: Ic274c87c9c274a05537715b5f19662a7ceaeb2b8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112116
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx 
b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
index 5dbbb00a0844..0466f252166e 100644
--- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
+++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
@@ -34,8 +34,9 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XEnumerationAccess.hpp>
 
-#include <com/sun/star/script/XInvocation.hpp>
 #include <com/sun/star/script/Invocation.hpp>
+#include <com/sun/star/script/XInvocation2.hpp>
+#include <com/sun/star/script/MemberType.hpp>
 
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/XTypeProvider.hpp>
@@ -522,40 +523,35 @@ void 
GenericPropertiesNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree,
         }
     }
 
-    uno::Reference<beans::XIntrospection> xIntrospection = 
beans::theIntrospection::get(mxContext);
-    if (!xIntrospection.is())
-        return;
-
-    auto xIntrospectionAccess = xIntrospection->inspect(maAny);
-    if (!xIntrospectionAccess.is())
-        return;
-
     auto xInvocationFactory = css::script::Invocation::create(mxContext);
     uno::Sequence<uno::Any> aParameters = { maAny };
     auto xInvocationInterface = 
xInvocationFactory->createInstanceWithArguments(aParameters);
-    uno::Reference<script::XInvocation> xInvocation(xInvocationInterface, 
uno::UNO_QUERY);
+    if (!xInvocationInterface.is())
+        return;
 
-    const auto xProperties = xIntrospectionAccess->getProperties(
-        beans::PropertyConcept::ALL - beans::PropertyConcept::DANGEROUS);
+    uno::Reference<script::XInvocation2> xInvocation(xInvocationInterface, 
uno::UNO_QUERY);
+    if (!xInvocation.is())
+        return;
 
-    for (auto const& xProperty : xProperties)
+    const auto aInvocationInfoSequence = xInvocation->getInfo();
+    for (auto const& aInvocationInfo : aInvocationInfoSequence)
     {
-        uno::Any aCurrentAny;
-
-        try
+        if (aInvocationInfo.eMemberType == script::MemberType_PROPERTY)
         {
-            if (xInvocation->hasProperty(xProperty.Name))
+            uno::Any aCurrentAny;
+            auto const& aPropertyName = aInvocationInfo.aName;
+            try
+            {
+                aCurrentAny = xInvocation->getValue(aPropertyName);
+            }
+            catch (...)
             {
-                aCurrentAny = xInvocation->getValue(xProperty.Name);
             }
-        }
-        catch (...)
-        {
-        }
 
-        auto* pObjectInspectorNode = createNodeObjectForAny(xProperty.Name, 
aCurrentAny);
-        if (pObjectInspectorNode)
-            lclAppendNodeToParent(pTree, pParent, pObjectInspectorNode);
+            auto* pObjectInspectorNode = createNodeObjectForAny(aPropertyName, 
aCurrentAny);
+            if (pObjectInspectorNode)
+                lclAppendNodeToParent(pTree, pParent, pObjectInspectorNode);
+        }
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to