summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-05-30 19:57:41 +0200
committerXisco Faulí <xiscofauli@libreoffice.org>2019-06-03 21:37:47 +0200
commitac8368767d3c50c46a764987bf0fd783579f3d9f (patch)
treecd139c8d041ef658dd34637b40fc16dc4756e9c0 /sc/source
parent4ace5fdb0472cdfbbd64f52eac473d21baea6601 (diff)
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@numbertext.org> (cherry picked from commit 32a11727a0f709c11685d4200b1db08dac211dec) Reviewed-on: https://gerrit.libreoffice.org/73381
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/filter/excel/xename.cxx25
1 files changed, 24 insertions, 1 deletions
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 );
}