| 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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 if (wsSearchCategory != wsCategory) { | 670 if (wsSearchCategory != wsCategory) { |
| 671 continue; | 671 continue; |
| 672 } | 672 } |
| 673 while (ccf < iLenf) { | 673 while (ccf < iLenf) { |
| 674 if (pStr[ccf] == '(') { | 674 if (pStr[ccf] == '(') { |
| 675 ccf++; | 675 ccf++; |
| 676 CFX_WideString wsLCID; | 676 CFX_WideString wsLCID; |
| 677 while (ccf < iLenf && pStr[ccf] != ')') { | 677 while (ccf < iLenf && pStr[ccf] != ')') { |
| 678 wsLCID += pStr[ccf++]; | 678 wsLCID += pStr[ccf++]; |
| 679 } | 679 } |
| 680 pLocale = GetPatternLocale(wsLCID.AsStringC()); | 680 pLocale = GetPatternLocale(wsLCID); |
| 681 } else if (pStr[ccf] == '{') { | 681 } else if (pStr[ccf] == '{') { |
| 682 bBrackOpen = TRUE; | 682 bBrackOpen = TRUE; |
| 683 break; | 683 break; |
| 684 } | 684 } |
| 685 ccf++; | 685 ccf++; |
| 686 } | 686 } |
| 687 } else if (pStr[ccf] != '}') { | 687 } else if (pStr[ccf] != '}') { |
| 688 wsPurgePattern += pStr[ccf]; | 688 wsPurgePattern += pStr[ccf]; |
| 689 } | 689 } |
| 690 ccf++; | 690 ccf++; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 ccf = 0; | 730 ccf = 0; |
| 731 continue; | 731 continue; |
| 732 } | 732 } |
| 733 while (ccf < iLenf) { | 733 while (ccf < iLenf) { |
| 734 if (pStr[ccf] == '(') { | 734 if (pStr[ccf] == '(') { |
| 735 ccf++; | 735 ccf++; |
| 736 CFX_WideString wsLCID; | 736 CFX_WideString wsLCID; |
| 737 while (ccf < iLenf && pStr[ccf] != ')') { | 737 while (ccf < iLenf && pStr[ccf] != ')') { |
| 738 wsLCID += pStr[ccf++]; | 738 wsLCID += pStr[ccf++]; |
| 739 } | 739 } |
| 740 pLocale = GetPatternLocale(wsLCID.AsStringC()); | 740 pLocale = GetPatternLocale(wsLCID); |
| 741 } else if (pStr[ccf] == '{') { | 741 } else if (pStr[ccf] == '{') { |
| 742 bBrackOpen = TRUE; | 742 bBrackOpen = TRUE; |
| 743 break; | 743 break; |
| 744 } else if (pStr[ccf] == '.') { | 744 } else if (pStr[ccf] == '.') { |
| 745 CFX_WideString wsSubCategory; | 745 CFX_WideString wsSubCategory; |
| 746 ccf++; | 746 ccf++; |
| 747 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 747 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 748 wsSubCategory += pStr[ccf++]; | 748 wsSubCategory += pStr[ccf++]; |
| 749 } | 749 } |
| 750 uint32_t dwSubHash = | 750 uint32_t dwSubHash = |
| (...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 } else { | 2185 } else { |
| 2186 continue; | 2186 continue; |
| 2187 } | 2187 } |
| 2188 while (ccf < iLenf) { | 2188 while (ccf < iLenf) { |
| 2189 if (pStr[ccf] == '(') { | 2189 if (pStr[ccf] == '(') { |
| 2190 ccf++; | 2190 ccf++; |
| 2191 CFX_WideString wsLCID; | 2191 CFX_WideString wsLCID; |
| 2192 while (ccf < iLenf && pStr[ccf] != ')') { | 2192 while (ccf < iLenf && pStr[ccf] != ')') { |
| 2193 wsLCID += pStr[ccf++]; | 2193 wsLCID += pStr[ccf++]; |
| 2194 } | 2194 } |
| 2195 pLocale = GetPatternLocale(wsLCID.AsStringC()); | 2195 pLocale = GetPatternLocale(wsLCID); |
| 2196 } else if (pStr[ccf] == '{') { | 2196 } else if (pStr[ccf] == '{') { |
| 2197 bBraceOpen = TRUE; | 2197 bBraceOpen = TRUE; |
| 2198 break; | 2198 break; |
| 2199 } else if (pStr[ccf] == '.') { | 2199 } else if (pStr[ccf] == '.') { |
| 2200 CFX_WideString wsSubCategory; | 2200 CFX_WideString wsSubCategory; |
| 2201 ccf++; | 2201 ccf++; |
| 2202 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 2202 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 2203 wsSubCategory += pStr[ccf++]; | 2203 wsSubCategory += pStr[ccf++]; |
| 2204 } | 2204 } |
| 2205 uint32_t dwSubHash = | 2205 uint32_t dwSubHash = |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2876 uint32_t dwNumStyle = 0; | 2876 uint32_t dwNumStyle = 0; |
| 2877 CFX_WideString wsNumFormat; | 2877 CFX_WideString wsNumFormat; |
| 2878 IFX_Locale* pLocale = | 2878 IFX_Locale* pLocale = |
| 2879 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); | 2879 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); |
| 2880 if (!pLocale || wsNumFormat.IsEmpty()) { | 2880 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 2881 return FALSE; | 2881 return FALSE; |
| 2882 } | 2882 } |
| 2883 int32_t cc = 0, ccf = 0; | 2883 int32_t cc = 0, ccf = 0; |
| 2884 const FX_WCHAR* strf = wsNumFormat.c_str(); | 2884 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 2885 int lenf = wsNumFormat.GetLength(); | 2885 int lenf = wsNumFormat.GetLength(); |
| 2886 CFX_WideString wsSrcNum = wsInputNum; | 2886 CFX_WideString wsSrcNum(wsInputNum); |
| 2887 wsSrcNum.TrimLeft('0'); | 2887 wsSrcNum.TrimLeft('0'); |
| 2888 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { | 2888 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { |
| 2889 wsSrcNum.Insert(0, '0'); | 2889 wsSrcNum.Insert(0, '0'); |
| 2890 } | 2890 } |
| 2891 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC()); | 2891 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC()); |
| 2892 if (dwNumStyle & FX_NUMSTYLE_Percent) { | 2892 if (dwNumStyle & FX_NUMSTYLE_Percent) { |
| 2893 decimal = decimal * CFX_Decimal(100); | 2893 decimal = decimal * CFX_Decimal(100); |
| 2894 wsSrcNum = decimal; | 2894 wsSrcNum = decimal; |
| 2895 } | 2895 } |
| 2896 int32_t exponent = 0; | 2896 int32_t exponent = 0; |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4262 if (eCategory == FX_DATETIMETYPE_Date && | 4262 if (eCategory == FX_DATETIMETYPE_Date && |
| 4263 FX_DateFromCanonical(wsSrcDateTime, dt)) { | 4263 FX_DateFromCanonical(wsSrcDateTime, dt)) { |
| 4264 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4264 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, |
| 4265 wsOutput); | 4265 wsOutput); |
| 4266 } else if (eCategory == FX_DATETIMETYPE_Time && | 4266 } else if (eCategory == FX_DATETIMETYPE_Time && |
| 4267 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale)) { | 4267 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale)) { |
| 4268 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4268 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, |
| 4269 wsOutput); | 4269 wsOutput); |
| 4270 } | 4270 } |
| 4271 } else { | 4271 } else { |
| 4272 CFX_WideStringC wsSrcDate(wsSrcDateTime.c_str(), iT); | 4272 CFX_WideString wsSrcDate(wsSrcDateTime.c_str(), iT); |
| 4273 CFX_WideStringC wsSrcTime(wsSrcDateTime.c_str() + iT + 1, | 4273 CFX_WideStringC wsSrcTime(wsSrcDateTime.c_str() + iT + 1, |
| 4274 wsSrcDateTime.GetLength() - iT - 1); | 4274 wsSrcDateTime.GetLength() - iT - 1); |
| 4275 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { | 4275 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { |
| 4276 return FALSE; | 4276 return FALSE; |
| 4277 } | 4277 } |
| 4278 if (FX_DateFromCanonical(wsSrcDate, dt) && | 4278 if (FX_DateFromCanonical(wsSrcDate, dt) && |
| 4279 FX_TimeFromCanonical(wsSrcTime, dt, pLocale)) { | 4279 FX_TimeFromCanonical(wsSrcTime, dt, pLocale)) { |
| 4280 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, | 4280 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, |
| 4281 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, | 4281 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, |
| 4282 wsOutput); | 4282 wsOutput); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4338 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 4338 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 4339 iPattern++; | 4339 iPattern++; |
| 4340 continue; | 4340 continue; |
| 4341 } else { | 4341 } else { |
| 4342 wsOutput += pStrPattern[iPattern++]; | 4342 wsOutput += pStrPattern[iPattern++]; |
| 4343 continue; | 4343 continue; |
| 4344 } | 4344 } |
| 4345 } | 4345 } |
| 4346 return TRUE; | 4346 return TRUE; |
| 4347 } | 4347 } |
| 4348 IFX_Locale* CFX_FormatString::GetPatternLocale( | 4348 IFX_Locale* CFX_FormatString::GetPatternLocale(const CFX_WideString& wsLocale) { |
| 4349 const CFX_WideStringC& wsLocale) { | |
| 4350 if (m_bUseLCID) { | |
| 4351 } | |
| 4352 return m_pLocaleMgr->GetLocaleByName(wsLocale); | 4349 return m_pLocaleMgr->GetLocaleByName(wsLocale); |
| 4353 } | 4350 } |
| 4354 #define FXMATH_DECIMAL_SCALELIMIT 0x1c | 4351 #define FXMATH_DECIMAL_SCALELIMIT 0x1c |
| 4355 #define FXMATH_DECIMAL_NEGMASK (0x80000000L) | 4352 #define FXMATH_DECIMAL_NEGMASK (0x80000000L) |
| 4356 #define FXMATH_DECIMAL_FORCEBOOL(x) (!(!(x))) | 4353 #define FXMATH_DECIMAL_FORCEBOOL(x) (!(!(x))) |
| 4357 #define FXMATH_DECIMAL_MAKEFLAGS(NEG, SCALE) \ | 4354 #define FXMATH_DECIMAL_MAKEFLAGS(NEG, SCALE) \ |
| 4358 (((SCALE) << 0x10) | ((NEG) ? FXMATH_DECIMAL_NEGMASK : 0)) | 4355 (((SCALE) << 0x10) | ((NEG) ? FXMATH_DECIMAL_NEGMASK : 0)) |
| 4359 #define FXMATH_DECIMAL_FLAGS2NEG(FLAGS) \ | 4356 #define FXMATH_DECIMAL_FLAGS2NEG(FLAGS) \ |
| 4360 FXMATH_DECIMAL_FORCEBOOL((FLAGS)&FXMATH_DECIMAL_NEGMASK) | 4357 FXMATH_DECIMAL_FORCEBOOL((FLAGS)&FXMATH_DECIMAL_NEGMASK) |
| 4361 #define FXMATH_DECIMAL_FLAGS2SCALE(FLAGS) \ | 4358 #define FXMATH_DECIMAL_FLAGS2SCALE(FLAGS) \ |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4988 } | 4985 } |
| 4989 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 4986 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
| 4990 return Multiply(val); | 4987 return Multiply(val); |
| 4991 } | 4988 } |
| 4992 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 4989 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
| 4993 return Divide(val); | 4990 return Divide(val); |
| 4994 } | 4991 } |
| 4995 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 4992 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
| 4996 return Modulus(val); | 4993 return Modulus(val); |
| 4997 } | 4994 } |
| OLD | NEW |