From d6a35250140d9b698a3ded4972025ae385021eab Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 4 Feb 2021 22:35:47 +0900 Subject: devtools: show properties nested if the the property is an object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the property value is an object, show the expander and allow to show properties of that object nested. Change-Id: I93edf1a47738b9d6f15949dd4116b92ee54c8f12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110463 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- .../devtools/DevelopmentToolDockingWindow.cxx | 54 ++++++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'svx') diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx b/svx/source/devtools/DevelopmentToolDockingWindow.cxx index 8c519e807125..113b1b05baea 100644 --- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx +++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx @@ -344,14 +344,14 @@ public: } }; -class PropertiesNode : public ObjectInspectorNamedNode +class GenericPropertiesNode : public ObjectInspectorNamedNode { public: uno::Reference mxContext; - PropertiesNode(css::uno::Reference const& xObject, - uno::Reference const& xContext) - : ObjectInspectorNamedNode("Properties", xObject) + GenericPropertiesNode(OUString const& rName, uno::Reference const& xObject, + uno::Reference const& xContext) + : ObjectInspectorNamedNode(rName, xObject) , mxContext(xContext) { } @@ -370,29 +370,63 @@ public: for (auto const& xProperty : xProperties) { - std::unique_ptr pCurrent = pTree->make_iterator(); - lclAppendNodeWithIterToParent(pTree, rParent, *pCurrent, - new ObjectInspectorNamedNode(xProperty.Name, mxObject)); - + OUString aValue; + uno::Any aAny; + uno::Reference xCurrent = mxObject; if (xPropertySet.is()) { - OUString aValue; try { - uno::Any aAny = xPropertySet->getPropertyValue(xProperty.Name); + aAny = xPropertySet->getPropertyValue(xProperty.Name); aValue = AnyToString(aAny, mxContext); } catch (const beans::UnknownPropertyException&) { aValue = "UnknownPropertyException"; } + } + bool bComplex = false; + if (aAny.hasValue()) + { + auto xInterface = uno::Reference(aAny, uno::UNO_QUERY); + if (xInterface.is()) + { + xCurrent = xInterface; + bComplex = true; + } + } + std::unique_ptr pCurrent = pTree->make_iterator(); + if (bComplex) + { + lclAppendNodeWithIterToParent( + pTree, rParent, *pCurrent, + new GenericPropertiesNode(xProperty.Name, xCurrent, mxContext), true); + } + else + { + lclAppendNodeWithIterToParent( + pTree, rParent, *pCurrent, + new ObjectInspectorNamedNode(xProperty.Name, xCurrent), false); + } + if (!aValue.isEmpty()) + { pTree->set_text(*pCurrent, aValue, 1); } } } }; +class PropertiesNode : public GenericPropertiesNode +{ +public: + PropertiesNode(uno::Reference const& xObject, + uno::Reference const& xContext) + : GenericPropertiesNode("Properties", xObject, xContext) + { + } +}; + class InterfacesNode : public ObjectInspectorNamedNode { public: -- cgit