tdf#142600 - List tables in order of their appearance

Change-Id: I1e653bf3a646161825b465ea2fc20ab48308f0ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116767
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index f7c6cecc..b98a9a1 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -239,6 +239,7 @@ public:
    SC_DLLPUBLIC iterator begin();
    SC_DLLPUBLIC iterator end();
    SC_DLLPUBLIC size_t size() const;
    SC_DLLPUBLIC size_t index_size() const;
    bool empty() const;

    /** Insert object into set.
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 7987b8a..5465a28 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -801,6 +801,11 @@ size_t ScRangeName::size() const
    return m_Data.size();
}

size_t ScRangeName::index_size() const
{
    return maIndexToData.size();
}

bool ScRangeName::empty() const
{
    return m_Data.empty();
diff --git a/sc/source/ui/miscdlgs/linkarea.cxx b/sc/source/ui/miscdlgs/linkarea.cxx
index 480347e..1deb977 100644
--- a/sc/source/ui/miscdlgs/linkarea.cxx
+++ b/sc/source/ui/miscdlgs/linkarea.cxx
@@ -250,11 +250,15 @@ void ScLinkedAreaDlg::UpdateSourceRanges()
            m_xLbRanges->append_text("CSV_all");
        }

        ScAreaNameIterator aIter(m_pSourceShell->GetDocument());
        ScRange aDummy;
        OUString aName;
        while ( aIter.Next( aName, aDummy ) )
            m_xLbRanges->append_text(aName);
        // tdf#142600 - list tables in order of their appearance in the document's source
        const ScRangeName* pRangeName = m_pSourceShell->GetDocument().GetRangeName();
        for (size_t i = 1; i <= pRangeName->index_size(); i++)
        {
            if (const ScRangeData* pRangeData = pRangeName->findByIndex(i))
            {
                m_xLbRanges->append_text(pRangeData->GetName());
            }
        }
    }

    m_xLbRanges->thaw();