summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl/cpwl_appstream.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-10 18:44:45 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 18:44:45 +0000
commit4f261fffddddd97602e88fe462fef1a18a0b4782 (patch)
treee3a93a859d189a5fe46791d7954396b2b394cbd4 /fpdfsdk/pwl/cpwl_appstream.cpp
parentb353f8c32b2d17cbea5ace6eb5f7edb8663e37be (diff)
downloadpdfium-4f261fffddddd97602e88fe462fef1a18a0b4782.tar.xz
Get rid of non-const ref parameter in CPDFSDK_InterForm::OnFormat().
Return Optional<WideString> instead. Change the call stack to accept Optional<WideString>. Change-Id: I020589fac8a1de4974070268a19b4acad64c4092 Reviewed-on: https://pdfium-review.googlesource.com/c/43601 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl/cpwl_appstream.cpp')
-rw-r--r--fpdfsdk/pwl/cpwl_appstream.cpp21
1 files changed, 9 insertions, 12 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 =