summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-29 11:02:17 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-29 15:21:35 +0000
commit9ad342b60490b9e88896aaf2eb7fb8f7bfa73e5a (patch)
tree2eae047becb4856266e4404f762ce3a122b311b3
parent21362ee6370e6ef0f5a8275af5afde3f127887c9 (diff)
downloadpdfium-9ad342b60490b9e88896aaf2eb7fb8f7bfa73e5a.tar.xz
Return values instead of out paramschromium/3056
This CL updates the IFX_Locale code and subclasses to return CFX_WideStrings instead of taking out params. Change-Id: Id03499c68161e809607e73b9d8ec778e24631845 Reviewed-on: https://pdfium-review.googlesource.com/3252 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--xfa/fgas/localization/fgas_locale.cpp231
-rw-r--r--xfa/fgas/localization/fgas_locale.h31
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp38
-rw-r--r--xfa/fxfa/parser/cxfa_localevalue.cpp22
-rw-r--r--xfa/fxfa/parser/cxfa_nodelocale.cpp114
-rw-r--r--xfa/fxfa/parser/cxfa_nodelocale.h35
-rw-r--r--xfa/fxfa/parser/cxfa_timezoneprovider.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_timezoneprovider.h2
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp82
-rw-r--r--xfa/fxfa/parser/cxfa_xmllocale.cpp130
-rw-r--r--xfa/fxfa/parser/cxfa_xmllocale.h42
11 files changed, 304 insertions, 427 deletions
diff --git a/xfa/fgas/localization/fgas_locale.cpp b/xfa/fgas/localization/fgas_locale.cpp
index 7fddbb4496..17aae595dc 100644
--- a/xfa/fgas/localization/fgas_locale.cpp
+++ b/xfa/fgas/localization/fgas_locale.cpp
@@ -65,26 +65,26 @@ const wchar_t gs_wsTimeSymbols[] = L"hHkKMSFAzZ";
const wchar_t gs_wsDateSymbols[] = L"DJMEeGgYwW";
const wchar_t gs_wsConstChars[] = L",-:/. ";
-int32_t ParseTimeZone(const wchar_t* pStr, int32_t iLen, FX_TIMEZONE& tz) {
- tz.tzHour = 0;
- tz.tzMinute = 0;
+int32_t ParseTimeZone(const wchar_t* pStr, int32_t iLen, FX_TIMEZONE* tz) {
+ tz->tzHour = 0;
+ tz->tzMinute = 0;
if (iLen < 0)
return 0;
int32_t iStart = 1;
int32_t iEnd = iStart + 2;
while (iStart < iLen && iStart < iEnd)
- tz.tzHour = tz.tzHour * 10 + pStr[iStart++] - '0';
+ tz->tzHour = tz->tzHour * 10 + pStr[iStart++] - '0';
if (iStart < iLen && pStr[iStart] == ':')
iStart++;
iEnd = iStart + 2;
while (iStart < iLen && iStart < iEnd)
- tz.tzMinute = tz.tzMinute * 10 + pStr[iStart++] - '0';
+ tz->tzMinute = tz->tzMinute * 10 + pStr[iStart++] - '0';
if (pStr[0] == '-')
- tz.tzHour = -tz.tzHour;
+ tz->tzHour = -tz->tzHour;
return iStart;
}
@@ -285,10 +285,9 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
CFX_WideString wsMonthNameAbbr;
uint16_t i = 0;
for (; i < 12; i++) {
- pLocale->GetMonthName(i, wsMonthNameAbbr, true);
- if (wsMonthNameAbbr.IsEmpty()) {
+ wsMonthNameAbbr = pLocale->GetMonthName(i, true);
+ if (wsMonthNameAbbr.IsEmpty())
continue;
- }
if (!FXSYS_wcsncmp(wsMonthNameAbbr.c_str(), str + cc,
wsMonthNameAbbr.GetLength())) {
break;
@@ -302,10 +301,9 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
CFX_WideString wsMonthName;
uint16_t i = 0;
for (; i < 12; i++) {
- pLocale->GetMonthName(i, wsMonthName, false);
- if (wsMonthName.IsEmpty()) {
+ wsMonthName = pLocale->GetMonthName(i, false);
+ if (wsMonthName.IsEmpty())
continue;
- }
if (!FXSYS_wcsncmp(wsMonthName.c_str(), str + cc,
wsMonthName.GetLength())) {
break;
@@ -321,10 +319,9 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
CFX_WideString wsDayNameAbbr;
uint16_t i = 0;
for (; i < 7; i++) {
- pLocale->GetDayName(i, wsDayNameAbbr, true);
- if (wsDayNameAbbr.IsEmpty()) {
+ wsDayNameAbbr = pLocale->GetDayName(i, true);
+ if (wsDayNameAbbr.IsEmpty())
continue;
- }
if (!FXSYS_wcsncmp(wsDayNameAbbr.c_str(), str + cc,
wsDayNameAbbr.GetLength())) {
break;
@@ -337,10 +334,9 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
CFX_WideString wsDayName;
int32_t i = 0;
for (; i < 7; i++) {
- pLocale->GetDayName(i, wsDayName, false);
- if (wsDayName == L"") {
+ wsDayName = pLocale->GetDayName(i, false);
+ if (wsDayName == L"")
continue;
- }
if (!FXSYS_wcsncmp(wsDayName.c_str(), str + cc,
wsDayName.GetLength())) {
break;
@@ -402,8 +398,7 @@ void ResolveZone(uint8_t& wHour,
FX_TIMEZONE tzDiff,
IFX_Locale* pLocale) {
int32_t iMinuteDiff = wHour * 60 + wMinute;
- FX_TIMEZONE tzLocale;
- pLocale->GetTimeZone(&tzLocale);
+ FX_TIMEZONE tzLocale = pLocale->GetTimeZone();
iMinuteDiff += tzLocale.tzHour * 60 +
(tzLocale.tzHour < 0 ? -tzLocale.tzMinute : tzLocale.tzMinute);
iMinuteDiff -= tzDiff.tzHour * 60 +
@@ -545,10 +540,8 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
i++;
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'A', '1')) {
- CFX_WideString wsAM;
- pLocale->GetMeridiemName(wsAM, true);
- CFX_WideString wsPM;
- pLocale->GetMeridiemName(wsPM, false);
+ CFX_WideString wsAM = pLocale->GetMeridiemName(true);
+ CFX_WideString wsPM = pLocale->GetMeridiemName(false);
if ((cc + wsAM.GetLength() <= len) &&
(CFX_WideStringC(str + cc, wsAM.GetLength()) == wsAM)) {
cc += wsAM.GetLength();
@@ -570,9 +563,9 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
FX_TIMEZONE tzDiff;
tzDiff.tzHour = 0;
tzDiff.tzMinute = 0;
- if (cc < len && (str[cc] == '-' || str[cc] == '+')) {
- cc += ParseTimeZone(str + cc, len - cc, tzDiff);
- }
+ if (cc < len && (str[cc] == '-' || str[cc] == '+'))
+ cc += ParseTimeZone(str + cc, len - cc, &tzDiff);
+
ResolveZone(hour, minute, tzDiff, pLocale);
} else {
const FX_LOCALETIMEZONEINFO* pEnd =
@@ -590,7 +583,7 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
} else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) {
if (str[cc] != 'Z') {
FX_TIMEZONE tzDiff;
- cc += ParseTimeZone(str + cc, len - cc, tzDiff);
+ cc += ParseTimeZone(str + cc, len - cc, &tzDiff);
ResolveZone(hour, minute, tzDiff, pLocale);
} else {
cc++;
@@ -737,13 +730,9 @@ bool DateFormat(const CFX_WideString& wsDatePattern,
wsMonth.Format(L"%02d", month);
wsResult += wsMonth;
} else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) {
- CFX_WideString wsTemp;
- pLocale->GetMonthName(month - 1, wsTemp, true);
- wsResult += wsTemp;
+ wsResult += pLocale->GetMonthName(month - 1, true);
} else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) {
- CFX_WideString wsTemp;
- pLocale->GetMonthName(month - 1, wsTemp, false);
- wsResult += wsTemp;
+ wsResult += pLocale->GetMonthName(month - 1, false);
} else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) {
uint16_t wWeekDay = GetWeekDay(year, month, day);
CFX_WideString wsWeekDay;
@@ -751,25 +740,18 @@ bool DateFormat(const CFX_WideString& wsDatePattern,
wsResult += wsWeekDay;
} else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) {
uint16_t wWeekDay = GetWeekDay(year, month, day);
- CFX_WideString wsTemp;
- pLocale->GetDayName(wWeekDay, wsTemp, true);
- wsResult += wsTemp;
+ wsResult += pLocale->GetDayName(wWeekDay, true);
} else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) {
uint16_t wWeekDay = GetWeekDay(year, month, day);
- if (pLocale) {
- CFX_WideString wsTemp;
- pLocale->GetDayName(wWeekDay, wsTemp, false);
- wsResult += wsTemp;
- }
+ if (pLocale)
+ wsResult += pLocale->GetDayName(wWeekDay, false);
} else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) {
uint16_t wWeekDay = GetWeekDay(year, month, day);
CFX_WideString wsWeekDay;
wsWeekDay.Format(L"%d", wWeekDay ? wWeekDay : 7);
wsResult += wsWeekDay;
} else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) {
- CFX_WideString wsTemp;
- pLocale->GetEraName(wsTemp, year < 0);
- wsResult += wsTemp;
+ wsResult += pLocale->GetEraName(year < 0);
} else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) {
CFX_WideString wsYear;
wsYear.Format(L"%02d", year % 100);
@@ -895,32 +877,22 @@ bool TimeFormat(const CFX_WideString& wsTimePattern,
wsMilliseconds.Format(L"%03d", millisecond);
wsResult += wsMilliseconds;
} else if (dwSymbol == FXBSTR_ID(0, 0, 'A', '1')) {
- CFX_WideString wsMeridiem;
- pLocale->GetMeridiemName(wsMeridiem, !bPM);
- wsResult += wsMeridiem;
+ wsResult += pLocale->GetMeridiemName(!bPM);
} else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) {
wsResult += L"GMT";
- FX_TIMEZONE tz;
- pLocale->GetTimeZone(&tz);
+ FX_TIMEZONE tz = pLocale->GetTimeZone();
if (!bGMT && (tz.tzHour != 0 || tz.tzMinute != 0)) {
- if (tz.tzHour < 0) {
- wsResult += L"-";
- } else {
- wsResult += L"+";
- }
+ wsResult += tz.tzHour < 0 ? L"-" : L"+";
+
CFX_WideString wsTimezone;
wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute);
wsResult += wsTimezone;
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) {
- FX_TIMEZONE tz;
- pLocale->GetTimeZone(&tz);
+ FX_TIMEZONE tz = pLocale->GetTimeZone();
if (!bGMT && tz.tzHour != 0 && tz.tzMinute != 0) {
- if (tz.tzHour < 0) {
- wsResult += L"-";
- } else {
- wsResult += L"+";
- }
+ wsResult += tz.tzHour < 0 ? L"-" : L"+";
+
CFX_WideString wsTimezone;
wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute);
wsResult += wsTimezone;
@@ -1094,7 +1066,7 @@ bool FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
tzDiff.tzHour = 0;
tzDiff.tzMinute = 0;
if (str[cc] != 'Z')
- cc += ParseTimeZone(str + cc, len - cc, tzDiff);
+ cc += ParseTimeZone(str + cc, len - cc, &tzDiff);
ResolveZone(hour, minute, tzDiff, pLocale);
}
}
@@ -1323,12 +1295,12 @@ IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern,
break;
}
}
- wsSubCategory.clear();
- if (!pLocale) {
+ if (!pLocale)
pLocale = m_pLocaleMgr->GetDefLocale();
- }
+
ASSERT(pLocale);
- pLocale->GetNumPattern(eSubCategory, wsSubCategory);
+
+ wsSubCategory = pLocale->GetNumPattern(eSubCategory);
iDotIndex = wsSubCategory.Find('.');
if (iDotIndex > 0) {
iDotIndex += wsPurgePattern.GetLength();
@@ -1447,25 +1419,24 @@ bool CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
const CFX_WideString& wsPattern,
CFX_WideString& wsValue) {
wsValue.clear();
- if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) {
+ if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty())
return false;
- }
+
int32_t dot_index_f = -1;
uint32_t dwFormatStyle = 0;
CFX_WideString wsNumFormat;
IFX_Locale* pLocale =
GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat);
- if (!pLocale || wsNumFormat.IsEmpty()) {
+ if (!pLocale || wsNumFormat.IsEmpty())
return false;
- }
+
int32_t iExponent = 0;
- CFX_WideString wsDotSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol);
- CFX_WideString wsGroupSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol);
+ CFX_WideString wsDotSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
+ CFX_WideString wsGroupSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping);
int32_t iGroupLen = wsGroupSymbol.GetLength();
- CFX_WideString wsMinus;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus);
+ CFX_WideString wsMinus = pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus);
int32_t iMinusLen = wsMinus.GetLength();
int cc = 0, ccf = 0;
const wchar_t* str = wsSrcNum.c_str();
@@ -1578,8 +1549,8 @@ bool CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
ccf--;
} break;
case '$': {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol);
+ CFX_WideString wsSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
cc -= iSymbolLen - 1;
if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) {
@@ -1641,8 +1612,8 @@ bool CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
case 'v':
return false;
case '%': {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol);
+ CFX_WideString wsSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent);
int32_t iSysmbolLen = wsSymbol.GetLength();
cc -= iSysmbolLen - 1;
if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) {
@@ -1797,9 +1768,8 @@ bool CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
ccf++;
} break;
case '$': {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol,
- wsSymbol);
+ CFX_WideString wsSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
if (cc + iSymbolLen > len ||
FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) {
@@ -1853,8 +1823,8 @@ bool CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
case 'v':
return false;
case '%': {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol);
+ CFX_WideString wsSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent);
int32_t iSysmbolLen = wsSymbol.GetLength();
if (cc + iSysmbolLen <= len &&
!FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) {
@@ -2013,17 +1983,17 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat(
ASSERT(pLocale);
switch (eCategory) {
case FX_LOCALECATEGORY_Date:
- pLocale->GetDatePattern(eSubCategory, wsDatePattern);
- wsDatePattern = wsTempPattern + wsDatePattern;
+ wsDatePattern =
+ wsTempPattern + pLocale->GetDatePattern(eSubCategory);
break;
case FX_LOCALECATEGORY_Time:
- pLocale->GetTimePattern(eSubCategory, wsTimePattern);
- wsTimePattern = wsTempPattern + wsTimePattern;
+ wsTimePattern =
+ wsTempPattern + pLocale->GetTimePattern(eSubCategory);
break;
case FX_LOCALECATEGORY_DateTime:
- pLocale->GetDatePattern(eSubCategory, wsDatePattern);
- wsDatePattern = wsTempPattern + wsDatePattern;
- pLocale->GetTimePattern(eSubCategory, wsTimePattern);
+ wsDatePattern =
+ wsTempPattern + pLocale->GetDatePattern(eSubCategory);
+ wsTimePattern = pLocale->GetTimePattern(eSubCategory);
break;
default:
break;
@@ -2310,8 +2280,8 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
wsSrcNum.TrimRight(L"0");
wsSrcNum.TrimRight(L".");
}
- CFX_WideString wsGroupSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol);
+ CFX_WideString wsGroupSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping);
bool bNeg = false;
if (wsSrcNum[0] == '-') {
bNeg = true;
@@ -2370,9 +2340,8 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
break;
case 'S':
if (bNeg) {
- CFX_WideString wsMinusSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol);
- wsOutput = wsMinusSymbol + wsOutput;
+ wsOutput =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus) + wsOutput;
bAddNeg = true;
} else {
wsOutput = L' ' + wsOutput;
@@ -2381,9 +2350,8 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
break;
case 's':
if (bNeg) {
- CFX_WideString wsMinusSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol);
- wsOutput = wsMinusSymbol + wsOutput;
+ wsOutput =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus) + wsOutput;
bAddNeg = true;
}
ccf--;
@@ -2396,9 +2364,9 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
ccf--;
break;
case '$': {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol);
- wsOutput = wsSymbol + wsOutput;
+ wsOutput =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol) +
+ wsOutput;
}
ccf--;
break;
@@ -2443,9 +2411,8 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
}
break;
case '%': {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol);
- wsOutput = wsSymbol + wsOutput;
+ wsOutput =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent) + wsOutput;
}
ccf--;
break;
@@ -2491,28 +2458,25 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
wsOutput += wsSrcNum[i];
}
if (dot_index < len) {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol);
- wsOutput += wsSymbol;
+ wsOutput += pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
wsOutput += wsSrcNum.Right(len - dot_index - 1);
}
if (bNeg) {
- CFX_WideString wsMinusymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol);
- wsOutput = wsMinusymbol + wsOutput;
+ wsOutput =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus) + wsOutput;
}
return false;
}
if (dot_index_f == wsNumFormat.GetLength()) {
if (!bAddNeg && bNeg) {
- CFX_WideString wsMinusymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol);
- wsOutput = wsMinusymbol + wsOutput;
+ wsOutput =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus) + wsOutput;
}
return true;
}
- CFX_WideString wsDotSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol);
+
+ CFX_WideString wsDotSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
if (strf[dot_index_f] == 'V') {
wsOutput += wsDotSymbol;
} else if (strf[dot_index_f] == '.') {
@@ -2570,14 +2534,11 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
CFX_WideString wsExp;
wsExp.Format(L"E%+d", exponent);
wsOutput += wsExp;
- }
ccf++;
- break;
- case '$': {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol);
- wsOutput += wsSymbol;
- }
+ } break;
+ case '$':
+ wsOutput +=
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol);
ccf++;
break;
case 'c':
@@ -2620,22 +2581,18 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
bAddNeg = true;
}
break;
- case '%': {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol);
- wsOutput += wsSymbol;
- }
+ case '%':
+ wsOutput += pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent);
ccf++;
break;
- case '8': {
- while (ccf < lenf && strf[ccf] == '8') {
+ case '8':
+ while (ccf < lenf && strf[ccf] == '8')
ccf++;
- }
while (cc < len && FXSYS_isDecimalDigit(str[cc])) {
wsOutput += str[cc];
cc++;
}
- } break;
+ break;
case ',':
wsOutput += wsGroupSymbol;
ccf++;
@@ -2662,10 +2619,8 @@ bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
}
}
if (!bAddNeg && bNeg) {
- CFX_WideString wsMinusymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol);
- wsOutput =
- wsMinusymbol + wsOutput[0] + wsOutput.Mid(1, wsOutput.GetLength() - 1);
+ wsOutput = pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus) +
+ wsOutput[0] + wsOutput.Mid(1, wsOutput.GetLength() - 1);
}
return true;
}
diff --git a/xfa/fgas/localization/fgas_locale.h b/xfa/fgas/localization/fgas_locale.h
index 449430b5c2..5d8ddc0b52 100644
--- a/xfa/fgas/localization/fgas_locale.h
+++ b/xfa/fgas/localization/fgas_locale.h
@@ -59,25 +59,18 @@ class IFX_Locale {
virtual ~IFX_Locale() {}
virtual CFX_WideString GetName() const = 0;
- virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
- CFX_WideString& wsNumSymbol) const = 0;
- virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const = 0;
- virtual void GetMonthName(int32_t nMonth,
- CFX_WideString& wsMonthName,
- bool bAbbr = true) const = 0;
- virtual void GetDayName(int32_t nWeek,
- CFX_WideString& wsDayName,
- bool bAbbr = true) const = 0;
- virtual void GetMeridiemName(CFX_WideString& wsMeridiemName,
- bool bAM = true) const = 0;
- virtual void GetTimeZone(FX_TIMEZONE* tz) const = 0;
- virtual void GetEraName(CFX_WideString& wsEraName, bool bAD = true) const = 0;
- virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const = 0;
- virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const = 0;
- virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
- CFX_WideString& wsPattern) const = 0;
+ virtual CFX_WideString GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const = 0;
+ virtual CFX_WideString GetDateTimeSymbols() const = 0;
+ virtual CFX_WideString GetMonthName(int32_t nMonth, bool bAbbr) const = 0;
+ virtual CFX_WideString GetDayName(int32_t nWeek, bool bAbbr) const = 0;
+ virtual CFX_WideString GetMeridiemName(bool bAM) const = 0;
+ virtual FX_TIMEZONE GetTimeZone() const = 0;
+ virtual CFX_WideString GetEraName(bool bAD) const = 0;
+ virtual CFX_WideString GetDatePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const = 0;
+ virtual CFX_WideString GetTimePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const = 0;
+ virtual CFX_WideString GetNumPattern(FX_LOCALENUMSUBCATEGORY eType) const = 0;
};
bool FX_DateFromCanonical(const CFX_WideString& wsDate, CFX_Unitime* datetime);
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 218e58b096..83f65edd4a 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -1168,13 +1168,10 @@ void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
int32_t second = uniTime.GetSecond();
int32_t milSecond = uniTime.GetMillisecond();
- FX_TIMEZONE tzLocale;
- pMgr->GetDefLocale()->GetTimeZone(&tzLocale);
-
// TODO(dsinclair): See if there is other time conversion code in pdfium and
// consolidate.
int32_t mins = hour * 60 + min;
- mins -= (tzLocale.tzHour * 60);
+ mins -= (pMgr->GetDefLocale()->GetTimeZone().tzHour * 60);
while (mins > 1440)
mins -= 1440;
while (mins < 0)
@@ -1568,7 +1565,7 @@ void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis,
CFX_WideString wsFormat;
if (formatString.IsEmpty())
- pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
+ wsFormat = pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default);
else
wsFormat = CFX_WideString::FromUTF8(formatString.AsStringC());
@@ -1588,10 +1585,7 @@ void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis,
int32_t milSecond = uniTime.GetMillisecond();
int32_t mins = hour * 60 + min;
- FX_TIMEZONE tz;
- CXFA_TimeZoneProvider provider;
- provider.GetTimeZone(&tz);
- mins -= (tz.tzHour * 60);
+ mins -= (CXFA_TimeZoneProvider().GetTimeZone().tzHour * 60);
while (mins > 1440)
mins -= 1440;
@@ -1942,7 +1936,7 @@ bool CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis,
CFX_WideString wsFormat;
if (szFormat.IsEmpty())
- pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
+ wsFormat = pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default);
else
wsFormat = CFX_WideString::FromUTF8(szFormat);
@@ -1979,7 +1973,7 @@ bool CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis,
CFX_WideString wsFormat;
if (szFormat.IsEmpty())
- pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
+ wsFormat = pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default);
else
wsFormat = CFX_WideString::FromUTF8(szFormat);
@@ -2017,7 +2011,7 @@ bool CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis,
CFX_WideString wsFormat;
if (szFormat.IsEmpty())
- pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
+ wsFormat = pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default);
else
wsFormat = CFX_WideString::FromUTF8(szFormat);
@@ -2055,7 +2049,7 @@ bool CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis,
CFX_WideString wsFormat;
if (szFormat.IsEmpty())
- pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
+ wsFormat = pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default);
else
wsFormat = CFX_WideString::FromUTF8(szFormat);
@@ -2094,7 +2088,7 @@ bool CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis,
CFX_WideString wsFormat;
if (szFormat.IsEmpty())
- pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
+ wsFormat = pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default);
else
wsFormat = CFX_WideString::FromUTF8(szFormat);
@@ -2206,12 +2200,10 @@ void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis,
if (!pLocale)
return;
- CFX_WideString strRet;
- pLocale->GetDatePattern(strStyle, strRet);
+ CFX_WideString strRet = pLocale->GetDatePattern(strStyle);
if (!bStandard) {
- CFX_WideString wsSymbols;
- pLocale->GetDateTimeSymbols(wsSymbols);
- AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date);
+ AlternateDateTimeSymbols(strRet, pLocale->GetDateTimeSymbols(),
+ g_sAltTable_Date);
}
strFormat = strRet.UTF8Encode();
}
@@ -2257,12 +2249,10 @@ void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis,
if (!pLocale)
return;
- CFX_WideString strRet;
- pLocale->GetTimePattern(strStyle, strRet);
+ CFX_WideString strRet = pLocale->GetTimePattern(strStyle);
if (!bStandard) {
- CFX_WideString wsSymbols;
- pLocale->GetDateTimeSymbols(wsSymbols);
- AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time);
+ AlternateDateTimeSymbols(strRet, pLocale->GetDateTimeSymbols(),
+ g_sAltTable_Time);
}
strFormat = strRet.UTF8Encode();
}
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 189d7d9605..a5238d2c3f 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -940,28 +940,26 @@ bool CXFA_LocaleValue::ValidateNumericTemp(CFX_WideString& wsNumeric,
}
n++;
}
- if (n == nCount) {
+ if (n == nCount)
return true;
- }
- if (nf == nCountFmt) {
+ if (nf == nCountFmt)
return false;
- }
+
while (nf < nCountFmt && (cf = pFmt[nf]) != L'.') {
ASSERT(cf == L'z' || cf == L'*');
++nf;
}
CFX_WideString wsDecimalSymbol;
- if (pLocale) {
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDecimalSymbol);
- } else {
+ if (pLocale)
+ wsDecimalSymbol = pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
+ else
wsDecimalSymbol = CFX_WideString(L'.');
- }
- if (pFmt[nf] != L'.') {
+
+ if (pFmt[nf] != L'.')
return false;
- }
- if (wsDecimalSymbol != CFX_WideStringC(c) && c != L'.') {
+ if (wsDecimalSymbol != CFX_WideStringC(c) && c != L'.')
return false;
- }
+
++nf;
++n;
bLimit = true;
diff --git a/xfa/fxfa/parser/cxfa_nodelocale.cpp b/xfa/fxfa/parser/cxfa_nodelocale.cpp
index 49d55c884c..fac3cc3335 100644
--- a/xfa/fxfa/parser/cxfa_nodelocale.cpp
+++ b/xfa/fxfa/parser/cxfa_nodelocale.cpp
@@ -35,7 +35,7 @@ CFX_WideString XFA_PatternToString(FX_LOCALENUMSUBCATEGORY category) {
case FX_LOCALENUMPATTERN_Integer:
return g_FX_Integer;
}
- return L"";
+ return CFX_WideString();
}
CXFA_NodeLocale::CXFA_NodeLocale(CXFA_Node* pLocale) : m_pLocale(pLocale) {}
@@ -47,108 +47,89 @@ CFX_WideString CXFA_NodeLocale::GetName() const {
: nullptr);
}
-void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
- CFX_WideString& wsNumSymbol) const {
+CFX_WideString CXFA_NodeLocale::GetNumbericSymbol(
+ FX_LOCALENUMSYMBOL eType) const {
switch (eType) {
case FX_LOCALENUMSYMBOL_Decimal:
- wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, L"decimal");
- break;
+ return GetSymbol(XFA_Element::NumberSymbols, L"decimal");
case FX_LOCALENUMSYMBOL_Grouping:
- wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, L"grouping");
- break;
+ return GetSymbol(XFA_Element::NumberSymbols, L"grouping");
case FX_LOCALENUMSYMBOL_Percent:
- wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, L"percent");
- break;
+ return GetSymbol(XFA_Element::NumberSymbols, L"percent");
case FX_LOCALENUMSYMBOL_Minus:
- wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, L"minus");
- break;
+ return GetSymbol(XFA_Element::NumberSymbols, L"minus");
case FX_LOCALENUMSYMBOL_Zero:
- wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, L"zero");
- break;
+ return GetSymbol(XFA_Element::NumberSymbols, L"zero");
case FX_LOCALENUMSYMBOL_CurrencySymbol:
- wsNumSymbol = GetSymbol(XFA_Element::CurrencySymbols, L"symbol");
- break;
+ return GetSymbol(XFA_Element::CurrencySymbols, L"symbol");
case FX_LOCALENUMSYMBOL_CurrencyName:
- wsNumSymbol = GetSymbol(XFA_Element::CurrencySymbols, L"isoname");
- break;
+ return GetSymbol(XFA_Element::CurrencySymbols, L"isoname");
}
+ return CFX_WideString();
}
-void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const {
+CFX_WideString CXFA_NodeLocale::GetDateTimeSymbols() const {
CXFA_Node* pSymbols =
m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols)
: nullptr;
- wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString();
+ return pSymbols ? pSymbols->GetContent() : CFX_WideString();
}
-void CXFA_NodeLocale::GetMonthName(int32_t nMonth,
- CFX_WideString& wsMonthName,
- bool bAbbr) const {
- wsMonthName = GetCalendarSymbol(XFA_Element::MonthNames, nMonth, bAbbr);
+CFX_WideString CXFA_NodeLocale::GetMonthName(int32_t nMonth, bool bAbbr) const {
+ return GetCalendarSymbol(XFA_Element::MonthNames, nMonth, bAbbr);
}
-void CXFA_NodeLocale::GetDayName(int32_t nWeek,
- CFX_WideString& wsDayName,
- bool bAbbr) const {
- wsDayName = GetCalendarSymbol(XFA_Element::DayNames, nWeek, bAbbr);
+CFX_WideString CXFA_NodeLocale::GetDayName(int32_t nWeek, bool bAbbr) const {
+ return GetCalendarSymbol(XFA_Element::DayNames, nWeek, bAbbr);
}
-void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName,
- bool bAM) const {
- wsMeridiemName =
- GetCalendarSymbol(XFA_Element::MeridiemNames, bAM ? 0 : 1, false);
+CFX_WideString CXFA_NodeLocale::GetMeridiemName(bool bAM) const {
+ return GetCalendarSymbol(XFA_Element::MeridiemNames, bAM ? 0 : 1, false);
}
-void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE* tz) const {
- CXFA_TimeZoneProvider provider;
- provider.GetTimeZone(tz);
+FX_TIMEZONE CXFA_NodeLocale::GetTimeZone() const {
+ return CXFA_TimeZoneProvider().GetTimeZone();
}
-void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, bool bAD) const {
- wsEraName = GetCalendarSymbol(XFA_Element::EraNames, bAD ? 1 : 0, false);
+CFX_WideString CXFA_NodeLocale::GetEraName(bool bAD) const {
+ return GetCalendarSymbol(XFA_Element::EraNames, bAD ? 1 : 0, false);
}
-void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
+CFX_WideString CXFA_NodeLocale::GetDatePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const {
switch (eType) {
case FX_LOCALEDATETIMESUBCATEGORY_Short:
- wsPattern = GetSymbol(XFA_Element::DatePatterns, L"short");
- break;
+ return GetSymbol(XFA_Element::DatePatterns, L"short");
case FX_LOCALEDATETIMESUBCATEGORY_Medium:
case FX_LOCALEDATETIMESUBCATEGORY_Default:
- wsPattern = GetSymbol(XFA_Element::DatePatterns, L"med");
- break;
+ return GetSymbol(XFA_Element::DatePatterns, L"med");
case FX_LOCALEDATETIMESUBCATEGORY_Full:
- wsPattern = GetSymbol(XFA_Element::DatePatterns, L"full");
- break;
+ return GetSymbol(XFA_Element::DatePatterns, L"full");
case FX_LOCALEDATETIMESUBCATEGORY_Long:
- wsPattern = GetSymbol(XFA_Element::DatePatterns, L"long");
- break;
+ return GetSymbol(XFA_Element::DatePatterns, L"long");
}
+ return CFX_WideString();
}
-void CXFA_NodeLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
+CFX_WideString CXFA_NodeLocale::GetTimePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const {
switch (eType) {
case FX_LOCALEDATETIMESUBCATEGORY_Short:
- wsPattern = GetSymbol(XFA_Element::TimePatterns, L"short");
- break;
+ return GetSymbol(XFA_Element::TimePatterns, L"short");
case FX_LOCALEDATETIMESUBCATEGORY_Medium:
case FX_LOCALEDATETIMESUBCATEGORY_Default:
- wsPattern = GetSymbol(XFA_Element::TimePatterns, L"med");
- break;
+ return GetSymbol(XFA_Element::TimePatterns, L"med");
case FX_LOCALEDATETIMESUBCATEGORY_Full:
- wsPattern = GetSymbol(XFA_Element::TimePatterns, L"full");
- break;
+ return GetSymbol(XFA_Element::TimePatterns, L"full");
case FX_LOCALEDATETIMESUBCATEGORY_Long:
- wsPattern = GetSymbol(XFA_Element::TimePatterns, L"long");
- break;
+ return GetSymbol(XFA_Element::TimePatterns, L"long");
}
+ return CFX_WideString();
}
-void CXFA_NodeLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
- wsPattern = XFA_PatternToString(eType);
+CFX_WideString CXFA_NodeLocale::GetNumPattern(
+ FX_LOCALENUMSUBCATEGORY eType) const {
+ return XFA_PatternToString(eType);
}
CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent,
@@ -180,13 +161,14 @@ CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
CXFA_Node* pCalendar =
m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols)
: nullptr;
- if (pCalendar) {
- CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement);
- for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) {
- if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) {
- CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown);
- return pSymbol ? pSymbol->GetContent() : CFX_WideString();
- }
+ if (!pCalendar)
+ return CFX_WideString();
+
+ CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement);
+ for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) {
+ if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) {
+ CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown);
+ return pSymbol ? pSymbol->GetContent() : CFX_WideString();
}
}
return CFX_WideString();
diff --git a/xfa/fxfa/parser/cxfa_nodelocale.h b/xfa/fxfa/parser/cxfa_nodelocale.h
index db3b2303e7..0059d19888 100644
--- a/xfa/fxfa/parser/cxfa_nodelocale.h
+++ b/xfa/fxfa/parser/cxfa_nodelocale.h
@@ -21,27 +21,20 @@ class CXFA_NodeLocale : public IFX_Locale {
// IFX_Locale
CFX_WideString GetName() const override;
- void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
- CFX_WideString& wsNumSymbol) const override;
-
- void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const override;
- void GetMonthName(int32_t nMonth,
- CFX_WideString& wsMonthName,
- bool bAbbr = true) const override;
- void GetDayName(int32_t nWeek,
- CFX_WideString& wsDayName,
- bool bAbbr = true) const override;
- void GetMeridiemName(CFX_WideString& wsMeridiemName,
- bool bAM = true) const override;
- void GetTimeZone(FX_TIMEZONE* tz) const override;
- void GetEraName(CFX_WideString& wsEraName, bool bAD = true) const override;
-
- void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const override;
- void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const override;
- void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
- CFX_WideString& wsPattern) const override;
+ CFX_WideString GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const override;
+
+ CFX_WideString GetDateTimeSymbols() const override;
+ CFX_WideString GetMonthName(int32_t nMonth, bool bAbbr) const override;
+ CFX_WideString GetDayName(int32_t nWeek, bool bAbbr) const override;
+ CFX_WideString GetMeridiemName(bool bAM) const override;
+ FX_TIMEZONE GetTimeZone() const override;
+ CFX_WideString GetEraName(bool bAD) const override;
+
+ CFX_WideString GetDatePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const override;
+ CFX_WideString GetTimePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const override;
+ CFX_WideString GetNumPattern(FX_LOCALENUMSUBCATEGORY eType) const override;
private:
CXFA_Node* GetNodeByName(CXFA_Node* pParent,
diff --git a/xfa/fxfa/parser/cxfa_timezoneprovider.cpp b/xfa/fxfa/parser/cxfa_timezoneprovider.cpp
index 65ce61e10b..ae31977e6d 100644
--- a/xfa/fxfa/parser/cxfa_timezoneprovider.cpp
+++ b/xfa/fxfa/parser/cxfa_timezoneprovider.cpp
@@ -30,7 +30,3 @@ CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() {
}
CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {}
-
-void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE* tz) const {
- *tz = m_tz;
-}
diff --git a/xfa/fxfa/parser/cxfa_timezoneprovider.h b/xfa/fxfa/parser/cxfa_timezoneprovider.h
index 05230cc122..493da32288 100644
--- a/xfa/fxfa/parser/cxfa_timezoneprovider.h
+++ b/xfa/fxfa/parser/cxfa_timezoneprovider.h
@@ -14,7 +14,7 @@ class CXFA_TimeZoneProvider {
CXFA_TimeZoneProvider();
~CXFA_TimeZoneProvider();
- void GetTimeZone(FX_TIMEZONE* tz) const;
+ FX_TIMEZONE GetTimeZone() const { return m_tz; }
private:
FX_TIMEZONE m_tz;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index e6cd75fe62..6da501b4a3 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -1486,7 +1486,7 @@ bool CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture,
return true;
}
}
- CFX_WideString wsDataPicture, wsTimePicture;
+
IFX_Locale* pLocale = GetLocal();
if (!pLocale)
return false;
@@ -1494,19 +1494,18 @@ bool CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture,
uint32_t dwType = widgetValue.GetType();
switch (dwType) {
case XFA_VT_DATE:
- pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium,
- wsPicture);
+ wsPicture =
+ pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium);
break;
case XFA_VT_TIME:
- pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium,
- wsPicture);
+ wsPicture =
+ pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium);
break;
case XFA_VT_DATETIME:
- pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium,
- wsDataPicture);
- pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium,
- wsTimePicture);
- wsPicture = wsDataPicture + L"T" + wsTimePicture;
+ wsPicture =
+ pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium) +
+ L"T" +
+ pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium);
break;
case XFA_VT_DECIMAL:
case XFA_VT_FLOAT:
@@ -1516,7 +1515,6 @@ bool CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture,
}
return true;
}
-
case XFA_VALUEPICTURE_Edit: {
CXFA_Node* pUI = m_pNode->GetChild(0, XFA_Element::Ui);
if (pUI) {
@@ -1525,32 +1523,29 @@ bool CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture,
return true;
}
}
- {
- CFX_WideString wsDataPicture, wsTimePicture;
- IFX_Locale* pLocale = GetLocal();
- if (!pLocale) {
- return false;
- }
- uint32_t dwType = widgetValue.GetType();
- switch (dwType) {
- case XFA_VT_DATE:
- pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short,
- wsPicture);
- break;
- case XFA_VT_TIME:
- pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short,
- wsPicture);
- break;
- case XFA_VT_DATETIME:
- pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short,
- wsDataPicture);
- pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short,
- wsTimePicture);
- wsPicture = wsDataPicture + L"T" + wsTimePicture;
- break;
- default:
- break;
- }
+
+ IFX_Locale* pLocale = GetLocal();
+ if (!pLocale)
+ return false;
+
+ uint32_t dwType = widgetValue.GetType();
+ switch (dwType) {
+ case XFA_VT_DATE:
+ wsPicture =
+ pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short);
+ break;
+ case XFA_VT_TIME:
+ wsPicture =
+ pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short);
+ break;
+ case XFA_VT_DATETIME:
+ wsPicture =
+ pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short) +
+ L"T" +
+ pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short);
+ break;
+ default:
+ break;
}
return true;
}
@@ -1783,8 +1778,8 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
return;
CFX_WideString wsSrcNum = wsValue;
- CFX_WideString wsGroupSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol);
+ CFX_WideString wsGroupSymbol =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping);
bool bNeg = false;
if (wsSrcNum[0] == '-') {
bNeg = true;
@@ -1806,15 +1801,12 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
wsOutput += wsSrcNum[i];
}
if (dot_index < len) {
- CFX_WideString wsSymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol);
- wsOutput += wsSymbol;
+ wsOutput += pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
wsOutput += wsSrcNum.Right(len - dot_index - 1);
}
if (bNeg) {
- CFX_WideString wsMinusymbol;
- pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol);
- wsOutput = wsMinusymbol + wsOutput;
+ wsOutput =
+ pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus) + wsOutput;
}
}
}
diff --git a/xfa/fxfa/parser/cxfa_xmllocale.cpp b/xfa/fxfa/parser/cxfa_xmllocale.cpp
index c4aae15020..cbac7772a2 100644
--- a/xfa/fxfa/parser/cxfa_xmllocale.cpp
+++ b/xfa/fxfa/parser/cxfa_xmllocale.cpp
@@ -25,8 +25,8 @@ CFX_WideString CXFA_XMLLocale::GetName() const {
return m_pLocaleData ? m_pLocaleData->GetAttrValue("name") : CFX_WideString();
}
-void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
- CFX_WideString& wsNumSymbol) const {
+CFX_WideString CXFA_XMLLocale::GetNumbericSymbol(
+ FX_LOCALENUMSYMBOL eType) const {
CFX_ByteString bsSymbols;
CFX_WideString wsName;
switch (eType) {
@@ -59,87 +59,77 @@ void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
wsName = L"isoname";
break;
default:
- return;
+ return CFX_WideString();
}
CXML_Element* pElement = m_pLocaleData->GetElement("", bsSymbols.AsStringC());
if (!pElement)
- return;
+ return CFX_WideString();
- GetPattern(pElement,
- CFX_ByteStringC(bsSymbols.c_str(), bsSymbols.GetLength() - 1),
- wsName.AsStringC(), wsNumSymbol);
+ return GetPattern(
+ pElement, CFX_ByteStringC(bsSymbols.c_str(), bsSymbols.GetLength() - 1),
+ wsName.AsStringC());
}
-void CXFA_XMLLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const {
+CFX_WideString CXFA_XMLLocale::GetDateTimeSymbols() const {
if (!m_pLocaleData)
- return;
+ return CFX_WideString();
CFX_ByteString bsSpace;
CXML_Element* pNumberSymbols =
m_pLocaleData->GetElement(bsSpace.AsStringC(), "dateTimeSymbols");
- if (!pNumberSymbols)
- return;
-
- wsDtSymbol = pNumberSymbols->GetContent(0);
+ return pNumberSymbols ? pNumberSymbols->GetContent(0) : CFX_WideString();
}
-void CXFA_XMLLocale::GetMonthName(int32_t nMonth,
- CFX_WideString& wsMonthName,
- bool bAbbr) const {
- wsMonthName = GetCalendarSymbol("month", nMonth, bAbbr);
+CFX_WideString CXFA_XMLLocale::GetMonthName(int32_t nMonth, bool bAbbr) const {
+ return GetCalendarSymbol("month", nMonth, bAbbr);
}
-void CXFA_XMLLocale::GetDayName(int32_t nWeek,
- CFX_WideString& wsDayName,
- bool bAbbr) const {
- wsDayName = GetCalendarSymbol("day", nWeek, bAbbr);
+CFX_WideString CXFA_XMLLocale::GetDayName(int32_t nWeek, bool bAbbr) const {
+ return GetCalendarSymbol("day", nWeek, bAbbr);
}
-void CXFA_XMLLocale::GetMeridiemName(CFX_WideString& wsMeridiemName,
- bool bAM) const {
- wsMeridiemName = GetCalendarSymbol("meridiem", bAM ? 0 : 1, false);
+CFX_WideString CXFA_XMLLocale::GetMeridiemName(bool bAM) const {
+ return GetCalendarSymbol("meridiem", bAM ? 0 : 1, false);
}
-void CXFA_XMLLocale::GetTimeZone(FX_TIMEZONE* tz) const {
- CXFA_TimeZoneProvider provider;
- provider.GetTimeZone(tz);
+FX_TIMEZONE CXFA_XMLLocale::GetTimeZone() const {
+ return CXFA_TimeZoneProvider().GetTimeZone();
}
-void CXFA_XMLLocale::GetEraName(CFX_WideString& wsEraName, bool bAD) const {
- wsEraName = GetCalendarSymbol("era", bAD ? 1 : 0, false);
+CFX_WideString CXFA_XMLLocale::GetEraName(bool bAD) const {
+ return GetCalendarSymbol("era", bAD ? 1 : 0, false);
}
CFX_WideString CXFA_XMLLocale::GetCalendarSymbol(const CFX_ByteStringC& symbol,
int index,
bool bAbbr) const {
+ if (!m_pLocaleData)
+ return CFX_WideString();
+
+ CXML_Element* pChild = m_pLocaleData->GetElement("", "calendarSymbols");
+ if (!pChild)
+ return CFX_WideString();
+
CFX_ByteString pstrSymbolNames = symbol + "Names";
- CFX_WideString wsSymbolName = L"";
- if (m_pLocaleData) {
- CXML_Element* pChild = m_pLocaleData->GetElement("", "calendarSymbols");
- if (pChild) {
- CXML_Element* pSymbolNames =
- pChild->GetElement("", pstrSymbolNames.AsStringC());
- if (pSymbolNames) {
- if ((!!pSymbolNames->GetAttrInteger("abbr")) != bAbbr) {
- pSymbolNames = pChild->GetElement("", pstrSymbolNames.AsStringC(), 1);
- }
- if (pSymbolNames && (!!pSymbolNames->GetAttrInteger("abbr")) == bAbbr) {
- CXML_Element* pSymbolName =
- pSymbolNames->GetElement("", symbol, index);
- if (pSymbolName)
- wsSymbolName = pSymbolName->GetContent(0);
- }
- }
- }
- }
- return wsSymbolName;
+ CXML_Element* pSymbolNames =
+ pChild->GetElement("", pstrSymbolNames.AsStringC());
+ if (!pSymbolNames)
+ return CFX_WideString();
+ if ((!!pSymbolNames->GetAttrInteger("abbr")) != bAbbr)
+ pSymbolNames = pChild->GetElement("", pstrSymbolNames.AsStringC(), 1);
+
+ if (!pSymbolNames || (!!pSymbolNames->GetAttrInteger("abbr")) != bAbbr)
+ return CFX_WideString();
+
+ CXML_Element* pSymbolName = pSymbolNames->GetElement("", symbol, index);
+ return pSymbolName ? pSymbolName->GetContent(0) : CFX_WideString();
}
-void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
+CFX_WideString CXFA_XMLLocale::GetDatePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const {
CXML_Element* pElement = m_pLocaleData->GetElement("", "datePatterns");
if (!pElement)
- return;
+ return CFX_WideString();
CFX_WideString wsName;
switch (eType) {
@@ -157,14 +147,14 @@ void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
wsName = L"long";
break;
}
- GetPattern(pElement, "datePattern", wsName.AsStringC(), wsPattern);
+ return GetPattern(pElement, "datePattern", wsName.AsStringC());
}
-void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
+CFX_WideString CXFA_XMLLocale::GetTimePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const {
CXML_Element* pElement = m_pLocaleData->GetElement("", "timePatterns");
if (!pElement)
- return;
+ return CFX_WideString();
CFX_WideString wsName;
switch (eType) {
@@ -182,28 +172,24 @@ void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
wsName = L"long";
break;
}
- GetPattern(pElement, "timePattern", wsName.AsStringC(), wsPattern);
+ return GetPattern(pElement, "timePattern", wsName.AsStringC());
}
-void CXFA_XMLLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
- CXML_Element* pElement = m_pLocaleData->GetElement("", "numberPatterns");
- if (!pElement)
- return;
-
- wsPattern = XFA_PatternToString(eType);
+CFX_WideString CXFA_XMLLocale::GetNumPattern(
+ FX_LOCALENUMSUBCATEGORY eType) const {
+ return m_pLocaleData->GetElement("", "numberPatterns")
+ ? XFA_PatternToString(eType)
+ : CFX_WideString();
}
-void CXFA_XMLLocale::GetPattern(CXML_Element* pElement,
- const CFX_ByteStringC& bsTag,
- const CFX_WideStringC& wsName,
- CFX_WideString& wsPattern) const {
+CFX_WideString CXFA_XMLLocale::GetPattern(CXML_Element* pElement,
+ const CFX_ByteStringC& bsTag,
+ const CFX_WideStringC& wsName) const {
int32_t iCount = pElement->CountElements("", bsTag);
for (int32_t i = 0; i < iCount; i++) {
CXML_Element* pChild = pElement->GetElement("", bsTag, i);
- if (pChild->GetAttrValue("name") == wsName) {
- wsPattern = pChild->GetContent(0);
- return;
- }
+ if (pChild->GetAttrValue("name") == wsName)
+ return pChild->GetContent(0);
}
+ return CFX_WideString();
}
diff --git a/xfa/fxfa/parser/cxfa_xmllocale.h b/xfa/fxfa/parser/cxfa_xmllocale.h
index b631697b40..7616c115a1 100644
--- a/xfa/fxfa/parser/cxfa_xmllocale.h
+++ b/xfa/fxfa/parser/cxfa_xmllocale.h
@@ -19,33 +19,25 @@ class CXFA_XMLLocale : public IFX_Locale {
// IFX_Locale
CFX_WideString GetName() const override;
- void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
- CFX_WideString& wsNumSymbol) const override;
-
- void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const override;
- void GetMonthName(int32_t nMonth,
- CFX_WideString& wsMonthName,
- bool bAbbr = true) const override;
- void GetDayName(int32_t nWeek,
- CFX_WideString& wsDayName,
- bool bAbbr = true) const override;
- void GetMeridiemName(CFX_WideString& wsMeridiemName,
- bool bAM = true) const override;
- void GetTimeZone(FX_TIMEZONE* tz) const override;
- void GetEraName(CFX_WideString& wsEraName, bool bAD = true) const override;
-
- void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const override;
- void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const override;
- void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
- CFX_WideString& wsPattern) const override;
+ CFX_WideString GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const override;
+
+ CFX_WideString GetDateTimeSymbols() const override;
+ CFX_WideString GetMonthName(int32_t nMonth, bool bAbbr) const override;
+ CFX_WideString GetDayName(int32_t nWeek, bool bAbbr) const override;
+ CFX_WideString GetMeridiemName(bool bAM) const override;
+ FX_TIMEZONE GetTimeZone() const override;
+ CFX_WideString GetEraName(bool bAD) const override;
+
+ CFX_WideString GetDatePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const override;
+ CFX_WideString GetTimePattern(
+ FX_LOCALEDATETIMESUBCATEGORY eType) const override;
+ CFX_WideString GetNumPattern(FX_LOCALENUMSUBCATEGORY eType) const override;
private:
- void GetPattern(CXML_Element* pElement,
- const CFX_ByteStringC& bsTag,
- const CFX_WideStringC& wsName,
- CFX_WideString& wsPattern) const;
+ CFX_WideString GetPattern(CXML_Element* pElement,
+ const CFX_ByteStringC& bsTag,
+ const CFX_WideStringC& wsName) const;
CFX_WideString GetCalendarSymbol(const CFX_ByteStringC& symbol,
int index,
bool bAbbr) const;