summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-02-18 12:02:06 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-22 06:29:00 +0100
commitfed778b1cf85b100d5744ceffabb08a3d1243271 (patch)
tree1d0b59fe9246208600d8d861a417eaf2449d3f8f /sfx2
parent883607d55154eadbc4fa8d1920500af1060ee69e (diff)
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@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/devtools/ObjectInspectorTreeHandler.cxx81
1 files changed, 79 insertions, 2 deletions
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));
}
}