[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sc/qa sc/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 3 19:38:33 UTC 2019
sc/qa/unit/data/ods/tdf112567.ods |binary
sc/qa/unit/subsequent_export-test.cxx | 31 +++++++++++++++++++++++++++++++
sc/source/filter/excel/xename.cxx | 25 ++++++++++++++++++++++++-
3 files changed, 55 insertions(+), 1 deletion(-)
New commits:
commit ac8368767d3c50c46a764987bf0fd783579f3d9f
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Thu May 30 19:57:41 2019 +0200
Commit: Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Mon Jun 3 21:37:47 2019 +0200
tdf#112567 XLSX export: correct built-in names
Non-en_US locale setting resulted broken XLSX export
with incorrect localized range separator. The previous
commit 19976f079800ec4c1d0d5d7e226986cb41f834c2
"tdf#112567 XLSX export: fix broken built-in names"
only avoided of the bad export of the XSLX documents
with correct definedName.
Note: this commit fixes the bad XLSX documents
during the next import/export cycle.
Change-Id: I9101c5df0f29c7a42fd49f4c2765dcf47a711916
Reviewed-on: https://gerrit.libreoffice.org/73220
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 32a11727a0f709c11685d4200b1db08dac211dec)
Reviewed-on: https://gerrit.libreoffice.org/73381
diff --git a/sc/qa/unit/data/ods/tdf112567.ods b/sc/qa/unit/data/ods/tdf112567.ods
new file mode 100644
index 000000000000..fda79997e534
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf112567.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 94bfd5ae4f36..416fb9f32139 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -220,6 +220,7 @@ public:
void testTdf91634XLSX();
void testTdf115159();
void testTdf112567();
+ void testTdf112567b();
void testTdf123645XLSX();
void testTdf125173XLSX();
void testTdf79972XLSX();
@@ -348,6 +349,7 @@ public:
CPPUNIT_TEST(testTdf91634XLSX);
CPPUNIT_TEST(testTdf115159);
CPPUNIT_TEST(testTdf112567);
+ CPPUNIT_TEST(testTdf112567b);
CPPUNIT_TEST(testTdf123645XLSX);
CPPUNIT_TEST(testTdf125173XLSX);
CPPUNIT_TEST(testTdf79972XLSX);
@@ -4334,6 +4336,35 @@ void ScExportTest::testTdf112567()
xDocSh->DoClose();
}
+void ScExportTest::testTdf112567b()
+{
+ // 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_ODS);
+ 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);
+
+ //and it contains "," instead of ";"
+ assertXPathContent(pDoc, "/x:workbook/x:definedNames/x:definedName[1]", "Sheet1!$A:$A,Sheet1!$1:$1");
+
+ xDocSh->DoClose();
+}
+
void ScExportTest::testTdf123645XLSX()
{
ScDocShellRef xDocSh = loadDoc("chart_hyperlink.", FORMAT_XLSX);
diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx
index ee418fb80d5c..35d84b86194e 100644
--- a/sc/source/filter/excel/xename.cxx
+++ b/sc/source/filter/excel/xename.cxx
@@ -92,6 +92,8 @@ public:
private:
/** Writes the body of the NAME record to the passed stream. */
virtual void WriteBody( XclExpStream& rStrm ) override;
+ /** Convert localized range separators */
+ OUString GetWithDefaultRangeSeparator( const OUString& rSymbol ) const;
private:
OUString maOrigName; /// The original user-defined name.
@@ -294,6 +296,27 @@ void XclExpName::Save( XclExpStream& rStrm )
XclExpRecord::Save( rStrm );
}
+OUString XclExpName::GetWithDefaultRangeSeparator( const OUString& rSymbol ) const
+{
+ sal_Int32 nPos = rSymbol.indexOf(';');
+ if ( nPos > -1 )
+ {
+ // convert with validation
+ ScRange aRange;
+ ScAddress::Details detailsXL( ::formula::FormulaGrammar::CONV_XL_A1 );
+ ScRefFlags nRes = aRange.Parse( rSymbol.copy(0, nPos), &GetDocRef(), detailsXL );
+ if ( nRes & ScRefFlags::VALID )
+ {
+ nRes = aRange.Parse( rSymbol.copy(nPos+1), &GetDocRef(), detailsXL );
+ if ( nRes & ScRefFlags::VALID )
+ {
+ return rSymbol.replaceFirst(";", ",");
+ }
+ }
+ }
+ return rSymbol;
+}
+
void XclExpName::SaveXml( XclExpXmlStream& rStrm )
{
sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream();
@@ -314,7 +337,7 @@ void XclExpName::SaveXml( XclExpXmlStream& rStrm )
// OOXTODO: XML_workbookParameter, "",
// OOXTODO: XML_xlm, ""
);
- rWorkbook->writeEscaped( msSymbol );
+ rWorkbook->writeEscaped( GetWithDefaultRangeSeparator( msSymbol ) );
rWorkbook->endElement( XML_definedName );
}
More information about the Libreoffice-commits
mailing list