From 1f04e6111013673880767e98834fa9bb649c7aac Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 5 Jan 2018 10:31:04 -0500 Subject: Convert CFWL_DateTimePicker::FormatDateString to return WideString Change-Id: I2141cfb5d2bcb61b1a4f637fe30efc91776039b2 Reviewed-on: https://pdfium-review.googlesource.com/22263 Commit-Queue: Ryan Harrison Reviewed-by: dsinclair --- xfa/fwl/cfwl_datetimepicker.cpp | 23 ++++++++++++----------- xfa/fwl/cfwl_datetimepicker.h | 5 +---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index 8dcdf887f7..f3da454354 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp @@ -208,18 +208,20 @@ void CFWL_DateTimePicker::DrawDropDownButton(CXFA_Graphics* pGraphics, pTheme->DrawBackground(¶m); } -void CFWL_DateTimePicker::FormatDateString(int32_t iYear, - int32_t iMonth, - int32_t iDay, - WideString& wsText) { +WideString CFWL_DateTimePicker::FormatDateString(int32_t iYear, + int32_t iMonth, + int32_t iDay) { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) == FWL_STYLEEXT_DTP_ShortDateFormat) { - 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 = - WideString::Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); + return WideString::Format(L"%d-%d-%d", iYear, iMonth, iDay); } + + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) == + FWL_STYLEEXT_DTP_LongDateFormat) { + return WideString::Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); + } + + return WideString(); } void CFWL_DateTimePicker::ShowMonthCalendar(bool bActivate) { @@ -308,8 +310,7 @@ void CFWL_DateTimePicker::ProcessSelChanged(int32_t iYear, m_iMonth = iMonth; m_iDay = iDay; - WideString wsText; - FormatDateString(m_iYear, m_iMonth, m_iDay, wsText); + WideString wsText = FormatDateString(m_iYear, m_iMonth, m_iDay); m_pEdit->SetText(wsText); m_pEdit->Update(); RepaintRect(m_rtClient); diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h index 97c5cd196e..6d536016dd 100644 --- a/xfa/fwl/cfwl_datetimepicker.h +++ b/xfa/fwl/cfwl_datetimepicker.h @@ -72,10 +72,7 @@ class CFWL_DateTimePicker : public CFWL_Widget { void DrawDropDownButton(CXFA_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix); - void FormatDateString(int32_t iYear, - int32_t iMonth, - int32_t iDay, - WideString& wsText); + WideString FormatDateString(int32_t iYear, int32_t iMonth, int32_t iDay); void ResetEditAlignment(); void InitProxyForm(); void OnFocusChanged(CFWL_Message* pMsg, bool bSet); -- cgit v1.2.3