Cleanup some PWL interfaces. This CL removes IPWL_Edit_Notfy and removes the OnKillFocus override from IPWL_FocusHandler. Review-Url: https://codereview.chromium.org/2144813002
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp index 262c485..4b84733 100644 --- a/fpdfsdk/formfiller/cffl_combobox.cpp +++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -267,19 +267,9 @@ unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE); - - pEdit->SetEditNotify(this); } } -void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd) { - ASSERT(m_pApp); -} - -void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit) { - ASSERT(pEdit); -} - CFX_WideString CFFL_ComboBox::GetSelectExportText() { CFX_WideString swRet;
diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h index 947f425..6b8fb49 100644 --- a/fpdfsdk/formfiller/cffl_combobox.h +++ b/fpdfsdk/formfiller/cffl_combobox.h
@@ -19,9 +19,7 @@ CFX_WideString sValue; }; -class CFFL_ComboBox : public CFFL_FormFiller, - public IPWL_FocusHandler, - public IPWL_Edit_Notify { +class CFFL_ComboBox : public CFFL_FormFiller, public IPWL_FocusHandler { public: CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); ~CFFL_ComboBox() override; @@ -49,10 +47,6 @@ // IPWL_FocusHandler: void OnSetFocus(CPWL_Wnd* pWnd) override; - void OnKillFocus(CPWL_Wnd* pWnd) override; - - // IPWL_Edit_Notify: - void OnAddUndo(CPWL_Edit* pEdit) override; #ifdef PDF_ENABLE_XFA // CFFL_FormFiller:
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index 4f32f42..5e69031 100644 --- a/fpdfsdk/formfiller/cffl_textfield.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -279,11 +279,5 @@ unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE); - - pEdit->SetEditNotify(this); } } - -void CFFL_TextField::OnKillFocus(CPWL_Wnd* pWnd) {} - -void CFFL_TextField::OnAddUndo(CPWL_Edit* pEdit) {}
diff --git a/fpdfsdk/formfiller/cffl_textfield.h b/fpdfsdk/formfiller/cffl_textfield.h index d7bfc9e..34968e8 100644 --- a/fpdfsdk/formfiller/cffl_textfield.h +++ b/fpdfsdk/formfiller/cffl_textfield.h
@@ -21,9 +21,7 @@ CFX_WideString sValue; }; -class CFFL_TextField : public CFFL_FormFiller, - public IPWL_FocusHandler, - public IPWL_Edit_Notify { +class CFFL_TextField : public CFFL_FormFiller, public IPWL_FocusHandler { public: CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); ~CFFL_TextField() override; @@ -51,10 +49,6 @@ // IPWL_FocusHandler: void OnSetFocus(CPWL_Wnd* pWnd) override; - void OnKillFocus(CPWL_Wnd* pWnd) override; - - // IPWL_Edit_Notify: - void OnAddUndo(CPWL_Edit* pEdit) override; #ifdef PDF_ENABLE_XFA // CFFL_FormFiller:
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index 2125eb8..fb219ca 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -3094,8 +3094,6 @@ void CFX_Edit::EndGroupUndo() { m_pGroupUndoItem->UpdateItems(); m_Undo.AddItem(m_pGroupUndoItem); - if (m_bOprNotify && m_pOprNotify) - m_pOprNotify->OnAddUndo(m_pGroupUndoItem); m_pGroupUndoItem = nullptr; } @@ -3104,15 +3102,11 @@ m_pGroupUndoItem->AddUndoItem(pEditUndoItem); } else { m_Undo.AddItem(pEditUndoItem); - if (m_bOprNotify && m_pOprNotify) - m_pOprNotify->OnAddUndo(pEditUndoItem); } } void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { m_Undo.AddItem(pUndoItem); - if (m_bOprNotify && m_pOprNotify) - m_pOprNotify->OnAddUndo(pUndoItem); } CFX_Edit_LineRectArray::CFX_Edit_LineRectArray() {}
diff --git a/fpdfsdk/fxedit/include/fxet_edit.h b/fpdfsdk/fxedit/include/fxet_edit.h index 3bf5849..4287705 100644 --- a/fpdfsdk/fxedit/include/fxet_edit.h +++ b/fpdfsdk/fxedit/include/fxet_edit.h
@@ -566,7 +566,6 @@ friend class CFXEU_Backspace; friend class CFXEU_Delete; friend class CFXEU_Clear; - friend class CFXEU_ClearRich; friend class CFXEU_InsertText; void SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end);
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index d729945..39ea822 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp
@@ -104,11 +104,6 @@ return rcClient; } -void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, - FX_BOOL bPaint) { - m_pEdit->SetAlignmentH((int32_t)nFormat, bPaint); -} - void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, FX_BOOL bPaint) { m_pEdit->SetAlignmentV((int32_t)nFormat, bPaint); @@ -464,14 +459,7 @@ m_pEdit->SelectNone(); SetCaret(FALSE, CFX_FloatPoint(0.0f, 0.0f), CFX_FloatPoint(0.0f, 0.0f)); - SetCharSet(FXFONT_ANSI_CHARSET); - - if (!IsReadOnly()) { - if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) - pFocusHandler->OnKillFocus(this); - } - m_bFocus = FALSE; } @@ -770,10 +758,6 @@ m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), GetLatinWordsRange(place))); } - - if (m_pEditNotify) { - m_pEditNotify->OnInsertReturn(place, oldplace); - } } void CPWL_Edit::OnBackSpace(const CPVT_WordPlace& place, @@ -782,10 +766,6 @@ m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), GetLatinWordsRange(place))); } - - if (m_pEditNotify) { - m_pEditNotify->OnBackSpace(place, oldplace); - } } void CPWL_Edit::OnDelete(const CPVT_WordPlace& place, @@ -794,10 +774,6 @@ m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), GetLatinWordsRange(place))); } - - if (m_pEditNotify) { - m_pEditNotify->OnDelete(place, oldplace); - } } void CPWL_Edit::OnClear(const CPVT_WordPlace& place, @@ -806,10 +782,6 @@ m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), GetLatinWordsRange(place))); } - - if (m_pEditNotify) { - m_pEditNotify->OnClear(place, oldplace); - } } void CPWL_Edit::OnInsertWord(const CPVT_WordPlace& place, @@ -818,10 +790,6 @@ m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), GetLatinWordsRange(place))); } - - if (m_pEditNotify) { - m_pEditNotify->OnInsertWord(place, oldplace); - } } void CPWL_Edit::OnInsertText(const CPVT_WordPlace& place, @@ -830,16 +798,6 @@ m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), GetLatinWordsRange(place))); } - - if (m_pEditNotify) { - m_pEditNotify->OnInsertText(place, oldplace); - } -} - -void CPWL_Edit::OnAddUndo(IFX_Edit_UndoItem* pUndoItem) { - if (m_pEditNotify) { - m_pEditNotify->OnAddUndo(this); - } } CPVT_WordRange CPWL_Edit::CombineWordRange(const CPVT_WordRange& wr1,
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.h b/fpdfsdk/pdfwindow/PWL_Edit.h index e1518ef..008e1fd 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.h +++ b/fpdfsdk/pdfwindow/PWL_Edit.h
@@ -70,8 +70,6 @@ void OnSetFocus() override; void OnKillFocus() override; - void SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat = PEAH_LEFT, - FX_BOOL bPaint = TRUE); // 0:left 1:right 2:middle void SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat = PEAV_TOP, FX_BOOL bPaint = TRUE); // 0:top 1:bottom 2:center @@ -126,7 +124,6 @@ void OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); void OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - void OnAddUndo(IFX_Edit_UndoItem* pUndoItem); private: CPVT_WordRange GetSelectWordRange() const;
diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp index dd1094a..1bb17db 100644 --- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp +++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
@@ -25,12 +25,10 @@ : m_pEdit(new CFX_Edit), m_pEditCaret(nullptr), m_bMouseDown(FALSE), - m_pEditNotify(nullptr), m_nCharSet(DEFAULT_CHARSET), m_nCodePage(0) {} -CPWL_EditCtrl::~CPWL_EditCtrl() { -} +CPWL_EditCtrl::~CPWL_EditCtrl() {} void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { cp.eCursorType = FXCT_VBEAM; @@ -566,13 +564,10 @@ OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t) nullptr); } -void CPWL_EditCtrl::IOnContentChange(const CFX_FloatRect& rcContent) { - if (IsValid()) { - if (m_pEditNotify) { - m_pEditNotify->OnContentChange(rcContent); - } - } -} +void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps, + const CPVT_WordProps& wordProps) {} + +void CPWL_EditCtrl::IOnContentChange(const CFX_FloatRect& rcContent) {} void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) { InvalidateRect(pRect);
diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.h b/fpdfsdk/pdfwindow/PWL_EditCtrl.h index 028c41b..f767d1b 100644 --- a/fpdfsdk/pdfwindow/PWL_EditCtrl.h +++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.h
@@ -15,7 +15,6 @@ class CPWL_Caret; class CPWL_Edit; class CPWL_EditCtrl; -class IPWL_Edit_Notify; struct CPVT_SecProps; struct CPVT_WordPlace; struct CPVT_WordProps; @@ -25,36 +24,6 @@ enum PWL_EDIT_ALIGNFORMAT_V { PEAV_TOP = 0, PEAV_CENTER, PEAV_BOTTOM }; -class IPWL_Edit_Notify { - public: - virtual ~IPWL_Edit_Notify() {} - // when the position of caret is changed in edit - virtual void OnCaretMove(int32_t x1, int32_t y1, int32_t x2, int32_t y2) {} - virtual void OnContentChange(const CFX_FloatRect& rcContent) {} - // OprType: 0 InsertWord - // 1 InsertReturn - // 2 BackSpace - // 3 Delete - // 4 Clear - // 5 InsertText - // 6 SetText - virtual void OnInsertWord(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) {} - virtual void OnInsertReturn(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) {} - virtual void OnBackSpace(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) {} - virtual void OnDelete(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) {} - virtual void OnClear(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) {} - virtual void OnInsertText(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) {} - virtual void OnSetText(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) {} - virtual void OnAddUndo(CPWL_Edit* pEdit) {} -}; - class CPWL_EditCtrl : public CPWL_Wnd { friend class CPWL_Edit_Notify; @@ -85,8 +54,6 @@ CFX_FloatPoint GetScrollPos() const; void SetScrollPos(const CFX_FloatPoint& point); - void SetEditNotify(IPWL_Edit_Notify* pNotify) { m_pEditNotify = pNotify; } - void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; } int32_t GetCharSet() const; @@ -162,7 +129,6 @@ std::unique_ptr<CFX_Edit> m_pEdit; CPWL_Caret* m_pEditCaret; FX_BOOL m_bMouseDown; - IPWL_Edit_Notify* m_pEditNotify; private: void CreateEditCaret(const PWL_CREATEPARAM& cp);
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h index 197bdf0..2e780c6 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/pdfwindow/PWL_Wnd.h
@@ -182,7 +182,6 @@ public: virtual ~IPWL_FocusHandler() {} virtual void OnSetFocus(CPWL_Wnd* pWnd) = 0; - virtual void OnKillFocus(CPWL_Wnd* pWnd) = 0; }; struct PWL_CREATEPARAM {