extract NaturalSortCompare from ListBox

Change-Id: I260c83778aea06eba9ae774739c6dc31fe5366d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88613
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx
index 3cf7d2d..f002c7d 100644
--- a/include/vcl/lstbox.hxx
+++ b/include/vcl/lstbox.hxx
@@ -276,8 +276,6 @@ public:

    void EnableQuickSelection( bool b );

    static sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB);

    virtual FactoryFunction GetUITestFactory() const override;

    virtual boost::property_tree::ptree DumpAsPropertyTree() override;
diff --git a/include/vcl/naturalsort.hxx b/include/vcl/naturalsort.hxx
new file mode 100644
index 0000000..852c847
--- /dev/null
+++ b/include/vcl/naturalsort.hxx
@@ -0,0 +1,19 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#pragma once

#include <vcl/dllapi.h>

namespace vcl
{
VCL_DLLPUBLIC sal_Int32 NaturalSortCompare(const OUString& rA, const OUString& rB);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx
index 218f987..c9c5191 100644
--- a/sw/inc/pch/precompiled_sw.hxx
+++ b/sw/inc/pch/precompiled_sw.hxx
@@ -13,7 +13,7 @@
 manual changes will be rewritten by the next run of update_pch.sh (which presumably
 also fixes all possible problems, so it's usually better to use it).

 Generated on 2020-02-05 21:00:03 using:
 Generated on 2020-02-13 15:23:10 using:
 ./bin/update_pch sw sw --cutoff=7 --exclude:system --exclude:module --include:local

 If after updating build fails, use the following command to locate conflicting headers:
@@ -68,9 +68,6 @@
#include <rtl/math.hxx>
#include <rtl/ref.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/string.h>
#include <rtl/stringconcat.hxx>
#include <rtl/stringutils.hxx>
#include <rtl/tencinfo.h>
#include <rtl/textenc.h>
#include <rtl/unload.h>
diff --git a/sw/source/uibase/inc/swcont.hxx b/sw/source/uibase/inc/swcont.hxx
index f116935..fb2d0a9 100644
--- a/sw/source/uibase/inc/swcont.hxx
+++ b/sw/source/uibase/inc/swcont.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_SW_SOURCE_UIBASE_INC_SWCONT_HXX

#include <rtl/ustring.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/naturalsort.hxx>

class SwContentType;

@@ -92,7 +92,7 @@ public:
        // at first sort by position and then by name
        if (nYPosition != rCont.nYPosition)
            return nYPosition < rCont.nYPosition;
        return ListBox::NaturalSortCompare(sContentName, rCont.sContentName) < 0;
        return vcl::NaturalSortCompare(sContentName, rCont.sContentName) < 0;
    }

    bool        IsInvisible() const {return bInvisible;}
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index c1ad5e8..c4486f92 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -25,6 +25,7 @@
#include <vcl/scrbar.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/i18nhelp.hxx>
#include <vcl/naturalsort.hxx>

#include <listbox.hxx>
#include <controldata.hxx>
@@ -110,10 +111,13 @@ namespace
    };
}

sal_Int32 ListBox::NaturalSortCompare(const OUString &rA, const OUString &rB)
namespace vcl
{
    const comphelper::string::NaturalStringSorter &rSorter = theSorter::get();
    return rSorter.compare(rA, rB);
    sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB)
    {
        const comphelper::string::NaturalStringSorter &rSorter = theSorter::get();
        return rSorter.compare(rA, rB);
    }
}

sal_Int32 ImplEntryList::InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry, bool bSort )
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 68bf337..2870f7a 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -23,7 +23,7 @@
#include <bitmaps.hlst>

#include <vcl/commandevent.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/naturalsort.hxx>
#include <vcl/print.hxx>
#include <vcl/wall.hxx>
#include <vcl/decoview.hxx>
@@ -57,7 +57,7 @@ enum
namespace {
   bool lcl_ListBoxCompare( const OUString& rStr1, const OUString& rStr2 )
   {
       return ListBox::NaturalSortCompare( rStr1, rStr2 ) < 0;
       return vcl::NaturalSortCompare( rStr1, rStr2 ) < 0;
   }
}