svl/source/numbers/zformat.cxx  |   12 ++++++------
 svl/source/numbers/zforscan.cxx |   30 +++++++++++++++++++-----------
 svl/source/numbers/zforscan.hxx |   13 +++++++++----
 3 files changed, 34 insertions(+), 21 deletions(-)

New commits:
commit a4bf4aa86d5560bd7bd740d4a9637e5c637c9116
Author: Laurent BP <laurent.balland-poir...@laposte.net>
Date:   Sun Oct 22 17:29:52 2017 +0200

    Make StandardColor and sErrStr static
    
    StandardColor cannot be made const because GetColor returns a pointer on it
    
    Change-Id: I974b1463012431069910db32a2cd7280b5d0b17e
    Reviewed-on: https://gerrit.libreoffice.org/43790
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 0a9036193016..29d66a073d4f 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2740,7 +2740,7 @@ bool SvNumberformat::ImpGetFractionOutput(double fNumber,
 
     if (fNum > D_MAX_U_INT32 || rInfo.nCntExp > 9) // Too large
     {
-        sBuff = rScan.GetErrorString();
+        sBuff = ImpSvNumberformatScan::GetErrorString();
         return false;
     }
     if (rInfo.nCntExp == 0)
@@ -2758,7 +2758,7 @@ bool SvNumberformat::ImpGetFractionOutput(double fNumber,
 
         if (fNum1 > D_MAX_U_INT32)
         {
-            sBuff = rScan.GetErrorString();
+            sBuff = ImpSvNumberformatScan::GetErrorString();
             return false;
         }
         nFrac = (sal_uInt64) floor(fNum1);
@@ -2901,7 +2901,7 @@ bool SvNumberformat::ImpGetTimeOutput(double fNumber,
     {
         if (fNumber > 1.0E10) // Too large
         {
-            sBuff = rScan.GetErrorString();
+            sBuff = ImpSvNumberformatScan::GetErrorString();
             return false;
         }
     }
@@ -2934,7 +2934,7 @@ bool SvNumberformat::ImpGetTimeOutput(double fNumber,
     }
     if( floor( fTime ) > D_MAX_U_INT32 )
     {
-        sBuff = rScan.GetErrorString();
+        sBuff = ImpSvNumberformatScan::GetErrorString();
         return false;
     }
     sal_uInt32 nSeconds = (sal_uInt32)floor( fTime );
@@ -4097,7 +4097,7 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber,
         }
         else
         {
-            sStr = rScan.GetErrorString();
+            sStr = ImpSvNumberformatScan::GetErrorString();
             return false;
         }
     }
@@ -4614,7 +4614,7 @@ void SvNumberformat::GetFormatSpecialInfo(bool& bThousand,
 
     const Color* pColor = NumFor[1].GetColor();
     IsRed = fLimit1 == 0.0 && fLimit2 == 0.0 && pColor
-        && (*pColor == rScan.GetRedColor());
+        && (*pColor == ImpSvNumberformatScan::GetRedColor());
 }
 
 void SvNumberformat::GetNumForInfo( sal_uInt16 nNumFor, short& rScannedType,
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index e5e2b7dc83ff..f845b5f2ed5d 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -101,6 +101,11 @@ const ::std::vector<OUString> 
ImpSvNumberformatScan::sEnglishKeyword =
     "t"        // NF_KEY_THAI_T Thai T modifier, speciality of Thai Excel, 
only used with Thai locale and converted to [NatNum1]
 };             // only exception as lowercase
 
+::std::vector<Color> ImpSvNumberformatScan::StandardColor;
+bool ImpSvNumberformatScan::bStandardColorNeedInitialization = true;
+
+const OUString ImpSvNumberformatScan::sErrStr =  "###";
+
 ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP )
     : maNullDate( 30, 12, 1899)
     , eNewLnge(LANGUAGE_DONTKNOW)
@@ -129,20 +134,23 @@ ImpSvNumberformatScan::ImpSvNumberformatScan( 
SvNumberFormatter* pFormatterP )
     bKeywordsNeedInit = true;            // locale dependent keywords
     bCompatCurNeedInit = true;           // locale dependent compatibility 
