devtools: add "Type" column to object inspector

Change-Id: I45a9efbf8f99ba86e0fa6f2e6fb9c74ac11b5aeb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110736
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Tomaž Vajngerl
2021-02-09 19:29:50 +09:00
committed by Tomaž Vajngerl
parent 5a3b9b4b34
commit 07f8efa33f
2 changed files with 32 additions and 70 deletions

View File

@@ -55,7 +55,7 @@ TypeToIdlClass(const uno::Type& rType, const uno::Reference<uno::XComponentConte
return xRetClass;
}
OUString AnyToString(const uno::Any& aValue, const uno::Reference<uno::XComponentContext>& xContext)
OUString AnyToString(const uno::Any& aValue)
{
uno::Type aValType = aValue.getValueType();
uno::TypeClass eType = aValType.getTypeClass();
@@ -63,69 +63,6 @@ OUString AnyToString(const uno::Any& aValue, const uno::Reference<uno::XComponen
OUString aRetStr;
switch (eType)
{
case uno::TypeClass_TYPE:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <TYPE>";
break;
}
case uno::TypeClass_INTERFACE:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <INTERFACE>";
break;
}
case uno::TypeClass_SERVICE:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <SERVICE>";
break;
}
case uno::TypeClass_STRUCT:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <STRUCT>";
break;
}
case uno::TypeClass_TYPEDEF:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <TYPEDEF>";
break;
}
case uno::TypeClass_ENUM:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <ENUM>";
break;
}
case uno::TypeClass_EXCEPTION:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <EXCEPTION>";
break;
}
case uno::TypeClass_SEQUENCE:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <SEQUENCE>";
break;
}
case uno::TypeClass_VOID:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <VOID>";
break;
}
case uno::TypeClass_ANY:
{
auto xIdlClass = TypeToIdlClass(aValType, xContext);
aRetStr = xIdlClass->getName() + " <ANY>";
break;
}
case uno::TypeClass_UNKNOWN:
aRetStr = "<Unknown>";
break;
case uno::TypeClass_BOOLEAN:
{
bool bBool = aValue.get<bool>();
@@ -186,6 +123,13 @@ OUString AnyToString(const uno::Any& aValue, const uno::Reference<uno::XComponen
return aRetStr;
}
OUString getAnyType(const uno::Any& aValue, const uno::Reference<uno::XComponentContext>& xContext)
{
uno::Type aValType = aValue.getValueType();
auto xIdlClass = TypeToIdlClass(aValType, xContext);
return xIdlClass->getName();
}
// Object inspector nodes
class ObjectInspectorNode
@@ -312,6 +256,7 @@ public:
for (auto const& xProperty : xProperties)
{
OUString aValue;
OUString aType;
uno::Any aAny;
uno::Reference<uno::XInterface> xCurrent = mxObject;
@@ -320,12 +265,14 @@ public:
if (xInvocation->hasProperty(xProperty.Name))
{
aAny = xInvocation->getValue(xProperty.Name);
aValue = AnyToString(aAny, mxContext);
aValue = AnyToString(aAny);
aType = getAnyType(aAny, mxContext);
}
}
catch (...)
{
aValue = "<?>";
aType = "?";
}
bool bComplex = false;
@@ -357,6 +304,10 @@ public:
{
pTree->set_text(*pCurrent, aValue, 1);
}
if (!aType.isEmpty())
{
pTree->set_text(*pCurrent, aType, 2);
}
}
}
};

View File

@@ -16,6 +16,8 @@
<column type="gchararray"/>
<!-- column-name value -->
<column type="gchararray"/>
<!-- column-name type -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
@@ -31,7 +33,7 @@
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="position">800</property>
<property name="position">250</property>
<property name="wide-handle">True</property>
<child>
<!-- n-columns=1 n-rows=2 -->
@@ -169,12 +171,9 @@
<property name="resizable">True</property>
<property name="title" translatable="yes" context="developmenttool|object">Object</property>
<child>
<object class="GtkCellRendererText" id="obj_insp_cellrenderertext1">
<property name="ellipsize">end</property>
</object>
<object class="GtkCellRendererText" id="obj_insp_cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
<attribute name="weight">2</attribute>
</attributes>
</child>
</object>
@@ -191,6 +190,18 @@
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="resizable">True</property>
<property name="title" translatable="yes" context="developmenttool|type">Type</property>
<child>
<object class="GtkCellRendererText" id="obj_insp_cellrenderertext3"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>