tdf#100352 sfx classification: support localized policy files

The example policy is at:

instdir/share/classification/example.xml

If there is a localized version, e.g.:

instdir/share/classification/example_hu-HU.xml

(same syntax as already used for the autocorrect files), then use that
instead of the configured policy.

Change-Id: I0369e69f90a633af0676981f0c5760f8477b3c8c
Reviewed-on: https://gerrit.libreoffice.org/26535
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index f7357a4..cda045f 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -33,6 +33,7 @@
#include <tools/datetime.hxx>
#include <unotools/datetime.hxx>
#include <vcl/layout.hxx>
#include <svl/fstathelper.hxx>
#include <config_folders.h>

using namespace com::sun::star;
@@ -355,6 +356,19 @@ void SfxClassificationHelper::Impl::parsePolicy()
    uno::Reference<uno::XComponentContext> xComponentContext = comphelper::getProcessComponentContext();
    SvtPathOptions aOptions;
    OUString aPath = aOptions.GetClassificationPath();

    // See if there is a localized variant next to the configured XML.
    OUString aExtension(".xml");
    if (aPath.endsWith(aExtension))
    {
        OUString aBase = aPath.copy(0, aPath.getLength() - aExtension.getLength());
        const LanguageTag& rLanguageTag = Application::GetSettings().GetLanguageTag();
        // Expected format is "<original path>_xx-XX.xml".
        OUString aLocalized = aBase + "_" + rLanguageTag.getBcp47() + aExtension;
        if (FStatHelper::IsDocument(aLocalized))
            aPath = aLocalized;
    }

    SvStream* pStream = utl::UcbStreamHelper::CreateStream(aPath, StreamMode::READ);
    uno::Reference<io::XInputStream> xInputStream(new utl::OStreamWrapper(*pStream));
    xml::sax::InputSource aParserInput;