Remove most remaining virtual methods from IPDFSDK_AnnotHandler. Move the overrides from methods like GetText() and SelectAllText() to CPDFSDK_Annot instead. Continue removing CPDFSDK_AnnotHandlerMgr pass-throughs, such that IPDFSDK_AnnotHandler and CPDFSDK_AnnotHandlerMgr are close to being completely dead code. Change-Id: I1ddf4b8b1155cfadb60e20a25aca06893681434d Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/92371 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_annot.h b/fpdfsdk/cpdfsdk_annot.h index 17a68b4..a899d51 100644 --- a/fpdfsdk/cpdfsdk_annot.h +++ b/fpdfsdk/cpdfsdk_annot.h
@@ -12,6 +12,7 @@ #include "core/fxcrt/mask.h" #include "core/fxcrt/observed_ptr.h" #include "core/fxcrt/unowned_ptr.h" +#include "core/fxcrt/widestring.h" #include "public/fpdf_fwlevent.h" class CPDF_Page; @@ -72,6 +73,12 @@ virtual bool CanRedo() = 0; virtual bool Undo() = 0; virtual bool Redo() = 0; + virtual WideString GetText() = 0; + virtual WideString GetSelectedText() = 0; + virtual void ReplaceSelection(const WideString& text) = 0; + virtual bool SelectAllText() = 0; + virtual bool SetIndexSelected(int index, bool selected) = 0; + virtual bool IsIndexSelected(int index) = 0; // Callers must check if `pAnnot` is still valid after calling these methods, // before accessing them again.
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp index 6b5f93b..f3dc413 100644 --- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp +++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -46,24 +46,6 @@ ->NewAnnot(pAnnot, pPageView); } -WideString CPDFSDK_AnnotHandlerMgr::Annot_GetText(CPDFSDK_Annot* pAnnot) { - return GetAnnotHandler(pAnnot)->GetText(pAnnot); -} - -WideString CPDFSDK_AnnotHandlerMgr::Annot_GetSelectedText( - CPDFSDK_Annot* pAnnot) { - return GetAnnotHandler(pAnnot)->GetSelectedText(pAnnot); -} - -void CPDFSDK_AnnotHandlerMgr::Annot_ReplaceSelection(CPDFSDK_Annot* pAnnot, - const WideString& text) { - GetAnnotHandler(pAnnot)->ReplaceSelection(pAnnot, text); -} - -bool CPDFSDK_AnnotHandlerMgr::Annot_SelectAllText(CPDFSDK_Annot* pAnnot) { - return GetAnnotHandler(pAnnot)->SelectAllText(pAnnot); -} - IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( CPDFSDK_Annot* pAnnot) const { return GetAnnotHandlerOfType(pAnnot->GetAnnotSubtype()); @@ -81,19 +63,3 @@ return m_pBAAnnotHandler.get(); } - -bool CPDFSDK_AnnotHandlerMgr::Annot_SetIndexSelected( - ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected) { - DCHECK(pAnnot); - return GetAnnotHandler(pAnnot.Get()) - ->SetIndexSelected(pAnnot, index, selected); -} - -bool CPDFSDK_AnnotHandlerMgr::Annot_IsIndexSelected( - ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index) { - DCHECK(pAnnot); - return GetAnnotHandler(pAnnot.Get())->IsIndexSelected(pAnnot, index); -}
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.h b/fpdfsdk/cpdfsdk_annothandlermgr.h index 54aa63e..0987301 100644 --- a/fpdfsdk/cpdfsdk_annothandlermgr.h +++ b/fpdfsdk/cpdfsdk_annothandlermgr.h
@@ -34,16 +34,6 @@ std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); - WideString Annot_GetText(CPDFSDK_Annot* pAnnot); - WideString Annot_GetSelectedText(CPDFSDK_Annot* pAnnot); - void Annot_ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text); - bool Annot_SelectAllText(CPDFSDK_Annot* pAnnot); - - bool Annot_SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected); - bool Annot_IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, int index); - private: friend class CPDFSDK_BAAnnotHandlerTest;
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index 01428d8..c94fc60 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -395,6 +395,28 @@ return false; } +WideString CPDFSDK_BAAnnot::GetText() { + return WideString(); +} + +WideString CPDFSDK_BAAnnot::GetSelectedText() { + return WideString(); +} + +void CPDFSDK_BAAnnot::ReplaceSelection(const WideString& text) {} + +bool CPDFSDK_BAAnnot::SelectAllText() { + return false; +} + +bool CPDFSDK_BAAnnot::SetIndexSelected(int index, bool selected) { + return false; +} + +bool CPDFSDK_BAAnnot::IsIndexSelected(int index) { + return false; +} + CPDF_Dest CPDFSDK_BAAnnot::GetDestination() const { if (m_pAnnot->GetSubtype() != CPDF_Annot::Subtype::LINK) return CPDF_Dest(nullptr);
diff --git a/fpdfsdk/cpdfsdk_baannot.h b/fpdfsdk/cpdfsdk_baannot.h index c1223ae..383ee8a 100644 --- a/fpdfsdk/cpdfsdk_baannot.h +++ b/fpdfsdk/cpdfsdk_baannot.h
@@ -42,6 +42,12 @@ bool CanRedo() override; bool Undo() override; bool Redo() override; + WideString GetText() override; + WideString GetSelectedText() override; + void ReplaceSelection(const WideString& text) override; + bool SelectAllText() override; + bool SetIndexSelected(int index, bool selected) override; + bool IsIndexSelected(int index) override; virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); virtual bool IsAppearanceValid();
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp index f5ee821..65522fe 100644 --- a/fpdfsdk/cpdfsdk_baannothandler.cpp +++ b/fpdfsdk/cpdfsdk_baannothandler.cpp
@@ -32,30 +32,3 @@ CHECK(pPageView); return std::make_unique<CPDFSDK_BAAnnot>(pAnnot, pPageView); } - -bool CPDFSDK_BAAnnotHandler::SetIndexSelected( - ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected) { - return false; -} - -bool CPDFSDK_BAAnnotHandler::IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index) { - return false; -} - -WideString CPDFSDK_BAAnnotHandler::GetText(CPDFSDK_Annot* pAnnot) { - return WideString(); -} - -WideString CPDFSDK_BAAnnotHandler::GetSelectedText(CPDFSDK_Annot* pAnnot) { - return WideString(); -} - -void CPDFSDK_BAAnnotHandler::ReplaceSelection(CPDFSDK_Annot* pAnnot, - const WideString& text) {} - -bool CPDFSDK_BAAnnotHandler::SelectAllText(CPDFSDK_Annot* pAnnot) { - return false; -}
diff --git a/fpdfsdk/cpdfsdk_baannothandler.h b/fpdfsdk/cpdfsdk_baannothandler.h index 550beba..5030958 100644 --- a/fpdfsdk/cpdfsdk_baannothandler.h +++ b/fpdfsdk/cpdfsdk_baannothandler.h
@@ -24,16 +24,6 @@ // IPDFSDK_AnnotHandler: std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) override; - - WideString GetText(CPDFSDK_Annot* pAnnot) override; - WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override; - void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override; - bool SelectAllText(CPDFSDK_Annot* pAnnot) override; - - bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected) override; - bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, int index) override; }; #endif // FPDFSDK_CPDFSDK_BAANNOTHANDLER_H_
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index 21afa5f..e6daccb 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -206,13 +206,8 @@ #endif // PDF_ENABLE_XFA WideString CPDFSDK_PageView::GetFocusedFormText() { - if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { - CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = - m_pFormFillEnv->GetAnnotHandlerMgr(); - return pAnnotHandlerMgr->Annot_GetText(pAnnot); - } - - return WideString(); + CPDFSDK_Annot* annot = GetFocusAnnot(); + return annot ? annot->GetText() : WideString(); } CPDFSDK_Annot* CPDFSDK_PageView::GetNextAnnot(CPDFSDK_Annot* pAnnot) { @@ -256,30 +251,21 @@ } WideString CPDFSDK_PageView::GetSelectedText() { - if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { - CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = - m_pFormFillEnv->GetAnnotHandlerMgr(); - return pAnnotHandlerMgr->Annot_GetSelectedText(pAnnot); - } - - return WideString(); + CPDFSDK_Annot* annot = GetFocusAnnot(); + if (!annot) + return WideString(); + return annot->GetSelectedText(); } void CPDFSDK_PageView::ReplaceSelection(const WideString& text) { - if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { - CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = - m_pFormFillEnv->GetAnnotHandlerMgr(); - pAnnotHandlerMgr->Annot_ReplaceSelection(pAnnot, text); - } + CPDFSDK_Annot* annot = GetFocusAnnot(); + if (annot) + annot->ReplaceSelection(text); } bool CPDFSDK_PageView::SelectAllText() { CPDFSDK_Annot* annot = GetFocusAnnot(); - if (!annot) - return false; - - CPDFSDK_AnnotHandlerMgr* handler = m_pFormFillEnv->GetAnnotHandlerMgr(); - return handler->Annot_SelectAllText(annot); + return annot && annot->SelectAllText(); } bool CPDFSDK_PageView::CanUndo() { @@ -458,26 +444,13 @@ } bool CPDFSDK_PageView::SetIndexSelected(int index, bool selected) { - if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { - ObservedPtr<CPDFSDK_Annot> pAnnotObserved(pAnnot); - CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = - m_pFormFillEnv->GetAnnotHandlerMgr(); - return pAnnotHandlerMgr->Annot_SetIndexSelected(pAnnotObserved, index, - selected); - } - - return false; + CPDFSDK_Annot* annot = GetFocusAnnot(); + return annot && annot->SetIndexSelected(index, selected); } bool CPDFSDK_PageView::IsIndexSelected(int index) { - if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { - ObservedPtr<CPDFSDK_Annot> pAnnotObserved(pAnnot); - CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = - m_pFormFillEnv->GetAnnotHandlerMgr(); - return pAnnotHandlerMgr->Annot_IsIndexSelected(pAnnotObserved, index); - } - - return false; + CPDFSDK_Annot* annot = GetFocusAnnot(); + return annot && annot->IsIndexSelected(index); } bool CPDFSDK_PageView::OnChar(uint32_t nChar, Mask<FWL_EVENTFLAG> nFlags) {
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index d85fbbc..2346cbf 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -846,6 +846,42 @@ return !IsSignatureWidget() && GetInteractiveFormFiller()->Redo(this); } +WideString CPDFSDK_Widget::GetText() { + if (IsSignatureWidget()) + return WideString(); + return GetInteractiveFormFiller()->GetText(this); +} + +WideString CPDFSDK_Widget::GetSelectedText() { + if (IsSignatureWidget()) + return WideString(); + return GetInteractiveFormFiller()->GetSelectedText(this); +} + +void CPDFSDK_Widget::ReplaceSelection(const WideString& text) { + if (IsSignatureWidget()) + return; + + GetInteractiveFormFiller()->ReplaceSelection(this, text); +} + +bool CPDFSDK_Widget::SelectAllText() { + return !IsSignatureWidget() && + GetInteractiveFormFiller()->SelectAllText(this); +} + +bool CPDFSDK_Widget::SetIndexSelected(int index, bool selected) { + ObservedPtr<CPDFSDK_Widget> observer(this); + return !IsSignatureWidget() && GetInteractiveFormFiller()->SetIndexSelected( + observer, index, selected); +} + +bool CPDFSDK_Widget::IsIndexSelected(int index) { + ObservedPtr<CPDFSDK_Widget> observer(this); + return !IsSignatureWidget() && + GetInteractiveFormFiller()->IsIndexSelected(observer, index); +} + void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CFX_Matrix& mtUser2Device, CPDF_Annot::AppearanceMode mode) {
diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h index 94c5dd3..9d4090b 100644 --- a/fpdfsdk/cpdfsdk_widget.h +++ b/fpdfsdk/cpdfsdk_widget.h
@@ -63,6 +63,12 @@ bool CanRedo() override; bool Undo() override; bool Redo() override; + WideString GetText() override; + WideString GetSelectedText() override; + void ReplaceSelection(const WideString& text) override; + bool SelectAllText() override; + bool SetIndexSelected(int index, bool selected) override; + bool IsIndexSelected(int index) override; void DrawAppearance(CFX_RenderDevice* pDevice, const CFX_Matrix& mtUser2Device, CPDF_Annot::AppearanceMode mode) override;
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index 5e81188..989a7d0 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -45,61 +45,3 @@ pWidget->ResetAppearance(absl::nullopt, CPDFSDK_Widget::kValueUnchanged); return pWidget; } - -bool CPDFSDK_WidgetHandler::SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected) { - ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get())); - return !pWidget->IsSignatureWidget() && - GetFormFillEnvironment()->GetInteractiveFormFiller()->SetIndexSelected( - pWidget, index, selected); -} - -bool CPDFSDK_WidgetHandler::IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index) { - ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get())); - return !pWidget->IsSignatureWidget() && - GetFormFillEnvironment()->GetInteractiveFormFiller()->IsIndexSelected( - pWidget, index); -} - -WideString CPDFSDK_WidgetHandler::GetText(CPDFSDK_Annot* pAnnot) { - CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); - if (pWidget->IsSignatureWidget()) - return WideString(); - - return GetFormFillEnvironment()->GetInteractiveFormFiller()->GetText(pWidget); -} - -WideString CPDFSDK_WidgetHandler::GetSelectedText(CPDFSDK_Annot* pAnnot) { - CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); - if (pWidget->IsSignatureWidget()) - return WideString(); - - return GetFormFillEnvironment()->GetInteractiveFormFiller()->GetSelectedText( - pWidget); -} - -void CPDFSDK_WidgetHandler::ReplaceSelection(CPDFSDK_Annot* pAnnot, - const WideString& text) { - CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); - if (pWidget->IsSignatureWidget()) - return; - - GetFormFillEnvironment()->GetInteractiveFormFiller()->ReplaceSelection( - pWidget, text); -} - -bool CPDFSDK_WidgetHandler::SelectAllText(CPDFSDK_Annot* pAnnot) { - CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); - return !pWidget->IsSignatureWidget() && - GetFormFillEnvironment()->GetInteractiveFormFiller()->SelectAllText( - pWidget); -} - -bool CPDFSDK_WidgetHandler::IsFocusableAnnot( - const CPDF_Annot::Subtype& annot_type) const { - DCHECK_EQ(annot_type, CPDF_Annot::Subtype::WIDGET); - return pdfium::Contains(GetFormFillEnvironment()->GetFocusableAnnotSubtypes(), - annot_type); -}
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h index 1028cc1..793889c 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.h +++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -24,18 +24,6 @@ // IPDFSDK_AnnotHandler: std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) override; - - WideString GetText(CPDFSDK_Annot* pAnnot) override; - WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override; - void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override; - bool SelectAllText(CPDFSDK_Annot* pAnnot) override; - bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected) override; - bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, int index) override; - - private: - bool IsFocusableAnnot(const CPDF_Annot::Subtype& annot_type) const; }; #endif // FPDFSDK_CPDFSDK_WIDGETHANDLER_H_
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp index fb0abd4..202ab42 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
@@ -222,6 +222,39 @@ return widget_handler && widget_handler->Redo(GetXFAFFWidget()); } +WideString CPDFXFA_Widget::GetText() { + CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler(); + if (!widget_handler) + return WideString(); + return widget_handler->GetText(GetXFAFFWidget()); +} + +WideString CPDFXFA_Widget::GetSelectedText() { + CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler(); + if (!widget_handler) + return WideString(); + return widget_handler->GetSelectedText(GetXFAFFWidget()); +} + +void CPDFXFA_Widget::ReplaceSelection(const WideString& text) { + CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler(); + if (widget_handler) + widget_handler->PasteText(GetXFAFFWidget(), text); +} + +bool CPDFXFA_Widget::SelectAllText() { + CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler(); + return widget_handler && widget_handler->SelectAllText(GetXFAFFWidget()); +} + +bool CPDFXFA_Widget::SetIndexSelected(int index, bool selected) { + return false; +} + +bool CPDFXFA_Widget::IsIndexSelected(int index) { + return false; +} + CXFA_FFDocView* CPDFXFA_Widget::GetDocView() { CXFA_FFPageView* page_view = GetXFAFFWidget()->GetPageView(); return page_view ? page_view->GetDocView() : nullptr;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widget.h b/fpdfsdk/fpdfxfa/cpdfxfa_widget.h index 3dbcb4a..7346f8e 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_widget.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_widget.h
@@ -36,6 +36,12 @@ bool CanRedo() override; bool Undo() override; bool Redo() override; + WideString GetText() override; + WideString GetSelectedText() override; + void ReplaceSelection(const WideString& text) override; + bool SelectAllText() override; + bool SetIndexSelected(int index, bool selected) override; + bool IsIndexSelected(int index) override; CXFA_FFWidget* GetXFAFFWidget() const { return m_pXFAFFWidget.Get(); }
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp index 4aab472..bf96e92 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
@@ -208,72 +208,3 @@ CPDFSDK_PageView* pPageView) { return nullptr; } - -WideString CPDFXFA_WidgetHandler::GetText(CPDFSDK_Annot* pAnnot) { - CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot); - CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(); - return pWidgetHandler->GetText(pXFAWidget->GetXFAFFWidget()); -} - -WideString CPDFXFA_WidgetHandler::GetSelectedText(CPDFSDK_Annot* pAnnot) { - CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot); - CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(); - return pWidgetHandler->GetSelectedText(pXFAWidget->GetXFAFFWidget()); -} - -void CPDFXFA_WidgetHandler::ReplaceSelection(CPDFSDK_Annot* pAnnot, - const WideString& text) { - CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot); - CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(); - return pWidgetHandler->PasteText(pXFAWidget->GetXFAFFWidget(), text); -} - -bool CPDFXFA_WidgetHandler::SelectAllText(CPDFSDK_Annot* pAnnot) { - CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot); - CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(); - return pWidgetHandler->SelectAllText(pXFAWidget->GetXFAFFWidget()); -} - -bool CPDFXFA_WidgetHandler::SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected) { - return false; -} - -bool CPDFXFA_WidgetHandler::IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index) { - return false; -} - -CXFA_FFWidgetHandler* CPDFXFA_WidgetHandler::GetXFAFFWidgetHandler() { - auto* pDoc = static_cast<CPDFXFA_Context*>( - GetFormFillEnvironment()->GetDocExtension()); - if (!pDoc) - return nullptr; - - CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); - if (!pDocView) - return nullptr; - - return pDocView->GetWidgetHandler(); -} - -Mask<XFA_FWL_KeyFlag> CPDFXFA_WidgetHandler::GetKeyFlags( - Mask<FWL_EVENTFLAG> dwFlag) { - Mask<XFA_FWL_KeyFlag> dwFWLFlag; - - if (dwFlag & FWL_EVENTFLAG_ControlKey) - dwFWLFlag |= XFA_FWL_KeyFlag::kCtrl; - if (dwFlag & FWL_EVENTFLAG_LeftButtonDown) - dwFWLFlag |= XFA_FWL_KeyFlag::kLButton; - if (dwFlag & FWL_EVENTFLAG_MiddleButtonDown) - dwFWLFlag |= XFA_FWL_KeyFlag::kMButton; - if (dwFlag & FWL_EVENTFLAG_RightButtonDown) - dwFWLFlag |= XFA_FWL_KeyFlag::kRButton; - if (dwFlag & FWL_EVENTFLAG_ShiftKey) - dwFWLFlag |= XFA_FWL_KeyFlag::kShift; - if (dwFlag & FWL_EVENTFLAG_AltKey) - dwFWLFlag |= XFA_FWL_KeyFlag::kAlt; - - return dwFWLFlag; -}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h index 81269b9..d75bdb4 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
@@ -17,7 +17,6 @@ class CPDF_Annot; class CPDFSDK_Annot; class CPDFSDK_PageView; -class CXFA_FFWidgetHandler; class CPDFXFA_WidgetHandler final : public IPDFSDK_AnnotHandler { public: @@ -27,19 +26,6 @@ // IPDFSDK_AnnotHandler: std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) override; - - WideString GetText(CPDFSDK_Annot* pAnnot) override; - WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override; - void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override; - bool SelectAllText(CPDFSDK_Annot* pAnnot) override; - bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected) override; - bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, int index) override; - - private: - CXFA_FFWidgetHandler* GetXFAFFWidgetHandler(); - Mask<XFA_FWL_KeyFlag> GetKeyFlags(Mask<FWL_EVENTFLAG> dwFlag); }; #endif // FPDFSDK_FPDFXFA_CPDFXFA_WIDGETHANDLER_H_
diff --git a/fpdfsdk/ipdfsdk_annothandler.h b/fpdfsdk/ipdfsdk_annothandler.h index ed90bd9..1796e54 100644 --- a/fpdfsdk/ipdfsdk_annothandler.h +++ b/fpdfsdk/ipdfsdk_annothandler.h
@@ -37,17 +37,6 @@ CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) = 0; - virtual WideString GetText(CPDFSDK_Annot* pAnnot) = 0; - virtual WideString GetSelectedText(CPDFSDK_Annot* pAnnot) = 0; - virtual void ReplaceSelection(CPDFSDK_Annot* pAnnot, - const WideString& text) = 0; - virtual bool SelectAllText(CPDFSDK_Annot* pAnnot) = 0; - virtual bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index, - bool selected) = 0; - virtual bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, - int index) = 0; - private: UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv; };