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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 uint32_t dwSubHash = FX_HashCode_String_GetW( | 758 uint32_t dwSubHash = FX_HashCode_String_GetW( |
759 wsSubCategory.c_str(), wsSubCategory.GetLength()); | 759 wsSubCategory.c_str(), wsSubCategory.GetLength()); |
760 FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; | 760 FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; |
761 for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { | 761 for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { |
762 if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { | 762 if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { |
763 eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] | 763 eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] |
764 .eSubCategory; | 764 .eSubCategory; |
765 break; | 765 break; |
766 } | 766 } |
767 } | 767 } |
768 wsSubCategory.Empty(); | 768 wsSubCategory.clear(); |
769 if (!pLocale) { | 769 if (!pLocale) { |
770 pLocale = m_pLocaleMgr->GetDefLocale(); | 770 pLocale = m_pLocaleMgr->GetDefLocale(); |
771 } | 771 } |
772 FXSYS_assert(pLocale != NULL); | 772 FXSYS_assert(pLocale != NULL); |
773 pLocale->GetNumPattern(eSubCategory, wsSubCategory); | 773 pLocale->GetNumPattern(eSubCategory, wsSubCategory); |
774 iDotIndex = wsSubCategory.Find('.'); | 774 iDotIndex = wsSubCategory.Find('.'); |
775 if (iDotIndex > 0) { | 775 if (iDotIndex > 0) { |
776 iDotIndex += wsPurgePattern.GetLength(); | 776 iDotIndex += wsPurgePattern.GetLength(); |
777 bFindDot = TRUE; | 777 bFindDot = TRUE; |
778 dwStyle |= FX_NUMSTYLE_DotVorv; | 778 dwStyle |= FX_NUMSTYLE_DotVorv; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 iDotIndex = wsNum.Find('.'); | 831 iDotIndex = wsNum.Find('.'); |
832 if (iDotIndex < 0) { | 832 if (iDotIndex < 0) { |
833 iDotIndex = iLenf; | 833 iDotIndex = iLenf; |
834 return FALSE; | 834 return FALSE; |
835 } | 835 } |
836 return TRUE; | 836 return TRUE; |
837 } | 837 } |
838 FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText, | 838 FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText, |
839 const CFX_WideString& wsPattern, | 839 const CFX_WideString& wsPattern, |
840 CFX_WideString& wsValue) { | 840 CFX_WideString& wsValue) { |
841 wsValue.Empty(); | 841 wsValue.clear(); |
842 if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) { | 842 if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) { |
843 return FALSE; | 843 return FALSE; |
844 } | 844 } |
845 CFX_WideString wsTextFormat; | 845 CFX_WideString wsTextFormat; |
846 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); | 846 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); |
847 if (wsTextFormat.IsEmpty()) { | 847 if (wsTextFormat.IsEmpty()) { |
848 return FALSE; | 848 return FALSE; |
849 } | 849 } |
850 int32_t iText = 0, iPattern = 0; | 850 int32_t iText = 0, iPattern = 0; |
851 const FX_WCHAR* pStrText = wsSrcText.c_str(); | 851 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 if (j > i) { | 1656 if (j > i) { |
1657 pDst[nIndex++] = '.'; | 1657 pDst[nIndex++] = '.'; |
1658 FXSYS_wcsncpy(pDst + nIndex, pStr + i + 1, j - i); | 1658 FXSYS_wcsncpy(pDst + nIndex, pStr + i + 1, j - i); |
1659 nIndex += j - i; | 1659 nIndex += j - i; |
1660 } | 1660 } |
1661 wsResult.ReleaseBuffer(nIndex); | 1661 wsResult.ReleaseBuffer(nIndex); |
1662 } | 1662 } |
1663 FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, | 1663 FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, |
1664 const CFX_WideString& wsPattern, | 1664 const CFX_WideString& wsPattern, |
1665 CFX_WideString& wsValue) { | 1665 CFX_WideString& wsValue) { |
1666 wsValue.Empty(); | 1666 wsValue.clear(); |
1667 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { | 1667 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { |
1668 return FALSE; | 1668 return FALSE; |
1669 } | 1669 } |
1670 int32_t dot_index_f = -1; | 1670 int32_t dot_index_f = -1; |
1671 uint32_t dwFormatStyle = 0; | 1671 uint32_t dwFormatStyle = 0; |
1672 CFX_WideString wsNumFormat; | 1672 CFX_WideString wsNumFormat; |
1673 IFX_Locale* pLocale = | 1673 IFX_Locale* pLocale = |
1674 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); | 1674 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); |
1675 if (!pLocale || wsNumFormat.IsEmpty()) { | 1675 if (!pLocale || wsNumFormat.IsEmpty()) { |
1676 return FALSE; | 1676 return FALSE; |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 wsTimePattern = wsTempPattern + wsTimePattern; | 2235 wsTimePattern = wsTempPattern + wsTimePattern; |
2236 break; | 2236 break; |
2237 case FX_LOCALECATEGORY_DateTime: | 2237 case FX_LOCALECATEGORY_DateTime: |
2238 pLocale->GetDatePattern(eSubCategory, wsDatePattern); | 2238 pLocale->GetDatePattern(eSubCategory, wsDatePattern); |
2239 wsDatePattern = wsTempPattern + wsDatePattern; | 2239 wsDatePattern = wsTempPattern + wsDatePattern; |
2240 pLocale->GetTimePattern(eSubCategory, wsTimePattern); | 2240 pLocale->GetTimePattern(eSubCategory, wsTimePattern); |
2241 break; | 2241 break; |
2242 default: | 2242 default: |
2243 break; | 2243 break; |
2244 } | 2244 } |
2245 wsTempPattern.Empty(); | 2245 wsTempPattern.clear(); |
2246 continue; | 2246 continue; |
2247 } | 2247 } |
2248 ccf++; | 2248 ccf++; |
2249 } | 2249 } |
2250 } else if (pStr[ccf] == '}') { | 2250 } else if (pStr[ccf] == '}') { |
2251 bBraceOpen = FALSE; | 2251 bBraceOpen = FALSE; |
2252 if (!wsTempPattern.IsEmpty()) { | 2252 if (!wsTempPattern.IsEmpty()) { |
2253 if (eCategory == FX_LOCALECATEGORY_Time) { | 2253 if (eCategory == FX_LOCALECATEGORY_Time) { |
2254 wsTimePattern = wsTempPattern; | 2254 wsTimePattern = wsTempPattern; |
2255 } else if (eCategory == FX_LOCALECATEGORY_Date) { | 2255 } else if (eCategory == FX_LOCALECATEGORY_Date) { |
2256 wsDatePattern = wsTempPattern; | 2256 wsDatePattern = wsTempPattern; |
2257 } | 2257 } |
2258 wsTempPattern.Empty(); | 2258 wsTempPattern.clear(); |
2259 } | 2259 } |
2260 } else { | 2260 } else { |
2261 wsTempPattern += pStr[ccf]; | 2261 wsTempPattern += pStr[ccf]; |
2262 } | 2262 } |
2263 ccf++; | 2263 ccf++; |
2264 } | 2264 } |
2265 if (!wsTempPattern.IsEmpty()) { | 2265 if (!wsTempPattern.IsEmpty()) { |
2266 if (eCategory == FX_LOCALECATEGORY_Date) { | 2266 if (eCategory == FX_LOCALECATEGORY_Date) { |
2267 wsDatePattern += wsTempPattern; | 2267 wsDatePattern += wsTempPattern; |
2268 } else { | 2268 } else { |
2269 wsTimePattern += wsTempPattern; | 2269 wsTimePattern += wsTempPattern; |
2270 } | 2270 } |
2271 } | 2271 } |
2272 if (!pLocale) { | 2272 if (!pLocale) { |
2273 pLocale = m_pLocaleMgr->GetDefLocale(); | 2273 pLocale = m_pLocaleMgr->GetDefLocale(); |
2274 } | 2274 } |
2275 if (!iFindCategory) { | 2275 if (!iFindCategory) { |
2276 wsTimePattern.Empty(); | 2276 wsTimePattern.clear(); |
2277 wsDatePattern = wsPattern; | 2277 wsDatePattern = wsPattern; |
2278 } | 2278 } |
2279 return (FX_DATETIMETYPE)iFindCategory; | 2279 return (FX_DATETIMETYPE)iFindCategory; |
2280 } | 2280 } |
2281 static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate, | 2281 static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate, |
2282 const CFX_WideString& wsDatePattern, | 2282 const CFX_WideString& wsDatePattern, |
2283 IFX_Locale* pLocale, | 2283 IFX_Locale* pLocale, |
2284 CFX_Unitime& datetime, | 2284 CFX_Unitime& datetime, |
2285 int32_t& cc) { | 2285 int32_t& cc) { |
2286 int32_t year = 1900; | 2286 int32_t year = 1900; |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3116 wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; | 3116 wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; |
3117 ccf--; | 3117 ccf--; |
3118 break; | 3118 break; |
3119 default: | 3119 default: |
3120 wsOutput = strf[ccf] + wsOutput; | 3120 wsOutput = strf[ccf] + wsOutput; |
3121 ccf--; | 3121 ccf--; |
3122 } | 3122 } |
3123 } | 3123 } |
3124 if (cc >= 0) { | 3124 if (cc >= 0) { |
3125 int nPos = dot_index % 3; | 3125 int nPos = dot_index % 3; |
3126 wsOutput.Empty(); | 3126 wsOutput.clear(); |
3127 for (int32_t i = 0; i < dot_index; i++) { | 3127 for (int32_t i = 0; i < dot_index; i++) { |
3128 if (i % 3 == nPos && i != 0) { | 3128 if (i % 3 == nPos && i != 0) { |
3129 wsOutput += wsGroupSymbol; | 3129 wsOutput += wsGroupSymbol; |
3130 } | 3130 } |
3131 wsOutput += wsSrcNum[i]; | 3131 wsOutput += wsSrcNum[i]; |
3132 } | 3132 } |
3133 if (dot_index < len) { | 3133 if (dot_index < len) { |
3134 CFX_WideString wsSymbol; | 3134 CFX_WideString wsSymbol; |
3135 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); | 3135 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); |
3136 wsOutput += wsSymbol; | 3136 wsOutput += wsSymbol; |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3533 wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; | 3533 wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; |
3534 ccf--; | 3534 ccf--; |
3535 break; | 3535 break; |
3536 default: | 3536 default: |
3537 wsOutput = strf[ccf] + wsOutput; | 3537 wsOutput = strf[ccf] + wsOutput; |
3538 ccf--; | 3538 ccf--; |
3539 } | 3539 } |
3540 } | 3540 } |
3541 if (cc >= 0) { | 3541 if (cc >= 0) { |
3542 int nPos = dot_index % 3; | 3542 int nPos = dot_index % 3; |
3543 wsOutput.Empty(); | 3543 wsOutput.clear(); |
3544 for (int32_t i = 0; i < dot_index; i++) { | 3544 for (int32_t i = 0; i < dot_index; i++) { |
3545 if (i % 3 == nPos && i != 0) { | 3545 if (i % 3 == nPos && i != 0) { |
3546 wsOutput += wsGroupSymbol; | 3546 wsOutput += wsGroupSymbol; |
3547 } | 3547 } |
3548 wsOutput += wsNumeric[i]; | 3548 wsOutput += wsNumeric[i]; |
3549 } | 3549 } |
3550 if (dot_index < len) { | 3550 if (dot_index < len) { |
3551 CFX_WideString wsSymbol; | 3551 CFX_WideString wsSymbol; |
3552 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); | 3552 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); |
3553 wsOutput += wsSymbol; | 3553 wsOutput += wsSymbol; |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4247 CFX_WideString wsDatePattern, wsTimePattern; | 4247 CFX_WideString wsDatePattern, wsTimePattern; |
4248 IFX_Locale* pLocale = NULL; | 4248 IFX_Locale* pLocale = NULL; |
4249 FX_DATETIMETYPE eCategory = | 4249 FX_DATETIMETYPE eCategory = |
4250 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); | 4250 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); |
4251 if (!pLocale) { | 4251 if (!pLocale) { |
4252 return FALSE; | 4252 return FALSE; |
4253 } | 4253 } |
4254 if (eCategory == FX_DATETIMETYPE_Unknown) { | 4254 if (eCategory == FX_DATETIMETYPE_Unknown) { |
4255 if (eDateTimeType == FX_DATETIMETYPE_Time) { | 4255 if (eDateTimeType == FX_DATETIMETYPE_Time) { |
4256 wsTimePattern = wsDatePattern; | 4256 wsTimePattern = wsDatePattern; |
4257 wsDatePattern.Empty(); | 4257 wsDatePattern.clear(); |
4258 } | 4258 } |
4259 eCategory = eDateTimeType; | 4259 eCategory = eDateTimeType; |
4260 } | 4260 } |
4261 if (eCategory == FX_DATETIMETYPE_Unknown) { | 4261 if (eCategory == FX_DATETIMETYPE_Unknown) { |
4262 return FALSE; | 4262 return FALSE; |
4263 } | 4263 } |
4264 CFX_Unitime dt(0); | 4264 CFX_Unitime dt(0); |
4265 int32_t iT = wsSrcDateTime.Find(L"T"); | 4265 int32_t iT = wsSrcDateTime.Find(L"T"); |
4266 if (iT < 0) { | 4266 if (iT < 0) { |
4267 if (eCategory == FX_DATETIMETYPE_Date && | 4267 if (eCategory == FX_DATETIMETYPE_Date && |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4993 } | 4993 } |
4994 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 4994 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
4995 return Multiply(val); | 4995 return Multiply(val); |
4996 } | 4996 } |
4997 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 4997 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
4998 return Divide(val); | 4998 return Divide(val); |
4999 } | 4999 } |
5000 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 5000 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
5001 return Modulus(val); | 5001 return Modulus(val); |
5002 } | 5002 } |
OLD | NEW |