diff options
author | Laurent Balland-Poirier <laurent.balland-poirier@laposte.net> | 2016-08-27 19:14:39 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-09-01 09:18:00 +0000 |
commit | 662f5a5a16339ecda071ea6b95afefeea63c4fe9 (patch) | |
tree | 8517b3787702fc0ab2dd6cea6aa70b92a9cbe13a /svl | |
parent | fcf417a77369853195d6727b2db8df290663256e (diff) |
tdf#79398 Insert LCID in the correct sub-format
During XL export, LCID is insert in format if necessary.
If there are several sub-formats ([>0];[<0];[0])
this commit insert LCID in the correct one.
Change-Id: I016c38a3338634113bfc0aa7e20e028e2e01e201
Reviewed-on: https://gerrit.libreoffice.org/28427
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/numbers/zformat.cxx | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 767daddb709c..67f38ee1aa5c 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -4633,24 +4633,22 @@ static void lcl_SvNumberformat_AddLimitStringImpl( OUString& rStr, } } -void lcl_insertLCID( OUStringBuffer& aFormatStr, const OUString& rLCIDString ) +void lcl_insertLCID( OUStringBuffer& aFormatStr, const OUString& rLCIDString, sal_Int32 nPosInsertLCID ) { OUStringBuffer aLCIDString; if ( !rLCIDString.isEmpty() ) { aLCIDString = "[$-" + rLCIDString + "]"; } - sal_Int32 nPosDBNum = aFormatStr.lastIndexOf("[DBNum"); - if ( nPosDBNum >= 0 ) - { - if ( rLCIDString.getLength() > 4 ) // remove DBNumX code if long LCID - aFormatStr.remove( nPosDBNum, 8 ); - else - nPosDBNum += 8; // other insert LCID after DBNum + // Search for only last DBNum which is the last element before insertion position + if ( nPosInsertLCID >= 8 + && rLCIDString.getLength() > 4 + && aFormatStr.indexOf( "[DBNum", nPosInsertLCID-8) == nPosInsertLCID-8 ) + { // remove DBNumX code if long LCID + nPosInsertLCID -= 8; + aFormatStr.remove( nPosInsertLCID, 8 ); } - else - nPosDBNum = 0; - aFormatStr.insert( nPosDBNum, aLCIDString.toString() ); + aFormatStr.insert( nPosInsertLCID, aLCIDString.toString() ); } OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords, @@ -4774,6 +4772,7 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords, { aStr.append( aPrefix ); } + sal_Int32 nPosInsertLCID = aStr.getLength(); if ( nAnz ) { const short* pType = NumFor[n].Info().nTypeArray; @@ -4834,11 +4833,11 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords, MsLangId::getRealLanguage( aNatNum.GetLang() ) == LANGUAGE_THAI ) { - lcl_insertLCID( aStr, "D07041E" ); // date in Thai digit, Buddhist era + lcl_insertLCID( aStr, "D07041E", nPosInsertLCID ); // date in Thai digit, Buddhist era } else { - lcl_insertLCID( aStr, "107041E" ); // date in Arabic digit, Buddhist era + lcl_insertLCID( aStr, "107041E", nPosInsertLCID ); // date in Arabic digit, Buddhist era } j = j+2; bLCIDInserted = true; @@ -4857,12 +4856,13 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords, rKeywords[NF_KEY_THAI_T] == "T" && MsLangId::getRealLanguage( aNatNum.GetLang()) == LANGUAGE_THAI ) { - lcl_insertLCID( aStr, "D00041E" ); // number in Thai digit + lcl_insertLCID( aStr, "D00041E", nPosInsertLCID ); // number in Thai digit } else if ( aNatNum.IsComplete() && aNatNum.GetDBNum() > 0 ) { lcl_insertLCID( aStr, OUString::number( sal::static_int_cast<sal_Int32>( - MsLangId::getRealLanguage( aNatNum.GetLang())), 16).toAsciiUpperCase()); + MsLangId::getRealLanguage( aNatNum.GetLang())), 16).toAsciiUpperCase(), + nPosInsertLCID); } } } |