[Libreoffice-commits] core.git: sfx2/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Fri Feb 12 10:21:47 UTC 2021
sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 81 ++++++++++++++++++++
1 file changed, 81 insertions(+)
New commits:
commit d8cfa8473c9b163747eb9172832fdbcbf886bde8
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Feb 11 16:50:19 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Feb 12 11:21:03 2021 +0100
devtools: handle structs in object inspector
Change-Id: I76dd2486c67f7098ae16f5f4f40cebf35573092e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110796
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
index 65ba40428d7b..8dbc389d2103 100644
--- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
+++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
@@ -406,6 +406,21 @@ public:
}
};
+class StructNode : public BasicValueNode
+{
+public:
+ StructNode(OUString const& rName, uno::Any const& rAny,
+ uno::Reference<uno::XComponentContext> const& xContext)
+ : BasicValueNode(rName, rAny, xContext)
+ {
+ }
+
+ bool shouldShowExpander() override { return true; }
+
+ void fillChildren(std::unique_ptr<weld::TreeView>& pTree,
+ weld::TreeIter const& rParent) override;
+};
+
class SequenceNode : public BasicValueNode
{
public:
@@ -453,6 +468,14 @@ public:
}
break;
+ case uno::TypeClass_STRUCT:
+ {
+ lclAppendNodeToParent(
+ pTree, rParent,
+ new StructNode(OUString::number(i), aCurrentAny, mxContext));
+ }
+ break;
+
default:
{
lclAppendNodeToParent(
@@ -536,6 +559,13 @@ void GenericPropertiesNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree,
}
break;
+ case uno::TypeClass_STRUCT:
+ {
+ lclAppendNodeToParent(pTree, rParent,
+ new StructNode(xProperty.Name, aCurrentAny, mxContext));
+ }
+ break;
+
default:
{
lclAppendNodeToParent(pTree, rParent,
@@ -546,6 +576,57 @@ void GenericPropertiesNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree,
}
}
+void StructNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree, weld::TreeIter const& rParent)
+{
+ auto xReflection = reflection::theCoreReflection::get(mxContext);
+ uno::Reference<reflection::XIdlClass> xClass
+ = xReflection->forName(maAny.getValueType().getTypeName());
+
+ const auto xFields = xClass->getFields();
+
+ for (auto const& xField : xFields)
+ {
+ OUString aFieldName = xField->getName();
+ uno::Any aFieldValue = xField->get(maAny);
+
+ switch (aFieldValue.getValueType().getTypeClass())
+ {
+ case uno::TypeClass_INTERFACE:
+ {
+ auto xInterface = uno::Reference<uno::XInterface>(aFieldValue, uno::UNO_QUERY);
+ if (xInterface.is())
+ {
+ lclAppendNodeToParent(
+ pTree, rParent,
+ new GenericPropertiesNode(aFieldName, aFieldValue, mxContext));
+ }
+ }
+ break;
+
+ case uno::TypeClass_SEQUENCE:
+ {
+ lclAppendNodeToParent(pTree, rParent,
+ new SequenceNode(aFieldName, aFieldValue, mxContext));
+ }
+ break;
+
+ case uno::TypeClass_STRUCT:
+ {
+ lclAppendNodeToParent(pTree, rParent,
+ new StructNode(aFieldName, aFieldValue, mxContext));
+ }
+ break;
+
+ default:
+ {
+ lclAppendNodeToParent(pTree, rParent,
+ new BasicValueNode(aFieldName, aFieldValue, mxContext));
+ }
+ break;
+ }
+ }
+}
+
} // end anonymous namespace
ObjectInspectorTreeHandler::ObjectInspectorTreeHandler(
More information about the Libreoffice-commits
mailing list