summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-20 20:35:48 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-20 20:35:48 +0000
commit1b36b90f2e33f5a80e6ae9b22821a623a9d62782 (patch)
tree60c79894c81732faa6a5fba7f7fd56ff8b602ecc
parent71803d230109cb841a323c579082a5cbd6fcbe3c (diff)
downloadpdfium-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>
-rw-r--r--fxjs/cjx_node.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffdatetimeedit.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffnumericedit.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_binddata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_binddata.h2
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp9
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp80
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h2
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp4
9 files changed, 43 insertions, 70 deletions
diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp
index bf8c1f726e..8f99b1a5b8 100644
--- a/fxjs/cjx_node.cpp
+++ b/fxjs/cjx_node.cpp
@@ -1452,8 +1452,8 @@ void CJX_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
pContainerWidgetData = pFormNode->GetContainerWidgetData();
if (pContainerWidgetData) {
- pContainerWidgetData->GetPictureContent(wsPicture,
- XFA_VALUEPICTURE_DataBind);
+ wsPicture = pContainerWidgetData->GetPictureContent(
+ XFA_VALUEPICTURE_DataBind);
}
if (!wsPicture.IsEmpty())
break;
diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
index 54878ae211..7958162a89 100644
--- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp
+++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
@@ -182,8 +182,7 @@ void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget,
int32_t iYear,
int32_t iMonth,
int32_t iDay) {
- WideString wsPicture;
- m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit);
+ WideString wsPicture = m_pDataAcc->GetPictureContent(XFA_VALUEPICTURE_Edit);
CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr());
date.SetDate(CFX_DateTime(iYear, iMonth, iDay, 0, 0, 0, 0));
diff --git a/xfa/fxfa/cxfa_ffnumericedit.cpp b/xfa/fxfa/cxfa_ffnumericedit.cpp
index b8e9a1c4ea..f6199561a4 100644
--- a/xfa/fxfa/cxfa_ffnumericedit.cpp
+++ b/xfa/fxfa/cxfa_ffnumericedit.cpp
@@ -78,8 +78,7 @@ void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) {
}
bool CXFA_FFNumericEdit::OnValidate(CFWL_Widget* pWidget, WideString& wsText) {
- WideString wsPattern;
- m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit);
+ WideString wsPattern = m_pDataAcc->GetPictureContent(XFA_VALUEPICTURE_Edit);
if (!wsPattern.IsEmpty())
return true;
diff --git a/xfa/fxfa/parser/cxfa_binddata.cpp b/xfa/fxfa/parser/cxfa_binddata.cpp
index 79f375fa6a..19c4c96c87 100644
--- a/xfa/fxfa/parser/cxfa_binddata.cpp
+++ b/xfa/fxfa/parser/cxfa_binddata.cpp
@@ -10,9 +10,9 @@
CXFA_BindData::CXFA_BindData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-void CXFA_BindData::GetPicture(WideString& wsPicture) {
+WideString CXFA_BindData::GetPicture() {
CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_Element::Picture, false);
if (!pPicture)
- return;
- wsPicture = pPicture->JSNode()->GetContent(false);
+ return L"";
+ return pPicture->JSNode()->GetContent(false);
}
diff --git a/xfa/fxfa/parser/cxfa_binddata.h b/xfa/fxfa/parser/cxfa_binddata.h
index 100f1c3c3b..fde030fc50 100644
--- a/xfa/fxfa/parser/cxfa_binddata.h
+++ b/xfa/fxfa/parser/cxfa_binddata.h
@@ -16,7 +16,7 @@ class CXFA_BindData : public CXFA_DataData {
public:
explicit CXFA_BindData(CXFA_Node* pNode);
- void GetPicture(WideString& wsPicture);
+ WideString GetPicture();
};
#endif // XFA_FXFA_PARSER_CXFA_BINDDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index c667c08d10..185b2a935a 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -472,11 +472,12 @@ CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() {
} else {
WideString wsPicture;
if (pFieldWidgetData) {
- pFieldWidgetData->GetPictureContent(wsPicture,
- XFA_VALUEPICTURE_DataBind);
+ wsPicture =
+ pFieldWidgetData->GetPictureContent(XFA_VALUEPICTURE_DataBind);
}
if (!wsPicture.IsEmpty())
return pFieldWidgetData;
+
CXFA_Node* pDataNode = GetBindData();
if (!pDataNode)
return nullptr;
@@ -486,8 +487,8 @@ CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() {
continue;
pFieldWidgetData = pFormNode->GetWidgetData();
if (pFieldWidgetData) {
- pFieldWidgetData->GetPictureContent(wsPicture,
- XFA_VALUEPICTURE_DataBind);
+ wsPicture =
+ pFieldWidgetData->GetPictureContent(XFA_VALUEPICTURE_DataBind);
}
if (!wsPicture.IsEmpty())
break;
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;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 12e811361b..84369f7177 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -120,7 +120,7 @@ class CXFA_WidgetData : public CXFA_DataData {
int32_t GetHorizontalScrollPolicy();
int32_t GetNumberOfCells();
bool SetValue(const WideString& wsValue, XFA_VALUEPICTURE eValueType);
- bool GetPictureContent(WideString& wsPicture, XFA_VALUEPICTURE ePicture);
+ WideString GetPictureContent(XFA_VALUEPICTURE ePicture);
IFX_Locale* GetLocal();
bool GetValue(WideString& wsValue, XFA_VALUEPICTURE eValueType);
bool GetNormalizeDataValue(const WideString& wsValue,
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 3a70135aea..ac7fb2ec85 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -357,8 +357,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
XFA_Element::DateTime);
break;
case XFA_Element::NumericEdit: {
- WideString wsPicture;
- pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind);
+ WideString wsPicture =
+ pWidgetData->GetPictureContent(XFA_VALUEPICTURE_DataBind);
if (wsPicture.IsEmpty()) {
WideString wsOutput;
pWidgetData->NormalizeNumStr(wsNormalizeValue, wsOutput);