summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_widget.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-08 11:28:14 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-08 11:28:14 -0700
commita31da74cffa8c3ff919051cc49bc006aeb55d345 (patch)
tree0457bd7c0a74298d47e25cd1cdbf13b2622493ef /fpdfsdk/cpdfsdk_widget.cpp
parentcd5dc855df0ca37b7667b5f3ceb951d2d417d99f (diff)
downloadpdfium-a31da74cffa8c3ff919051cc49bc006aeb55d345.tar.xz
Pass CFX_WideString further down widget callers
Avoid a couple of places where we copy the raw string back into a brand-new widestring. There are a few places where the difference between a null ptr and an empty string control the logic, and I left these as-is. Other places can just take the string by const ref. Review-Url: https://codereview.chromium.org/2323493002
Diffstat (limited to 'fpdfsdk/cpdfsdk_widget.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index d518a56109..a8ebef6e99 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -739,7 +739,7 @@ void CPDFSDK_Widget::ResetAppearance(FX_BOOL bValueChanged) {
case FIELDTYPE_COMBOBOX: {
FX_BOOL bFormatted = FALSE;
CFX_WideString sValue = OnFormat(bFormatted);
- ResetAppearance(bFormatted ? sValue.c_str() : nullptr, TRUE);
+ ResetAppearance(bFormatted ? &sValue : nullptr, TRUE);
break;
}
default:
@@ -749,7 +749,7 @@ void CPDFSDK_Widget::ResetAppearance(FX_BOOL bValueChanged) {
}
#endif // PDF_ENABLE_XFA
-void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue,
+void CPDFSDK_Widget::ResetAppearance(const CFX_WideString* sValue,
FX_BOOL bValueChanged) {
SetAppModified();
@@ -1353,7 +1353,7 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() {
SetAppState("Off");
}
-void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) {
+void CPDFSDK_Widget::ResetAppearance_ComboBox(const CFX_WideString* sValue) {
CPDF_FormControl* pControl = GetFormControl();
CPDF_FormField* pField = pControl->GetField();
CFX_ByteTextBuf sBody, sLines;
@@ -1387,10 +1387,9 @@ void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) {
pEdit->Initialize();
if (sValue) {
- pEdit->SetText(sValue);
+ pEdit->SetText(*sValue);
} else {
int32_t nCurSel = pField->GetSelectedIndex(0);
-
if (nCurSel < 0)
pEdit->SetText(pField->GetValue().c_str());
else
@@ -1512,7 +1511,7 @@ void CPDFSDK_Widget::ResetAppearance_ListBox() {
WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
}
-void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
+void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) {
CPDF_FormControl* pControl = GetFormControl();
CPDF_FormField* pField = pControl->GetField();
CFX_ByteTextBuf sBody, sLines;
@@ -1554,7 +1553,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
CFX_WideString sValueTmp;
if (!sValue && GetMixXFAWidget()) {
sValueTmp = GetValue(TRUE);
- sValue = sValueTmp.c_str();
+ sValue = &sValueTmp;
}
#endif // PDF_ENABLE_XFA
@@ -1568,7 +1567,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
}
} else {
if (sValue)
- nMaxLen = wcslen((const wchar_t*)sValue);
+ nMaxLen = sValue->GetLength();
pEdit->SetLimitChar(nMaxLen);
}
}
@@ -1581,7 +1580,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
pEdit->Initialize();
if (sValue)
- pEdit->SetText(sValue);
+ pEdit->SetText(*sValue);
else
pEdit->SetText(pField->GetValue().c_str());