[Libreoffice-commits] core.git: svl/source

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Thu Sep 1 09:18:24 UTC 2016


 svl/source/numbers/zformat.cxx |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 662f5a5a16339ecda071ea6b95afefeea63c4fe9
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Sat Aug 27 19:14:39 2016 +0200

    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 at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 767dadd..67f38ee 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);
             }
         }
     }


More information about the Libreoffice-commits mailing list