diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-21 09:16:26 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-06-21 13:56:10 +0000 |
commit | c9a16da8617634955eacded60083bec7ffd8b58b (patch) | |
tree | 54f170a7932fccbabd446039e10e1a0c5905651c /sfx2/source | |
parent | 204a2800c8ba3ed35f81ab295e43d9a3e79c7925 (diff) |
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.
(cherry picked from commit 1811e656f08ba011a3c2a51cc60e90d2fa58e4c2)
Change-Id: I0369e69f90a633af0676981f0c5760f8477b3c8c
Reviewed-on: https://gerrit.libreoffice.org/26549
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/view/classificationhelper.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index 0c93e93dd636..8a3bc96238af 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; |