sc/source/ui/xmlsource/xmlsourcedlg.cxx |   34 ++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

New commits:
commit 4d9a8f07b77917b0756dc2d8d8082c6e63e560a2
Author:     Kohei Yoshida <ko...@libreoffice.org>
AuthorDate: Mon Feb 13 22:12:59 2023 -0500
Commit:     Kohei Yoshida <ko...@libreoffice.org>
CommitDate: Tue Feb 14 04:09:44 2023 +0000

    tdf#153604: include the root element when traversing the tree
    
    Change-Id: I35098e687eea832c075f68861e04be7b492ed25e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146966
    Tested-by: Jenkins
    Reviewed-by: Kohei Yoshida <ko...@libreoffice.org>

diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx 
b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 902c8c0a0bec..663db63475d8 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -448,31 +448,33 @@ void getFieldLinks(
     ScOrcusImportXMLParam::RangeLink& rRangeLink, std::vector<size_t>& 
rNamespaces,
     const weld::TreeView& rTree, const weld::TreeIter& rEntry)
 {
+    OUString aPath = getXPath(rTree, rEntry, rNamespaces);
+    const ScOrcusXMLTreeParam::EntryData* pUserData = 
ScOrcusXMLTreeParam::getUserData(rTree, rEntry);
+
+    if (pUserData)
+    {
+        if (pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat)
+            // nested repeat element automatically becomes a row-group node.
+            rRangeLink.maRowGroups.push_back(
+                OUStringToOString(aPath, RTL_TEXTENCODING_UTF8));
+
+        if (pUserData->mbLeafNode && !aPath.isEmpty())
+            // XPath should never be empty anyway, but it won't hurt to 
check...
+            rRangeLink.maFieldPaths.push_back(OUStringToOString(aPath, 
RTL_TEXTENCODING_UTF8));
+    }
+
     std::unique_ptr<weld::TreeIter> xChild(rTree.make_iterator(&rEntry));
+
     if (!rTree.iter_children(*xChild))
         // No more children.  We're done.
         return;
 
     do
     {
-        OUString aPath = getXPath(rTree, *xChild, rNamespaces);
-        const ScOrcusXMLTreeParam::EntryData* pUserData = 
ScOrcusXMLTreeParam::getUserData(rTree, *xChild);
-
-        if (pUserData)
-        {
-            if (pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat)
-                // nested repeat element automatically becomes a row-group 
node.
-                rRangeLink.maRowGroups.push_back(
-                    OUStringToOString(aPath, RTL_TEXTENCODING_UTF8));
-
-            if (pUserData->mbLeafNode && !aPath.isEmpty())
-                // XPath should never be empty anyway, but it won't hurt to 
check...
-                rRangeLink.maFieldPaths.push_back(OUStringToOString(aPath, 
RTL_TEXTENCODING_UTF8));
-        }
-
         // Walk recursively.
         getFieldLinks(rRangeLink, rNamespaces, rTree, *xChild);
-    } while (rTree.iter_next_sibling(*xChild));
+    }
+    while (rTree.iter_next_sibling(*xChild));
 }
 
 void removeDuplicates(std::vector<size_t>& rArray)

Reply via email to