sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+)
New commits: commit c32b19185a32d5e531b7b785f6977580f187b479 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Feb 23 22:04:30 2021 +0900 Commit: Tomaž Vajngerl <qui...@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 <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits