| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 #include "core/fxcrt/include/fx_xml.h" | 10 #include "core/fxcrt/include/fx_xml.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 CFX_ByteString bsSpace; | 111 CFX_ByteString bsSpace; |
| 112 CFX_WideString wsName = gs_LocalNumberSymbols[eType]; | 112 CFX_WideString wsName = gs_LocalNumberSymbols[eType]; |
| 113 CXML_Element* pNumberSymbols = | 113 CXML_Element* pNumberSymbols = |
| 114 m_pElement->GetElement(bsSpace.AsByteStringC(), "numberSymbols"); | 114 m_pElement->GetElement(bsSpace.AsByteStringC(), "numberSymbols"); |
| 115 if (!pNumberSymbols) { | 115 if (!pNumberSymbols) { |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 wsNumSymbol = FX_GetXMLContent(bsSpace.AsByteStringC(), pNumberSymbols, | 118 wsNumSymbol = FX_GetXMLContent(bsSpace.AsByteStringC(), pNumberSymbols, |
| 119 "numberSymbol", wsName); | 119 "numberSymbol", wsName.AsWideStringC()); |
| 120 } | 120 } |
| 121 void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { | 121 void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { |
| 122 if (!m_pElement) { | 122 if (!m_pElement) { |
| 123 return; | 123 return; |
| 124 } | 124 } |
| 125 CFX_ByteString bsSpace; | 125 CFX_ByteString bsSpace; |
| 126 CXML_Element* pNumberSymbols = | 126 CXML_Element* pNumberSymbols = |
| 127 m_pElement->GetElement(bsSpace.AsByteStringC(), "dateTimeSymbols"); | 127 m_pElement->GetElement(bsSpace.AsByteStringC(), "dateTimeSymbols"); |
| 128 if (!pNumberSymbols) { | 128 if (!pNumberSymbols) { |
| 129 return; | 129 return; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 const CFX_ByteString& bsCategory, | 230 const CFX_ByteString& bsCategory, |
| 231 const CFX_WideString& wsSubCategory, | 231 const CFX_WideString& wsSubCategory, |
| 232 CFX_WideString& wsPattern) { | 232 CFX_WideString& wsPattern) { |
| 233 CFX_ByteString bsSpace; | 233 CFX_ByteString bsSpace; |
| 234 CXML_Element* pDatePatterns = pXmlElement->GetElement( | 234 CXML_Element* pDatePatterns = pXmlElement->GetElement( |
| 235 bsSpace.AsByteStringC(), (bsCategory + "s").AsByteStringC()); | 235 bsSpace.AsByteStringC(), (bsCategory + "s").AsByteStringC()); |
| 236 if (!pDatePatterns) { | 236 if (!pDatePatterns) { |
| 237 return; | 237 return; |
| 238 } | 238 } |
| 239 wsPattern = FX_GetXMLContent(bsSpace.AsByteStringC(), pDatePatterns, | 239 wsPattern = FX_GetXMLContent(bsSpace.AsByteStringC(), pDatePatterns, |
| 240 bsCategory.AsByteStringC(), wsSubCategory); | 240 bsCategory.AsByteStringC(), |
| 241 wsSubCategory.AsWideStringC()); |
| 241 } | 242 } |
| 242 static void FX_GetDateTimePattern(CXML_Element* pXmlElement, | 243 static void FX_GetDateTimePattern(CXML_Element* pXmlElement, |
| 243 const CFX_ByteString& bsCategory, | 244 const CFX_ByteString& bsCategory, |
| 244 FX_LOCALEDATETIMESUBCATEGORY eType, | 245 FX_LOCALEDATETIMESUBCATEGORY eType, |
| 245 CFX_WideString& wsPattern) { | 246 CFX_WideString& wsPattern) { |
| 246 CFX_WideString wsType = g_FXLocaleDateTimeSubCatData[eType].pName; | 247 CFX_WideString wsType = g_FXLocaleDateTimeSubCatData[eType].pName; |
| 247 FX_GetPattern(pXmlElement, bsCategory, wsType, wsPattern); | 248 FX_GetPattern(pXmlElement, bsCategory, wsType, wsPattern); |
| 248 } | 249 } |
| 249 void CFX_Locale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, | 250 void CFX_Locale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, |
| 250 CFX_WideString& wsPattern) const { | 251 CFX_WideString& wsPattern) const { |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 if (wsSearchCategory != wsCategory) { | 686 if (wsSearchCategory != wsCategory) { |
| 686 continue; | 687 continue; |
| 687 } | 688 } |
| 688 while (ccf < iLenf) { | 689 while (ccf < iLenf) { |
| 689 if (pStr[ccf] == '(') { | 690 if (pStr[ccf] == '(') { |
| 690 ccf++; | 691 ccf++; |
| 691 CFX_WideString wsLCID; | 692 CFX_WideString wsLCID; |
| 692 while (ccf < iLenf && pStr[ccf] != ')') { | 693 while (ccf < iLenf && pStr[ccf] != ')') { |
| 693 wsLCID += pStr[ccf++]; | 694 wsLCID += pStr[ccf++]; |
| 694 } | 695 } |
| 695 pLocale = GetPatternLocale(wsLCID); | 696 pLocale = GetPatternLocale(wsLCID.AsWideStringC()); |
| 696 } else if (pStr[ccf] == '{') { | 697 } else if (pStr[ccf] == '{') { |
| 697 bBrackOpen = TRUE; | 698 bBrackOpen = TRUE; |
| 698 break; | 699 break; |
| 699 } | 700 } |
| 700 ccf++; | 701 ccf++; |
| 701 } | 702 } |
| 702 } else if (pStr[ccf] != '}') { | 703 } else if (pStr[ccf] != '}') { |
| 703 wsPurgePattern += pStr[ccf]; | 704 wsPurgePattern += pStr[ccf]; |
| 704 } | 705 } |
| 705 ccf++; | 706 ccf++; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 ccf = 0; | 745 ccf = 0; |
| 745 continue; | 746 continue; |
| 746 } | 747 } |
| 747 while (ccf < iLenf) { | 748 while (ccf < iLenf) { |
| 748 if (pStr[ccf] == '(') { | 749 if (pStr[ccf] == '(') { |
| 749 ccf++; | 750 ccf++; |
| 750 CFX_WideString wsLCID; | 751 CFX_WideString wsLCID; |
| 751 while (ccf < iLenf && pStr[ccf] != ')') { | 752 while (ccf < iLenf && pStr[ccf] != ')') { |
| 752 wsLCID += pStr[ccf++]; | 753 wsLCID += pStr[ccf++]; |
| 753 } | 754 } |
| 754 pLocale = GetPatternLocale(wsLCID); | 755 pLocale = GetPatternLocale(wsLCID.AsWideStringC()); |
| 755 } else if (pStr[ccf] == '{') { | 756 } else if (pStr[ccf] == '{') { |
| 756 bBrackOpen = TRUE; | 757 bBrackOpen = TRUE; |
| 757 break; | 758 break; |
| 758 } else if (pStr[ccf] == '.') { | 759 } else if (pStr[ccf] == '.') { |
| 759 CFX_WideString wsSubCategory; | 760 CFX_WideString wsSubCategory; |
| 760 ccf++; | 761 ccf++; |
| 761 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 762 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 762 wsSubCategory += pStr[ccf++]; | 763 wsSubCategory += pStr[ccf++]; |
| 763 } | 764 } |
| 764 uint32_t dwSubHash = | 765 uint32_t dwSubHash = |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 return FALSE; | 1732 return FALSE; |
| 1732 } | 1733 } |
| 1733 cc--; | 1734 cc--; |
| 1734 ccf--; | 1735 ccf--; |
| 1735 break; | 1736 break; |
| 1736 } | 1737 } |
| 1737 case '9': | 1738 case '9': |
| 1738 if (!FX_IsDigit(str[cc])) { | 1739 if (!FX_IsDigit(str[cc])) { |
| 1739 return FALSE; | 1740 return FALSE; |
| 1740 } | 1741 } |
| 1741 wsValue = CFX_WideStringC(str[cc]) + wsValue; | 1742 wsValue = str[cc] + wsValue; |
| 1742 cc--; | 1743 cc--; |
| 1743 ccf--; | 1744 ccf--; |
| 1744 break; | 1745 break; |
| 1745 case 'z': | 1746 case 'z': |
| 1746 if (FX_IsDigit(str[cc])) { | 1747 if (FX_IsDigit(str[cc])) { |
| 1747 wsValue = CFX_WideStringC(str[cc]) + wsValue; | 1748 wsValue = str[cc] + wsValue; |
| 1748 cc--; | 1749 cc--; |
| 1749 } | 1750 } |
| 1750 ccf--; | 1751 ccf--; |
| 1751 break; | 1752 break; |
| 1752 case 'Z': | 1753 case 'Z': |
| 1753 if (str[cc] != ' ') { | 1754 if (str[cc] != ' ') { |
| 1754 if (FX_IsDigit(str[cc])) { | 1755 if (FX_IsDigit(str[cc])) { |
| 1755 wsValue = CFX_WideStringC(str[cc]) + wsValue; | 1756 wsValue = str[cc] + wsValue; |
| 1756 cc--; | 1757 cc--; |
| 1757 } | 1758 } |
| 1758 } else { | 1759 } else { |
| 1759 cc--; | 1760 cc--; |
| 1760 } | 1761 } |
| 1761 ccf--; | 1762 ccf--; |
| 1762 break; | 1763 break; |
| 1763 case 'S': | 1764 case 'S': |
| 1764 if (str[cc] == '+' || str[cc] == ' ') { | 1765 if (str[cc] == '+' || str[cc] == ' ') { |
| 1765 cc--; | 1766 cc--; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 } | 2150 } |
| 2150 cc++; | 2151 cc++; |
| 2151 ccf++; | 2152 ccf++; |
| 2152 } | 2153 } |
| 2153 } | 2154 } |
| 2154 if (cc != len) { | 2155 if (cc != len) { |
| 2155 return FALSE; | 2156 return FALSE; |
| 2156 } | 2157 } |
| 2157 } | 2158 } |
| 2158 if (iExponent || bHavePercentSymbol) { | 2159 if (iExponent || bHavePercentSymbol) { |
| 2159 CFX_Decimal decimal = CFX_Decimal(wsValue); | 2160 CFX_Decimal decimal = CFX_Decimal(wsValue.AsWideStringC()); |
| 2160 if (iExponent) { | 2161 if (iExponent) { |
| 2161 decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent)); | 2162 decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent)); |
| 2162 } | 2163 } |
| 2163 if (bHavePercentSymbol) { | 2164 if (bHavePercentSymbol) { |
| 2164 decimal = decimal / CFX_Decimal(100); | 2165 decimal = decimal / CFX_Decimal(100); |
| 2165 } | 2166 } |
| 2166 wsValue = decimal; | 2167 wsValue = decimal; |
| 2167 } | 2168 } |
| 2168 if (bNeg) { | 2169 if (bNeg) { |
| 2169 wsValue = CFX_WideStringC('-') + wsValue; | 2170 wsValue = L'-' + wsValue; |
| 2170 } | 2171 } |
| 2171 return TRUE; | 2172 return TRUE; |
| 2172 } | 2173 } |
| 2173 FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( | 2174 FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( |
| 2174 const CFX_WideString& wsPattern, | 2175 const CFX_WideString& wsPattern, |
| 2175 IFX_Locale*& pLocale, | 2176 IFX_Locale*& pLocale, |
| 2176 CFX_WideString& wsDatePattern, | 2177 CFX_WideString& wsDatePattern, |
| 2177 CFX_WideString& wsTimePattern) { | 2178 CFX_WideString& wsTimePattern) { |
| 2178 pLocale = NULL; | 2179 pLocale = NULL; |
| 2179 CFX_WideString wsTempPattern; | 2180 CFX_WideString wsTempPattern; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2221 } else { | 2222 } else { |
| 2222 continue; | 2223 continue; |
| 2223 } | 2224 } |
| 2224 while (ccf < iLenf) { | 2225 while (ccf < iLenf) { |
| 2225 if (pStr[ccf] == '(') { | 2226 if (pStr[ccf] == '(') { |
| 2226 ccf++; | 2227 ccf++; |
| 2227 CFX_WideString wsLCID; | 2228 CFX_WideString wsLCID; |
| 2228 while (ccf < iLenf && pStr[ccf] != ')') { | 2229 while (ccf < iLenf && pStr[ccf] != ')') { |
| 2229 wsLCID += pStr[ccf++]; | 2230 wsLCID += pStr[ccf++]; |
| 2230 } | 2231 } |
| 2231 pLocale = GetPatternLocale(wsLCID); | 2232 pLocale = GetPatternLocale(wsLCID.AsWideStringC()); |
| 2232 } else if (pStr[ccf] == '{') { | 2233 } else if (pStr[ccf] == '{') { |
| 2233 bBraceOpen = TRUE; | 2234 bBraceOpen = TRUE; |
| 2234 break; | 2235 break; |
| 2235 } else if (pStr[ccf] == '.') { | 2236 } else if (pStr[ccf] == '.') { |
| 2236 CFX_WideString wsSubCategory; | 2237 CFX_WideString wsSubCategory; |
| 2237 ccf++; | 2238 ccf++; |
| 2238 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 2239 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 2239 wsSubCategory += pStr[ccf++]; | 2240 wsSubCategory += pStr[ccf++]; |
| 2240 } | 2241 } |
| 2241 uint32_t dwSubHash = | 2242 uint32_t dwSubHash = |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2919 return FALSE; | 2920 return FALSE; |
| 2920 } | 2921 } |
| 2921 int32_t cc = 0, ccf = 0; | 2922 int32_t cc = 0, ccf = 0; |
| 2922 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; | 2923 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; |
| 2923 int lenf = wsNumFormat.GetLength(); | 2924 int lenf = wsNumFormat.GetLength(); |
| 2924 CFX_WideString wsSrcNum = wsInputNum; | 2925 CFX_WideString wsSrcNum = wsInputNum; |
| 2925 wsSrcNum.TrimLeft('0'); | 2926 wsSrcNum.TrimLeft('0'); |
| 2926 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { | 2927 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { |
| 2927 wsSrcNum.Insert(0, '0'); | 2928 wsSrcNum.Insert(0, '0'); |
| 2928 } | 2929 } |
| 2929 CFX_Decimal decimal = CFX_Decimal(wsSrcNum); | 2930 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsWideStringC()); |
| 2930 if (dwNumStyle & FX_NUMSTYLE_Percent) { | 2931 if (dwNumStyle & FX_NUMSTYLE_Percent) { |
| 2931 decimal = decimal * CFX_Decimal(100); | 2932 decimal = decimal * CFX_Decimal(100); |
| 2932 wsSrcNum = decimal; | 2933 wsSrcNum = decimal; |
| 2933 } | 2934 } |
| 2934 int32_t exponent = 0; | 2935 int32_t exponent = 0; |
| 2935 if (dwNumStyle & FX_NUMSTYLE_Exponent) { | 2936 if (dwNumStyle & FX_NUMSTYLE_Exponent) { |
| 2936 int fixed_count = 0; | 2937 int fixed_count = 0; |
| 2937 while (ccf < dot_index_f) { | 2938 while (ccf < dot_index_f) { |
| 2938 switch (strf[ccf]) { | 2939 switch (strf[ccf]) { |
| 2939 case '\'': | 2940 case '\'': |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2997 } | 2998 } |
| 2998 ccf = dot_index_f - 1; | 2999 ccf = dot_index_f - 1; |
| 2999 cc = dot_index - 1; | 3000 cc = dot_index - 1; |
| 3000 while (ccf >= 0) { | 3001 while (ccf >= 0) { |
| 3001 switch (strf[ccf]) { | 3002 switch (strf[ccf]) { |
| 3002 case '9': | 3003 case '9': |
| 3003 if (cc >= 0) { | 3004 if (cc >= 0) { |
| 3004 if (!FX_IsDigit(str[cc])) { | 3005 if (!FX_IsDigit(str[cc])) { |
| 3005 return FALSE; | 3006 return FALSE; |
| 3006 } | 3007 } |
| 3007 wsOutput = CFX_WideStringC(str[cc]) + wsOutput; | 3008 wsOutput = str[cc] + wsOutput; |
| 3008 cc--; | 3009 cc--; |
| 3009 } else { | 3010 } else { |
| 3010 wsOutput = CFX_WideStringC(L'0') + wsOutput; | 3011 wsOutput = L'0' + wsOutput; |
| 3011 } | 3012 } |
| 3012 ccf--; | 3013 ccf--; |
| 3013 break; | 3014 break; |
| 3014 case 'z': | 3015 case 'z': |
| 3015 if (cc >= 0) { | 3016 if (cc >= 0) { |
| 3016 if (!FX_IsDigit(str[cc])) { | 3017 if (!FX_IsDigit(str[cc])) { |
| 3017 return FALSE; | 3018 return FALSE; |
| 3018 } | 3019 } |
| 3019 if (str[0] != '0') { | 3020 if (str[0] != '0') { |
| 3020 wsOutput = CFX_WideStringC(str[cc]) + wsOutput; | 3021 wsOutput = str[cc] + wsOutput; |
| 3021 } | 3022 } |
| 3022 cc--; | 3023 cc--; |
| 3023 } | 3024 } |
| 3024 ccf--; | 3025 ccf--; |
| 3025 break; | 3026 break; |
| 3026 case 'Z': | 3027 case 'Z': |
| 3027 if (cc >= 0) { | 3028 if (cc >= 0) { |
| 3028 if (!FX_IsDigit(str[cc])) { | 3029 if (!FX_IsDigit(str[cc])) { |
| 3029 return FALSE; | 3030 return FALSE; |
| 3030 } | 3031 } |
| 3031 if (str[0] == '0') { | 3032 if (str[0] == '0') { |
| 3032 wsOutput = CFX_WideStringC(L' ') + wsOutput; | 3033 wsOutput = L' ' + wsOutput; |
| 3033 } else { | 3034 } else { |
| 3034 wsOutput = CFX_WideStringC(str[cc]) + wsOutput; | 3035 wsOutput = str[cc] + wsOutput; |
| 3035 } | 3036 } |
| 3036 cc--; | 3037 cc--; |
| 3037 } else { | 3038 } else { |
| 3038 wsOutput = CFX_WideStringC(L' ') + wsOutput; | 3039 wsOutput = L' ' + wsOutput; |
| 3039 } | 3040 } |
| 3040 ccf--; | 3041 ccf--; |
| 3041 break; | 3042 break; |
| 3042 case 'S': | 3043 case 'S': |
| 3043 if (bNeg) { | 3044 if (bNeg) { |
| 3044 CFX_WideString wsMinusSymbol; | 3045 CFX_WideString wsMinusSymbol; |
| 3045 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); | 3046 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); |
| 3046 wsOutput = wsMinusSymbol + wsOutput; | 3047 wsOutput = wsMinusSymbol + wsOutput; |
| 3047 bAddNeg = TRUE; | 3048 bAddNeg = TRUE; |
| 3048 } else { | 3049 } else { |
| 3049 wsOutput = CFX_WideStringC(L' ') + wsOutput; | 3050 wsOutput = L' ' + wsOutput; |
| 3050 } | 3051 } |
| 3051 ccf--; | 3052 ccf--; |
| 3052 break; | 3053 break; |
| 3053 case 's': | 3054 case 's': |
| 3054 if (bNeg) { | 3055 if (bNeg) { |
| 3055 CFX_WideString wsMinusSymbol; | 3056 CFX_WideString wsMinusSymbol; |
| 3056 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); | 3057 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); |
| 3057 wsOutput = wsMinusSymbol + wsOutput; | 3058 wsOutput = wsMinusSymbol + wsOutput; |
| 3058 bAddNeg = TRUE; | 3059 bAddNeg = TRUE; |
| 3059 } | 3060 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3141 } else { | 3142 } else { |
| 3142 wsOutput = L" " + wsOutput; | 3143 wsOutput = L" " + wsOutput; |
| 3143 } | 3144 } |
| 3144 ccf--; | 3145 ccf--; |
| 3145 break; | 3146 break; |
| 3146 case '\'': | 3147 case '\'': |
| 3147 wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; | 3148 wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; |
| 3148 ccf--; | 3149 ccf--; |
| 3149 break; | 3150 break; |
| 3150 default: | 3151 default: |
| 3151 wsOutput = CFX_WideStringC(strf[ccf]) + wsOutput; | 3152 wsOutput = strf[ccf] + wsOutput; |
| 3152 ccf--; | 3153 ccf--; |
| 3153 } | 3154 } |
| 3154 } | 3155 } |
| 3155 if (cc >= 0) { | 3156 if (cc >= 0) { |
| 3156 int nPos = dot_index % 3; | 3157 int nPos = dot_index % 3; |
| 3157 wsOutput.Empty(); | 3158 wsOutput.Empty(); |
| 3158 for (int32_t i = 0; i < dot_index; i++) { | 3159 for (int32_t i = 0; i < dot_index; i++) { |
| 3159 if (i % 3 == nPos && i != 0) { | 3160 if (i % 3 == nPos && i != 0) { |
| 3160 wsOutput += wsGroupSymbol; | 3161 wsOutput += wsGroupSymbol; |
| 3161 } | 3162 } |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3420 int dot_index = wsNumeric.Find('.'); | 3421 int dot_index = wsNumeric.Find('.'); |
| 3421 if (dot_index == -1) { | 3422 if (dot_index == -1) { |
| 3422 dot_index = len; | 3423 dot_index = len; |
| 3423 } | 3424 } |
| 3424 ccf = dot_index_f - 1; | 3425 ccf = dot_index_f - 1; |
| 3425 cc = dot_index - 1; | 3426 cc = dot_index - 1; |
| 3426 while (ccf >= 0) { | 3427 while (ccf >= 0) { |
| 3427 switch (strf[ccf]) { | 3428 switch (strf[ccf]) { |
| 3428 case '9': | 3429 case '9': |
| 3429 if (cc >= 0) { | 3430 if (cc >= 0) { |
| 3430 wsOutput = CFX_WideStringC(str[cc]) + wsOutput; | 3431 wsOutput = str[cc] + wsOutput; |
| 3431 cc--; | 3432 cc--; |
| 3432 } else { | 3433 } else { |
| 3433 wsOutput = CFX_WideStringC(L'0') + wsOutput; | 3434 wsOutput = L'0' + wsOutput; |
| 3434 } | 3435 } |
| 3435 ccf--; | 3436 ccf--; |
| 3436 break; | 3437 break; |
| 3437 case 'z': | 3438 case 'z': |
| 3438 if (cc >= 0) { | 3439 if (cc >= 0) { |
| 3439 if (lcNum.m_Integral != 0) { | 3440 if (lcNum.m_Integral != 0) { |
| 3440 wsOutput = CFX_WideStringC(str[cc]) + wsOutput; | 3441 wsOutput = str[cc] + wsOutput; |
| 3441 } | 3442 } |
| 3442 cc--; | 3443 cc--; |
| 3443 } | 3444 } |
| 3444 ccf--; | 3445 ccf--; |
| 3445 break; | 3446 break; |
| 3446 case 'Z': | 3447 case 'Z': |
| 3447 if (cc >= 0) { | 3448 if (cc >= 0) { |
| 3448 if (lcNum.m_Integral == 0) { | 3449 if (lcNum.m_Integral == 0) { |
| 3449 wsOutput = CFX_WideStringC(L' ') + wsOutput; | 3450 wsOutput = L' ' + wsOutput; |
| 3450 } else { | 3451 } else { |
| 3451 wsOutput = CFX_WideStringC(str[cc]) + wsOutput; | 3452 wsOutput = str[cc] + wsOutput; |
| 3452 } | 3453 } |
| 3453 cc--; | 3454 cc--; |
| 3454 } else { | 3455 } else { |
| 3455 wsOutput = CFX_WideStringC(L' ') + wsOutput; | 3456 wsOutput = L' ' + wsOutput; |
| 3456 } | 3457 } |
| 3457 ccf--; | 3458 ccf--; |
| 3458 break; | 3459 break; |
| 3459 case 'S': | 3460 case 'S': |
| 3460 if (bNeg) { | 3461 if (bNeg) { |
| 3461 CFX_WideString wsMinusSymbol; | 3462 CFX_WideString wsMinusSymbol; |
| 3462 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); | 3463 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); |
| 3463 wsOutput = wsMinusSymbol + wsOutput; | 3464 wsOutput = wsMinusSymbol + wsOutput; |
| 3464 bAddNeg = TRUE; | 3465 bAddNeg = TRUE; |
| 3465 } else { | 3466 } else { |
| 3466 wsOutput = CFX_WideStringC(L' ') + wsOutput; | 3467 wsOutput = L' ' + wsOutput; |
| 3467 } | 3468 } |
| 3468 ccf--; | 3469 ccf--; |
| 3469 break; | 3470 break; |
| 3470 case 's': | 3471 case 's': |
| 3471 if (bNeg) { | 3472 if (bNeg) { |
| 3472 CFX_WideString wsMinusSymbol; | 3473 CFX_WideString wsMinusSymbol; |
| 3473 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); | 3474 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); |
| 3474 wsOutput = wsMinusSymbol + wsOutput; | 3475 wsOutput = wsMinusSymbol + wsOutput; |
| 3475 bAddNeg = TRUE; | 3476 bAddNeg = TRUE; |
| 3476 } | 3477 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3558 } else { | 3559 } else { |
| 3559 wsOutput = L" " + wsOutput; | 3560 wsOutput = L" " + wsOutput; |
| 3560 } | 3561 } |
| 3561 ccf--; | 3562 ccf--; |
| 3562 break; | 3563 break; |
| 3563 case '\'': | 3564 case '\'': |
| 3564 wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; | 3565 wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; |
| 3565 ccf--; | 3566 ccf--; |
| 3566 break; | 3567 break; |
| 3567 default: | 3568 default: |
| 3568 wsOutput = CFX_WideStringC(strf[ccf]) + wsOutput; | 3569 wsOutput = strf[ccf] + wsOutput; |
| 3569 ccf--; | 3570 ccf--; |
| 3570 } | 3571 } |
| 3571 } | 3572 } |
| 3572 if (cc >= 0) { | 3573 if (cc >= 0) { |
| 3573 int nPos = dot_index % 3; | 3574 int nPos = dot_index % 3; |
| 3574 wsOutput.Empty(); | 3575 wsOutput.Empty(); |
| 3575 for (int32_t i = 0; i < dot_index; i++) { | 3576 for (int32_t i = 0; i < dot_index; i++) { |
| 3576 if (i % 3 == nPos && i != 0) { | 3577 if (i % 3 == nPos && i != 0) { |
| 3577 wsOutput += wsGroupSymbol; | 3578 wsOutput += wsGroupSymbol; |
| 3578 } | 3579 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3747 wsOutput[0] + wsMinusymbol + wsOutput.Mid(1, wsOutput.GetLength() - 1); | 3748 wsOutput[0] + wsMinusymbol + wsOutput.Mid(1, wsOutput.GetLength() - 1); |
| 3748 } | 3749 } |
| 3749 return TRUE; | 3750 return TRUE; |
| 3750 } | 3751 } |
| 3751 FX_BOOL CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum, | 3752 FX_BOOL CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum, |
| 3752 const CFX_WideString& wsPattern, | 3753 const CFX_WideString& wsPattern, |
| 3753 CFX_WideString& wsOutput) { | 3754 CFX_WideString& wsOutput) { |
| 3754 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { | 3755 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { |
| 3755 return FALSE; | 3756 return FALSE; |
| 3756 } | 3757 } |
| 3757 return FormatStrNum(wsSrcNum, wsPattern, wsOutput); | 3758 return FormatStrNum(wsSrcNum.AsWideStringC(), wsPattern, wsOutput); |
| 3758 } | 3759 } |
| 3759 FX_BOOL CFX_FormatString::FormatNum(FX_FLOAT fNum, | 3760 FX_BOOL CFX_FormatString::FormatNum(FX_FLOAT fNum, |
| 3760 const CFX_WideString& wsPattern, | 3761 const CFX_WideString& wsPattern, |
| 3761 CFX_WideString& wsOutput) { | 3762 CFX_WideString& wsOutput) { |
| 3762 if (wsPattern.IsEmpty()) { | 3763 if (wsPattern.IsEmpty()) { |
| 3763 return FALSE; | 3764 return FALSE; |
| 3764 } | 3765 } |
| 3765 CFX_LCNumeric lcNum(fNum); | 3766 CFX_LCNumeric lcNum(fNum); |
| 3766 return FormatLCNumeric(lcNum, wsPattern, wsOutput); | 3767 return FormatLCNumeric(lcNum, wsPattern, wsOutput); |
| 3767 } | 3768 } |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4249 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); | 4250 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); |
| 4250 if (pLocale == NULL || eCategory == FX_DATETIMETYPE_Unknown) { | 4251 if (pLocale == NULL || eCategory == FX_DATETIMETYPE_Unknown) { |
| 4251 return FALSE; | 4252 return FALSE; |
| 4252 } | 4253 } |
| 4253 CFX_Unitime dt(0); | 4254 CFX_Unitime dt(0); |
| 4254 int32_t iT = wsSrcDateTime.Find(L"T"); | 4255 int32_t iT = wsSrcDateTime.Find(L"T"); |
| 4255 if (iT < 0) { | 4256 if (iT < 0) { |
| 4256 if (eCategory == FX_DATETIMETYPE_Date) { | 4257 if (eCategory == FX_DATETIMETYPE_Date) { |
| 4257 FX_DateFromCanonical(wsSrcDateTime, dt); | 4258 FX_DateFromCanonical(wsSrcDateTime, dt); |
| 4258 } else if (eCategory == FX_DATETIMETYPE_Time) { | 4259 } else if (eCategory == FX_DATETIMETYPE_Time) { |
| 4259 FX_TimeFromCanonical(wsSrcDateTime, dt, pLocale); | 4260 FX_TimeFromCanonical(wsSrcDateTime.AsWideStringC(), dt, pLocale); |
| 4260 } | 4261 } |
| 4261 } else { | 4262 } else { |
| 4262 FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt); | 4263 FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt); |
| 4263 FX_TimeFromCanonical( | 4264 FX_TimeFromCanonical( |
| 4264 wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1), dt, pLocale); | 4265 wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1).AsWideStringC(), |
| 4266 dt, pLocale); |
| 4265 } | 4267 } |
| 4266 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, | 4268 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, |
| 4267 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, | 4269 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, |
| 4268 wsOutput); | 4270 wsOutput); |
| 4269 } | 4271 } |
| 4270 FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, | 4272 FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, |
| 4271 const CFX_WideString& wsPattern, | 4273 const CFX_WideString& wsPattern, |
| 4272 CFX_WideString& wsOutput, | 4274 CFX_WideString& wsOutput, |
| 4273 FX_DATETIMETYPE eDateTimeType) { | 4275 FX_DATETIMETYPE eDateTimeType) { |
| 4274 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { | 4276 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4292 return FALSE; | 4294 return FALSE; |
| 4293 } | 4295 } |
| 4294 CFX_Unitime dt(0); | 4296 CFX_Unitime dt(0); |
| 4295 int32_t iT = wsSrcDateTime.Find(L"T"); | 4297 int32_t iT = wsSrcDateTime.Find(L"T"); |
| 4296 if (iT < 0) { | 4298 if (iT < 0) { |
| 4297 if (eCategory == FX_DATETIMETYPE_Date && | 4299 if (eCategory == FX_DATETIMETYPE_Date && |
| 4298 FX_DateFromCanonical(wsSrcDateTime, dt)) { | 4300 FX_DateFromCanonical(wsSrcDateTime, dt)) { |
| 4299 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4301 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, |
| 4300 wsOutput); | 4302 wsOutput); |
| 4301 } else if (eCategory == FX_DATETIMETYPE_Time && | 4303 } else if (eCategory == FX_DATETIMETYPE_Time && |
| 4302 FX_TimeFromCanonical(wsSrcDateTime, dt, pLocale)) { | 4304 FX_TimeFromCanonical(wsSrcDateTime.AsWideStringC(), dt, |
| 4305 pLocale)) { |
| 4303 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4306 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, |
| 4304 wsOutput); | 4307 wsOutput); |
| 4305 } | 4308 } |
| 4306 } else { | 4309 } else { |
| 4307 CFX_WideStringC wsSrcDate((const FX_WCHAR*)wsSrcDateTime, iT); | 4310 CFX_WideStringC wsSrcDate((const FX_WCHAR*)wsSrcDateTime, iT); |
| 4308 CFX_WideStringC wsSrcTime((const FX_WCHAR*)wsSrcDateTime + iT + 1, | 4311 CFX_WideStringC wsSrcTime((const FX_WCHAR*)wsSrcDateTime + iT + 1, |
| 4309 wsSrcDateTime.GetLength() - iT - 1); | 4312 wsSrcDateTime.GetLength() - iT - 1); |
| 4310 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { | 4313 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { |
| 4311 return FALSE; | 4314 return FALSE; |
| 4312 } | 4315 } |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4729 scale++; | 4732 scale++; |
| 4730 } | 4733 } |
| 4731 } | 4734 } |
| 4732 cont: | 4735 cont: |
| 4733 str++; | 4736 str++; |
| 4734 } | 4737 } |
| 4735 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(negmet && IsNotZero(), scale); | 4738 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(negmet && IsNotZero(), scale); |
| 4736 } | 4739 } |
| 4737 | 4740 |
| 4738 CFX_Decimal::CFX_Decimal(const CFX_ByteStringC& strObj) { | 4741 CFX_Decimal::CFX_Decimal(const CFX_ByteStringC& strObj) { |
| 4739 *this = CFX_Decimal(CFX_WideString::FromLocal(strObj)); | 4742 *this = CFX_Decimal(CFX_WideString::FromLocal(strObj).AsWideStringC()); |
| 4740 } | 4743 } |
| 4741 | 4744 |
| 4742 CFX_Decimal::operator CFX_WideString() const { | 4745 CFX_Decimal::operator CFX_WideString() const { |
| 4743 CFX_WideString retString; | 4746 CFX_WideString retString; |
| 4744 CFX_WideString tmpbuf; | 4747 CFX_WideString tmpbuf; |
| 4745 uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; | 4748 uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; |
| 4746 while (phi || pmid || plo) { | 4749 while (phi || pmid || plo) { |
| 4747 tmpbuf += fxmath_decimal_helper_div10(phi, pmid, plo) + '0'; | 4750 tmpbuf += fxmath_decimal_helper_div10(phi, pmid, plo) + '0'; |
| 4748 } | 4751 } |
| 4749 uint8_t outputlen = (uint8_t)tmpbuf.GetLength(); | 4752 uint8_t outputlen = (uint8_t)tmpbuf.GetLength(); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5023 } | 5026 } |
| 5024 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 5027 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
| 5025 return Multiply(val); | 5028 return Multiply(val); |
| 5026 } | 5029 } |
| 5027 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 5030 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
| 5028 return Divide(val); | 5031 return Divide(val); |
| 5029 } | 5032 } |
| 5030 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 5033 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
| 5031 return Modulus(val); | 5034 return Modulus(val); |
| 5032 } | 5035 } |
| OLD | NEW |