diff options
Diffstat (limited to 'fpdfsdk/pwl')
-rw-r--r-- | fpdfsdk/pwl/cpwl_appstream.cpp | 21 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_appstream.h | 9 |
2 files changed, 14 insertions, 16 deletions
diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp index 8ced563161..d2ffd2a9b1 100644 --- a/fpdfsdk/pwl/cpwl_appstream.cpp +++ b/fpdfsdk/pwl/cpwl_appstream.cpp @@ -1580,7 +1580,7 @@ void CPWL_AppStream::SetAsRadioButton() { widget_->SetAppState("Off"); } -void CPWL_AppStream::SetAsComboBox(const WideString* sValue) { +void CPWL_AppStream::SetAsComboBox(Optional<WideString> sValue) { CPDF_FormControl* pControl = widget_->GetFormControl(); CPDF_FormField* pField = pControl->GetField(); std::ostringstream sBody; @@ -1614,8 +1614,8 @@ void CPWL_AppStream::SetAsComboBox(const WideString* sValue) { pEdit->Initialize(); - if (sValue) { - pEdit->SetText(*sValue); + if (sValue.has_value()) { + pEdit->SetText(sValue.value()); } else { int32_t nCurSel = pField->GetSelectedIndex(0); if (nCurSel < 0) @@ -1736,7 +1736,7 @@ void CPWL_AppStream::SetAsListBox() { ""); } -void CPWL_AppStream::SetAsTextField(const WideString* sValue) { +void CPWL_AppStream::SetAsTextField(Optional<WideString> sValue) { CPDF_FormControl* pControl = widget_->GetFormControl(); CPDF_FormField* pField = pControl->GetField(); std::ostringstream sBody; @@ -1775,11 +1775,8 @@ void CPWL_AppStream::SetAsTextField(const WideString* sValue) { float fFontSize = widget_->GetFontSize(); #ifdef PDF_ENABLE_XFA - WideString sValueTmp; - if (!sValue && widget_->GetMixXFAWidget()) { - sValueTmp = widget_->GetValue(); - sValue = &sValueTmp; - } + if (!sValue.has_value() && widget_->GetMixXFAWidget()) + sValue = widget_->GetValue(); #endif // PDF_ENABLE_XFA if (nMaxLen > 0) { @@ -1791,8 +1788,8 @@ void CPWL_AppStream::SetAsTextField(const WideString* sValue) { rcClient, nMaxLen); } } else { - if (sValue) - nMaxLen = sValue->GetLength(); + if (sValue.has_value()) + nMaxLen = sValue.value().GetLength(); pEdit->SetLimitChar(nMaxLen); } } @@ -1803,7 +1800,7 @@ void CPWL_AppStream::SetAsTextField(const WideString* sValue) { pEdit->SetFontSize(fFontSize); pEdit->Initialize(); - pEdit->SetText(sValue ? *sValue : pField->GetValue()); + pEdit->SetText(sValue.value_or(pField->GetValue())); CFX_FloatRect rcContent = pEdit->GetContentRect(); ByteString sEdit = diff --git a/fpdfsdk/pwl/cpwl_appstream.h b/fpdfsdk/pwl/cpwl_appstream.h index 810e79c9e7..1c3afab592 100644 --- a/fpdfsdk/pwl/cpwl_appstream.h +++ b/fpdfsdk/pwl/cpwl_appstream.h @@ -9,6 +9,7 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/unowned_ptr.h" +#include "third_party/base/optional.h" class CPDFSDK_Widget; class CPDF_Dictionary; @@ -22,9 +23,9 @@ class CPWL_AppStream { void SetAsPushButton(); void SetAsCheckBox(); void SetAsRadioButton(); - void SetAsComboBox(const WideString* sValue); + void SetAsComboBox(Optional<WideString> sValue); void SetAsListBox(); - void SetAsTextField(const WideString* sValue); + void SetAsTextField(Optional<WideString> sValue); private: void AddImage(const ByteString& sAPType, CPDF_Stream* pImage); @@ -36,8 +37,8 @@ class CPWL_AppStream { ByteString GetBackgroundAppStream() const; ByteString GetBorderAppStream() const; - UnownedPtr<CPDFSDK_Widget> widget_; - UnownedPtr<CPDF_Dictionary> dict_; + UnownedPtr<CPDFSDK_Widget> const widget_; + UnownedPtr<CPDF_Dictionary> const dict_; }; #endif // FPDFSDK_PWL_CPWL_APPSTREAM_H_ |