sfx2/source/devtools/ObjectInspectorTreeHandler.cxx |   28 ++++++++------------
 1 file changed, 12 insertions(+), 16 deletions(-)

New commits:
commit 46035be60691ba799910565456a5425dd1af3e14
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Mar 4 22:02:33 2021 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Mar 12 16:00:15 2021 +0100

    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 <qui...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

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:
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to