From 6aec70bc09cb65b169fe6ca1af65e8929aeea43a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 23 Nov 2017 17:02:23 +0000 Subject: Cleanup CXFA_WidgetData This CL cleans up return values, out-params and changes simple methods to boolean checks where possible in CXFA_WidgetData. Change-Id: I29daa67993730f3e9d61cb6fdf918a886cc9120e Reviewed-on: https://pdfium-review.googlesource.com/19230 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- fpdfsdk/cpdfsdk_widget.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index 0c525129c4..65b75ca844 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -294,7 +294,7 @@ void CPDFSDK_Widget::Synchronize(bool bSynchronizeElse) { break; } case FIELDTYPE_TEXTFIELD: - pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); + pWidgetAcc->SetValue(XFA_VALUEPICTURE_Edit, pFormField->GetValue()); break; case FIELDTYPE_LISTBOX: { pWidgetAcc->ClearAllSelections(); @@ -314,7 +314,7 @@ void CPDFSDK_Widget::Synchronize(bool bSynchronizeElse) { if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems(false)) pWidgetAcc->SetItemState(nIndex, true, false, false, true); } - pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); + pWidgetAcc->SetValue(XFA_VALUEPICTURE_Edit, pFormField->GetValue()); break; } } @@ -377,9 +377,8 @@ void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, } case FIELDTYPE_TEXTFIELD: { if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { - WideString sValue; - pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); - pFormField->SetValue(sValue, true); + pFormField->SetValue(pWidgetAcc->GetValue(XFA_VALUEPICTURE_Display), + true); } break; } @@ -408,10 +407,8 @@ void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, pFormField->SetItemSelection(nIndex, true, true); } } - - WideString sValue; - pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); - pFormField->SetValue(sValue, true); + pFormField->SetValue(pWidgetAcc->GetValue(XFA_VALUEPICTURE_Display), + true); } break; } @@ -432,10 +429,8 @@ void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(false); i < sz; i++) { - WideString swText; - pWidgetAcc->GetChoiceListItem(swText, i, false); - - pFormField->InsertOption(swText, i, true); + pFormField->InsertOption( + pWidgetAcc->GetChoiceListItem(i, false).value_or(L""), i, true); } } break; @@ -447,10 +442,8 @@ void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(false); i < sz; i++) { - WideString swText; - pWidgetAcc->GetChoiceListItem(swText, i, false); - - pFormField->InsertOption(swText, i, false); + pFormField->InsertOption( + pWidgetAcc->GetChoiceListItem(i, false).value_or(L""), i, false); } } @@ -610,10 +603,8 @@ int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { WideString CPDFSDK_Widget::GetValue(bool bDisplay) const { if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { - WideString sValue; - pWidgetAcc->GetValue( - sValue, bDisplay ? XFA_VALUEPICTURE_Display : XFA_VALUEPICTURE_Edit); - return sValue; + return pWidgetAcc->GetValue(bDisplay ? XFA_VALUEPICTURE_Display + : XFA_VALUEPICTURE_Edit); } } #else -- cgit v1.2.3