Replace |CPWL_ComboBox::operator CPWL_Edit()| with explicit method.
More casts go away.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1467653002 .
diff --git a/fpdfsdk/include/pdfwindow/PWL_ComboBox.h b/fpdfsdk/include/pdfwindow/PWL_ComboBox.h
index be0ef0f..9edb02c 100644
--- a/fpdfsdk/include/pdfwindow/PWL_ComboBox.h
+++ b/fpdfsdk/include/pdfwindow/PWL_ComboBox.h
@@ -49,7 +49,7 @@
CPWL_ComboBox();
~CPWL_ComboBox() override {}
- operator CPWL_Edit*() { return m_pEdit; }
+ CPWL_Edit* GetEdit() const { return m_pEdit; }
// CPWL_Wnd:
CFX_ByteString GetClassName() const override;
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
index ddaa519..858cc62 100644
--- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
+++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
@@ -137,8 +137,8 @@
switch (type) {
case CPDF_AAction::KeyStroke:
if (CPWL_ComboBox* pComboBox =
- (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
+ static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
+ if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
fa.bFieldFull = pEdit->IsTextFull();
int nSelStart = 0;
int nSelEnd = 0;
@@ -157,8 +157,8 @@
break;
case CPDF_AAction::Validate:
if (CPWL_ComboBox* pComboBox =
- (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
+ static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
+ if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
fa.sValue = pEdit->GetText();
}
}
@@ -179,8 +179,8 @@
switch (type) {
case CPDF_AAction::KeyStroke:
if (CPWL_ComboBox* pComboBox =
- (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
+ static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
+ if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
pEdit->ReplaceSel(fa.sChange.c_str());
}
@@ -210,10 +210,10 @@
ASSERT(pPageView != NULL);
if (CPWL_ComboBox* pComboBox =
- (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
+ static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
m_State.nIndex = pComboBox->GetSelect();
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
+ if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
pEdit->GetSel(m_State.nStart, m_State.nEnd);
m_State.sValue = pEdit->GetText();
}
@@ -224,11 +224,11 @@
ASSERT(pPageView != NULL);
if (CPWL_ComboBox* pComboBox =
- (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE)) {
+ static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, TRUE))) {
if (m_State.nIndex >= 0)
pComboBox->SetSelect(m_State.nIndex);
else {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) {
+ if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
pEdit->SetText(m_State.sValue.c_str());
pEdit->SetSel(m_State.nStart, m_State.nEnd);
}