currency strings
 
-    StandardColor[0]  =  Color(COL_BLACK);
-    StandardColor[1]  =  Color(COL_LIGHTBLUE);
-    StandardColor[2]  =  Color(COL_LIGHTGREEN);
-    StandardColor[3]  =  Color(COL_LIGHTCYAN);
-    StandardColor[4]  =  Color(COL_LIGHTRED);
-    StandardColor[5]  =  Color(COL_LIGHTMAGENTA);
-    StandardColor[6]  =  Color(COL_BROWN);
-    StandardColor[7]  =  Color(COL_GRAY);
-    StandardColor[8]  =  Color(COL_YELLOW);
-    StandardColor[9]  =  Color(COL_WHITE);
+    if ( bStandardColorNeedInitialization )
+    {
+        bStandardColorNeedInitialization = false;
+        StandardColor.push_back( Color(COL_BLACK) );
+        StandardColor.push_back( Color(COL_LIGHTBLUE) );
+        StandardColor.push_back( Color(COL_LIGHTGREEN) );
+        StandardColor.push_back( Color(COL_LIGHTCYAN) );
+        StandardColor.push_back( Color(COL_LIGHTRED) );
+        StandardColor.push_back( Color(COL_LIGHTMAGENTA) );
+        StandardColor.push_back( Color(COL_BROWN) );
+        StandardColor.push_back( Color(COL_GRAY) );
+        StandardColor.push_back( Color(COL_YELLOW) );
+        StandardColor.push_back( Color(COL_WHITE) );
+    }
 
     nStandardPrec = 2;
 
-    sErrStr =  "###";
     Reset();
 }
 
diff --git a/svl/source/numbers/zforscan.hxx b/svl/source/numbers/zforscan.hxx
index 77c16ab1db4c..37c59c5010be 100644
--- a/svl/source/numbers/zforscan.hxx
+++ b/svl/source/numbers/zforscan.hxx
@@ -82,7 +82,11 @@ public:
     const OUString& GetFalseString() const    { return GetSpecialKeyword( 
NF_KEY_FALSE ); }
     const OUString& GetRedString() const      { return 
GetKeywords()[NF_KEY_RED]; }
     const OUString& GetBooleanString() const  { return 
GetKeywords()[NF_KEY_BOOLEAN]; }
-    const OUString& GetErrorString() const    { return sErrStr; }
+    static const OUString& GetErrorString()   { return sErrStr; }
+    static const ::std::vector<Color> & GetStandardColor()
+        {
+            return StandardColor;
+        }
 
     const Date& GetNullDate() const           { return maNullDate; }
     const OUString& GetStandardName() const
@@ -94,7 +98,7 @@ public:
             return sNameStandardFormat;
         }
     sal_uInt16 GetStandardPrec() const          { return nStandardPrec; }
-    const Color& GetRedColor() const            { return StandardColor[4]; }
+    static const Color& GetRedColor()           { return StandardColor[4]; }
     Color* GetColor(OUString& sStr); // Set main colors or defines colors
 
     // the compatibility currency symbol for old automatic currency formats
@@ -154,7 +158,8 @@ public:
 private: // Private section
     NfKeywordTable sKeyword;                    // Syntax keywords
     static const ::std::vector<OUString> sEnglishKeyword; // English Syntax 
keywords
-    Color StandardColor[NF_MAX_DEFAULT_COLORS]; // Standard color array
+    static ::std::vector<Color> StandardColor;  // Standard color array
+    static bool bStandardColorNeedInitialization; // initialize Standard color 
array
     Date maNullDate;                            // 30Dec1899
     OUString sNameStandardFormat;               // "Standard"
     sal_uInt16 nStandardPrec;                   // Default Precision for 
Standardformat
@@ -185,7 +190,7 @@ private: // Private section
     OUString sCurSymbol;                        // Currency symbol for 
compatibility format codes
     OUString sCurString;                        // Currency symbol in upper 
case
     OUString sCurAbbrev;                        // Currency abbreviation
-    OUString sErrStr;                           // String for error output
+    static const OUString sErrStr;              // String for error output
 
     bool bConvertMode;                          // Set in the convert mode
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to