Kaydet (Commit) 19976f07 authored tarafından László Németh's avatar László Németh

tdf#112567 XLSX export: fix broken built-in names

Localized range separators resulted broken XLSX export
with duplicated built-in names. For example, XLSX export
of a Format->Print range using Hungarian locale in LibO
raised an error message in MSO, because the export
contained the same range also with a bad semicolon:

<definedName>Sheet1!$A:$A;Sheet1!$1:$1</definedName>
<definedName>Sheet1!$A:$A,Sheet1!$1:$1</definedName>

Change-Id: Iee6ff7c5f5952fc1e736cebfc290c64a851786ab
Reviewed-on: https://gerrit.libreoffice.org/71538
Tested-by: Jenkins
Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst f07e91ac
......@@ -60,6 +60,8 @@
#include <editeng/colritem.hxx>
#include <formula/grammar.hxx>
#include <unotools/useroptions.hxx>
#include <comphelper/scopeguard.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <tools/datetime.hxx>
#include <svl/zformat.hxx>
......@@ -214,6 +216,7 @@ public:
void testTdf115192XLSX();
void testTdf91634XLSX();
void testTdf115159();
void testTdf112567();
void testTdf123645XLSX();
void testXltxExport();
......@@ -336,6 +339,7 @@ public:
CPPUNIT_TEST(testTdf115192XLSX);
CPPUNIT_TEST(testTdf91634XLSX);
CPPUNIT_TEST(testTdf115159);
CPPUNIT_TEST(testTdf112567);
CPPUNIT_TEST(testTdf123645XLSX);
CPPUNIT_TEST(testXltxExport);
......@@ -4199,6 +4203,32 @@ void ScExportTest::testTdf115159()
xDocSh->DoClose();
}
void ScExportTest::testTdf112567()
{
// Set the system locale to Hungarian (a language with different range separator)
SvtSysLocaleOptions aOptions;
aOptions.SetLocaleConfigString("hu-HU");
aOptions.Commit();
comphelper::ScopeGuard g([&aOptions] {
aOptions.SetLocaleConfigString(OUString());
aOptions.Commit();
});
ScDocShellRef xShell = loadDoc("tdf112567.", FORMAT_XLSX);
CPPUNIT_ASSERT(xShell.is());
ScDocShellRef xDocSh = saveAndReload(xShell.get(), FORMAT_XLSX);
CPPUNIT_ASSERT(xDocSh.is());
xShell->DoClose();
xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/workbook.xml", FORMAT_XLSX);
CPPUNIT_ASSERT(pDoc);
//assert the existing OOXML built-in name is not duplicated
assertXPath(pDoc, "/x:workbook/x:definedNames/x:definedName", 1);
xDocSh->DoClose();
}
void ScExportTest::testTdf123645XLSX()
{
ScDocShellRef xDocSh = loadDoc("chart_hyperlink.", FORMAT_XLSX);
......
......@@ -537,8 +537,14 @@ sal_uInt16 XclExpNameManagerImpl::FindBuiltInNameIdx(
for( size_t nPos = 0; nPos < mnFirstUserIdx; ++nPos )
{
XclExpNameRef xName = maNameList.GetRecord( nPos );
if( xName->GetBuiltInName() == cBuiltIn && xName->GetSymbol() == sSymbol )
if( xName->GetBuiltInName() == cBuiltIn && xName->GetSymbol().replace(';', ',') == sSymbol.replace(';', ',') )
{
// tdf#112567 restore the original built-in names with non-localized separators
// TODO: support more localizations, if needed
if ( xName->GetSymbol() != sSymbol )
{
xName->SetSymbol(xName->GetSymbol().replace(';', ','));
}
return static_cast< sal_uInt16 >( nPos + 1 );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment