Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: xfa/fxfa/parser/xfa_localevalue.cpp

Issue 1882213002: Cleanup various IFX_ text interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fxfa/fm2js/xfa_fm2jsapi.h" 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
10 #include "xfa/fxfa/parser/xfa_docdata.h" 11 #include "xfa/fxfa/parser/xfa_docdata.h"
11 #include "xfa/fxfa/parser/xfa_doclayout.h" 12 #include "xfa/fxfa/parser/xfa_doclayout.h"
12 #include "xfa/fxfa/parser/xfa_document.h" 13 #include "xfa/fxfa/parser/xfa_document.h"
13 #include "xfa/fxfa/parser/xfa_localemgr.h" 14 #include "xfa/fxfa/parser/xfa_localemgr.h"
14 #include "xfa/fxfa/parser/xfa_object.h" 15 #include "xfa/fxfa/parser/xfa_object.h"
15 #include "xfa/fxfa/parser/xfa_parser.h" 16 #include "xfa/fxfa/parser/xfa_parser.h"
16 #include "xfa/fxfa/parser/xfa_script.h" 17 #include "xfa/fxfa/parser/xfa_script.h"
17 #include "xfa/fxfa/parser/xfa_utils.h" 18 #include "xfa/fxfa/parser/xfa_utils.h"
18 19
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 99 }
99 FX_BOOL CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue, 100 FX_BOOL CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue,
100 const CFX_WideString& wsPattern, 101 const CFX_WideString& wsPattern,
101 IFX_Locale* pLocale, 102 IFX_Locale* pLocale,
102 CFX_WideString* pMatchFormat) { 103 CFX_WideString* pMatchFormat) {
103 CFX_WideString wsOutput; 104 CFX_WideString wsOutput;
104 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); 105 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale();
105 if (pLocale) { 106 if (pLocale) {
106 m_pLocaleMgr->SetDefLocale(pLocale); 107 m_pLocaleMgr->SetDefLocale(pLocale);
107 } 108 }
108 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); 109 CFX_FormatString* pFormat = nullptr;
110 if (m_pLocaleMgr)
111 pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);
112
109 CFX_WideStringArray wsPatterns; 113 CFX_WideStringArray wsPatterns;
110 pFormat->SplitFormatString(wsPattern, wsPatterns); 114 pFormat->SplitFormatString(wsPattern, wsPatterns);
111 FX_BOOL bRet = FALSE; 115 FX_BOOL bRet = FALSE;
112 int32_t iCount = wsPatterns.GetSize(); 116 int32_t iCount = wsPatterns.GetSize();
113 int32_t i = 0; 117 int32_t i = 0;
114 for (; i < iCount && !bRet; i++) { 118 for (; i < iCount && !bRet; i++) {
115 CFX_WideString wsFormat = wsPatterns[i]; 119 CFX_WideString wsFormat = wsPatterns[i];
116 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); 120 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat);
117 eCategory = XFA_ValugeCategory(eCategory, m_dwType); 121 eCategory = XFA_ValugeCategory(eCategory, m_dwType);
118 switch (eCategory) { 122 switch (eCategory) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 IFX_Locale* pLocale) { 459 IFX_Locale* pLocale) {
456 m_dwType = XFA_VT_DATETIME; 460 m_dwType = XFA_VT_DATETIME;
457 return m_bValid = ParsePatternValue(wsDateTime, wsFormat, pLocale); 461 return m_bValid = ParsePatternValue(wsDateTime, wsFormat, pLocale);
458 } 462 }
459 FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult, 463 FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult,
460 const CFX_WideString& wsFormat, 464 const CFX_WideString& wsFormat,
461 IFX_Locale* pLocale, 465 IFX_Locale* pLocale,
462 XFA_VALUEPICTURE eValueType) const { 466 XFA_VALUEPICTURE eValueType) const {
463 wsResult.Empty(); 467 wsResult.Empty();
464 FX_BOOL bRet = FALSE; 468 FX_BOOL bRet = FALSE;
465 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); 469
470 CFX_FormatString* pFormat = nullptr;
471 if (m_pLocaleMgr)
472 pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);
473
466 CFX_WideStringArray wsPatterns; 474 CFX_WideStringArray wsPatterns;
467 pFormat->SplitFormatString(wsFormat, wsPatterns); 475 pFormat->SplitFormatString(wsFormat, wsPatterns);
468 int32_t iCount = wsPatterns.GetSize(); 476 int32_t iCount = wsPatterns.GetSize();
469 for (int32_t i = 0; i < iCount; i++) { 477 for (int32_t i = 0; i < iCount; i++) {
470 bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType); 478 bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType);
471 if (bRet) { 479 if (bRet) {
472 break; 480 break;
473 } 481 }
474 } 482 }
475 pFormat->Release(); 483 pFormat->Release();
476 return bRet; 484 return bRet;
477 } 485 }
478 FX_BOOL CXFA_LocaleValue::FormatSinglePattern( 486 FX_BOOL CXFA_LocaleValue::FormatSinglePattern(
479 CFX_WideString& wsResult, 487 CFX_WideString& wsResult,
480 const CFX_WideString& wsFormat, 488 const CFX_WideString& wsFormat,
481 IFX_Locale* pLocale, 489 IFX_Locale* pLocale,
482 XFA_VALUEPICTURE eValueType) const { 490 XFA_VALUEPICTURE eValueType) const {
483 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); 491 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale();
484 if (pLocale) { 492 if (pLocale) {
485 m_pLocaleMgr->SetDefLocale(pLocale); 493 m_pLocaleMgr->SetDefLocale(pLocale);
486 } 494 }
487 wsResult.Empty(); 495 wsResult.Empty();
488 FX_BOOL bRet = FALSE; 496 FX_BOOL bRet = FALSE;
489 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); 497
498 CFX_FormatString* pFormat = nullptr;
499 if (m_pLocaleMgr)
500 pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);
501
490 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); 502 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat);
491 eCategory = XFA_ValugeCategory(eCategory, m_dwType); 503 eCategory = XFA_ValugeCategory(eCategory, m_dwType);
492 switch (eCategory) { 504 switch (eCategory) {
493 case FX_LOCALECATEGORY_Null: 505 case FX_LOCALECATEGORY_Null:
494 if (m_wsValue.IsEmpty()) { 506 if (m_wsValue.IsEmpty()) {
495 bRet = pFormat->FormatNull(wsFormat, wsResult); 507 bRet = pFormat->FormatNull(wsFormat, wsResult);
496 } 508 }
497 break; 509 break;
498 case FX_LOCALECATEGORY_Zero: 510 case FX_LOCALECATEGORY_Zero:
499 if (m_wsValue == FX_WSTRC(L"0")) { 511 if (m_wsValue == FX_WSTRC(L"0")) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 CFX_Unitime dt; 798 CFX_Unitime dt;
787 return ValidateCanonicalDate(wsDate, dt) && ValidateCanonicalTime(wsTime); 799 return ValidateCanonicalDate(wsDate, dt) && ValidateCanonicalTime(wsTime);
788 } 800 }
789 FX_BOOL CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue, 801 FX_BOOL CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue,
790 const CFX_WideString& wsPattern, 802 const CFX_WideString& wsPattern,
791 IFX_Locale* pLocale) { 803 IFX_Locale* pLocale) {
792 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); 804 IFX_Locale* locale = m_pLocaleMgr->GetDefLocale();
793 if (pLocale) { 805 if (pLocale) {
794 m_pLocaleMgr->SetDefLocale(pLocale); 806 m_pLocaleMgr->SetDefLocale(pLocale);
795 } 807 }
796 IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); 808
809 CFX_FormatString* pFormat = nullptr;
810 if (m_pLocaleMgr)
811 pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);
812
797 CFX_WideStringArray wsPatterns; 813 CFX_WideStringArray wsPatterns;
798 pFormat->SplitFormatString(wsPattern, wsPatterns); 814 pFormat->SplitFormatString(wsPattern, wsPatterns);
799 FX_BOOL bRet = FALSE; 815 FX_BOOL bRet = FALSE;
800 int32_t iCount = wsPatterns.GetSize(); 816 int32_t iCount = wsPatterns.GetSize();
801 for (int32_t i = 0; i < iCount && !bRet; i++) { 817 for (int32_t i = 0; i < iCount && !bRet; i++) {
802 CFX_WideString wsFormat = wsPatterns[i]; 818 CFX_WideString wsFormat = wsPatterns[i];
803 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); 819 FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat);
804 eCategory = XFA_ValugeCategory(eCategory, m_dwType); 820 eCategory = XFA_ValugeCategory(eCategory, m_dwType);
805 switch (eCategory) { 821 switch (eCategory) {
806 case FX_LOCALECATEGORY_Null: 822 case FX_LOCALECATEGORY_Null:
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 } else if (cf == L'z') { 990 } else if (cf == L'z') {
975 nf++; 991 nf++;
976 } else { 992 } else {
977 return FALSE; 993 return FALSE;
978 } 994 }
979 } 995 }
980 n++; 996 n++;
981 } 997 }
982 return n == nCount; 998 return n == nCount;
983 } 999 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698