diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-02-23 22:04:30 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-02-26 06:19:55 +0100 |
commit | c32b19185a32d5e531b7b785f6977580f187b479 (patch) | |
tree | 1dde4c2c994e072c8d3fa053b3e03c7ae005f299 /sfx2 | |
parent | 958928086652c6a1c48663aa45e97f387fcf0b31 (diff) |
devtools: support XIndexAccess and XNameAccess in object inspector
If the current object in the object inspector is an container
that supports XNameAccess or XIndexAccess, we now show the named
or index values in the property view. This way the user can
navigate to sub-objects, which is sometimes needed because we get
an object supporting this intefaces, but can't navigate further.
Best example would be XShapeCollection, which is what you get when
selecting a shape (because with a selection we can select multiple
shapes), but it is not possible to navigate to the shape without
this change.
Change-Id: I6a18723eccbc41519e3eacf68bc5b6488e02fe22
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111529
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx index e672d256fbe6..98ed6cd2bae4 100644 --- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx +++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx @@ -30,6 +30,8 @@ #include <com/sun/star/reflection/XEnumTypeDescription.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/script/XInvocation.hpp> #include <com/sun/star/script/Invocation.hpp> @@ -483,6 +485,30 @@ void GenericPropertiesNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree, if (!maAny.hasValue()) return; + const auto xNameAccess = uno::Reference<container::XNameAccess>(maAny, uno::UNO_QUERY); + if (xNameAccess.is()) + { + const uno::Sequence<OUString> aNames = xNameAccess->getElementNames(); + for (OUString const& rName : aNames) + { + uno::Any aAny = xNameAccess->getByName(rName); + auto* pObjectInspectorNode = createNodeObjectForAny("@" + rName, aAny); + lclAppendNodeToParent(pTree, pParent, pObjectInspectorNode); + } + } + + const auto xIndexAccess = uno::Reference<container::XIndexAccess>(maAny, uno::UNO_QUERY); + if (xIndexAccess.is()) + { + for (sal_Int32 nIndex = 0; nIndex < xIndexAccess->getCount(); ++nIndex) + { + uno::Any aAny = xIndexAccess->getByIndex(nIndex); + auto* pObjectInspectorNode + = createNodeObjectForAny("@" + OUString::number(nIndex), aAny); + lclAppendNodeToParent(pTree, pParent, pObjectInspectorNode); + } + } + uno::Reference<beans::XIntrospection> xIntrospection = beans::theIntrospection::get(mxContext); auto xIntrospectionAccess = xIntrospection->inspect(maAny); auto xInvocationFactory = css::script::Invocation::create(mxContext); |