| 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 26 matching lines...) Expand all Loading... |
| 37 static const FX_LOCALESUBCATEGORYINFO g_FXLocaleNumSubCatData[] = { | 37 static const FX_LOCALESUBCATEGORYINFO g_FXLocaleNumSubCatData[] = { |
| 38 {0x46f95531, L"percent", FX_LOCALENUMPATTERN_Percent}, | 38 {0x46f95531, L"percent", FX_LOCALENUMPATTERN_Percent}, |
| 39 {0x4c4e8acb, L"currency", FX_LOCALENUMPATTERN_Currency}, | 39 {0x4c4e8acb, L"currency", FX_LOCALENUMPATTERN_Currency}, |
| 40 {0x54034c2f, L"decimal", FX_LOCALENUMPATTERN_Decimal}, | 40 {0x54034c2f, L"decimal", FX_LOCALENUMPATTERN_Decimal}, |
| 41 {0x7568e6ae, L"integer", FX_LOCALENUMPATTERN_Integer}, | 41 {0x7568e6ae, L"integer", FX_LOCALENUMPATTERN_Integer}, |
| 42 }; | 42 }; |
| 43 static const int32_t g_iFXLocaleNumSubCatCount = | 43 static const int32_t g_iFXLocaleNumSubCatCount = |
| 44 sizeof(g_FXLocaleNumSubCatData) / sizeof(FX_LOCALESUBCATEGORYINFO); | 44 sizeof(g_FXLocaleNumSubCatData) / sizeof(FX_LOCALESUBCATEGORYINFO); |
| 45 | 45 |
| 46 struct FX_LOCALETIMEZONEINFO { | 46 struct FX_LOCALETIMEZONEINFO { |
| 47 FX_DWORD uHash; | 47 uint32_t uHash; |
| 48 int16_t iHour; | 48 int16_t iHour; |
| 49 int16_t iMinute; | 49 int16_t iMinute; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 static const FX_LOCALETIMEZONEINFO g_FXLocaleTimeZoneData[] = { | 52 static const FX_LOCALETIMEZONEINFO g_FXLocaleTimeZoneData[] = { |
| 53 {FXBSTR_ID(0, 'C', 'D', 'T'), -5, 0}, {FXBSTR_ID(0, 'C', 'S', 'T'), -6, 0}, | 53 {FXBSTR_ID(0, 'C', 'D', 'T'), -5, 0}, {FXBSTR_ID(0, 'C', 'S', 'T'), -6, 0}, |
| 54 {FXBSTR_ID(0, 'E', 'D', 'T'), -4, 0}, {FXBSTR_ID(0, 'E', 'S', 'T'), -5, 0}, | 54 {FXBSTR_ID(0, 'E', 'D', 'T'), -4, 0}, {FXBSTR_ID(0, 'E', 'S', 'T'), -5, 0}, |
| 55 {FXBSTR_ID(0, 'M', 'D', 'T'), -6, 0}, {FXBSTR_ID(0, 'M', 'S', 'T'), -7, 0}, | 55 {FXBSTR_ID(0, 'M', 'D', 'T'), -6, 0}, {FXBSTR_ID(0, 'M', 'S', 'T'), -7, 0}, |
| 56 {FXBSTR_ID(0, 'P', 'D', 'T'), -7, 0}, {FXBSTR_ID(0, 'P', 'S', 'T'), -8, 0}, | 56 {FXBSTR_ID(0, 'P', 'D', 'T'), -7, 0}, {FXBSTR_ID(0, 'P', 'S', 'T'), -8, 0}, |
| 57 }; | 57 }; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 if (!FX_IsDigit(str[cc])) { | 360 if (!FX_IsDigit(str[cc])) { |
| 361 if ((str[cc] == 'E' || str[cc] == 'e')) | 361 if ((str[cc] == 'E' || str[cc] == 'e')) |
| 362 break; | 362 break; |
| 363 else | 363 else |
| 364 return FALSE; | 364 return FALSE; |
| 365 } | 365 } |
| 366 fraction += gs_fraction_scales[scale] * (str[cc] - '0'); | 366 fraction += gs_fraction_scales[scale] * (str[cc] - '0'); |
| 367 scale++; | 367 scale++; |
| 368 cc++; | 368 cc++; |
| 369 } | 369 } |
| 370 lcnum.m_Fractional = (FX_DWORD)(fraction * 4294967296.0); | 370 lcnum.m_Fractional = (uint32_t)(fraction * 4294967296.0); |
| 371 } | 371 } |
| 372 if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { | 372 if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { |
| 373 cc++; | 373 cc++; |
| 374 if (cc < len) { | 374 if (cc < len) { |
| 375 if (str[cc] == '+') { | 375 if (str[cc] == '+') { |
| 376 cc++; | 376 cc++; |
| 377 } else if (str[cc] == '-') { | 377 } else if (str[cc] == '-') { |
| 378 bExpSign = true; | 378 bExpSign = true; |
| 379 cc++; | 379 cc++; |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 while (cc < len) { | 382 while (cc < len) { |
| 383 if (FX_IsDigit(str[cc])) | 383 if (FX_IsDigit(str[cc])) |
| 384 return FALSE; | 384 return FALSE; |
| 385 lcnum.m_Exponent = lcnum.m_Exponent * 10 + str[cc] - '0'; | 385 lcnum.m_Exponent = lcnum.m_Exponent * 10 + str[cc] - '0'; |
| 386 cc++; | 386 cc++; |
| 387 } | 387 } |
| 388 lcnum.m_Exponent = bExpSign ? -lcnum.m_Exponent : lcnum.m_Exponent; | 388 lcnum.m_Exponent = bExpSign ? -lcnum.m_Exponent : lcnum.m_Exponent; |
| 389 } | 389 } |
| 390 return TRUE; | 390 return TRUE; |
| 391 } | 391 } |
| 392 | 392 |
| 393 CFX_LCNumeric::CFX_LCNumeric() { | 393 CFX_LCNumeric::CFX_LCNumeric() { |
| 394 m_Integral = 0; | 394 m_Integral = 0; |
| 395 m_Fractional = 0; | 395 m_Fractional = 0; |
| 396 m_Exponent = 0; | 396 m_Exponent = 0; |
| 397 } | 397 } |
| 398 CFX_LCNumeric::CFX_LCNumeric(int64_t integral, | 398 CFX_LCNumeric::CFX_LCNumeric(int64_t integral, |
| 399 FX_DWORD fractional, | 399 uint32_t fractional, |
| 400 int32_t exponent) { | 400 int32_t exponent) { |
| 401 m_Integral = integral; | 401 m_Integral = integral; |
| 402 m_Fractional = fractional; | 402 m_Fractional = fractional; |
| 403 m_Exponent = exponent; | 403 m_Exponent = exponent; |
| 404 } | 404 } |
| 405 CFX_LCNumeric::CFX_LCNumeric(FX_FLOAT dbRetValue) { | 405 CFX_LCNumeric::CFX_LCNumeric(FX_FLOAT dbRetValue) { |
| 406 m_Integral = (int64_t)dbRetValue; | 406 m_Integral = (int64_t)dbRetValue; |
| 407 m_Fractional = (FX_DWORD)(((dbRetValue > 0) ? (dbRetValue - m_Integral) | 407 m_Fractional = (uint32_t)(((dbRetValue > 0) ? (dbRetValue - m_Integral) |
| 408 : (m_Integral - dbRetValue)) * | 408 : (m_Integral - dbRetValue)) * |
| 409 4294967296); | 409 4294967296); |
| 410 m_Exponent = 0; | 410 m_Exponent = 0; |
| 411 } | 411 } |
| 412 CFX_LCNumeric::CFX_LCNumeric(double dbvalue) { | 412 CFX_LCNumeric::CFX_LCNumeric(double dbvalue) { |
| 413 m_Integral = (int64_t)dbvalue; | 413 m_Integral = (int64_t)dbvalue; |
| 414 m_Fractional = (FX_DWORD)( | 414 m_Fractional = (uint32_t)( |
| 415 ((dbvalue > 0) ? (dbvalue - m_Integral) : (m_Integral - dbvalue)) * | 415 ((dbvalue > 0) ? (dbvalue - m_Integral) : (m_Integral - dbvalue)) * |
| 416 4294967296); | 416 4294967296); |
| 417 m_Exponent = 0; | 417 m_Exponent = 0; |
| 418 } | 418 } |
| 419 CFX_LCNumeric::CFX_LCNumeric(CFX_WideString& wsNumeric) { | 419 CFX_LCNumeric::CFX_LCNumeric(CFX_WideString& wsNumeric) { |
| 420 FX_WStringToNumeric(wsNumeric, *this); | 420 FX_WStringToNumeric(wsNumeric, *this); |
| 421 } | 421 } |
| 422 FX_FLOAT CFX_LCNumeric::GetFloat() const { | 422 FX_FLOAT CFX_LCNumeric::GetFloat() const { |
| 423 FX_FLOAT dbRetValue = m_Fractional / 4294967296.0f; | 423 FX_FLOAT dbRetValue = m_Fractional / 4294967296.0f; |
| 424 dbRetValue = m_Integral + (m_Integral >= 0 ? dbRetValue : -dbRetValue); | 424 dbRetValue = m_Integral + (m_Integral >= 0 ? dbRetValue : -dbRetValue); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 if (pStr[ccf] == '.' || pStr[ccf] == '(') { | 592 if (pStr[ccf] == '.' || pStr[ccf] == '(') { |
| 593 break; | 593 break; |
| 594 } | 594 } |
| 595 if (pStr[ccf] == '{') { | 595 if (pStr[ccf] == '{') { |
| 596 bBraceOpen = TRUE; | 596 bBraceOpen = TRUE; |
| 597 break; | 597 break; |
| 598 } | 598 } |
| 599 wsCategory += pStr[ccf]; | 599 wsCategory += pStr[ccf]; |
| 600 ccf++; | 600 ccf++; |
| 601 } | 601 } |
| 602 FX_DWORD dwHash = | 602 uint32_t dwHash = |
| 603 FX_HashCode_String_GetW(wsCategory, wsCategory.GetLength()); | 603 FX_HashCode_String_GetW(wsCategory, wsCategory.GetLength()); |
| 604 if (dwHash == FX_LOCALECATEGORY_DateHash) { | 604 if (dwHash == FX_LOCALECATEGORY_DateHash) { |
| 605 if (eCategory == FX_LOCALECATEGORY_Time) { | 605 if (eCategory == FX_LOCALECATEGORY_Time) { |
| 606 return FX_LOCALECATEGORY_DateTime; | 606 return FX_LOCALECATEGORY_DateTime; |
| 607 } | 607 } |
| 608 eCategory = FX_LOCALECATEGORY_Date; | 608 eCategory = FX_LOCALECATEGORY_Date; |
| 609 } else if (dwHash == FX_LOCALECATEGORY_TimeHash) { | 609 } else if (dwHash == FX_LOCALECATEGORY_TimeHash) { |
| 610 if (eCategory == FX_LOCALECATEGORY_Date) { | 610 if (eCategory == FX_LOCALECATEGORY_Date) { |
| 611 return FX_LOCALECATEGORY_DateTime; | 611 return FX_LOCALECATEGORY_DateTime; |
| 612 } | 612 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 if (!pLocale) { | 708 if (!pLocale) { |
| 709 pLocale = m_pLocaleMgr->GetDefLocale(); | 709 pLocale = m_pLocaleMgr->GetDefLocale(); |
| 710 } | 710 } |
| 711 return pLocale; | 711 return pLocale; |
| 712 } | 712 } |
| 713 #define FX_NUMSTYLE_Percent 0x01 | 713 #define FX_NUMSTYLE_Percent 0x01 |
| 714 #define FX_NUMSTYLE_Exponent 0x02 | 714 #define FX_NUMSTYLE_Exponent 0x02 |
| 715 #define FX_NUMSTYLE_DotVorv 0x04 | 715 #define FX_NUMSTYLE_DotVorv 0x04 |
| 716 IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, | 716 IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, |
| 717 int32_t& iDotIndex, | 717 int32_t& iDotIndex, |
| 718 FX_DWORD& dwStyle, | 718 uint32_t& dwStyle, |
| 719 CFX_WideString& wsPurgePattern) { | 719 CFX_WideString& wsPurgePattern) { |
| 720 dwStyle = 0; | 720 dwStyle = 0; |
| 721 IFX_Locale* pLocale = NULL; | 721 IFX_Locale* pLocale = NULL; |
| 722 int32_t ccf = 0; | 722 int32_t ccf = 0; |
| 723 int32_t iLenf = wsPattern.GetLength(); | 723 int32_t iLenf = wsPattern.GetLength(); |
| 724 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; | 724 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; |
| 725 FX_BOOL bFindDot = FALSE; | 725 FX_BOOL bFindDot = FALSE; |
| 726 FX_BOOL bBrackOpen = FALSE; | 726 FX_BOOL bBrackOpen = FALSE; |
| 727 while (ccf < iLenf) { | 727 while (ccf < iLenf) { |
| 728 if (pStr[ccf] == '\'') { | 728 if (pStr[ccf] == '\'') { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 752 pLocale = GetPatternLocale(wsLCID); | 752 pLocale = GetPatternLocale(wsLCID); |
| 753 } else if (pStr[ccf] == '{') { | 753 } else if (pStr[ccf] == '{') { |
| 754 bBrackOpen = TRUE; | 754 bBrackOpen = TRUE; |
| 755 break; | 755 break; |
| 756 } else if (pStr[ccf] == '.') { | 756 } else if (pStr[ccf] == '.') { |
| 757 CFX_WideString wsSubCategory; | 757 CFX_WideString wsSubCategory; |
| 758 ccf++; | 758 ccf++; |
| 759 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 759 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 760 wsSubCategory += pStr[ccf++]; | 760 wsSubCategory += pStr[ccf++]; |
| 761 } | 761 } |
| 762 FX_DWORD dwSubHash = | 762 uint32_t dwSubHash = |
| 763 FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); | 763 FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); |
| 764 FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; | 764 FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; |
| 765 for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { | 765 for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { |
| 766 if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { | 766 if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { |
| 767 eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] | 767 eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] |
| 768 .eSubCategory; | 768 .eSubCategory; |
| 769 break; | 769 break; |
| 770 } | 770 } |
| 771 } | 771 } |
| 772 wsSubCategory.Empty(); | 772 wsSubCategory.Empty(); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 return iPattern == iLenPattern && iText == iLenText; | 913 return iPattern == iLenPattern && iText == iLenText; |
| 914 } | 914 } |
| 915 FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, | 915 FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, |
| 916 const CFX_WideString& wsPattern, | 916 const CFX_WideString& wsPattern, |
| 917 FX_FLOAT& fValue) { | 917 FX_FLOAT& fValue) { |
| 918 fValue = 0.0f; | 918 fValue = 0.0f; |
| 919 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { | 919 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { |
| 920 return FALSE; | 920 return FALSE; |
| 921 } | 921 } |
| 922 int32_t dot_index_f = -1; | 922 int32_t dot_index_f = -1; |
| 923 FX_DWORD dwFormatStyle = 0; | 923 uint32_t dwFormatStyle = 0; |
| 924 CFX_WideString wsNumFormat; | 924 CFX_WideString wsNumFormat; |
| 925 IFX_Locale* pLocale = | 925 IFX_Locale* pLocale = |
| 926 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); | 926 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); |
| 927 if (!pLocale || wsNumFormat.IsEmpty()) { | 927 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 928 return FALSE; | 928 return FALSE; |
| 929 } | 929 } |
| 930 int32_t iExponent = 0; | 930 int32_t iExponent = 0; |
| 931 CFX_WideString wsDotSymbol; | 931 CFX_WideString wsDotSymbol; |
| 932 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); | 932 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); |
| 933 CFX_WideString wsGroupSymbol; | 933 CFX_WideString wsGroupSymbol; |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 wsResult.ReleaseBuffer(nIndex); | 1679 wsResult.ReleaseBuffer(nIndex); |
| 1680 } | 1680 } |
| 1681 FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, | 1681 FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, |
| 1682 const CFX_WideString& wsPattern, | 1682 const CFX_WideString& wsPattern, |
| 1683 CFX_WideString& wsValue) { | 1683 CFX_WideString& wsValue) { |
| 1684 wsValue.Empty(); | 1684 wsValue.Empty(); |
| 1685 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { | 1685 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { |
| 1686 return FALSE; | 1686 return FALSE; |
| 1687 } | 1687 } |
| 1688 int32_t dot_index_f = -1; | 1688 int32_t dot_index_f = -1; |
| 1689 FX_DWORD dwFormatStyle = 0; | 1689 uint32_t dwFormatStyle = 0; |
| 1690 CFX_WideString wsNumFormat; | 1690 CFX_WideString wsNumFormat; |
| 1691 IFX_Locale* pLocale = | 1691 IFX_Locale* pLocale = |
| 1692 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); | 1692 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); |
| 1693 if (!pLocale || wsNumFormat.IsEmpty()) { | 1693 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 1694 return FALSE; | 1694 return FALSE; |
| 1695 } | 1695 } |
| 1696 int32_t iExponent = 0; | 1696 int32_t iExponent = 0; |
| 1697 CFX_WideString wsDotSymbol; | 1697 CFX_WideString wsDotSymbol; |
| 1698 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); | 1698 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); |
| 1699 CFX_WideString wsGroupSymbol; | 1699 CFX_WideString wsGroupSymbol; |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 pLocale = GetPatternLocale(wsLCID); | 2229 pLocale = GetPatternLocale(wsLCID); |
| 2230 } else if (pStr[ccf] == '{') { | 2230 } else if (pStr[ccf] == '{') { |
| 2231 bBraceOpen = TRUE; | 2231 bBraceOpen = TRUE; |
| 2232 break; | 2232 break; |
| 2233 } else if (pStr[ccf] == '.') { | 2233 } else if (pStr[ccf] == '.') { |
| 2234 CFX_WideString wsSubCategory; | 2234 CFX_WideString wsSubCategory; |
| 2235 ccf++; | 2235 ccf++; |
| 2236 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 2236 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 2237 wsSubCategory += pStr[ccf++]; | 2237 wsSubCategory += pStr[ccf++]; |
| 2238 } | 2238 } |
| 2239 FX_DWORD dwSubHash = | 2239 uint32_t dwSubHash = |
| 2240 FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); | 2240 FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); |
| 2241 FX_LOCALEDATETIMESUBCATEGORY eSubCategory = | 2241 FX_LOCALEDATETIMESUBCATEGORY eSubCategory = |
| 2242 FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2242 FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2243 for (int32_t i = 0; i < g_iFXLocaleDateTimeSubCatCount; i++) { | 2243 for (int32_t i = 0; i < g_iFXLocaleDateTimeSubCatCount; i++) { |
| 2244 if (g_FXLocaleDateTimeSubCatData[i].uHash == dwSubHash) { | 2244 if (g_FXLocaleDateTimeSubCatData[i].uHash == dwSubHash) { |
| 2245 eSubCategory = | 2245 eSubCategory = |
| 2246 (FX_LOCALEDATETIMESUBCATEGORY)g_FXLocaleDateTimeSubCatData[i] | 2246 (FX_LOCALEDATETIMESUBCATEGORY)g_FXLocaleDateTimeSubCatData[i] |
| 2247 .eSubCategory; | 2247 .eSubCategory; |
| 2248 break; | 2248 break; |
| 2249 } | 2249 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2330 ccf++; | 2330 ccf++; |
| 2331 continue; | 2331 continue; |
| 2332 } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { | 2332 } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { |
| 2333 if (strf[ccf] != str[cc]) { | 2333 if (strf[ccf] != str[cc]) { |
| 2334 return FALSE; | 2334 return FALSE; |
| 2335 } | 2335 } |
| 2336 cc++; | 2336 cc++; |
| 2337 ccf++; | 2337 ccf++; |
| 2338 continue; | 2338 continue; |
| 2339 } | 2339 } |
| 2340 FX_DWORD dwSymbolNum = 1; | 2340 uint32_t dwSymbolNum = 1; |
| 2341 FX_DWORD dwSymbol = strf[ccf++]; | 2341 uint32_t dwSymbol = strf[ccf++]; |
| 2342 while (ccf < lenf && strf[ccf] == dwSymbol) { | 2342 while (ccf < lenf && strf[ccf] == dwSymbol) { |
| 2343 ccf++; | 2343 ccf++; |
| 2344 dwSymbolNum++; | 2344 dwSymbolNum++; |
| 2345 } | 2345 } |
| 2346 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); | 2346 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); |
| 2347 if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { | 2347 if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { |
| 2348 if (!FX_IsDigit(str[cc])) { | 2348 if (!FX_IsDigit(str[cc])) { |
| 2349 return FALSE; | 2349 return FALSE; |
| 2350 } | 2350 } |
| 2351 day = str[cc++] - '0'; | 2351 day = str[cc++] - '0'; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2549 ccf++; | 2549 ccf++; |
| 2550 continue; | 2550 continue; |
| 2551 } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) == -1) { | 2551 } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) == -1) { |
| 2552 if (strf[ccf] != str[cc]) { | 2552 if (strf[ccf] != str[cc]) { |
| 2553 return FALSE; | 2553 return FALSE; |
| 2554 } | 2554 } |
| 2555 cc++; | 2555 cc++; |
| 2556 ccf++; | 2556 ccf++; |
| 2557 continue; | 2557 continue; |
| 2558 } | 2558 } |
| 2559 FX_DWORD dwSymbolNum = 1; | 2559 uint32_t dwSymbolNum = 1; |
| 2560 FX_DWORD dwSymbol = strf[ccf++]; | 2560 uint32_t dwSymbol = strf[ccf++]; |
| 2561 while (ccf < lenf && strf[ccf] == dwSymbol) { | 2561 while (ccf < lenf && strf[ccf] == dwSymbol) { |
| 2562 ccf++; | 2562 ccf++; |
| 2563 dwSymbolNum++; | 2563 dwSymbolNum++; |
| 2564 } | 2564 } |
| 2565 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); | 2565 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); |
| 2566 if (dwSymbol == FXBSTR_ID(0, 0, 'k', '1') || | 2566 if (dwSymbol == FXBSTR_ID(0, 0, 'k', '1') || |
| 2567 dwSymbol == FXBSTR_ID(0, 0, 'H', '1') || | 2567 dwSymbol == FXBSTR_ID(0, 0, 'H', '1') || |
| 2568 dwSymbol == FXBSTR_ID(0, 0, 'h', '1') || | 2568 dwSymbol == FXBSTR_ID(0, 0, 'h', '1') || |
| 2569 dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) { | 2569 dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) { |
| 2570 if (!FX_IsDigit(str[cc])) { | 2570 if (!FX_IsDigit(str[cc])) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 } else if ((cc + wsPM.GetLength() <= len) && | 2659 } else if ((cc + wsPM.GetLength() <= len) && |
| 2660 (CFX_WideStringC(str + cc, wsPM.GetLength()) == wsPM)) { | 2660 (CFX_WideStringC(str + cc, wsPM.GetLength()) == wsPM)) { |
| 2661 cc += wsPM.GetLength(); | 2661 cc += wsPM.GetLength(); |
| 2662 bHasA = TRUE; | 2662 bHasA = TRUE; |
| 2663 bPM = TRUE; | 2663 bPM = TRUE; |
| 2664 } | 2664 } |
| 2665 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) { | 2665 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) { |
| 2666 if (cc + 3 > len) { | 2666 if (cc + 3 > len) { |
| 2667 continue; | 2667 continue; |
| 2668 } | 2668 } |
| 2669 FX_DWORD dwHash = str[cc++]; | 2669 uint32_t dwHash = str[cc++]; |
| 2670 dwHash = (dwHash << 8) | str[cc++]; | 2670 dwHash = (dwHash << 8) | str[cc++]; |
| 2671 dwHash = (dwHash << 8) | str[cc++]; | 2671 dwHash = (dwHash << 8) | str[cc++]; |
| 2672 if (dwHash == FXBSTR_ID(0, 'G', 'M', 'T')) { | 2672 if (dwHash == FXBSTR_ID(0, 'G', 'M', 'T')) { |
| 2673 FX_TIMEZONE tzDiff; | 2673 FX_TIMEZONE tzDiff; |
| 2674 tzDiff.tzHour = 0; | 2674 tzDiff.tzHour = 0; |
| 2675 tzDiff.tzMinute = 0; | 2675 tzDiff.tzMinute = 0; |
| 2676 if (cc < len && (str[cc] == '-' || str[cc] == '+')) { | 2676 if (cc < len && (str[cc] == '-' || str[cc] == '+')) { |
| 2677 cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); | 2677 cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); |
| 2678 } | 2678 } |
| 2679 FX_ResolveZone(hour, minute, tzDiff, pLocale); | 2679 FX_ResolveZone(hour, minute, tzDiff, pLocale); |
| 2680 } else { | 2680 } else { |
| 2681 const FX_LOCALETIMEZONEINFO* pEnd = | 2681 const FX_LOCALETIMEZONEINFO* pEnd = |
| 2682 g_FXLocaleTimeZoneData + FX_ArraySize(g_FXLocaleTimeZoneData); | 2682 g_FXLocaleTimeZoneData + FX_ArraySize(g_FXLocaleTimeZoneData); |
| 2683 const FX_LOCALETIMEZONEINFO* pTimeZoneInfo = | 2683 const FX_LOCALETIMEZONEINFO* pTimeZoneInfo = |
| 2684 std::lower_bound(g_FXLocaleTimeZoneData, pEnd, dwHash, | 2684 std::lower_bound(g_FXLocaleTimeZoneData, pEnd, dwHash, |
| 2685 [](const FX_LOCALETIMEZONEINFO& info, | 2685 [](const FX_LOCALETIMEZONEINFO& info, |
| 2686 FX_DWORD hash) { return info.uHash < hash; }); | 2686 uint32_t hash) { return info.uHash < hash; }); |
| 2687 if (pTimeZoneInfo < pEnd && dwHash == pTimeZoneInfo->uHash) { | 2687 if (pTimeZoneInfo < pEnd && dwHash == pTimeZoneInfo->uHash) { |
| 2688 hour += pTimeZoneInfo->iHour; | 2688 hour += pTimeZoneInfo->iHour; |
| 2689 minute += pTimeZoneInfo->iHour > 0 ? pTimeZoneInfo->iMinute | 2689 minute += pTimeZoneInfo->iHour > 0 ? pTimeZoneInfo->iMinute |
| 2690 : -pTimeZoneInfo->iMinute; | 2690 : -pTimeZoneInfo->iMinute; |
| 2691 } | 2691 } |
| 2692 } | 2692 } |
| 2693 } else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) { | 2693 } else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) { |
| 2694 if (str[cc] != 'Z') { | 2694 if (str[cc] != 'Z') { |
| 2695 FX_TIMEZONE tzDiff; | 2695 FX_TIMEZONE tzDiff; |
| 2696 cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); | 2696 cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2902 } | 2902 } |
| 2903 return iTreading; | 2903 return iTreading; |
| 2904 } | 2904 } |
| 2905 FX_BOOL CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum, | 2905 FX_BOOL CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum, |
| 2906 const CFX_WideString& wsPattern, | 2906 const CFX_WideString& wsPattern, |
| 2907 CFX_WideString& wsOutput) { | 2907 CFX_WideString& wsOutput) { |
| 2908 if (wsInputNum.IsEmpty() || wsPattern.IsEmpty()) { | 2908 if (wsInputNum.IsEmpty() || wsPattern.IsEmpty()) { |
| 2909 return FALSE; | 2909 return FALSE; |
| 2910 } | 2910 } |
| 2911 int32_t dot_index_f = -1; | 2911 int32_t dot_index_f = -1; |
| 2912 FX_DWORD dwNumStyle = 0; | 2912 uint32_t dwNumStyle = 0; |
| 2913 CFX_WideString wsNumFormat; | 2913 CFX_WideString wsNumFormat; |
| 2914 IFX_Locale* pLocale = | 2914 IFX_Locale* pLocale = |
| 2915 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); | 2915 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); |
| 2916 if (!pLocale || wsNumFormat.IsEmpty()) { | 2916 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 2917 return FALSE; | 2917 return FALSE; |
| 2918 } | 2918 } |
| 2919 int32_t cc = 0, ccf = 0; | 2919 int32_t cc = 0, ccf = 0; |
| 2920 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; | 2920 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; |
| 2921 int lenf = wsNumFormat.GetLength(); | 2921 int lenf = wsNumFormat.GetLength(); |
| 2922 CFX_WideString wsSrcNum = wsInputNum; | 2922 CFX_WideString wsSrcNum = wsInputNum; |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3335 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); | 3335 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); |
| 3336 wsOutput = | 3336 wsOutput = |
| 3337 wsMinusymbol + wsOutput[0] + wsOutput.Mid(1, wsOutput.GetLength() - 1); | 3337 wsMinusymbol + wsOutput[0] + wsOutput.Mid(1, wsOutput.GetLength() - 1); |
| 3338 } | 3338 } |
| 3339 return TRUE; | 3339 return TRUE; |
| 3340 } | 3340 } |
| 3341 FX_BOOL CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum, | 3341 FX_BOOL CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum, |
| 3342 const CFX_WideString& wsPattern, | 3342 const CFX_WideString& wsPattern, |
| 3343 CFX_WideString& wsOutput) { | 3343 CFX_WideString& wsOutput) { |
| 3344 int32_t dot_index_f = -1; | 3344 int32_t dot_index_f = -1; |
| 3345 FX_DWORD dwNumStyle = 0; | 3345 uint32_t dwNumStyle = 0; |
| 3346 CFX_WideString wsNumFormat; | 3346 CFX_WideString wsNumFormat; |
| 3347 IFX_Locale* pLocale = | 3347 IFX_Locale* pLocale = |
| 3348 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); | 3348 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); |
| 3349 if (!pLocale || wsNumFormat.IsEmpty()) { | 3349 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 3350 return FALSE; | 3350 return FALSE; |
| 3351 } | 3351 } |
| 3352 int32_t cc = 0, ccf = 0; | 3352 int32_t cc = 0, ccf = 0; |
| 3353 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; | 3353 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; |
| 3354 int lenf = wsNumFormat.GetLength(); | 3354 int lenf = wsNumFormat.GetLength(); |
| 3355 double dbOrgRaw = lcNum.GetDouble(); | 3355 double dbOrgRaw = lcNum.GetDouble(); |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3979 int32_t lenf = wsDatePattern.GetLength(); | 3979 int32_t lenf = wsDatePattern.GetLength(); |
| 3980 while (ccf < lenf) { | 3980 while (ccf < lenf) { |
| 3981 if (strf[ccf] == '\'') { | 3981 if (strf[ccf] == '\'') { |
| 3982 wsResult += FX_GetLiteralText(strf, ccf, lenf); | 3982 wsResult += FX_GetLiteralText(strf, ccf, lenf); |
| 3983 ccf++; | 3983 ccf++; |
| 3984 continue; | 3984 continue; |
| 3985 } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { | 3985 } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { |
| 3986 wsResult += strf[ccf++]; | 3986 wsResult += strf[ccf++]; |
| 3987 continue; | 3987 continue; |
| 3988 } | 3988 } |
| 3989 FX_DWORD dwSymbolNum = 1; | 3989 uint32_t dwSymbolNum = 1; |
| 3990 FX_DWORD dwSymbol = strf[ccf++]; | 3990 uint32_t dwSymbol = strf[ccf++]; |
| 3991 while (ccf < lenf && strf[ccf] == dwSymbol) { | 3991 while (ccf < lenf && strf[ccf] == dwSymbol) { |
| 3992 ccf++; | 3992 ccf++; |
| 3993 dwSymbolNum++; | 3993 dwSymbolNum++; |
| 3994 } | 3994 } |
| 3995 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); | 3995 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); |
| 3996 if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { | 3996 if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { |
| 3997 CFX_WideString wsDay; | 3997 CFX_WideString wsDay; |
| 3998 wsDay.Format(L"%d", day); | 3998 wsDay.Format(L"%d", day); |
| 3999 wsResult += wsDay; | 3999 wsResult += wsDay; |
| 4000 } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { | 4000 } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4105 } | 4105 } |
| 4106 while (ccf < lenf) { | 4106 while (ccf < lenf) { |
| 4107 if (strf[ccf] == '\'') { | 4107 if (strf[ccf] == '\'') { |
| 4108 wsResult += FX_GetLiteralText(strf, ccf, lenf); | 4108 wsResult += FX_GetLiteralText(strf, ccf, lenf); |
| 4109 ccf++; | 4109 ccf++; |
| 4110 continue; | 4110 continue; |
| 4111 } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) < 0) { | 4111 } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) < 0) { |
| 4112 wsResult += strf[ccf++]; | 4112 wsResult += strf[ccf++]; |
| 4113 continue; | 4113 continue; |
| 4114 } | 4114 } |
| 4115 FX_DWORD dwSymbolNum = 1; | 4115 uint32_t dwSymbolNum = 1; |
| 4116 FX_DWORD dwSymbol = strf[ccf++]; | 4116 uint32_t dwSymbol = strf[ccf++]; |
| 4117 while (ccf < lenf && strf[ccf] == dwSymbol) { | 4117 while (ccf < lenf && strf[ccf] == dwSymbol) { |
| 4118 ccf++; | 4118 ccf++; |
| 4119 dwSymbolNum++; | 4119 dwSymbolNum++; |
| 4120 } | 4120 } |
| 4121 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); | 4121 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); |
| 4122 if (dwSymbol == FXBSTR_ID(0, 0, 'h', '1')) { | 4122 if (dwSymbol == FXBSTR_ID(0, 0, 'h', '1')) { |
| 4123 if (wHour > 12) { | 4123 if (wHour > 12) { |
| 4124 wHour -= 12; | 4124 wHour -= 12; |
| 4125 } | 4125 } |
| 4126 CFX_WideString wsHour; | 4126 CFX_WideString wsHour; |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5021 } | 5021 } |
| 5022 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 5022 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
| 5023 return Multiply(val); | 5023 return Multiply(val); |
| 5024 } | 5024 } |
| 5025 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 5025 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
| 5026 return Divide(val); | 5026 return Divide(val); |
| 5027 } | 5027 } |
| 5028 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 5028 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
| 5029 return Modulus(val); | 5029 return Modulus(val); |
| 5030 } | 5030 } |
| OLD | NEW |