[Libreoffice-commits] core.git: sfx2/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 22 05:29:46 UTC 2021
sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 81 +++++++++++++++++++-
1 file changed, 79 insertions(+), 2 deletions(-)
New commits:
commit fed778b1cf85b100d5744ceffabb08a3d1243271
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Feb 18 12:02:06 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Feb 22 06:29:00 2021 +0100
devtools: add MethodNode to show the column values for methods
This adds the MethodNode, which uses reflection to get the info
for a perticular method - mainly the return type and input/output
parameters. The types have been simplified for this view.
Change-Id: I81f895d3cdf1472ae4b21227572b7ccfad607018
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111094
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 6ea018564865..39f2d70eb06a 100644
--- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
+++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
@@ -268,6 +268,84 @@ public:
OUString getObjectName() override { return msName; }
};
+class MethodNode : public ObjectInspectorNodeInterface
+{
+private:
+ uno::Reference<reflection::XIdlMethod> mxMethod;
+
+public:
+ MethodNode(uno::Reference<reflection::XIdlMethod> const& xMethod)
+ : mxMethod(xMethod)
+ {
+ }
+
+ OUString getObjectName() override { return mxMethod->getName(); }
+
+ static OUString simpleTypeName(uno::Reference<reflection::XIdlClass> const& xClass)
+ {
+ switch (xClass->getTypeClass())
+ {
+ case uno::TypeClass_INTERFACE:
+ return "object";
+ case uno::TypeClass_STRUCT:
+ return "struct";
+ case uno::TypeClass_ENUM:
+ return "enum";
+ case uno::TypeClass_SEQUENCE:
+ return "sequence";
+ default:
+ break;
+ }
+ return xClass->getName();
+ }
+
+ std::vector<std::pair<sal_Int32, OUString>> getColumnValues() override
+ {
+ OUString aInString;
+ OUString aOutString;
+
+ auto xClass = mxMethod->getReturnType();
+ aOutString = simpleTypeName(xClass);
+
+ const auto aParameters = mxMethod->getParameterInfos();
+ bool bFirst = true;
+ for (auto const& rParameterInfo : aParameters)
+ {
+ if (!bFirst)
+ aInString += ", ";
+ else
+ bFirst = false;
+
+ switch (rParameterInfo.aMode)
+ {
+ case reflection::ParamMode_IN:
+ aInString += "[in] ";
+ break;
+ case reflection::ParamMode_OUT:
+ aInString += "[out] ";
+ break;
+ case reflection::ParamMode_INOUT:
+ aInString += "[in&out] ";
+ break;
+ default:
+ break;
+ }
+
+ aInString += rParameterInfo.aName + " : " + simpleTypeName(rParameterInfo.aType);
+ }
+
+ return {
+ { 1, aOutString },
+ { 2, aInString },
+ };
+ }
+
+ void fillChildren(std::unique_ptr<weld::TreeView>& /*rTree*/,
+ const weld::TreeIter* /*pParent*/) override
+ {
+ }
+};
+
class BasicValueNode : public SimpleStringNode
{
protected:
@@ -626,8 +704,7 @@ void ObjectInspectorTreeHandler::appendMethods(uno::Reference<uno::XInterface> c
const auto xMethods = xIntrospectionAccess->getMethods(beans::MethodConcept::ALL);
for (auto const& xMethod : xMethods)
{
- OUString aMethodName = xMethod->getName();
- lclAppendNode(mpMethodsTreeView, new SimpleStringNode(aMethodName));
+ lclAppendNode(mpMethodsTreeView, new MethodNode(xMethod));
}
}
More information about the Libreoffice-commits
mailing list