diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-20 20:35:48 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-20 20:35:48 +0000 |
commit | 1b36b90f2e33f5a80e6ae9b22821a623a9d62782 (patch) | |
tree | 60c79894c81732faa6a5fba7f7fd56ff8b602ecc /xfa/fxfa/parser/cxfa_widgetdata.cpp | |
parent | 71803d230109cb841a323c579082a5cbd6fcbe3c (diff) | |
download | pdfium-1b36b90f2e33f5a80e6ae9b22821a623a9d62782.tar.xz |
Convert picture methods to return the string
This CL converts CXFA_BindData::GetPicture and
CXFA_WidgetData::GetPictureContent to return the WideString instead of
taking an out param.
The original bool result was never checked.
Change-Id: I4503d53ac7276edea811a28c34c7d8cc4cb50572
Reviewed-on: https://pdfium-review.googlesource.com/18810
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_widgetdata.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 80 |
1 files changed, 27 insertions, 53 deletions
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index e87abd8ff7..894411760c 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -1388,8 +1388,7 @@ bool CXFA_WidgetData::SetValue(const WideString& wsValue, m_bPreNull = m_bIsNull; m_bIsNull = false; WideString wsNewText(wsValue); - WideString wsPicture; - GetPictureContent(wsPicture, eValueType); + WideString wsPicture = GetPictureContent(eValueType); bool bValidate = true; bool bSyncData = false; CXFA_Node* pNode = GetUIChild(); @@ -1434,10 +1433,9 @@ bool CXFA_WidgetData::SetValue(const WideString& wsValue, return bValidate; } -bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture, - XFA_VALUEPICTURE ePicture) { +WideString CXFA_WidgetData::GetPictureContent(XFA_VALUEPICTURE ePicture) { if (ePicture == XFA_VALUEPICTURE_Raw) - return false; + return L""; CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); switch (ePicture) { @@ -1448,40 +1446,30 @@ bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture, pFormat->GetChild(0, XFA_Element::Picture, false)) { pdfium::Optional<WideString> picture = pPicture->JSNode()->TryContent(false, true); - if (picture) { - wsPicture = *picture; - return true; - } + if (picture) + return *picture; } } IFX_Locale* pLocale = GetLocal(); if (!pLocale) - return false; + return L""; uint32_t dwType = widgetValue.GetType(); switch (dwType) { case XFA_VT_DATE: - wsPicture = - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium); - break; + return pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium); case XFA_VT_TIME: - wsPicture = - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium); - break; + return pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium); case XFA_VT_DATETIME: - wsPicture = - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium) + - L"T" + - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium); - break; + return pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium) + + L"T" + + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium); case XFA_VT_DECIMAL: case XFA_VT_FLOAT: - break; default: - break; + return L""; } - return true; } case XFA_VALUEPICTURE_Edit: { CXFA_Node* pUI = m_pNode->GetChild(0, XFA_Element::Ui, false); @@ -1490,50 +1478,39 @@ bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture, pUI->GetChild(0, XFA_Element::Picture, false)) { pdfium::Optional<WideString> picture = pPicture->JSNode()->TryContent(false, true); - if (picture) { - wsPicture = *picture; - return true; - } + if (picture) + return *picture; } } IFX_Locale* pLocale = GetLocal(); if (!pLocale) - return false; + return L""; uint32_t dwType = widgetValue.GetType(); switch (dwType) { case XFA_VT_DATE: - wsPicture = - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short); - break; + return pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short); case XFA_VT_TIME: - wsPicture = - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short); - break; + return pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short); case XFA_VT_DATETIME: - wsPicture = - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short) + - L"T" + - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short); - break; + return pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short) + + L"T" + + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short); default: - break; + return L""; } - return true; } case XFA_VALUEPICTURE_DataBind: { CXFA_BindData bindData = GetBindData(); - if (bindData) { - bindData.GetPicture(wsPicture); - return true; - } + if (bindData) + return bindData.GetPicture(); break; } default: break; } - return false; + return L""; } IFX_Locale* CXFA_WidgetData::GetLocal() { @@ -1555,8 +1532,7 @@ bool CXFA_WidgetData::GetValue(WideString& wsValue, if (eValueType == XFA_VALUEPICTURE_Display) GetItemLabel(wsValue.AsStringView(), wsValue); - WideString wsPicture; - GetPictureContent(wsPicture, eValueType); + WideString wsPicture = GetPictureContent(eValueType); CXFA_Node* pNode = GetUIChild(); if (!pNode) return true; @@ -1624,8 +1600,7 @@ bool CXFA_WidgetData::GetNormalizeDataValue(const WideString& wsValue, if (wsValue.IsEmpty()) return true; - WideString wsPicture; - GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); + WideString wsPicture = GetPictureContent(XFA_VALUEPICTURE_DataBind); if (wsPicture.IsEmpty()) return true; @@ -1648,8 +1623,7 @@ bool CXFA_WidgetData::GetFormatDataValue(const WideString& wsValue, if (wsValue.IsEmpty()) return true; - WideString wsPicture; - GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); + WideString wsPicture = GetPictureContent(XFA_VALUEPICTURE_DataBind); if (wsPicture.IsEmpty()) return true; |