[Libreoffice-commits] core.git: sfx2/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Fri Feb 26 05:21:32 UTC 2021
sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 26 ++++++++++++++++++++
1 file changed, 26 insertions(+)
New commits:
commit c32b19185a32d5e531b7b785f6977580f187b479
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Feb 23 22:04:30 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Feb 26 06:19:55 2021 +0100
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 at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
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);
More information about the Libreoffice-commits
mailing list