summaryrefslogtreecommitdiff
path: root/fpdfsdk/formfiller/cffl_textfield.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/formfiller/cffl_textfield.cpp')
-rw-r--r--fpdfsdk/formfiller/cffl_textfield.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index 65f28fef11..ae3cb06e99 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -6,10 +6,13 @@
#include "fpdfsdk/formfiller/cffl_textfield.h"
+#include <utility>
+
#include "fpdfsdk/cpdfsdk_common.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_widget.h"
#include "fpdfsdk/formfiller/cba_fontmap.h"
+#include "third_party/base/ptr_util.h"
CFFL_TextField::CFFL_TextField(CPDFSDK_FormFillEnvironment* pApp,
CPDFSDK_Widget* pWidget)
@@ -66,15 +69,15 @@ CPWL_Wnd::CreateParams CFFL_TextField::GetCreateParam() {
return cp;
}
-CPWL_Wnd* CFFL_TextField::NewPDFWindow(const CPWL_Wnd::CreateParams& cp) {
- auto* pWnd = new CPWL_Edit();
+std::unique_ptr<CPWL_Wnd> CFFL_TextField::NewPDFWindow(
+ const CPWL_Wnd::CreateParams& cp) {
+ auto pWnd = pdfium::MakeUnique<CPWL_Edit>();
pWnd->AttachFFLData(this);
pWnd->Create(cp);
pWnd->SetFillerNotify(m_pFormFillEnv->GetInteractiveFormFiller());
int32_t nMaxLen = m_pWidget->GetMaxLen();
WideString swValue = m_pWidget->GetValue();
-
if (nMaxLen > 0) {
if (pWnd->HasFlag(PES_CHARARRAY)) {
pWnd->SetCharArray(nMaxLen);
@@ -83,9 +86,8 @@ CPWL_Wnd* CFFL_TextField::NewPDFWindow(const CPWL_Wnd::CreateParams& cp) {
pWnd->SetLimitChar(nMaxLen);
}
}
-
pWnd->SetText(swValue);
- return pWnd;
+ return std::move(pWnd);
}
bool CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot,