diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-16 21:45:18 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-16 21:45:18 +0000 |
commit | 3f1c832dda209cf6682bb75316c07d71332fe6c3 (patch) | |
tree | 79e274e65a500bc7964fe4328a6185c805274640 /xfa | |
parent | 40d522134a11867adb95f77c0b7891932e0739a2 (diff) | |
download | pdfium-3f1c832dda209cf6682bb75316c07d71332fe6c3.tar.xz |
Make WideString::{Format|FormatV} static
This CL moves the Format and FormatV methods from WideString to be
static.
Bug: pdfium:934
Change-Id: I9941d6a2a5bbf0a82087cd0ea5d0f8fc42eecd3e
Reviewed-on: https://pdfium-review.googlesource.com/18630
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fgas/crt/cfgas_formatstring.cpp | 19 | ||||
-rw-r--r-- | xfa/fwl/cfwl_datetimepicker.cpp | 5 | ||||
-rw-r--r-- | xfa/fwl/cfwl_monthcalendar.cpp | 21 | ||||
-rw-r--r-- | xfa/fwl/cfwl_monthcalendar.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffnotify.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fftextedit.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textlayout.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 20 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_dataexporter.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_filldata.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_localevalue.cpp | 27 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_measurement.cpp | 28 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_nodehelper.cpp | 9 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_strokedata.cpp | 6 |
15 files changed, 70 insertions, 105 deletions
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp index 87b07691a4..eaac969fd8 100644 --- a/xfa/fgas/crt/cfgas_formatstring.cpp +++ b/xfa/fgas/crt/cfgas_formatstring.cpp @@ -554,9 +554,8 @@ uint16_t GetWeekOfYear(uint16_t year, uint16_t month, uint16_t day) { } WideString NumToString(size_t fmt_size, int32_t value) { - WideString str; - str.Format(fmt_size == 1 ? L"%d" : fmt_size == 2 ? L"%02d" : L"%03d", value); - return str; + return WideString::Format( + fmt_size == 1 ? L"%d" : fmt_size == 2 ? L"%02d" : L"%03d", value); } WideString DateFormat(const WideString& wsDatePattern, @@ -684,10 +683,8 @@ WideString TimeFormat(const WideString& wsTimePattern, FX_TIMEZONE tz = pLocale->GetTimeZone(); if (tz.tzHour != 0 || tz.tzMinute != 0) { wsResult += tz.tzHour < 0 ? L"-" : L"+"; - - WideString wsTimezone; - wsTimezone.Format(L"%02d:%02d", abs(tz.tzHour), tz.tzMinute); - wsResult += wsTimezone; + wsResult += + WideString::Format(L"%02d:%02d", abs(tz.tzHour), tz.tzMinute); } } } @@ -2006,9 +2003,7 @@ bool CFGAS_FormatString::FormatStrNum(const WideStringView& wsInputNum, ccf--; break; case 'E': { - WideString wsExp; - wsExp.Format(L"E%+d", exponent); - *wsOutput = wsExp + *wsOutput; + *wsOutput = WideString::Format(L"E%+d", exponent) + *wsOutput; ccf--; break; } @@ -2164,9 +2159,7 @@ bool CFGAS_FormatString::FormatStrNum(const WideStringView& wsInputNum, ccf++; break; case 'E': { - WideString wsExp; - wsExp.Format(L"E%+d", exponent); - *wsOutput += wsExp; + *wsOutput += WideString::Format(L"E%+d", exponent); ccf++; break; } diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index cd58dc7f92..8dcdf887f7 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp @@ -214,10 +214,11 @@ void CFWL_DateTimePicker::FormatDateString(int32_t iYear, WideString& wsText) { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) == FWL_STYLEEXT_DTP_ShortDateFormat) { - wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay); + wsText = WideString::Format(L"%d-%d-%d", iYear, iMonth, iDay); } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) == FWL_STYLEEXT_DTP_LongDateFormat) { - wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); + wsText = + WideString::Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); } } diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp index 82cef65c3c..5f23a1e8e9 100644 --- a/xfa/fwl/cfwl_monthcalendar.cpp +++ b/xfa/fwl/cfwl_monthcalendar.cpp @@ -430,9 +430,8 @@ CFX_SizeF CFWL_MonthCalendar::CalcSize() { float fDayMaxW = 0.0f; float fDayMaxH = 0.0f; for (int day = 10; day <= 31; day++) { - WideString wsDay; - wsDay.Format(L"%d", day); - CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider, false); + CFX_SizeF sz = CalcTextSize(WideString::Format(L"%d", day), + m_pProperties->m_pThemeProvider, false); fDayMaxW = (fDayMaxW >= sz.width) ? fDayMaxW : sz.width; fDayMaxH = (fDayMaxH >= sz.height) ? fDayMaxH : sz.height; } @@ -579,8 +578,6 @@ void CFWL_MonthCalendar::ResetDateItem() { if (iDayOfWeek >= 7) iDayOfWeek = 0; - WideString wsDay; - wsDay.Format(L"%d", i + 1); uint32_t dwStates = 0; if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) dwStates |= FWL_ITEMSTATE_MCD_Flag; @@ -588,8 +585,8 @@ void CFWL_MonthCalendar::ResetDateItem() { dwStates |= FWL_ITEMSTATE_MCD_Selected; CFX_RectF rtDate; - m_arrDates.push_back(pdfium::MakeUnique<DATEINFO>(i + 1, iDayOfWeek, - dwStates, rtDate, wsDay)); + m_arrDates.push_back(pdfium::MakeUnique<DATEINFO>( + i + 1, iDayOfWeek, dwStates, rtDate, WideString::Format(L"%d", i + 1))); iDayOfWeek++; } } @@ -680,17 +677,13 @@ WideString CFWL_MonthCalendar::GetHeadText(int32_t iYear, int32_t iMonth) { L"April", L"May", L"June", L"July", L"August", L"September", L"October", L"November", L"December"}; - WideString wsHead; - wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear); - return wsHead; + return WideString::Format(L"%s, %d", pMonth[iMonth - 1], iYear); } WideString CFWL_MonthCalendar::GetTodayText(int32_t iYear, int32_t iMonth, int32_t iDay) { - WideString wsToday; - wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear); - return wsToday; + return WideString::Format(L", %d/%d/%d", iDay, iMonth, iYear); } int32_t CFWL_MonthCalendar::GetDayAtPoint(const CFX_PointF& point) const { @@ -893,7 +886,7 @@ CFWL_MonthCalendar::DATEINFO::DATEINFO(int32_t day, int32_t dayofweek, uint32_t dwSt, CFX_RectF rc, - WideString& wsday) + const WideString& wsday) : iDay(day), iDayOfWeek(dayofweek), dwStates(dwSt), diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h index 325fa96158..7b68600bbc 100644 --- a/xfa/fwl/cfwl_monthcalendar.h +++ b/xfa/fwl/cfwl_monthcalendar.h @@ -79,7 +79,7 @@ class CFWL_MonthCalendar : public CFWL_Widget { int32_t dayofweek, uint32_t dwSt, CFX_RectF rc, - WideString& wsday); + const WideString& wsday); ~DATEINFO(); int32_t iDay; diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index d076fdeddb..3895d54569 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -163,12 +163,10 @@ void CXFA_FFDocView::ShowNullTestMsg() { wsMsg += m_arrNullTestMsg[i] + L"\n"; if (iRemain > 0) { - WideString wsTemp; - wsTemp.Format( - L"Message limit exceeded. Remaining %d " - L"validation errors not reported.", - iRemain); - wsMsg += L"\n" + wsTemp; + wsMsg += L"\n" + WideString::Format( + L"Message limit exceeded. Remaining %d " + L"validation errors not reported.", + iRemain); } pAppProvider->MsgBox(wsMsg, pAppProvider->GetAppTitle(), XFA_MBICON_Status, XFA_MB_OK); diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index 6e3cdd9411..fb63556da9 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -286,12 +286,10 @@ void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) { WideString CXFA_FFNotify::GetCurrentDateTime() { CFX_DateTime dataTime; dataTime.Now(); - - WideString wsDateTime; - wsDateTime.Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(), - dataTime.GetMonth(), dataTime.GetDay(), dataTime.GetHour(), - dataTime.GetMinute(), dataTime.GetSecond()); - return wsDateTime; + return WideString::Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(), + dataTime.GetMonth(), dataTime.GetDay(), + dataTime.GetHour(), dataTime.GetMinute(), + dataTime.GetSecond()); } void CXFA_FFNotify::ResetData(CXFA_WidgetData* pWidgetData) { diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp index 61f48d7f54..848eab875f 100644 --- a/xfa/fxfa/cxfa_fftextedit.cpp +++ b/xfa/fxfa/cxfa_fftextedit.cpp @@ -203,10 +203,9 @@ void CXFA_FFTextEdit::ValidateNumberField(const WideString& wsText) { WideString wsSomField; pAcc->GetNode()->GetSOMExpression(wsSomField); - WideString wsMessage; - wsMessage.Format(L"%s can not contain %s", wsText.c_str(), - wsSomField.c_str()); - pAppProvider->MsgBox(wsMessage, pAppProvider->GetAppTitle(), XFA_MBICON_Error, + pAppProvider->MsgBox(WideString::Format(L"%s can not contain %s", + wsText.c_str(), wsSomField.c_str()), + pAppProvider->GetAppTitle(), XFA_MBICON_Error, XFA_MB_OK); } diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index 532079e4a7..bec116c65e 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -756,7 +756,7 @@ bool CXFA_TextLayout::LoadRichText( } else if (wsName == L"li") { bCurLi = true; if (bIsOl) - wsText.Format(L"%d. ", iLiCount); + wsText = WideString::Format(L"%d. ", iLiCount); else wsText = 0x00B7 + WideStringView(L" ", 1); } else if (!bContentNode) { diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index a579646fd9..b019bf636c 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -472,7 +472,8 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_ValidateData validateData, case XFA_ATTRIBUTEENUM_Error: { if (wsNullMsg.IsEmpty()) { wsCaptionName = GetValidateCaptionName(bVersionFlag); - wsNullMsg.Format(L"%s cannot be blank.", wsCaptionName.c_str()); + wsNullMsg = + WideString::Format(L"%s cannot be blank.", wsCaptionName.c_str()); } pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); return XFA_EVENTERROR_Error; @@ -483,7 +484,7 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_ValidateData validateData, if (wsNullMsg.IsEmpty()) { wsCaptionName = GetValidateCaptionName(bVersionFlag); - wsNullMsg.Format( + wsNullMsg = WideString::Format( L"%s cannot be blank. To ignore validations for %s, click Ignore.", wsCaptionName.c_str(), wsCaptionName.c_str()); } @@ -518,21 +519,16 @@ WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) { WideString CXFA_WidgetAcc::GetValidateMessage(bool bError, bool bVersionFlag) { WideString wsCaptionName = GetValidateCaptionName(bVersionFlag); - WideString wsMessage; - if (bVersionFlag) { - wsMessage.Format(L"%s validation failed", wsCaptionName.c_str()); - return wsMessage; - } + if (bVersionFlag) + return WideString::Format(L"%s validation failed", wsCaptionName.c_str()); if (bError) { - wsMessage.Format(L"The value you entered for %s is invalid.", - wsCaptionName.c_str()); - return wsMessage; + return WideString::Format(L"The value you entered for %s is invalid.", + wsCaptionName.c_str()); } - wsMessage.Format( + return WideString::Format( L"The value you entered for %s is invalid. To ignore " L"validations for %s, click Ignore.", wsCaptionName.c_str(), wsCaptionName.c_str()); - return wsMessage; } int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index c86a7f7d51..e8a37719fe 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -162,7 +162,8 @@ void RecognizeXFAVersionNumber(CXFA_Node* pTemplateRoot, if (eVersion == XFA_VERSION_UNKNOWN) eVersion = XFA_VERSION_DEFAULT; - wsVersionNumber.Format(L"%i.%i", eVersion / 100, eVersion % 100); + wsVersionNumber = + WideString::Format(L"%i.%i", eVersion / 100, eVersion % 100); } void RegenerateFormFile_Changed(CXFA_Node* pNode, diff --git a/xfa/fxfa/parser/cxfa_filldata.cpp b/xfa/fxfa/parser/cxfa_filldata.cpp index da249548f9..9f57b8de7d 100644 --- a/xfa/fxfa/parser/cxfa_filldata.cpp +++ b/xfa/fxfa/parser/cxfa_filldata.cpp @@ -19,14 +19,14 @@ int32_t CXFA_FillData::GetPresence() { void CXFA_FillData::SetColor(FX_ARGB color) { CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Color, true); - WideString wsColor; int a; int r; int g; int b; std::tie(a, r, g, b) = ArgbDecode(color); - wsColor.Format(L"%d,%d,%d", r, g, b); - pNode->JSNode()->SetCData(XFA_Attribute::Value, wsColor, false, false); + pNode->JSNode()->SetCData(XFA_Attribute::Value, + WideString::Format(L"%d,%d,%d", r, g, b), false, + false); } FX_ARGB CXFA_FillData::GetColor(bool bText) { diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp index 109254fe2c..09e3577887 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.cpp +++ b/xfa/fxfa/parser/cxfa_localevalue.cpp @@ -292,32 +292,27 @@ CFX_DateTime CXFA_LocaleValue::GetTime() const { bool CXFA_LocaleValue::SetDate(const CFX_DateTime& d) { m_dwType = XFA_VT_DATE; - m_wsValue.Format(L"%04d-%02d-%02d", d.GetYear(), d.GetMonth(), d.GetDay()); + m_wsValue = WideString::Format(L"%04d-%02d-%02d", d.GetYear(), d.GetMonth(), + d.GetDay()); return true; } bool CXFA_LocaleValue::SetTime(const CFX_DateTime& t) { m_dwType = XFA_VT_TIME; - m_wsValue.Format(L"%02d:%02d:%02d", t.GetHour(), t.GetMinute(), - t.GetSecond()); - if (t.GetMillisecond() > 0) { - WideString wsTemp; - wsTemp.Format(L"%:03d", t.GetMillisecond()); - m_wsValue += wsTemp; - } + m_wsValue = WideString::Format(L"%02d:%02d:%02d", t.GetHour(), t.GetMinute(), + t.GetSecond()); + if (t.GetMillisecond() > 0) + m_wsValue += WideString::Format(L"%:03d", t.GetMillisecond()); return true; } bool CXFA_LocaleValue::SetDateTime(const CFX_DateTime& dt) { m_dwType = XFA_VT_DATETIME; - m_wsValue.Format(L"%04d-%02d-%02dT%02d:%02d:%02d", dt.GetYear(), - dt.GetMonth(), dt.GetDay(), dt.GetHour(), dt.GetMinute(), - dt.GetSecond()); - if (dt.GetMillisecond() > 0) { - WideString wsTemp; - wsTemp.Format(L"%:03d", dt.GetMillisecond()); - m_wsValue += wsTemp; - } + m_wsValue = WideString::Format(L"%04d-%02d-%02dT%02d:%02d:%02d", dt.GetYear(), + dt.GetMonth(), dt.GetDay(), dt.GetHour(), + dt.GetMinute(), dt.GetSecond()); + if (dt.GetMillisecond() > 0) + m_wsValue += WideString::Format(L"%:03d", dt.GetMillisecond()); return true; } diff --git a/xfa/fxfa/parser/cxfa_measurement.cpp b/xfa/fxfa/parser/cxfa_measurement.cpp index 91e39af969..288ed0cd31 100644 --- a/xfa/fxfa/parser/cxfa_measurement.cpp +++ b/xfa/fxfa/parser/cxfa_measurement.cpp @@ -46,37 +46,27 @@ void CXFA_Measurement::SetString(const WideStringView& wsMeasure) { } WideString CXFA_Measurement::ToString() const { - WideString wsMeasure; switch (GetUnit()) { case XFA_Unit::Mm: - wsMeasure.Format(L"%.8gmm", GetValue()); - break; + return WideString::Format(L"%.8gmm", GetValue()); case XFA_Unit::Pt: - wsMeasure.Format(L"%.8gpt", GetValue()); - break; + return WideString::Format(L"%.8gpt", GetValue()); case XFA_Unit::In: - wsMeasure.Format(L"%.8gin", GetValue()); - break; + return WideString::Format(L"%.8gin", GetValue()); case XFA_Unit::Cm: - wsMeasure.Format(L"%.8gcm", GetValue()); - break; + return WideString::Format(L"%.8gcm", GetValue()); case XFA_Unit::Mp: - wsMeasure.Format(L"%.8gmp", GetValue()); - break; + return WideString::Format(L"%.8gmp", GetValue()); case XFA_Unit::Pc: - wsMeasure.Format(L"%.8gpc", GetValue()); - break; + return WideString::Format(L"%.8gpc", GetValue()); case XFA_Unit::Em: - wsMeasure.Format(L"%.8gem", GetValue()); - break; + return WideString::Format(L"%.8gem", GetValue()); case XFA_Unit::Percent: - wsMeasure.Format(L"%.8g%%", GetValue()); - break; + return WideString::Format(L"%.8g%%", GetValue()); default: - wsMeasure.Format(L"%.8g", GetValue()); break; } - return wsMeasure; + return WideString::Format(L"%.8g", GetValue()); } float CXFA_Measurement::ToUnit(XFA_Unit eUnit) const { diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp index bc1d5c2031..e8e88d2fc1 100644 --- a/xfa/fxfa/parser/cxfa_nodehelper.cpp +++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp @@ -256,14 +256,15 @@ void CXFA_NodeHelper::GetNameExpression(CXFA_Node* refNode, if (refNode->IsUnnamed() || (bIsProperty && refNode->GetElementType() != XFA_Element::PageSet)) { ws = refNode->GetClassName(); - wsName.Format(L"#%s[%d]", ws.c_str(), - GetIndex(refNode, eLogicType, bIsProperty, true)); + wsName = + WideString::Format(L"#%s[%d]", ws.c_str(), + GetIndex(refNode, eLogicType, bIsProperty, true)); return; } ws = refNode->JSNode()->GetCData(XFA_Attribute::Name); ws.Replace(L".", L"\\."); - wsName.Format(L"%s[%d]", ws.c_str(), - GetIndex(refNode, eLogicType, bIsProperty, false)); + wsName = WideString::Format( + L"%s[%d]", ws.c_str(), GetIndex(refNode, eLogicType, bIsProperty, false)); } bool CXFA_NodeHelper::NodeIsTransparent(CXFA_Node* refNode) { diff --git a/xfa/fxfa/parser/cxfa_strokedata.cpp b/xfa/fxfa/parser/cxfa_strokedata.cpp index 43354a38a4..edbac24237 100644 --- a/xfa/fxfa/parser/cxfa_strokedata.cpp +++ b/xfa/fxfa/parser/cxfa_strokedata.cpp @@ -60,14 +60,14 @@ void CXFA_StrokeData::SetColor(FX_ARGB argb) { CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Color, true); - WideString wsColor; int a; int r; int g; int b; std::tie(a, r, g, b) = ArgbDecode(argb); - wsColor.Format(L"%d,%d,%d", r, g, b); - pNode->JSNode()->SetCData(XFA_Attribute::Value, wsColor, false, false); + pNode->JSNode()->SetCData(XFA_Attribute::Value, + WideString::Format(L"%d,%d,%d", r, g, b), false, + false); } int32_t CXFA_StrokeData::GetJoinType() const { |