Use CXFA_FFField::GetNormalWidget() in more places. Precursor to making |CXFA_FFField::m_pNormalWidget| private. Fix nits with the ctor/dtor of the modified classes. Change-Id: I9c52bfc9735a4b82329d6a92c14933cbd6296541 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/62490 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp index 08fda05..aa93c96 100644 --- a/xfa/fxfa/cxfa_ffbarcode.cpp +++ b/xfa/fxfa/cxfa_ffbarcode.cpp
@@ -136,7 +136,7 @@ CXFA_FFBarcode::CXFA_FFBarcode(CXFA_Node* pNode, CXFA_Barcode* barcode) : CXFA_FFTextEdit(pNode), barcode_(barcode) {} -CXFA_FFBarcode::~CXFA_FFBarcode() {} +CXFA_FFBarcode::~CXFA_FFBarcode() = default; bool CXFA_FFBarcode::LoadWidget() { auto pNew = pdfium::MakeUnique<CFWL_Barcode>(GetFWLApp()); @@ -170,11 +170,11 @@ CXFA_FFWidget::RenderWidget(pGS, mtRotate, highlight); DrawBorder(pGS, m_pNode->GetUIBorder(), m_rtUI, mtRotate); RenderCaption(pGS, &mtRotate); - CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); + CFX_RectF rtWidget = GetNormalWidget()->GetWidgetRect(); CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); mt.Concat(mtRotate); - m_pNormalWidget->DrawWidget(pGS, mt); + GetNormalWidget()->DrawWidget(pGS, mt); } void CXFA_FFBarcode::UpdateWidgetProperty() { @@ -184,7 +184,7 @@ if (!info) return; - auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(m_pNormalWidget.get()); + auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(GetNormalWidget()); pBarCodeWidget->SetType(info->eBCType); Optional<WideString> encoding_string = barcode_->GetCharEncoding(); @@ -250,7 +250,7 @@ bool CXFA_FFBarcode::AcceptsFocusOnButtonDown(uint32_t dwFlags, const CFX_PointF& point, FWL_MouseCommand command) { - auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(m_pNormalWidget.get()); + auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(GetNormalWidget()); if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) return false; if (command == FWL_MouseCommand::LeftButtonDown && !m_pNode->IsOpenAccess())
diff --git a/xfa/fxfa/cxfa_ffbarcode.h b/xfa/fxfa/cxfa_ffbarcode.h index f51d48d..367a8b0 100644 --- a/xfa/fxfa/cxfa_ffbarcode.h +++ b/xfa/fxfa/cxfa_ffbarcode.h
@@ -104,7 +104,7 @@ FWL_MouseCommand command) override; private: - UnownedPtr<CXFA_Barcode> barcode_; + UnownedPtr<CXFA_Barcode> const barcode_; }; #endif // XFA_FXFA_CXFA_FFBARCODE_H_
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp index d48cf33..f72b63c 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.cpp +++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -28,7 +28,7 @@ CXFA_CheckButton* button) : CXFA_FFField(pNode), button_(button) {} -CXFA_FFCheckButton::~CXFA_FFCheckButton() {} +CXFA_FFCheckButton::~CXFA_FFCheckButton() = default; bool CXFA_FFCheckButton::LoadWidget() { auto pNew = pdfium::MakeUnique<CFWL_CheckBox>(GetFWLApp()); @@ -53,7 +53,7 @@ } void CXFA_FFCheckButton::UpdateWidgetProperty() { - auto* pCheckBox = static_cast<CFWL_CheckBox*>(m_pNormalWidget.get()); + auto* pCheckBox = static_cast<CFWL_CheckBox*>(GetNormalWidget()); if (!pCheckBox) return; @@ -183,8 +183,8 @@ m_rtUI.Normalize(); LayoutCaption(); SetFWLRect(); - if (m_pNormalWidget) - m_pNormalWidget->Update(); + if (GetNormalWidget()) + GetNormalWidget()->Update(); return true; } @@ -241,24 +241,24 @@ button_->IsRound() ? kRoundShape : kSquareShape); CFX_Matrix mt(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); mt.Concat(mtRotate); - GetApp()->GetFWLWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, mt); + GetApp()->GetFWLWidgetMgr()->OnDrawWidget(GetNormalWidget(), pGS, mt); } bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget || !IsButtonDown()) + if (!GetNormalWidget() || !IsButtonDown()) return false; SetButtonDown(false); SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::LeftButtonUp, dwFlags, + GetNormalWidget(), FWL_MouseCommand::LeftButtonUp, dwFlags, FWLToClient(point))); return true; } XFA_CHECKSTATE CXFA_FFCheckButton::FWLState2XFAState() { - uint32_t dwState = m_pNormalWidget->GetStates(); + uint32_t dwState = GetNormalWidget()->GetStates(); if (dwState & FWL_STATE_CKB_Checked) return XFA_CHECKSTATE_On; if (dwState & FWL_STATE_CKB_Neutral) @@ -279,20 +279,20 @@ void CXFA_FFCheckButton::SetFWLCheckState(XFA_CHECKSTATE eCheckState) { if (eCheckState == XFA_CHECKSTATE_Neutral) - m_pNormalWidget->SetStates(FWL_STATE_CKB_Neutral); + GetNormalWidget()->SetStates(FWL_STATE_CKB_Neutral); else if (eCheckState == XFA_CHECKSTATE_On) - m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked); + GetNormalWidget()->SetStates(FWL_STATE_CKB_Checked); else - m_pNormalWidget->RemoveStates(FWL_STATE_CKB_Checked); + GetNormalWidget()->RemoveStates(FWL_STATE_CKB_Checked); } bool CXFA_FFCheckButton::UpdateFWLData() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; XFA_CHECKSTATE eState = m_pNode->GetCheckState(); SetFWLCheckState(eState); - m_pNormalWidget->Update(); + GetNormalWidget()->Update(); return true; }
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.h b/xfa/fxfa/cxfa_ffcheckbutton.h index c8a2d56..3e5a723 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.h +++ b/xfa/fxfa/cxfa_ffcheckbutton.h
@@ -46,7 +46,7 @@ UnownedPtr<IFWL_WidgetDelegate> m_pOldDelegate; CFX_RectF m_rtCheckBox; - UnownedPtr<CXFA_CheckButton> button_; + UnownedPtr<CXFA_CheckButton> const button_; }; #endif // XFA_FXFA_CXFA_FFCHECKBUTTON_H_
diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp index 6093bb1..75d152ae1 100644 --- a/xfa/fxfa/cxfa_ffcombobox.cpp +++ b/xfa/fxfa/cxfa_ffcombobox.cpp
@@ -23,12 +23,15 @@ return static_cast<CFWL_ComboBox*>(widget); } +const CFWL_ComboBox* ToComboBox(const CFWL_Widget* widget) { + return static_cast<const CFWL_ComboBox*>(widget); +} + } // namespace -CXFA_FFComboBox::CXFA_FFComboBox(CXFA_Node* pNode) - : CXFA_FFDropDown(pNode), m_pOldDelegate(nullptr) {} +CXFA_FFComboBox::CXFA_FFComboBox(CXFA_Node* pNode) : CXFA_FFDropDown(pNode) {} -CXFA_FFComboBox::~CXFA_FFComboBox() {} +CXFA_FFComboBox::~CXFA_FFComboBox() = default; CFX_RectF CXFA_FFComboBox::GetBBox(FocusOption focus) { if (focus == kDrawFocus) @@ -37,7 +40,7 @@ } bool CXFA_FFComboBox::PtInActiveRect(const CFX_PointF& point) { - auto* pComboBox = ToComboBox(m_pNormalWidget.get()); + auto* pComboBox = ToComboBox(GetNormalWidget()); return pComboBox && pComboBox->GetBBox().Contains(point); } @@ -70,7 +73,7 @@ } void CXFA_FFComboBox::UpdateWidgetProperty() { - auto* pComboBox = ToComboBox(m_pNormalWidget.get()); + auto* pComboBox = ToComboBox(GetNormalWidget()); if (!pComboBox) return; @@ -86,7 +89,7 @@ dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; } dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + GetNormalWidget()->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); if (!m_pNode->IsHorizontalScrollPolicyOff()) dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; @@ -110,7 +113,7 @@ } void CXFA_FFComboBox::OpenDropDownList() { - ToComboBox(m_pNormalWidget.get())->OpenDropDownList(true); + ToComboBox(GetNormalWidget())->OpenDropDownList(true); } bool CXFA_FFComboBox::CommitData() { @@ -129,12 +132,12 @@ void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { pParam->m_eType = XFA_EVENT_Change; pParam->m_pTarget = m_pNode.Get(); - pParam->m_wsPrevText = ToComboBox(m_pNormalWidget.get())->GetEditText(); + pParam->m_wsPrevText = ToComboBox(GetNormalWidget())->GetEditText(); m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Change, pParam); } WideString CXFA_FFComboBox::GetCurrentText() const { - auto* pFWLcombobox = ToComboBox(m_pNormalWidget.get()); + auto* pFWLcombobox = ToComboBox(GetNormalWidget()); WideString wsText = pFWLcombobox->GetEditText(); int32_t iCursel = pFWLcombobox->GetCurSel(); if (iCursel >= 0) { @@ -186,7 +189,7 @@ } bool CXFA_FFComboBox::UpdateFWLData() { - auto* pComboBox = ToComboBox(m_pNormalWidget.get()); + auto* pComboBox = ToComboBox(GetNormalWidget()); if (!pComboBox) return false; @@ -203,31 +206,31 @@ bool CXFA_FFComboBox::CanUndo() { return m_pNode->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditCanUndo(); + ToComboBox(GetNormalWidget())->EditCanUndo(); } bool CXFA_FFComboBox::CanRedo() { return m_pNode->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditCanRedo(); + ToComboBox(GetNormalWidget())->EditCanRedo(); } bool CXFA_FFComboBox::Undo() { return m_pNode->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditUndo(); + ToComboBox(GetNormalWidget())->EditUndo(); } bool CXFA_FFComboBox::Redo() { return m_pNode->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditRedo(); + ToComboBox(GetNormalWidget())->EditRedo(); } bool CXFA_FFComboBox::CanCopy() { - return ToComboBox(m_pNormalWidget.get())->EditCanCopy(); + return ToComboBox(GetNormalWidget())->EditCanCopy(); } bool CXFA_FFComboBox::CanCut() { return m_pNode->IsOpenAccess() && m_pNode->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditCanCut(); + ToComboBox(GetNormalWidget())->EditCanCut(); } bool CXFA_FFComboBox::CanPaste() { @@ -235,35 +238,35 @@ } bool CXFA_FFComboBox::CanSelectAll() { - return ToComboBox(m_pNormalWidget.get())->EditCanSelectAll(); + return ToComboBox(GetNormalWidget())->EditCanSelectAll(); } Optional<WideString> CXFA_FFComboBox::Copy() { - return ToComboBox(m_pNormalWidget.get())->EditCopy(); + return ToComboBox(GetNormalWidget())->EditCopy(); } Optional<WideString> CXFA_FFComboBox::Cut() { if (!m_pNode->IsChoiceListAllowTextEntry()) return {}; - return ToComboBox(m_pNormalWidget.get())->EditCut(); + return ToComboBox(GetNormalWidget())->EditCut(); } bool CXFA_FFComboBox::Paste(const WideString& wsPaste) { return m_pNode->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditPaste(wsPaste); + ToComboBox(GetNormalWidget())->EditPaste(wsPaste); } void CXFA_FFComboBox::SelectAll() { - ToComboBox(m_pNormalWidget.get())->EditSelectAll(); + ToComboBox(GetNormalWidget())->EditSelectAll(); } void CXFA_FFComboBox::Delete() { - ToComboBox(m_pNormalWidget.get())->EditDelete(); + ToComboBox(GetNormalWidget())->EditDelete(); } void CXFA_FFComboBox::DeSelect() { - ToComboBox(m_pNormalWidget.get())->EditDeSelect(); + ToComboBox(GetNormalWidget())->EditDeSelect(); } WideString CXFA_FFComboBox::GetText() { @@ -275,24 +278,24 @@ } void CXFA_FFComboBox::SetItemState(int32_t nIndex, bool bSelected) { - ToComboBox(m_pNormalWidget.get())->SetCurSel(bSelected ? nIndex : -1); - m_pNormalWidget->Update(); + ToComboBox(GetNormalWidget())->SetCurSel(bSelected ? nIndex : -1); + GetNormalWidget()->Update(); InvalidateRect(); } void CXFA_FFComboBox::InsertItem(const WideString& wsLabel, int32_t nIndex) { - ToComboBox(m_pNormalWidget.get())->AddString(wsLabel); - m_pNormalWidget->Update(); + ToComboBox(GetNormalWidget())->AddString(wsLabel); + GetNormalWidget()->Update(); InvalidateRect(); } void CXFA_FFComboBox::DeleteItem(int32_t nIndex) { if (nIndex < 0) - ToComboBox(m_pNormalWidget.get())->RemoveAll(); + ToComboBox(GetNormalWidget())->RemoveAll(); else - ToComboBox(m_pNormalWidget.get())->RemoveAt(nIndex); + ToComboBox(GetNormalWidget())->RemoveAt(nIndex); - m_pNormalWidget->Update(); + GetNormalWidget()->Update(); InvalidateRect(); } @@ -335,20 +338,20 @@ switch (pEvent->GetType()) { case CFWL_Event::Type::SelectChanged: { auto* postEvent = static_cast<CFWL_EventSelectChanged*>(pEvent); - OnSelectChanged(m_pNormalWidget.get(), postEvent->bLButtonUp); + OnSelectChanged(GetNormalWidget(), postEvent->bLButtonUp); break; } case CFWL_Event::Type::EditChanged: { WideString wsChanged; - OnTextChanged(m_pNormalWidget.get(), wsChanged); + OnTextChanged(GetNormalWidget(), wsChanged); break; } case CFWL_Event::Type::PreDropDown: { - OnPreOpen(m_pNormalWidget.get()); + OnPreOpen(GetNormalWidget()); break; } case CFWL_Event::Type::PostDropDown: { - OnPostOpen(m_pNormalWidget.get()); + OnPostOpen(GetNormalWidget()); break; } default:
diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp index e38fae7..6d51e55 100644 --- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp +++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
@@ -23,10 +23,10 @@ CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_Node* pNode) : CXFA_FFTextEdit(pNode) {} -CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} +CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() = default; CFWL_DateTimePicker* CXFA_FFDateTimeEdit::GetPickerWidget() { - return static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); + return static_cast<CFWL_DateTimePicker*>(GetNormalWidget()); } CFX_RectF CXFA_FFDateTimeEdit::GetBBox(FocusOption focus) { @@ -85,7 +85,7 @@ uint32_t dwExtendedStyle = FWL_STYLEEXT_DTP_ShortDateFormat; dwExtendedStyle |= UpdateUIProperty(); dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + GetNormalWidget()->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); uint32_t dwEditStyles = 0; Optional<int32_t> numCells = m_pNode->GetNumberOfCells(); @@ -149,7 +149,7 @@ } bool CXFA_FFDateTimeEdit::UpdateFWLData() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; @@ -167,7 +167,7 @@ pPicker->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); } } - m_pNormalWidget->Update(); + GetNormalWidget()->Update(); return true; } @@ -207,7 +207,7 @@ void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { if (pEvent->GetType() == CFWL_Event::Type::SelectChanged) { auto* event = static_cast<CFWL_EventSelectChanged*>(pEvent); - OnSelectChanged(m_pNormalWidget.get(), event->iYear, event->iMonth, + OnSelectChanged(GetNormalWidget(), event->iYear, event->iMonth, event->iDay); return; }
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index e4c3fab..67fd590 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -79,10 +79,10 @@ RenderCaption(pGS, &mtRotate); DrawHighlight(pGS, &mtRotate, highlight, kSquareShape); - CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); + CFX_RectF rtWidget = GetNormalWidget()->GetWidgetRect(); CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); mt.Concat(mtRotate); - GetApp()->GetFWLWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, mt); + GetApp()->GetFWLWidgetMgr()->OnDrawWidget(GetNormalWidget(), pGS, mt); } void CXFA_FFField::DrawHighlight(CXFA_Graphics* pGS, @@ -124,12 +124,20 @@ } void CXFA_FFField::SetFWLThemeProvider() { - if (m_pNormalWidget) - m_pNormalWidget->SetThemeProvider(GetApp()->GetFWLTheme(GetDoc())); + if (GetNormalWidget()) + GetNormalWidget()->SetThemeProvider(GetApp()->GetFWLTheme(GetDoc())); +} + +CFWL_Widget* CXFA_FFField::GetNormalWidget() { + return m_pNormalWidget.get(); +} + +const CFWL_Widget* CXFA_FFField::GetNormalWidget() const { + return m_pNormalWidget.get(); } bool CXFA_FFField::IsLoaded() { - return m_pNormalWidget && CXFA_FFWidget::IsLoaded(); + return GetNormalWidget() && CXFA_FFWidget::IsLoaded(); } bool CXFA_FFField::LoadWidget() { @@ -156,8 +164,7 @@ fScrollOffset += pPrev->m_rtUI.height; pPrev = ToField(pPrev->GetLayoutItem()->GetPrev()); } - static_cast<CFWL_Edit*>(m_pNormalWidget.get()) - ->SetScrollOffset(fScrollOffset); + static_cast<CFWL_Edit*>(GetNormalWidget())->SetScrollOffset(fScrollOffset); } bool CXFA_FFField::PerformLayout() { @@ -166,8 +173,8 @@ LayoutCaption(); SetFWLRect(); SetEditScrollOffset(); - if (m_pNormalWidget) - m_pNormalWidget->Update(); + if (GetNormalWidget()) + GetNormalWidget()->Update(); return true; } @@ -339,8 +346,8 @@ } void CXFA_FFField::UpdateFWL() { - if (m_pNormalWidget) - m_pNormalWidget->Update(); + if (GetNormalWidget()) + GetNormalWidget()->Update(); } uint32_t CXFA_FFField::UpdateUIProperty() { @@ -351,7 +358,7 @@ } void CXFA_FFField::SetFWLRect() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return; CFX_RectF rtUi = m_rtUI; @@ -360,36 +367,37 @@ float fFontSize = m_pNode->GetFontSize(); rtUi.height = std::max(rtUi.height, fFontSize); } - m_pNormalWidget->SetWidgetRect(rtUi); + GetNormalWidget()->SetWidgetRect(rtUi); } bool CXFA_FFField::OnMouseEnter() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::Enter)); + GetNormalWidget(), FWL_MouseCommand::Enter)); return true; } bool CXFA_FFField::OnMouseExit() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::Leave)); + GetNormalWidget(), FWL_MouseCommand::Leave)); return true; } CFX_PointF CXFA_FFField::FWLToClient(const CFX_PointF& point) { - return m_pNormalWidget ? point - m_pNormalWidget->GetWidgetRect().TopLeft() - : point; + return GetNormalWidget() + ? point - GetNormalWidget()->GetWidgetRect().TopLeft() + : point; } bool CXFA_FFField::AcceptsFocusOnButtonDown(uint32_t dwFlags, const CFX_PointF& point, FWL_MouseCommand command) { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; if (!m_pNode->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) return false; @@ -402,81 +410,79 @@ void CXFA_FFField::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { SetButtonDown(true); SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::LeftButtonDown, dwFlags, + GetNormalWidget(), FWL_MouseCommand::LeftButtonDown, dwFlags, FWLToClient(point))); } bool CXFA_FFField::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; if (!IsButtonDown()) return false; SetButtonDown(false); SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::LeftButtonUp, dwFlags, + GetNormalWidget(), FWL_MouseCommand::LeftButtonUp, dwFlags, FWLToClient(point))); return true; } bool CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::LeftButtonDblClk, dwFlags, + GetNormalWidget(), FWL_MouseCommand::LeftButtonDblClk, dwFlags, FWLToClient(point))); return true; } bool CXFA_FFField::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::Move, dwFlags, - FWLToClient(point))); + GetNormalWidget(), FWL_MouseCommand::Move, dwFlags, FWLToClient(point))); return true; } bool CXFA_FFField::OnMouseWheel(uint32_t dwFlags, int16_t zDelta, const CFX_PointF& point) { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouseWheel>( - m_pNormalWidget.get(), dwFlags, FWLToClient(point), - CFX_PointF(zDelta, 0))); + GetNormalWidget(), dwFlags, FWLToClient(point), CFX_PointF(zDelta, 0))); return true; } void CXFA_FFField::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { SetButtonDown(true); SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::RightButtonDown, dwFlags, + GetNormalWidget(), FWL_MouseCommand::RightButtonDown, dwFlags, FWLToClient(point))); } bool CXFA_FFField::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; if (!IsButtonDown()) return false; SetButtonDown(false); SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::RightButtonUp, dwFlags, + GetNormalWidget(), FWL_MouseCommand::RightButtonUp, dwFlags, FWLToClient(point))); return true; } bool CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::RightButtonDblClk, dwFlags, + GetNormalWidget(), FWL_MouseCommand::RightButtonDblClk, dwFlags, FWLToClient(point))); return true; } @@ -485,20 +491,20 @@ if (!CXFA_FFWidget::OnSetFocus(pOldWidget)) return false; - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; SendMessageToFWLWidget( - pdfium::MakeUnique<CFWL_MessageSetFocus>(nullptr, m_pNormalWidget.get())); + pdfium::MakeUnique<CFWL_MessageSetFocus>(nullptr, GetNormalWidget())); GetLayoutItem()->SetStatusBits(XFA_WidgetStatus_Focused); InvalidateRect(); return true; } bool CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { - if (m_pNormalWidget) { - SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageKillFocus>( - nullptr, m_pNormalWidget.get())); + if (GetNormalWidget()) { + SendMessageToFWLWidget( + pdfium::MakeUnique<CFWL_MessageKillFocus>(nullptr, GetNormalWidget())); GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus_Focused); InvalidateRect(); } @@ -506,20 +512,20 @@ } bool CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { - if (!m_pNormalWidget || !GetDoc()->GetXFADoc()->IsInteractive()) + if (!GetNormalWidget() || !GetDoc()->GetXFADoc()->IsInteractive()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageKey>( - m_pNormalWidget.get(), FWL_KeyCommand::KeyDown, dwFlags, dwKeyCode)); + GetNormalWidget(), FWL_KeyCommand::KeyDown, dwFlags, dwKeyCode)); return true; } bool CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { - if (!m_pNormalWidget || !GetDoc()->GetXFADoc()->IsInteractive()) + if (!GetNormalWidget() || !GetDoc()->GetXFADoc()->IsInteractive()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageKey>( - m_pNormalWidget.get(), FWL_KeyCommand::KeyUp, dwFlags, dwKeyCode)); + GetNormalWidget(), FWL_KeyCommand::KeyUp, dwFlags, dwKeyCode)); return true; } @@ -528,19 +534,19 @@ return false; if (dwChar == XFA_FWL_VKEY_Tab) return true; - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; if (!m_pNode->IsOpenAccess()) return false; SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageKey>( - m_pNormalWidget.get(), FWL_KeyCommand::Char, dwFlags, dwChar)); + GetNormalWidget(), FWL_KeyCommand::Char, dwFlags, dwChar)); return true; } FWL_WidgetHit CXFA_FFField::OnHitTest(const CFX_PointF& point) { - if (m_pNormalWidget && - m_pNormalWidget->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown) { + if (GetNormalWidget() && GetNormalWidget()->HitTest(FWLToClient(point)) != + FWL_WidgetHit::Unknown) { return FWL_WidgetHit::Client; } @@ -556,7 +562,8 @@ } bool CXFA_FFField::PtInActiveRect(const CFX_PointF& point) { - return m_pNormalWidget && m_pNormalWidget->GetWidgetRect().Contains(point); + return GetNormalWidget() && + GetNormalWidget()->GetWidgetRect().Contains(point); } void CXFA_FFField::LayoutCaption() {
diff --git a/xfa/fxfa/cxfa_fffield.h b/xfa/fxfa/cxfa_fffield.h index d3ae1fb..d885859 100644 --- a/xfa/fxfa/cxfa_fffield.h +++ b/xfa/fxfa/cxfa_fffield.h
@@ -71,7 +71,8 @@ virtual void SetFWLRect(); void SetFWLThemeProvider(); - CFWL_Widget* GetNormalWidget() { return m_pNormalWidget.get(); } + CFWL_Widget* GetNormalWidget(); + const CFWL_Widget* GetNormalWidget() const; CFX_PointF FWLToClient(const CFX_PointF& point); void LayoutCaption(); void RenderCaption(CXFA_Graphics* pGS, CFX_Matrix* pMatrix);
diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index 0f50c6a..1cebdf6 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp
@@ -24,8 +24,7 @@ #include "xfa/fxfa/parser/cxfa_para.h" #include "xfa/fxfa/parser/cxfa_value.h" -CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_Node* pNode) - : CXFA_FFField(pNode), m_pOldDelegate(nullptr) {} +CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_Node* pNode) : CXFA_FFField(pNode) {} CXFA_FFImageEdit::~CXFA_FFImageEdit() { m_pNode->SetImageEditImage(nullptr); @@ -67,7 +66,7 @@ if (!pDIBitmap) return; - CFX_RectF rtImage = m_pNormalWidget->GetWidgetRect(); + CFX_RectF rtImage = GetNormalWidget()->GetWidgetRect(); XFA_AttributeValue iHorzAlign = XFA_AttributeValue::Left; XFA_AttributeValue iVertAlign = XFA_AttributeValue::Top; CXFA_Para* para = m_pNode->GetParaIfExists(); @@ -106,19 +105,19 @@ const CFX_PointF& point) { SetButtonDown(true); SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::LeftButtonDown, dwFlags, + GetNormalWidget(), FWL_MouseCommand::LeftButtonDown, dwFlags, FWLToClient(point))); } void CXFA_FFImageEdit::SetFWLRect() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return; CFX_RectF rtUIMargin = m_pNode->GetUIMargin(); CFX_RectF rtImage(m_rtUI); rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width, rtUIMargin.height); - m_pNormalWidget->SetWidgetRect(rtImage); + GetNormalWidget()->SetWidgetRect(rtImage); } bool CXFA_FFImageEdit::CommitData() {
diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp index 349f749..f15b89e 100644 --- a/xfa/fxfa/cxfa_fflistbox.cpp +++ b/xfa/fxfa/cxfa_fflistbox.cpp
@@ -26,16 +26,15 @@ } // namespace -CXFA_FFListBox::CXFA_FFListBox(CXFA_Node* pNode) - : CXFA_FFDropDown(pNode), m_pOldDelegate(nullptr) {} +CXFA_FFListBox::CXFA_FFListBox(CXFA_Node* pNode) : CXFA_FFDropDown(pNode) {} CXFA_FFListBox::~CXFA_FFListBox() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return; CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); + GetNormalWidget()->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->UnregisterEventTarget(GetNormalWidget()); } bool CXFA_FFListBox::LoadWidget() { @@ -79,7 +78,7 @@ } bool CXFA_FFListBox::CommitData() { - auto* pListBox = ToListBox(m_pNormalWidget.get()); + auto* pListBox = ToListBox(GetNormalWidget()); std::vector<int32_t> iSelArray; int32_t iSels = pListBox->CountSelItems(); for (int32_t i = 0; i < iSels; ++i) @@ -92,7 +91,7 @@ bool CXFA_FFListBox::IsDataChanged() { std::vector<int32_t> iSelArray = m_pNode->GetSelectedItems(); int32_t iOldSels = pdfium::CollectionSize<int32_t>(iSelArray); - auto* pListBox = ToListBox(m_pNormalWidget.get()); + auto* pListBox = ToListBox(GetNormalWidget()); int32_t iSels = pListBox->CountSelItems(); if (iOldSels != iSels) return true; @@ -132,10 +131,10 @@ } bool CXFA_FFListBox::UpdateFWLData() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; - auto* pListBox = ToListBox(m_pNormalWidget.get()); + auto* pListBox = ToListBox(GetNormalWidget()); std::vector<int32_t> iSelArray = m_pNode->GetSelectedItems(); std::vector<CFWL_ListItem*> selItemArray(iSelArray.size()); std::transform(iSelArray.begin(), iSelArray.end(), selItemArray.begin(), @@ -145,7 +144,7 @@ for (CFWL_ListItem* pItem : selItemArray) pListBox->SetSelItem(pItem, true); - m_pNormalWidget->Update(); + GetNormalWidget()->Update(); return true; } @@ -158,20 +157,20 @@ } void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) { - auto* pListBox = ToListBox(m_pNormalWidget.get()); + auto* pListBox = ToListBox(GetNormalWidget()); pListBox->SetSelItem(pListBox->GetSelItem(nIndex), bSelected); - m_pNormalWidget->Update(); + GetNormalWidget()->Update(); InvalidateRect(); } void CXFA_FFListBox::InsertItem(const WideString& wsLabel, int32_t nIndex) { - ToListBox(m_pNormalWidget.get())->AddString(wsLabel); - m_pNormalWidget->Update(); + ToListBox(GetNormalWidget())->AddString(wsLabel); + GetNormalWidget()->Update(); InvalidateRect(); } void CXFA_FFListBox::DeleteItem(int32_t nIndex) { - auto* pListBox = ToListBox(m_pNormalWidget.get()); + auto* pListBox = ToListBox(GetNormalWidget()); if (nIndex < 0) pListBox->DeleteAll(); else @@ -189,7 +188,7 @@ CXFA_FFField::OnProcessEvent(pEvent); switch (pEvent->GetType()) { case CFWL_Event::Type::SelectChanged: - OnSelectChanged(m_pNormalWidget.get()); + OnSelectChanged(GetNormalWidget()); break; default: break;
diff --git a/xfa/fxfa/cxfa_ffnumericedit.cpp b/xfa/fxfa/cxfa_ffnumericedit.cpp index 731c854..9240f27 100644 --- a/xfa/fxfa/cxfa_ffnumericedit.cpp +++ b/xfa/fxfa/cxfa_ffnumericedit.cpp
@@ -20,7 +20,7 @@ CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_Node* pNode) : CXFA_FFTextEdit(pNode) {} -CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} +CXFA_FFNumericEdit::~CXFA_FFNumericEdit() = default; bool CXFA_FFNumericEdit::LoadWidget() { auto pNewEdit = pdfium::MakeUnique<CFWL_Edit>( @@ -44,7 +44,7 @@ } void CXFA_FFNumericEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); + CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(GetNormalWidget()); if (!pWidget) return; @@ -64,13 +64,13 @@ if (!m_pNode->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + GetNormalWidget()->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); } void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { if (pEvent->GetType() == CFWL_Event::Type::Validate) { CFWL_EventValidate* event = static_cast<CFWL_EventValidate*>(pEvent); - event->bValidate = OnValidate(m_pNormalWidget.get(), event->wsInsert); + event->bValidate = OnValidate(GetNormalWidget(), event->wsInsert); return; } CXFA_FFTextEdit::OnProcessEvent(pEvent);
diff --git a/xfa/fxfa/cxfa_ffpasswordedit.cpp b/xfa/fxfa/cxfa_ffpasswordedit.cpp index 1ddef0e..100d14e 100644 --- a/xfa/fxfa/cxfa_ffpasswordedit.cpp +++ b/xfa/fxfa/cxfa_ffpasswordedit.cpp
@@ -19,7 +19,7 @@ CXFA_PasswordEdit* password_node) : CXFA_FFTextEdit(pNode), password_node_(password_node) {} -CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} +CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() = default; bool CXFA_FFPasswordEdit::LoadWidget() { auto pNewEdit = pdfium::MakeUnique<CFWL_Edit>( @@ -43,7 +43,7 @@ } void CXFA_FFPasswordEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); + CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(GetNormalWidget()); if (!pWidget) return; @@ -61,5 +61,5 @@ dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + GetNormalWidget()->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); }
diff --git a/xfa/fxfa/cxfa_ffpasswordedit.h b/xfa/fxfa/cxfa_ffpasswordedit.h index 3af4f96..a96efa0 100644 --- a/xfa/fxfa/cxfa_ffpasswordedit.h +++ b/xfa/fxfa/cxfa_ffpasswordedit.h
@@ -22,7 +22,7 @@ void UpdateWidgetProperty() override; private: - UnownedPtr<CXFA_PasswordEdit> password_node_; + UnownedPtr<CXFA_PasswordEdit> const password_node_; }; #endif // XFA_FXFA_CXFA_FFPASSWORDEDIT_H_
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp index 63d6d40..8811d24 100644 --- a/xfa/fxfa/cxfa_ffpushbutton.cpp +++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -46,7 +46,7 @@ CFX_RectF rtWidget = GetRectWithoutRotate(); CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); mt.Concat(mtRotate); - GetApp()->GetFWLWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, mt); + GetApp()->GetFWLWidgetMgr()->OnDrawWidget(GetNormalWidget(), pGS, mt); } bool CXFA_FFPushButton::LoadWidget() { @@ -84,7 +84,7 @@ default: break; } - m_pNormalWidget->ModifyStylesEx(dwStyleEx, 0xFFFFFFFF); + GetNormalWidget()->ModifyStylesEx(dwStyleEx, 0xFFFFFFFF); } bool CXFA_FFPushButton::PerformLayout() { @@ -103,8 +103,8 @@ LayoutHighlightCaption(); SetFWLRect(); - if (m_pNormalWidget) - m_pNormalWidget->Update(); + if (GetNormalWidget()) + GetNormalWidget()->Update(); return true; } @@ -175,7 +175,7 @@ mt.Concat(*pMatrix); } - uint32_t dwState = m_pNormalWidget->GetStates(); + uint32_t dwState = GetNormalWidget()->GetStates(); if (m_pDownTextLayout && (dwState & FWL_STATE_PSB_Pressed) && (dwState & FWL_STATE_PSB_Hovered)) { if (m_pDownTextLayout->DrawString(pRenderDevice, mt, rtClip, 0)) @@ -200,10 +200,11 @@ void CXFA_FFPushButton::OnDrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) { - if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) { - if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && - (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { - CFX_RectF rtFill(0, 0, m_pNormalWidget->GetWidgetRect().Size()); + auto* pWidget = GetNormalWidget(); + if (pWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) { + if ((pWidget->GetStates() & FWL_STATE_PSB_Pressed) && + (pWidget->GetStates() & FWL_STATE_PSB_Hovered)) { + CFX_RectF rtFill(0, 0, pWidget->GetWidgetRect().Size()); float fLineWith = GetLineWidth(); rtFill.Deflate(fLineWith, fLineWith); CXFA_GEPath path; @@ -214,15 +215,15 @@ return; } - if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteOutLine) { - if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && - (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { + if (pWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteOutLine) { + if ((pWidget->GetStates() & FWL_STATE_PSB_Pressed) && + (pWidget->GetStates() & FWL_STATE_PSB_Hovered)) { float fLineWidth = GetLineWidth(); pGraphics->SetStrokeColor(CXFA_GEColor(ArgbEncode(255, 128, 255, 255))); pGraphics->SetLineWidth(fLineWidth); CXFA_GEPath path; - CFX_RectF rect = m_pNormalWidget->GetWidgetRect(); + CFX_RectF rect = pWidget->GetWidgetRect(); path.AddRectangle(0, 0, rect.width, rect.height); pGraphics->StrokePath(&path, &matrix); }
diff --git a/xfa/fxfa/cxfa_ffpushbutton.h b/xfa/fxfa/cxfa_ffpushbutton.h index d8cd2f4..e4b34b5 100644 --- a/xfa/fxfa/cxfa_ffpushbutton.h +++ b/xfa/fxfa/cxfa_ffpushbutton.h
@@ -51,7 +51,7 @@ std::unique_ptr<CXFA_TextProvider> m_pRollProvider; std::unique_ptr<CXFA_TextProvider> m_pDownProvider; UnownedPtr<IFWL_WidgetDelegate> m_pOldDelegate; - UnownedPtr<CXFA_Button> button_; + UnownedPtr<CXFA_Button> const button_; }; #endif // XFA_FXFA_CXFA_FFPUSHBUTTON_H_
diff --git a/xfa/fxfa/cxfa_ffsignature.cpp b/xfa/fxfa/cxfa_ffsignature.cpp index 36e7fc4..88d10b6 100644 --- a/xfa/fxfa/cxfa_ffsignature.cpp +++ b/xfa/fxfa/cxfa_ffsignature.cpp
@@ -14,7 +14,7 @@ CXFA_FFSignature::CXFA_FFSignature(CXFA_Node* pNode) : CXFA_FFField(pNode) {} -CXFA_FFSignature::~CXFA_FFSignature() {} +CXFA_FFSignature::~CXFA_FFSignature() = default; bool CXFA_FFSignature::LoadWidget() { return CXFA_FFField::LoadWidget(); @@ -97,8 +97,8 @@ } FWL_WidgetHit CXFA_FFSignature::OnHitTest(const CFX_PointF& point) { - if (m_pNormalWidget && - m_pNormalWidget->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown) { + if (GetNormalWidget() && GetNormalWidget()->HitTest(FWLToClient(point)) != + FWL_WidgetHit::Unknown) { return FWL_WidgetHit::Client; }
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp index 7916432..8052290 100644 --- a/xfa/fxfa/cxfa_fftextedit.cpp +++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -31,14 +31,13 @@ } // namespace -CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_Node* pNode) - : CXFA_FFField(pNode), m_pOldDelegate(nullptr) {} +CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_Node* pNode) : CXFA_FFField(pNode) {} CXFA_FFTextEdit::~CXFA_FFTextEdit() { - if (m_pNormalWidget) { + if (GetNormalWidget()) { CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); + GetNormalWidget()->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->UnregisterEventTarget(GetNormalWidget()); } } @@ -64,7 +63,7 @@ } void CXFA_FFTextEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = ToEdit(m_pNormalWidget.get()); + CFWL_Edit* pWidget = ToEdit(GetNormalWidget()); if (!pWidget) return; @@ -104,8 +103,8 @@ } dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + GetNormalWidget()->ModifyStyles(dwStyle, 0xFFFFFFFF); + GetNormalWidget()->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); } bool CXFA_FFTextEdit::AcceptsFocusOnButtonDown(uint32_t dwFlags, @@ -127,7 +126,7 @@ } SetButtonDown(true); SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageMouse>( - m_pNormalWidget.get(), FWL_MouseCommand::LeftButtonDown, dwFlags, + GetNormalWidget(), FWL_MouseCommand::LeftButtonDown, dwFlags, FWLToClient(point))); } @@ -161,14 +160,14 @@ return false; SendMessageToFWLWidget( - pdfium::MakeUnique<CFWL_MessageSetFocus>(nullptr, m_pNormalWidget.get())); + pdfium::MakeUnique<CFWL_MessageSetFocus>(nullptr, GetNormalWidget())); return true; } bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { - SendMessageToFWLWidget(pdfium::MakeUnique<CFWL_MessageKillFocus>( - nullptr, m_pNormalWidget.get())); + SendMessageToFWLWidget( + pdfium::MakeUnique<CFWL_MessageKillFocus>(nullptr, GetNormalWidget())); GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus_Focused); SetEditScrollOffset(); @@ -184,7 +183,7 @@ } bool CXFA_FFTextEdit::CommitData() { - WideString wsText = ToEdit(m_pNormalWidget.get())->GetText(); + WideString wsText = ToEdit(GetNormalWidget())->GetText(); if (m_pNode->SetValue(XFA_VALUEPICTURE_Edit, wsText)) { m_pNode->UpdateUIDisplay(GetDoc()->GetDocView(), this); return true; @@ -251,10 +250,10 @@ } bool CXFA_FFTextEdit::UpdateFWLData() { - if (!m_pNormalWidget) + if (!GetNormalWidget()) return false; - CFWL_Edit* pEdit = ToEdit(m_pNormalWidget.get()); + CFWL_Edit* pEdit = ToEdit(GetNormalWidget()); XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; if (IsFocused()) eType = XFA_VALUEPICTURE_Edit; @@ -290,7 +289,7 @@ bUpdate = true; } if (bUpdate) - m_pNormalWidget->Update(); + GetNormalWidget()->Update(); return true; } @@ -332,11 +331,11 @@ CXFA_FFField::OnProcessEvent(pEvent); switch (pEvent->GetType()) { case CFWL_Event::Type::TextWillChange: - OnTextWillChange(m_pNormalWidget.get(), + OnTextWillChange(GetNormalWidget(), static_cast<CFWL_EventTextWillChange*>(pEvent)); break; case CFWL_Event::Type::TextFull: - OnTextFull(m_pNormalWidget.get()); + OnTextFull(GetNormalWidget()); break; default: break; @@ -350,66 +349,66 @@ } bool CXFA_FFTextEdit::CanUndo() { - return ToEdit(m_pNormalWidget.get())->CanUndo(); + return ToEdit(GetNormalWidget())->CanUndo(); } bool CXFA_FFTextEdit::CanRedo() { - return ToEdit(m_pNormalWidget.get())->CanRedo(); + return ToEdit(GetNormalWidget())->CanRedo(); } bool CXFA_FFTextEdit::Undo() { - return ToEdit(m_pNormalWidget.get())->Undo(); + return ToEdit(GetNormalWidget())->Undo(); } bool CXFA_FFTextEdit::Redo() { - return ToEdit(m_pNormalWidget.get())->Redo(); + return ToEdit(GetNormalWidget())->Redo(); } bool CXFA_FFTextEdit::CanCopy() { - return ToEdit(m_pNormalWidget.get())->HasSelection(); + return ToEdit(GetNormalWidget())->HasSelection(); } bool CXFA_FFTextEdit::CanCut() { - if (ToEdit(m_pNormalWidget.get())->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) + if (ToEdit(GetNormalWidget())->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) return false; - return ToEdit(m_pNormalWidget.get())->HasSelection(); + return ToEdit(GetNormalWidget())->HasSelection(); } bool CXFA_FFTextEdit::CanPaste() { - return !(ToEdit(m_pNormalWidget.get())->GetStylesEx() & + return !(ToEdit(GetNormalWidget())->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly); } bool CXFA_FFTextEdit::CanSelectAll() { - return ToEdit(m_pNormalWidget.get())->GetTextLength() > 0; + return ToEdit(GetNormalWidget())->GetTextLength() > 0; } Optional<WideString> CXFA_FFTextEdit::Copy() { - return ToEdit(m_pNormalWidget.get())->Copy(); + return ToEdit(GetNormalWidget())->Copy(); } Optional<WideString> CXFA_FFTextEdit::Cut() { - return ToEdit(m_pNormalWidget.get())->Cut(); + return ToEdit(GetNormalWidget())->Cut(); } bool CXFA_FFTextEdit::Paste(const WideString& wsPaste) { - return ToEdit(m_pNormalWidget.get())->Paste(wsPaste); + return ToEdit(GetNormalWidget())->Paste(wsPaste); } void CXFA_FFTextEdit::SelectAll() { - ToEdit(m_pNormalWidget.get())->SelectAll(); + ToEdit(GetNormalWidget())->SelectAll(); } void CXFA_FFTextEdit::Delete() { - ToEdit(m_pNormalWidget.get())->ClearText(); + ToEdit(GetNormalWidget())->ClearText(); } void CXFA_FFTextEdit::DeSelect() { - ToEdit(m_pNormalWidget.get())->ClearSelection(); + ToEdit(GetNormalWidget())->ClearSelection(); } WideString CXFA_FFTextEdit::GetText() { - return ToEdit(m_pNormalWidget.get())->GetText(); + return ToEdit(GetNormalWidget())->GetText(); } FormFieldType CXFA_FFTextEdit::GetFormFieldType() {