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 "../../../foxitlib.h" | 7 #include "../../../foxitlib.h" |
8 #include "../common/xfa_utils.h" | 8 #include "../common/xfa_utils.h" |
9 #include "../common/xfa_object.h" | 9 #include "../common/xfa_object.h" |
10 #include "../common/xfa_document.h" | 10 #include "../common/xfa_document.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 { | 93 { |
94 CFX_WideString wsOutput; | 94 CFX_WideString wsOutput; |
95 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); | 95 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); |
96 if (pLocale) { | 96 if (pLocale) { |
97 m_pLocaleMgr->SetDefLocale(pLocale); | 97 m_pLocaleMgr->SetDefLocale(pLocale); |
98 } | 98 } |
99 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); | 99 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); |
100 CFX_WideStringArray wsPatterns; | 100 CFX_WideStringArray wsPatterns; |
101 pFormat->SplitFormatString(wsPattern, wsPatterns); | 101 pFormat->SplitFormatString(wsPattern, wsPatterns); |
102 FX_BOOL bRet = FALSE; | 102 FX_BOOL bRet = FALSE; |
103 FX_INT32 iCount = wsPatterns.GetSize(); | 103 int32_t iCount = wsPatterns.GetSize(); |
104 FX_INT32 i = 0; | 104 int32_t i = 0; |
105 for (; i < iCount && !bRet; i++) { | 105 for (; i < iCount && !bRet; i++) { |
106 CFX_WideString wsFormat = wsPatterns[i]; | 106 CFX_WideString wsFormat = wsPatterns[i]; |
107 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); | 107 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); |
108 eCategory = XFA_ValugeCategory(eCategory, m_dwType); | 108 eCategory = XFA_ValugeCategory(eCategory, m_dwType); |
109 switch (eCategory) { | 109 switch (eCategory) { |
110 case FX_LOCALECATEGORY_Null: | 110 case FX_LOCALECATEGORY_Null: |
111 bRet = pFormat->ParseNull(wsValue, wsFormat); | 111 bRet = pFormat->ParseNull(wsValue, wsFormat); |
112 if (!bRet) { | 112 if (!bRet) { |
113 bRet = wsValue.IsEmpty(); | 113 bRet = wsValue.IsEmpty(); |
114 } | 114 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 { | 192 { |
193 if (m_bValid && m_dwType == XFA_VT_TEXT) { | 193 if (m_bValid && m_dwType == XFA_VT_TEXT) { |
194 return m_wsValue; | 194 return m_wsValue; |
195 } | 195 } |
196 return CFX_WideString(); | 196 return CFX_WideString(); |
197 } | 197 } |
198 FX_FLOAT CXFA_LocaleValue::GetNum() const | 198 FX_FLOAT CXFA_LocaleValue::GetNum() const |
199 { | 199 { |
200 if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || | 200 if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || |
201 m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { | 201 m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { |
202 FX_INT64 nIntegral = 0; | 202 int64_t nIntegral = 0; |
203 FX_DWORD dwFractional = 0; | 203 FX_DWORD dwFractional = 0; |
204 FX_INT32 nExponent = 0; | 204 int32_t nExponent = 0; |
205 int cc = 0; | 205 int cc = 0; |
206 FX_BOOL bNegative = FALSE, bExpSign = FALSE; | 206 FX_BOOL bNegative = FALSE, bExpSign = FALSE; |
207 FX_LPCWSTR str = (FX_LPCWSTR)m_wsValue; | 207 FX_LPCWSTR str = (FX_LPCWSTR)m_wsValue; |
208 int len = m_wsValue.GetLength(); | 208 int len = m_wsValue.GetLength(); |
209 while (XFA_IsSpace(str[cc]) && cc < len) { | 209 while (XFA_IsSpace(str[cc]) && cc < len) { |
210 cc++; | 210 cc++; |
211 } | 211 } |
212 if (cc >= len) { | 212 if (cc >= len) { |
213 return 0; | 213 return 0; |
214 } | 214 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 fValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); | 268 fValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); |
269 } | 269 } |
270 return fValue; | 270 return fValue; |
271 } | 271 } |
272 return 0; | 272 return 0; |
273 } | 273 } |
274 FX_DOUBLE CXFA_LocaleValue::GetDoubleNum() const | 274 FX_DOUBLE CXFA_LocaleValue::GetDoubleNum() const |
275 { | 275 { |
276 if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || | 276 if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || |
277 m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { | 277 m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { |
278 FX_INT64 nIntegral = 0; | 278 int64_t nIntegral = 0; |
279 FX_DWORD dwFractional = 0; | 279 FX_DWORD dwFractional = 0; |
280 FX_INT32 nExponent = 0; | 280 int32_t nExponent = 0; |
281 FX_INT32 cc = 0; | 281 int32_t cc = 0; |
282 FX_BOOL bNegative = FALSE, bExpSign = FALSE; | 282 FX_BOOL bNegative = FALSE, bExpSign = FALSE; |
283 FX_LPCWSTR str = (FX_LPCWSTR)m_wsValue; | 283 FX_LPCWSTR str = (FX_LPCWSTR)m_wsValue; |
284 int len = m_wsValue.GetLength(); | 284 int len = m_wsValue.GetLength(); |
285 while (XFA_IsSpace(str[cc]) && cc < len) { | 285 while (XFA_IsSpace(str[cc]) && cc < len) { |
286 cc++; | 286 cc++; |
287 } | 287 } |
288 if (cc >= len) { | 288 if (cc >= len) { |
289 return 0; | 289 return 0; |
290 } | 290 } |
291 if (str[0] == '+') { | 291 if (str[0] == '+') { |
292 cc++; | 292 cc++; |
293 } else if (str[0] == '-') { | 293 } else if (str[0] == '-') { |
294 bNegative = TRUE; | 294 bNegative = TRUE; |
295 cc++; | 295 cc++; |
296 } | 296 } |
297 FX_INT32 nIntegralLen = 0; | 297 int32_t nIntegralLen = 0; |
298 while (cc < len) { | 298 while (cc < len) { |
299 if (str[cc] == '.' || !XFA_IsDigit(str[cc]) || nIntegralLen > 17) { | 299 if (str[cc] == '.' || !XFA_IsDigit(str[cc]) || nIntegralLen > 17) { |
300 break; | 300 break; |
301 } | 301 } |
302 nIntegral = nIntegral * 10 + str[cc] - '0'; | 302 nIntegral = nIntegral * 10 + str[cc] - '0'; |
303 cc ++; | 303 cc ++; |
304 nIntegralLen++; | 304 nIntegralLen++; |
305 } | 305 } |
306 nIntegral = bNegative ? -nIntegral : nIntegral; | 306 nIntegral = bNegative ? -nIntegral : nIntegral; |
307 FX_INT32 scale = 0; | 307 int32_t scale = 0; |
308 FX_DOUBLE fraction = 0.0; | 308 FX_DOUBLE fraction = 0.0; |
309 if (cc < len && str[cc] == '.') { | 309 if (cc < len && str[cc] == '.') { |
310 cc ++; | 310 cc ++; |
311 while (cc < len) { | 311 while (cc < len) { |
312 fraction += fraction_scales[scale] * (str[cc] - '0'); | 312 fraction += fraction_scales[scale] * (str[cc] - '0'); |
313 scale ++; | 313 scale ++; |
314 cc ++; | 314 cc ++; |
315 if (scale == sizeof fraction_scales / sizeof(FX_DOUBLE) | 315 if (scale == sizeof fraction_scales / sizeof(FX_DOUBLE) |
316 || !XFA_IsDigit(str[cc])) { | 316 || !XFA_IsDigit(str[cc])) { |
317 break; | 317 break; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 CFX_Unitime dt(0); | 362 CFX_Unitime dt(0); |
363 FXSYS_assert(m_pLocaleMgr); | 363 FXSYS_assert(m_pLocaleMgr); |
364 FX_TimeFromCanonical(m_wsValue, dt, m_pLocaleMgr->GetDefLocale()); | 364 FX_TimeFromCanonical(m_wsValue, dt, m_pLocaleMgr->GetDefLocale()); |
365 return dt; | 365 return dt; |
366 } | 366 } |
367 return CFX_Unitime(); | 367 return CFX_Unitime(); |
368 } | 368 } |
369 CFX_Unitime CXFA_LocaleValue::GetDateTime() const | 369 CFX_Unitime CXFA_LocaleValue::GetDateTime() const |
370 { | 370 { |
371 if (m_bValid && m_dwType == XFA_VT_DATETIME) { | 371 if (m_bValid && m_dwType == XFA_VT_DATETIME) { |
372 FX_INT32 index = m_wsValue.Find('T'); | 372 int32_t index = m_wsValue.Find('T'); |
373 CFX_Unitime dt; | 373 CFX_Unitime dt; |
374 FX_DateFromCanonical(m_wsValue.Left(index), dt); | 374 FX_DateFromCanonical(m_wsValue.Left(index), dt); |
375 FXSYS_assert(m_pLocaleMgr); | 375 FXSYS_assert(m_pLocaleMgr); |
376 FX_TimeFromCanonical(m_wsValue.Right(m_wsValue.GetLength() - index - 1),
dt, m_pLocaleMgr->GetDefLocale()); | 376 FX_TimeFromCanonical(m_wsValue.Right(m_wsValue.GetLength() - index - 1),
dt, m_pLocaleMgr->GetDefLocale()); |
377 return dt; | 377 return dt; |
378 } | 378 } |
379 return CFX_Unitime(); | 379 return CFX_Unitime(); |
380 } | 380 } |
381 FX_BOOL CXFA_LocaleValue::SetText(const CFX_WideString& wsText) | 381 FX_BOOL CXFA_LocaleValue::SetText(const CFX_WideString& wsText) |
382 { | 382 { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 return m_bValid = ParsePatternValue(wsDateTime, wsFormat, pLocale); | 447 return m_bValid = ParsePatternValue(wsDateTime, wsFormat, pLocale); |
448 } | 448 } |
449 FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult, const CFX_Wid
eString& wsFormat, IFX_Locale* pLocale, | 449 FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult, const CFX_Wid
eString& wsFormat, IFX_Locale* pLocale, |
450 XFA_VALUEPICTURE eValueType) const | 450 XFA_VALUEPICTURE eValueType) const |
451 { | 451 { |
452 wsResult.Empty(); | 452 wsResult.Empty(); |
453 FX_BOOL bRet = FALSE; | 453 FX_BOOL bRet = FALSE; |
454 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); | 454 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); |
455 CFX_WideStringArray wsPatterns; | 455 CFX_WideStringArray wsPatterns; |
456 pFormat->SplitFormatString(wsFormat, wsPatterns); | 456 pFormat->SplitFormatString(wsFormat, wsPatterns); |
457 FX_INT32 iCount = wsPatterns.GetSize(); | 457 int32_t iCount = wsPatterns.GetSize(); |
458 for (FX_INT32 i = 0; i < iCount; i++) { | 458 for (int32_t i = 0; i < iCount; i++) { |
459 bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType)
; | 459 bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType)
; |
460 if (bRet) { | 460 if (bRet) { |
461 break; | 461 break; |
462 } | 462 } |
463 } | 463 } |
464 pFormat->Release(); | 464 pFormat->Release(); |
465 return bRet; | 465 return bRet; |
466 } | 466 } |
467 FX_BOOL CXFA_LocaleValue::FormatSinglePattern(CFX_WideString& wsResult, const CF
X_WideString& wsFormat, IFX_Locale* pLocale, | 467 FX_BOOL CXFA_LocaleValue::FormatSinglePattern(CFX_WideString& wsResult, const CF
X_WideString& wsFormat, IFX_Locale* pLocale, |
468 XFA_VALUEPICTURE eValueType) const | 468 XFA_VALUEPICTURE eValueType) const |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 } | 643 } |
644 } else { | 644 } else { |
645 if (wDay > 28) { | 645 if (wDay > 28) { |
646 return FALSE; | 646 return FALSE; |
647 } | 647 } |
648 } | 648 } |
649 } else if (wDay > LastDay[wMonth - 1]) { | 649 } else if (wDay > LastDay[wMonth - 1]) { |
650 return FALSE; | 650 return FALSE; |
651 } | 651 } |
652 CFX_Unitime ut; | 652 CFX_Unitime ut; |
653 ut.Set(wYear, static_cast<FX_BYTE>(wMonth), static_cast<FX_BYTE>(wDay)); | 653 ut.Set(wYear, static_cast<uint8_t>(wMonth), static_cast<uint8_t>(wDay)); |
654 unDate = unDate + ut; | 654 unDate = unDate + ut; |
655 return TRUE; | 655 return TRUE; |
656 } | 656 } |
657 FX_BOOL CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) | 657 FX_BOOL CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) |
658 { | 658 { |
659 int nLen = wsTime.GetLength(); | 659 int nLen = wsTime.GetLength(); |
660 if (nLen < 2) { | 660 if (nLen < 2) { |
661 return FALSE; | 661 return FALSE; |
662 } | 662 } |
663 const FX_WORD wCountH = 2, wCountM = 2, wCountS = 2, wCountF = 3; | 663 const FX_WORD wCountH = 2, wCountM = 2, wCountS = 2, wCountF = 3; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 return FALSE; | 711 return FALSE; |
712 } | 712 } |
713 wFraction = (pTime[nIndex] - '0') + wFraction * 10; | 713 wFraction = (pTime[nIndex] - '0') + wFraction * 10; |
714 nIndex++; | 714 nIndex++; |
715 } | 715 } |
716 } | 716 } |
717 if (nIndex < nLen) { | 717 if (nIndex < nLen) { |
718 if (pTime[nIndex] == 'Z') { | 718 if (pTime[nIndex] == 'Z') { |
719 nIndex++; | 719 nIndex++; |
720 } else if (pTime[nIndex] == '-' || pTime[nIndex] == '+') { | 720 } else if (pTime[nIndex] == '-' || pTime[nIndex] == '+') { |
721 FX_SHORT nOffsetH = 0, nOffsetM = 0; | 721 int16_t nOffsetH = 0, nOffsetM = 0; |
722 nIndex++; | 722 nIndex++; |
723 nStart = nIndex; | 723 nStart = nIndex; |
724 while (pTime[nIndex] != '\0' && nIndex - nStart < wCountH && nIndex
< nLen) { | 724 while (pTime[nIndex] != '\0' && nIndex - nStart < wCountH && nIndex
< nLen) { |
725 if (!XFA_IsDigit(pTime[nIndex])) { | 725 if (!XFA_IsDigit(pTime[nIndex])) { |
726 return FALSE; | 726 return FALSE; |
727 } | 727 } |
728 nOffsetH = (pTime[nIndex] - '0') + nOffsetH * 10; | 728 nOffsetH = (pTime[nIndex] - '0') + nOffsetH * 10; |
729 nIndex++; | 729 nIndex++; |
730 } | 730 } |
731 if (bSymbol) { | 731 if (bSymbol) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 FX_BOOL CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue, const
CFX_WideString& wsPattern, IFX_Locale* pLocale) | 789 FX_BOOL CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue, const
CFX_WideString& wsPattern, IFX_Locale* pLocale) |
790 { | 790 { |
791 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); | 791 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); |
792 if (pLocale) { | 792 if (pLocale) { |
793 m_pLocaleMgr->SetDefLocale(pLocale); | 793 m_pLocaleMgr->SetDefLocale(pLocale); |
794 } | 794 } |
795 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); | 795 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); |
796 CFX_WideStringArray wsPatterns; | 796 CFX_WideStringArray wsPatterns; |
797 pFormat->SplitFormatString(wsPattern, wsPatterns); | 797 pFormat->SplitFormatString(wsPattern, wsPatterns); |
798 FX_BOOL bRet = FALSE; | 798 FX_BOOL bRet = FALSE; |
799 FX_INT32 iCount = wsPatterns.GetSize(); | 799 int32_t iCount = wsPatterns.GetSize(); |
800 for (FX_INT32 i = 0; i < iCount && !bRet; i++) { | 800 for (int32_t i = 0; i < iCount && !bRet; i++) { |
801 CFX_WideString wsFormat = wsPatterns[i]; | 801 CFX_WideString wsFormat = wsPatterns[i]; |
802 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); | 802 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); |
803 eCategory = XFA_ValugeCategory(eCategory, m_dwType); | 803 eCategory = XFA_ValugeCategory(eCategory, m_dwType); |
804 switch (eCategory) { | 804 switch (eCategory) { |
805 case FX_LOCALECATEGORY_Null: | 805 case FX_LOCALECATEGORY_Null: |
806 bRet = pFormat->ParseNull(wsValue, wsFormat); | 806 bRet = pFormat->ParseNull(wsValue, wsFormat); |
807 if (bRet) { | 807 if (bRet) { |
808 m_wsValue.Empty(); | 808 m_wsValue.Empty(); |
809 } | 809 } |
810 break; | 810 break; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 } | 860 } |
861 if (!bRet) { | 861 if (!bRet) { |
862 m_wsValue = wsValue; | 862 m_wsValue = wsValue; |
863 } | 863 } |
864 pFormat->Release(); | 864 pFormat->Release(); |
865 if (pLocale) { | 865 if (pLocale) { |
866 m_pLocaleMgr->SetDefLocale(locale); | 866 m_pLocaleMgr->SetDefLocale(locale); |
867 } | 867 } |
868 return bRet; | 868 return bRet; |
869 } | 869 } |
870 void CXFA_LocaleValue::GetNumbericFormat(CFX_WideString &wsFormat, FX_INT32 nInt
Len, FX_INT32 nDecLen, FX_BOOL bSign ) | 870 void CXFA_LocaleValue::GetNumbericFormat(CFX_WideString &wsFormat, int32_t nIntL
en, int32_t nDecLen, FX_BOOL bSign ) |
871 { | 871 { |
872 FXSYS_assert(wsFormat.IsEmpty()); | 872 FXSYS_assert(wsFormat.IsEmpty()); |
873 FXSYS_assert(nIntLen >= -1 && nDecLen >= -1); | 873 FXSYS_assert(nIntLen >= -1 && nDecLen >= -1); |
874 FX_INT32 nTotalLen \ | 874 int32_t nTotalLen \ |
875 = (nIntLen >= 0 ? nIntLen : 2) \ | 875 = (nIntLen >= 0 ? nIntLen : 2) \ |
876 + (bSign ? 1 : 0) \ | 876 + (bSign ? 1 : 0) \ |
877 + (nDecLen >= 0 ? nDecLen : 2) \ | 877 + (nDecLen >= 0 ? nDecLen : 2) \ |
878 + (nDecLen == 0 ? 0 : 1); | 878 + (nDecLen == 0 ? 0 : 1); |
879 FX_LPWSTR lpBuf = wsFormat.GetBuffer(nTotalLen); | 879 FX_LPWSTR lpBuf = wsFormat.GetBuffer(nTotalLen); |
880 FX_INT32 nPos = 0; | 880 int32_t nPos = 0; |
881 if (bSign) { | 881 if (bSign) { |
882 lpBuf[nPos++] = L's'; | 882 lpBuf[nPos++] = L's'; |
883 } | 883 } |
884 if (nIntLen == -1) { | 884 if (nIntLen == -1) { |
885 lpBuf[nPos++] = L'z'; | 885 lpBuf[nPos++] = L'z'; |
886 lpBuf[nPos++] = L'*'; | 886 lpBuf[nPos++] = L'*'; |
887 } else { | 887 } else { |
888 while (nIntLen) { | 888 while (nIntLen) { |
889 lpBuf[nPos++] = L'z'; | 889 lpBuf[nPos++] = L'z'; |
890 nIntLen --; | 890 nIntLen --; |
891 } | 891 } |
892 } | 892 } |
893 if (nDecLen != 0) { | 893 if (nDecLen != 0) { |
894 lpBuf[nPos++] = L'.'; | 894 lpBuf[nPos++] = L'.'; |
895 } | 895 } |
896 if (nDecLen == -1) { | 896 if (nDecLen == -1) { |
897 lpBuf[nPos++] = L'z'; | 897 lpBuf[nPos++] = L'z'; |
898 lpBuf[nPos++] = L'*'; | 898 lpBuf[nPos++] = L'*'; |
899 } else { | 899 } else { |
900 while (nDecLen) { | 900 while (nDecLen) { |
901 lpBuf[nPos++] = L'z'; | 901 lpBuf[nPos++] = L'z'; |
902 nDecLen --; | 902 nDecLen --; |
903 } | 903 } |
904 } | 904 } |
905 wsFormat.ReleaseBuffer(nTotalLen); | 905 wsFormat.ReleaseBuffer(nTotalLen); |
906 } | 906 } |
907 FX_BOOL CXFA_LocaleValue::ValidateNumericTemp(CFX_WideString& wsNumeric, CFX_Wid
eString& wsFormat, IFX_Locale* pLocale , FX_INT32* pos ) | 907 FX_BOOL CXFA_LocaleValue::ValidateNumericTemp(CFX_WideString& wsNumeric, CFX_Wid
eString& wsFormat, IFX_Locale* pLocale , int32_t* pos ) |
908 { | 908 { |
909 if (wsFormat.IsEmpty() || wsNumeric.IsEmpty()) { | 909 if (wsFormat.IsEmpty() || wsNumeric.IsEmpty()) { |
910 return TRUE; | 910 return TRUE; |
911 } | 911 } |
912 FX_LPCWSTR pNum = FX_LPCWSTR(wsNumeric); | 912 FX_LPCWSTR pNum = FX_LPCWSTR(wsNumeric); |
913 FX_LPCWSTR pFmt = FX_LPCWSTR(wsFormat); | 913 FX_LPCWSTR pFmt = FX_LPCWSTR(wsFormat); |
914 FX_INT32 n = 0, nf = 0; | 914 int32_t n = 0, nf = 0; |
915 FX_WCHAR c = pNum[n]; | 915 FX_WCHAR c = pNum[n]; |
916 FX_WCHAR cf = pFmt[nf]; | 916 FX_WCHAR cf = pFmt[nf]; |
917 if (cf == L's') { | 917 if (cf == L's') { |
918 if (c == L'-' || c == L'+') { | 918 if (c == L'-' || c == L'+') { |
919 ++n; | 919 ++n; |
920 } | 920 } |
921 ++nf; | 921 ++nf; |
922 } | 922 } |
923 FX_BOOL bLimit = TRUE; | 923 FX_BOOL bLimit = TRUE; |
924 FX_INT32 nCount» » = wsNumeric.GetLength(); | 924 int32_t nCount» » = wsNumeric.GetLength(); |
925 FX_INT32 nCountFmt» = wsFormat.GetLength(); | 925 int32_t nCountFmt» = wsFormat.GetLength(); |
926 while (n < nCount && (bLimit ? nf < nCountFmt : TRUE) && XFA_IsDigit(c = pNu
m[n])) { | 926 while (n < nCount && (bLimit ? nf < nCountFmt : TRUE) && XFA_IsDigit(c = pNu
m[n])) { |
927 if (bLimit == TRUE) { | 927 if (bLimit == TRUE) { |
928 if ((cf = pFmt[nf]) == L'*') { | 928 if ((cf = pFmt[nf]) == L'*') { |
929 bLimit = FALSE; | 929 bLimit = FALSE; |
930 } else if (cf == L'z') { | 930 } else if (cf == L'z') { |
931 nf ++; | 931 nf ++; |
932 } else { | 932 } else { |
933 return FALSE; | 933 return FALSE; |
934 } | 934 } |
935 } | 935 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 } else if (cf == L'z') { | 967 } else if (cf == L'z') { |
968 nf ++; | 968 nf ++; |
969 } else { | 969 } else { |
970 return FALSE; | 970 return FALSE; |
971 } | 971 } |
972 } | 972 } |
973 n ++; | 973 n ++; |
974 } | 974 } |
975 return n == nCount; | 975 return n == nCount; |
976 } | 976 } |
OLD | NEW |