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 "xfa/fxfa/parser/xfa_localevalue.h" | 7 #include "xfa/fxfa/parser/xfa_localevalue.h" |
8 | 8 |
9 #include "xfa/fgas/localization/fgas_localeimp.h" | 9 #include "xfa/fgas/localization/fgas_localeimp.h" |
10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 case FX_LOCALECATEGORY_Num: { | 135 case FX_LOCALECATEGORY_Num: { |
136 CFX_WideString fNum; | 136 CFX_WideString fNum; |
137 bRet = pFormat->ParseNum(wsValue, wsFormat, fNum); | 137 bRet = pFormat->ParseNum(wsValue, wsFormat, fNum); |
138 if (!bRet) { | 138 if (!bRet) { |
139 bRet = pFormat->FormatNum(wsValue, wsFormat, wsOutput); | 139 bRet = pFormat->FormatNum(wsValue, wsFormat, wsOutput); |
140 } | 140 } |
141 break; | 141 break; |
142 } | 142 } |
143 case FX_LOCALECATEGORY_Text: | 143 case FX_LOCALECATEGORY_Text: |
144 bRet = pFormat->ParseText(wsValue, wsFormat, wsOutput); | 144 bRet = pFormat->ParseText(wsValue, wsFormat, wsOutput); |
145 wsOutput.Empty(); | 145 wsOutput.clear(); |
146 if (!bRet) { | 146 if (!bRet) { |
147 bRet = pFormat->FormatText(wsValue, wsFormat, wsOutput); | 147 bRet = pFormat->FormatText(wsValue, wsFormat, wsOutput); |
148 } | 148 } |
149 break; | 149 break; |
150 case FX_LOCALECATEGORY_Date: { | 150 case FX_LOCALECATEGORY_Date: { |
151 CFX_Unitime dt; | 151 CFX_Unitime dt; |
152 bRet = ValidateCanonicalDate(wsValue, dt); | 152 bRet = ValidateCanonicalDate(wsValue, dt); |
153 if (!bRet) { | 153 if (!bRet) { |
154 bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date, | 154 bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date, |
155 dt); | 155 dt); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 FX_BOOL CXFA_LocaleValue::SetDateTime(const CFX_WideString& wsDateTime, | 457 FX_BOOL CXFA_LocaleValue::SetDateTime(const CFX_WideString& wsDateTime, |
458 const CFX_WideString& wsFormat, | 458 const CFX_WideString& wsFormat, |
459 IFX_Locale* pLocale) { | 459 IFX_Locale* pLocale) { |
460 m_dwType = XFA_VT_DATETIME; | 460 m_dwType = XFA_VT_DATETIME; |
461 return m_bValid = ParsePatternValue(wsDateTime, wsFormat, pLocale); | 461 return m_bValid = ParsePatternValue(wsDateTime, wsFormat, pLocale); |
462 } | 462 } |
463 FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult, | 463 FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult, |
464 const CFX_WideString& wsFormat, | 464 const CFX_WideString& wsFormat, |
465 IFX_Locale* pLocale, | 465 IFX_Locale* pLocale, |
466 XFA_VALUEPICTURE eValueType) const { | 466 XFA_VALUEPICTURE eValueType) const { |
467 wsResult.Empty(); | 467 wsResult.clear(); |
468 FX_BOOL bRet = FALSE; | 468 FX_BOOL bRet = FALSE; |
469 | 469 |
470 CFX_FormatString* pFormat = nullptr; | 470 CFX_FormatString* pFormat = nullptr; |
471 if (m_pLocaleMgr) | 471 if (m_pLocaleMgr) |
472 pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE); | 472 pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE); |
473 | 473 |
474 CFX_WideStringArray wsPatterns; | 474 CFX_WideStringArray wsPatterns; |
475 pFormat->SplitFormatString(wsFormat, wsPatterns); | 475 pFormat->SplitFormatString(wsFormat, wsPatterns); |
476 int32_t iCount = wsPatterns.GetSize(); | 476 int32_t iCount = wsPatterns.GetSize(); |
477 for (int32_t i = 0; i < iCount; i++) { | 477 for (int32_t i = 0; i < iCount; i++) { |
478 bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType); | 478 bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType); |
479 if (bRet) { | 479 if (bRet) { |
480 break; | 480 break; |
481 } | 481 } |
482 } | 482 } |
483 pFormat->Release(); | 483 pFormat->Release(); |
484 return bRet; | 484 return bRet; |
485 } | 485 } |
486 FX_BOOL CXFA_LocaleValue::FormatSinglePattern( | 486 FX_BOOL CXFA_LocaleValue::FormatSinglePattern( |
487 CFX_WideString& wsResult, | 487 CFX_WideString& wsResult, |
488 const CFX_WideString& wsFormat, | 488 const CFX_WideString& wsFormat, |
489 IFX_Locale* pLocale, | 489 IFX_Locale* pLocale, |
490 XFA_VALUEPICTURE eValueType) const { | 490 XFA_VALUEPICTURE eValueType) const { |
491 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); | 491 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); |
492 if (pLocale) { | 492 if (pLocale) { |
493 m_pLocaleMgr->SetDefLocale(pLocale); | 493 m_pLocaleMgr->SetDefLocale(pLocale); |
494 } | 494 } |
495 wsResult.Empty(); | 495 wsResult.clear(); |
496 FX_BOOL bRet = FALSE; | 496 FX_BOOL bRet = FALSE; |
497 | 497 |
498 CFX_FormatString* pFormat = nullptr; | 498 CFX_FormatString* pFormat = nullptr; |
499 if (m_pLocaleMgr) | 499 if (m_pLocaleMgr) |
500 pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE); | 500 pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE); |
501 | 501 |
502 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); | 502 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); |
503 eCategory = XFA_ValugeCategory(eCategory, m_dwType); | 503 eCategory = XFA_ValugeCategory(eCategory, m_dwType); |
504 switch (eCategory) { | 504 switch (eCategory) { |
505 case FX_LOCALECATEGORY_Null: | 505 case FX_LOCALECATEGORY_Null: |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 FX_BOOL bRet = FALSE; | 815 FX_BOOL bRet = FALSE; |
816 int32_t iCount = wsPatterns.GetSize(); | 816 int32_t iCount = wsPatterns.GetSize(); |
817 for (int32_t i = 0; i < iCount && !bRet; i++) { | 817 for (int32_t i = 0; i < iCount && !bRet; i++) { |
818 CFX_WideString wsFormat = wsPatterns[i]; | 818 CFX_WideString wsFormat = wsPatterns[i]; |
819 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); | 819 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); |
820 eCategory = XFA_ValugeCategory(eCategory, m_dwType); | 820 eCategory = XFA_ValugeCategory(eCategory, m_dwType); |
821 switch (eCategory) { | 821 switch (eCategory) { |
822 case FX_LOCALECATEGORY_Null: | 822 case FX_LOCALECATEGORY_Null: |
823 bRet = pFormat->ParseNull(wsValue, wsFormat); | 823 bRet = pFormat->ParseNull(wsValue, wsFormat); |
824 if (bRet) { | 824 if (bRet) { |
825 m_wsValue.Empty(); | 825 m_wsValue.clear(); |
826 } | 826 } |
827 break; | 827 break; |
828 case FX_LOCALECATEGORY_Zero: | 828 case FX_LOCALECATEGORY_Zero: |
829 bRet = pFormat->ParseZero(wsValue, wsFormat); | 829 bRet = pFormat->ParseZero(wsValue, wsFormat); |
830 if (bRet) { | 830 if (bRet) { |
831 m_wsValue = FX_WSTRC(L"0"); | 831 m_wsValue = FX_WSTRC(L"0"); |
832 } | 832 } |
833 break; | 833 break; |
834 case FX_LOCALECATEGORY_Num: { | 834 case FX_LOCALECATEGORY_Num: { |
835 CFX_WideString fNum; | 835 CFX_WideString fNum; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 } else if (cf == L'z') { | 990 } else if (cf == L'z') { |
991 nf++; | 991 nf++; |
992 } else { | 992 } else { |
993 return FALSE; | 993 return FALSE; |
994 } | 994 } |
995 } | 995 } |
996 n++; | 996 n++; |
997 } | 997 } |
998 return n == nCount; | 998 return n == nCount; |
999 } | 999 } |
OLD | NEW |