diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-02-05 16:17:47 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-02-11 00:31:47 +0100 |
commit | 00aada5051e11e70f0da023fbb57c76ff3f0cba2 (patch) | |
tree | 3793ef97548c2e5865829743c909ffdc1f04db7a /svx | |
parent | 79797620e4010453fc6ef0da73d9dc154ee3e015 (diff) |
devtools: use xInvocation to get values of all property types
Without XInvocation we could only get the values of XPropertySet
type of properties. XInvocation however supports getting values
of all types of properties as it can invoke any kind of methods.
Change-Id: I1f6c7b932b8bc554bcf6600a8c9eef81b7b2cfa5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110464
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/devtools/DevelopmentToolDockingWindow.cxx | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx b/svx/source/devtools/DevelopmentToolDockingWindow.cxx index 113b1b05baea..f32d974a42dd 100644 --- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx +++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx @@ -27,6 +27,9 @@ #include <com/sun/star/reflection/XIdlReflection.hpp> #include <com/sun/star/reflection/XIdlMethod.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/script/Invocation.hpp> + #include <comphelper/processfactory.hxx> #include <sfx2/dispatch.hxx> @@ -362,29 +365,33 @@ public: uno::Reference<beans::XIntrospection> xIntrospection = beans::theIntrospection::get(mxContext); auto xIntrospectionAccess = xIntrospection->inspect(uno::makeAny(mxObject)); + auto xInvocationFactory = css::script::Invocation::create(mxContext); + uno::Sequence<uno::Any> aParameters = { uno::Any(mxObject) }; + auto xInvocationInterface = xInvocationFactory->createInstanceWithArguments(aParameters); + uno::Reference<script::XInvocation> xInvocation(xInvocationInterface, uno::UNO_QUERY); const auto xProperties = xIntrospectionAccess->getProperties( beans::PropertyConcept::ALL - beans::PropertyConcept::DANGEROUS); - uno::Reference<beans::XPropertySet> xPropertySet(mxObject, uno::UNO_QUERY); - for (auto const& xProperty : xProperties) { OUString aValue; uno::Any aAny; uno::Reference<uno::XInterface> xCurrent = mxObject; - if (xPropertySet.is()) + + try { - try + if (xInvocation->hasProperty(xProperty.Name)) { - aAny = xPropertySet->getPropertyValue(xProperty.Name); + aAny = xInvocation->getValue(xProperty.Name); aValue = AnyToString(aAny, mxContext); } - catch (const beans::UnknownPropertyException&) - { - aValue = "UnknownPropertyException"; - } } + catch (...) + { + aValue = "<?>"; + } + bool bComplex = false; if (aAny.hasValue()) { @@ -409,6 +416,7 @@ public: pTree, rParent, *pCurrent, new ObjectInspectorNamedNode(xProperty.Name, xCurrent), false); } + if (!aValue.isEmpty()) { pTree->set_text(*pCurrent, aValue, 1); @@ -652,4 +660,5 @@ void DevelopmentToolDockingWindow::introspect(uno::Reference<uno::XInterface> co mpClassListBox->thaw(); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |