[Libreoffice-commits] core.git: sfx2/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 11 14:47:10 UTC 2021


 sfx2/source/devtools/ObjectInspectorTreeHandler.cxx |  141 ++++++++++----------
 1 file changed, 71 insertions(+), 70 deletions(-)

New commits:
commit 763168bde2c3b48a2849b4c917e09b559468c434
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Feb 10 16:50:26 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Feb 11 15:46:27 2021 +0100

    devtools: move impl. of GenericPropertiesNode::fillChildren out
    
    Cyclic references will become problem, so move the implementation
    of fillChildren out of GenericPropertiesNode class definition.
    
    Change-Id: I222d7c09c3ce71cbe552abcef5cc0c7e86935d34
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110737
    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 6c2105cbc63e..24e41318059f 100644
--- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
+++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
@@ -240,76 +240,7 @@ public:
     }
 
     void fillChildren(std::unique_ptr<weld::TreeView>& pTree,
-                      weld::TreeIter const& rParent) override
-    {
-        uno::Reference<beans::XIntrospection> xIntrospection
-            = beans::theIntrospection::get(mxContext);
-        auto xIntrospectionAccess = xIntrospection->inspect(uno::makeAny(mxObject));
-        auto xInvocationFactory = css::script::Invocation::create(mxContext);
-        uno::Sequence<uno::Any> aParameters = { uno::Any(mxObject) };
-        auto xInvocationInterface = xInvocationFactory->createInstanceWithArguments(aParameters);
-        uno::Reference<script::XInvocation> xInvocation(xInvocationInterface, uno::UNO_QUERY);
-
-        const auto xProperties = xIntrospectionAccess->getProperties(
-            beans::PropertyConcept::ALL - beans::PropertyConcept::DANGEROUS);
-
-        for (auto const& xProperty : xProperties)
-        {
-            OUString aValue;
-            OUString aType;
-            uno::Any aAny;
-            uno::Reference<uno::XInterface> xCurrent = mxObject;
-
-            try
-            {
-                if (xInvocation->hasProperty(xProperty.Name))
-                {
-                    aAny = xInvocation->getValue(xProperty.Name);
-                    aValue = AnyToString(aAny);
-                    aType = getAnyType(aAny, mxContext);
-                }
-            }
-            catch (...)
-            {
-                aValue = "<?>";
-                aType = "?";
-            }
-
-            bool bComplex = false;
-            if (aAny.hasValue())
-            {
-                auto xInterface = uno::Reference<uno::XInterface>(aAny, uno::UNO_QUERY);
-                if (xInterface.is())
-                {
-                    xCurrent = xInterface;
-                    bComplex = true;
-                }
-            }
-
-            std::unique_ptr<weld::TreeIter> pCurrent = pTree->make_iterator();
-            if (bComplex)
-            {
-                lclAppendNodeWithIterToParent(
-                    pTree, rParent, *pCurrent,
-                    new GenericPropertiesNode(xProperty.Name, xCurrent, mxContext), true);
-            }
-            else
-            {
-                lclAppendNodeWithIterToParent(
-                    pTree, rParent, *pCurrent,
-                    new ObjectInspectorNamedNode(xProperty.Name, xCurrent), false);
-            }
-
-            if (!aValue.isEmpty())
-            {
-                pTree->set_text(*pCurrent, aValue, 1);
-            }
-            if (!aType.isEmpty())
-            {
-                pTree->set_text(*pCurrent, aType, 2);
-            }
-        }
-    }
+                      weld::TreeIter const& rParent) override;
 };
 
 class PropertiesNode : public GenericPropertiesNode
@@ -377,6 +308,76 @@ public:
     }
 };
 
+void GenericPropertiesNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree,
+                                         weld::TreeIter const& rParent)
+{
+    uno::Reference<beans::XIntrospection> xIntrospection = beans::theIntrospection::get(mxContext);
+    auto xIntrospectionAccess = xIntrospection->inspect(uno::makeAny(mxObject));
+    auto xInvocationFactory = css::script::Invocation::create(mxContext);
+    uno::Sequence<uno::Any> aParameters = { uno::Any(mxObject) };
+    auto xInvocationInterface = xInvocationFactory->createInstanceWithArguments(aParameters);
+    uno::Reference<script::XInvocation> xInvocation(xInvocationInterface, uno::UNO_QUERY);
+
+    const auto xProperties = xIntrospectionAccess->getProperties(
+        beans::PropertyConcept::ALL - beans::PropertyConcept::DANGEROUS);
+
+    for (auto const& xProperty : xProperties)
+    {
+        OUString aValue;
+        OUString aType;
+        uno::Any aAny;
+        uno::Reference<uno::XInterface> xCurrent = mxObject;
+
+        try
+        {
+            if (xInvocation->hasProperty(xProperty.Name))
+            {
+                aAny = xInvocation->getValue(xProperty.Name);
+                aValue = AnyToString(aAny);
+                aType = getAnyType(aAny, mxContext);
+            }
+        }
+        catch (...)
+        {
+            aValue = "<?>";
+            aType = "?";
+        }
+
+        bool bComplex = false;
+        if (aAny.hasValue())
+        {
+            auto xInterface = uno::Reference<uno::XInterface>(aAny, uno::UNO_QUERY);
+            if (xInterface.is())
+            {
+                xCurrent = xInterface;
+                bComplex = true;
+            }
+        }
+
+        std::unique_ptr<weld::TreeIter> pCurrent = pTree->make_iterator();
+        if (bComplex)
+        {
+            lclAppendNodeWithIterToParent(
+                pTree, rParent, *pCurrent,
+                new GenericPropertiesNode(xProperty.Name, xCurrent, mxContext), true);
+        }
+        else
+        {
+            lclAppendNodeWithIterToParent(pTree, rParent, *pCurrent,
+                                          new ObjectInspectorNamedNode(xProperty.Name, xCurrent),
+                                          false);
+        }
+
+        if (!aValue.isEmpty())
+        {
+            pTree->set_text(*pCurrent, aValue, 1);
+        }
+        if (!aType.isEmpty())
+        {
+            pTree->set_text(*pCurrent, aType, 2);
+        }
+    }
+}
 } // end anonymous namespace
 
 ObjectInspectorTreeHandler::ObjectInspectorTreeHandler(


More information about the Libreoffice-commits mailing list