summaryrefslogtreecommitdiff
path: root/xfa/fxfa
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 /xfa/fxfa
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>
Diffstat (limited to 'xfa/fxfa')
-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
9 files changed, 199 insertions, 270 deletions
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;