office-gobmx/unotools/source/misc/defaultencoding.cxx
Mike Kaganski ac0112ecef tdf#132796: use LO language settings to set default XLS language
This partially reverts fixes for i#63105 and i#71033, i.e. parts of
commits 6ca96e7aee and
35777f0b40.

Instead of using hard-coded Win-1252 for Excel files by default, use
LibreOffice locale language or default document language (as used for
old WMF, DXF and RTF files - see
20f6a6b159,
1a9a77f84c, and
f26bbdb386).

When a font in XLS specifies ANSI_CHARSET (0), allow using the default
encoding, not the corresponding Win-1252. This mimics Excel behaviour
for such fonts.

Do not use first font's encoding as file default encoding, as Excel
doesn't do that.

Do not consider font-specified encoding in ImportExcel::Rstring to
mimic Excel behaviour for cell number formats (but keep using it in
ImportExcel::ReadLabel for cell content).

Change-Id: I9860013a1244dc12f06f30c81a67909012c04913
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93612
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-05-07 12:23:40 +02:00

33 lines
1.1 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*/
#include <sal/config.h>
#include <unotools/configmgr.hxx>
#include <unotools/defaultencoding.hxx>
#include <officecfg/Office/Linguistic.hxx>
#include <officecfg/Setup.hxx>
#include <officecfg/System.hxx>
OUString utl_getLocaleForGlobalDefaultEncoding()
{
if (utl::ConfigManager::IsFuzzing())
return "en-US";
// First try document default language
OUString result(officecfg::Office::Linguistic::General::DefaultLocale::get());
// Fallback to LO locale
if (result.isEmpty())
result = officecfg::Setup::L10N::ooSetupSystemLocale::get();
// Fallback to system locale
if (result.isEmpty())
result = officecfg::System::L10N::Locale::get();
return result;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */