diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx index b536c4a084f4..87e92573fe36 100644 --- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx +++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -230,6 +231,16 @@ public: { } + bool shouldShowExpander() override + { + if (maAny.hasValue()) + { + auto xInterface = uno::Reference(maAny, uno::UNO_QUERY); + return xInterface.is(); + } + return false; + } + OUString getObjectName() override { return msName; } void fillChildren(std::unique_ptr& /*rTree*/, @@ -286,8 +297,6 @@ public: { } - bool shouldShowExpander() override { return true; } - void fillChildren(std::unique_ptr& pTree, weld::TreeIter const& rParent) override; }; @@ -300,6 +309,8 @@ public: : GenericPropertiesNode("Properties", xObject, uno::Any(), xContext) { } + + bool shouldShowExpander() override { return true; } }; class InterfacesNode : public ObjectInspectorNamedNode @@ -358,9 +369,78 @@ public: } }; +class SequenceNode : public ObjectInspectorNodeInterface +{ +private: + OUString maString; + uno::Any maAny; + uno::Reference mxContext; + +public: + SequenceNode(OUString const& rString, uno::Any const& rAny, + uno::Reference const& xContext) + : maString(rString) + , maAny(rAny) + , mxContext(xContext) + { + } + + bool shouldShowExpander() override { return true; } + + OUString getObjectName() override { return maString; } + + void fillChildren(std::unique_ptr& pTree, + weld::TreeIter const& rParent) override + { + auto xReflection = reflection::theCoreReflection::get(mxContext); + uno::Reference xClass + = xReflection->forName(maAny.getValueType().getTypeName()); + uno::Reference xIdlArray = xClass->getArray(); + + int nLength = xIdlArray->getLen(maAny); + + for (int i = 0; i < nLength; i++) + { + uno::Any aCurrentAny = xIdlArray->get(maAny, i); + uno::Reference xCurrent; + if (aCurrentAny.hasValue()) + { + auto xInterface = uno::Reference(aCurrentAny, uno::UNO_QUERY); + if (xInterface.is()) + xCurrent = xInterface; + } + + lclAppendNodeToParent( + pTree, rParent, + new GenericPropertiesNode(OUString::number(i), xCurrent, aCurrentAny, mxContext)); + } + } + + std::vector> getColumnValues() override + { + auto xReflection = reflection::theCoreReflection::get(mxContext); + uno::Reference xClass + = xReflection->forName(maAny.getValueType().getTypeName()); + uno::Reference xIdlArray = xClass->getArray(); + + int nLength = xIdlArray->getLen(maAny); + + OUString aValue = "0 to " + OUString::number(nLength - 1); + OUString aType = getAnyType(maAny, mxContext); + + return { + { 1, aValue }, + { 2, aType }, + }; + } +}; + void GenericPropertiesNode::fillChildren(std::unique_ptr& pTree, weld::TreeIter const& rParent) { + if (!mxObject.is()) + return; + uno::Reference xIntrospection = beans::theIntrospection::get(mxContext); auto xIntrospectionAccess = xIntrospection->inspect(uno::makeAny(mxObject)); auto xInvocationFactory = css::script::Invocation::create(mxContext); @@ -398,12 +478,19 @@ void GenericPropertiesNode::fillChildren(std::unique_ptr& pTree, } } + uno::TypeClass eTypeClass = aAny.getValueType().getTypeClass(); + if (bComplex) { lclAppendNodeToParent( pTree, rParent, new GenericPropertiesNode(xProperty.Name, xCurrent, aAny, mxContext)); } + else if (eTypeClass == uno::TypeClass_SEQUENCE) + { + lclAppendNodeToParent(pTree, rParent, + new SequenceNode(xProperty.Name, aAny, mxContext)); + } else { lclAppendNodeToParent( @@ -412,6 +499,7 @@ void GenericPropertiesNode::fillChildren(std::unique_ptr& pTree, } } } + } // end anonymous namespace ObjectInspectorTreeHandler::ObjectInspectorTreeHandler(