diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-03-04 22:02:33 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-03-12 16:00:15 +0100 |
commit | 46035be60691ba799910565456a5425dd1af3e14 (patch) | |
tree | cf3838cb77647b4b0161d86effabd65a6d4d3915 | |
parent | bd0dd2589c435078d8d974e3b37da5edb5f74f9f (diff) |
devtools: allow an Any without value in object inspector
If an Any doesn't have a value, still create the object so it will
be added to the object inspector, but with "NULL" string as the
value. This is needed to show that the property is available in
this object, but it hasn't been set to a value.
Change-Id: I986ceac436434af34709bdfc0588e4d15748c20e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112111
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx index a9687635c380..1977a30ce473 100644 --- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx +++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx @@ -72,7 +72,7 @@ OUString AnyToString(const uno::Any& aValue, const uno::Reference<uno::XComponen // return early if we don't have any value if (!aValue.hasValue()) - return aRetStr; + return "NULL"; uno::Type aValType = aValue.getValueType(); uno::TypeClass eType = aValType.getTypeClass(); @@ -81,7 +81,11 @@ OUString AnyToString(const uno::Any& aValue, const uno::Reference<uno::XComponen { case uno::TypeClass_INTERFACE: { - aRetStr = "<Object>"; + uno::Reference<uno::XInterface> xInterface(aValue, uno::UNO_QUERY); + if (!xInterface.is()) + aRetStr = "NULL"; + else + aRetStr = "<Object>"; break; } case uno::TypeClass_STRUCT: @@ -394,18 +398,13 @@ public: std::vector<std::pair<sal_Int32, OUString>> getColumnValues() override { - if (maAny.hasValue()) - { - OUString aValue = AnyToString(maAny, mxContext); - OUString aType = getAnyType(maAny, mxContext); - - return { - { 1, aValue }, - { 2, aType }, - }; - } + OUString aValue = AnyToString(maAny, mxContext); + OUString aType = getAnyType(maAny, mxContext); - return ObjectInspectorNodeInterface::getColumnValues(); + return { + { 1, aValue }, + { 2, aType }, + }; } }; @@ -595,9 +594,6 @@ void StructNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree, const weld ObjectInspectorNodeInterface* BasicValueNode::createNodeObjectForAny(OUString const& rName, uno::Any& rAny) { - if (!rAny.hasValue()) - return nullptr; - switch (rAny.getValueType().getTypeClass()) { case uno::TypeClass_INTERFACE: |