Centralize SetFormFillEnvironment() in IPDFSDK_AnnotHandler.
Make it the one true path for annot handlers to find the form
fill environment.
Change-Id: Iecbf11ec158acb330b5d752eb1a8c0b04e199442
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85150
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index 581ffd3..748f43f 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -67,6 +67,7 @@
"fpdf_thumbnail.cpp",
"fpdf_transformpage.cpp",
"fpdf_view.cpp",
+ "ipdfsdk_annothandler.cpp",
"ipdfsdk_annothandler.h",
]
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp
index c8ad3b1..26fdbd4 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.cpp
+++ b/fpdfsdk/cpdfsdk_baannothandler.cpp
@@ -44,11 +44,6 @@
CPDFSDK_BAAnnotHandler::~CPDFSDK_BAAnnotHandler() = default;
-void CPDFSDK_BAAnnotHandler::SetFormFillEnvironment(
- CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- form_fill_environment_ = pFormFillEnv;
-}
-
bool CPDFSDK_BAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
return false;
}
@@ -83,7 +78,7 @@
}
if (is_annotation_focused_ && IsFocusableAnnot(annot_type) &&
- pAnnot == form_fill_environment_->GetFocusAnnot()) {
+ pAnnot == GetFormFillEnvironment()->GetFocusAnnot()) {
CFX_FloatRect view_bounding_box =
GetViewBBox(pPageView, pAnnot->AsBAAnnot());
if (view_bounding_box.IsEmpty())
@@ -191,12 +186,12 @@
CPDF_Action action = ba_annot->GetAAction(CPDF_AAction::kKeyStroke);
if (action.GetDict()) {
- return form_fill_environment_->GetActionHandler()->DoAction_Link(
- action, CPDF_AAction::kKeyStroke, form_fill_environment_.Get(), nFlag);
+ return GetFormFillEnvironment()->GetActionHandler()->DoAction_Link(
+ action, CPDF_AAction::kKeyStroke, GetFormFillEnvironment(), nFlag);
}
- return form_fill_environment_->GetActionHandler()->DoAction_Destination(
- ba_annot->GetDestination(), form_fill_environment_.Get());
+ return GetFormFillEnvironment()->GetActionHandler()->DoAction_Destination(
+ ba_annot->GetDestination(), GetFormFillEnvironment());
}
bool CPDFSDK_BAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
@@ -211,7 +206,7 @@
const CPDF_Annot::Subtype& annot_type) const {
DCHECK(annot_type != CPDF_Annot::Subtype::WIDGET);
- return pdfium::Contains(form_fill_environment_->GetFocusableAnnotSubtypes(),
+ return pdfium::Contains(GetFormFillEnvironment()->GetFocusableAnnotSubtypes(),
annot_type);
}
@@ -223,7 +218,7 @@
view_bounding_box.Inflate(1, 1);
view_bounding_box.Normalize();
FX_RECT rect = view_bounding_box.GetOuterRect();
- form_fill_environment_->Invalidate(ba_annot->GetPage(), rect);
+ GetFormFillEnvironment()->Invalidate(ba_annot->GetPage(), rect);
}
}
diff --git a/fpdfsdk/cpdfsdk_baannothandler.h b/fpdfsdk/cpdfsdk_baannothandler.h
index 1c306c1..8013632 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.h
+++ b/fpdfsdk/cpdfsdk_baannothandler.h
@@ -10,13 +10,11 @@
#include <memory>
#include "core/fxcrt/fx_coordinates.h"
-#include "core/fxcrt/unowned_ptr.h"
#include "fpdfsdk/ipdfsdk_annothandler.h"
class CFX_Matrix;
class CFX_RenderDevice;
class CPDF_Annot;
-class CPDFSDK_FormFillEnvironment;
class CPDFSDK_Annot;
class CPDFSDK_PageView;
@@ -26,8 +24,6 @@
~CPDFSDK_BAAnnotHandler() override;
// IPDFSDK_AnnotHandler:
- void SetFormFillEnvironment(
- CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
bool CanAnswer(CPDFSDK_Annot* pAnnot) override;
std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot,
CPDFSDK_PageView* pPageView) override;
@@ -113,7 +109,6 @@
void InvalidateRect(CPDFSDK_Annot* annot);
bool IsFocusableAnnot(const CPDF_Annot::Subtype& annot_type) const;
- UnownedPtr<CPDFSDK_FormFillEnvironment> form_fill_environment_;
bool is_annotation_focused_ = false;
};
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 1be5b62..662c773 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -28,11 +28,6 @@
CPDFSDK_WidgetHandler::~CPDFSDK_WidgetHandler() = default;
-void CPDFSDK_WidgetHandler::SetFormFillEnvironment(
- CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- m_pFormFillEnv = pFormFillEnv;
-}
-
bool CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
if (pWidget->IsSignatureWidget())
@@ -57,7 +52,8 @@
std::unique_ptr<CPDFSDK_Annot> CPDFSDK_WidgetHandler::NewAnnot(
CPDF_Annot* pAnnot,
CPDFSDK_PageView* pPageView) {
- CPDFSDK_InteractiveForm* pForm = m_pFormFillEnv->GetInteractiveForm();
+ CPDFSDK_InteractiveForm* pForm =
+ GetFormFillEnvironment()->GetInteractiveForm();
CPDF_InteractiveForm* pPDFForm = pForm->GetInteractiveForm();
CPDF_FormControl* pCtrl = pPDFForm->GetControlByDict(pAnnot->GetAnnotDict());
if (!pCtrl)
@@ -73,7 +69,7 @@
void CPDFSDK_WidgetHandler::ReleaseAnnot(
std::unique_ptr<CPDFSDK_Annot> pAnnot) {
DCHECK(pAnnot);
- m_pFormFillEnv->GetInteractiveFormFiller()->OnDelete(pAnnot.get());
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnDelete(pAnnot.get());
std::unique_ptr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.release()));
CPDFSDK_InteractiveForm* pForm = pWidget->GetInteractiveForm();
@@ -90,8 +86,8 @@
pAnnot->AsBAAnnot()->DrawAppearance(
pDevice, mtUser2Device, CPDF_Annot::AppearanceMode::kNormal, nullptr);
} else {
- m_pFormFillEnv->GetInteractiveFormFiller()->OnDraw(pPageView, pAnnot,
- pDevice, mtUser2Device);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnDraw(
+ pPageView, pAnnot, pDevice, mtUser2Device);
}
}
@@ -99,8 +95,8 @@
ObservedPtr<CPDFSDK_Annot>* pAnnot,
Mask<FWL_EVENTFLAG> nFlag) {
if (!(*pAnnot)->IsSignatureWidget()) {
- m_pFormFillEnv->GetInteractiveFormFiller()->OnMouseEnter(pPageView, pAnnot,
- nFlag);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseEnter(
+ pPageView, pAnnot, nFlag);
}
}
@@ -108,8 +104,8 @@
ObservedPtr<CPDFSDK_Annot>* pAnnot,
Mask<FWL_EVENTFLAG> nFlag) {
if (!(*pAnnot)->IsSignatureWidget()) {
- m_pFormFillEnv->GetInteractiveFormFiller()->OnMouseExit(pPageView, pAnnot,
- nFlag);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseExit(
+ pPageView, pAnnot, nFlag);
}
}
@@ -118,7 +114,7 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnLButtonDown(
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonDown(
pPageView, pAnnot, nFlags, point);
}
@@ -127,7 +123,7 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnLButtonUp(
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonUp(
pPageView, pAnnot, nFlags, point);
}
@@ -136,7 +132,7 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnLButtonDblClk(
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonDblClk(
pPageView, pAnnot, nFlags, point);
}
@@ -145,7 +141,7 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnMouseMove(
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseMove(
pPageView, pAnnot, nFlags, point);
}
@@ -155,7 +151,7 @@
const CFX_PointF& point,
const CFX_Vector& delta) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnMouseWheel(
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseWheel(
pPageView, pAnnot, nFlags, point, delta);
}
@@ -164,7 +160,7 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnRButtonDown(
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnRButtonDown(
pPageView, pAnnot, nFlags, point);
}
@@ -173,7 +169,7 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnRButtonUp(
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnRButtonUp(
pPageView, pAnnot, nFlags, point);
}
@@ -188,16 +184,16 @@
uint32_t nChar,
Mask<FWL_EVENTFLAG> nFlags) {
return !pAnnot->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnChar(pAnnot, nChar,
- nFlags);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnChar(
+ pAnnot, nChar, nFlags);
}
bool CPDFSDK_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
FWL_VKEYCODE nKeyCode,
Mask<FWL_EVENTFLAG> nFlag) {
return !pAnnot->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->OnKeyDown(pAnnot, nKeyCode,
- nFlag);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnKeyDown(
+ pAnnot, nKeyCode, nFlag);
}
bool CPDFSDK_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
@@ -227,8 +223,7 @@
}
#ifdef PDF_ENABLE_XFA
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
- auto* pContext = pPageView->GetFormFillEnv()->GetDocExtension();
+ auto* pContext = GetFormFillEnvironment()->GetDocExtension();
if (pContext && pContext->ContainsExtensionForegroundForm()) {
if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
pWidget->ResetXFAAppearance(CPDFSDK_Widget::kValueUnchanged);
@@ -242,7 +237,8 @@
return false;
return (*pAnnot)->IsSignatureWidget() ||
- m_pFormFillEnv->GetInteractiveFormFiller()->OnSetFocus(pAnnot, nFlag);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnSetFocus(
+ pAnnot, nFlag);
}
bool CPDFSDK_WidgetHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
@@ -251,75 +247,84 @@
return false;
return (*pAnnot)->IsSignatureWidget() ||
- m_pFormFillEnv->GetInteractiveFormFiller()->OnKillFocus(pAnnot, nFlag);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnKillFocus(
+ pAnnot, nFlag);
}
bool CPDFSDK_WidgetHandler::SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
int index,
bool selected) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->SetIndexSelected(
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->SetIndexSelected(
pAnnot, index, selected);
}
bool CPDFSDK_WidgetHandler::IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
int index) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->IsIndexSelected(pAnnot,
- index);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->IsIndexSelected(
+ pAnnot, index);
}
CFX_FloatRect CPDFSDK_WidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot) {
if (!pAnnot->IsSignatureWidget()) {
return CFX_FloatRect(
- m_pFormFillEnv->GetInteractiveFormFiller()->GetViewBBox(pPageView,
- pAnnot));
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->GetViewBBox(
+ pPageView, pAnnot));
}
return CFX_FloatRect();
}
WideString CPDFSDK_WidgetHandler::GetText(CPDFSDK_Annot* pAnnot) {
- if (!pAnnot->IsSignatureWidget())
- return m_pFormFillEnv->GetInteractiveFormFiller()->GetText(pAnnot);
+ if (!pAnnot->IsSignatureWidget()) {
+ return GetFormFillEnvironment()->GetInteractiveFormFiller()->GetText(
+ pAnnot);
+ }
return WideString();
}
WideString CPDFSDK_WidgetHandler::GetSelectedText(CPDFSDK_Annot* pAnnot) {
- if (!pAnnot->IsSignatureWidget())
- return m_pFormFillEnv->GetInteractiveFormFiller()->GetSelectedText(pAnnot);
+ if (!pAnnot->IsSignatureWidget()) {
+ return GetFormFillEnvironment()
+ ->GetInteractiveFormFiller()
+ ->GetSelectedText(pAnnot);
+ }
return WideString();
}
void CPDFSDK_WidgetHandler::ReplaceSelection(CPDFSDK_Annot* pAnnot,
const WideString& text) {
- if (!pAnnot->IsSignatureWidget())
- m_pFormFillEnv->GetInteractiveFormFiller()->ReplaceSelection(pAnnot, text);
+ if (!pAnnot->IsSignatureWidget()) {
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->ReplaceSelection(
+ pAnnot, text);
+ }
}
bool CPDFSDK_WidgetHandler::SelectAllText(CPDFSDK_Annot* pAnnot) {
return !pAnnot->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->SelectAllText(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->SelectAllText(
+ pAnnot);
}
bool CPDFSDK_WidgetHandler::CanUndo(CPDFSDK_Annot* pAnnot) {
return !pAnnot->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->CanUndo(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->CanUndo(pAnnot);
}
bool CPDFSDK_WidgetHandler::CanRedo(CPDFSDK_Annot* pAnnot) {
return !pAnnot->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->CanRedo(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->CanRedo(pAnnot);
}
bool CPDFSDK_WidgetHandler::Undo(CPDFSDK_Annot* pAnnot) {
return !pAnnot->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->Undo(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->Undo(pAnnot);
}
bool CPDFSDK_WidgetHandler::Redo(CPDFSDK_Annot* pAnnot) {
return !pAnnot->IsSignatureWidget() &&
- m_pFormFillEnv->GetInteractiveFormFiller()->Redo(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->Redo(pAnnot);
}
bool CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
@@ -333,7 +338,6 @@
bool CPDFSDK_WidgetHandler::IsFocusableAnnot(
const CPDF_Annot::Subtype& annot_type) const {
DCHECK_EQ(annot_type, CPDF_Annot::Subtype::WIDGET);
-
- return pdfium::Contains(m_pFormFillEnv->GetFocusableAnnotSubtypes(),
+ return pdfium::Contains(GetFormFillEnvironment()->GetFocusableAnnotSubtypes(),
annot_type);
}
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h
index ee1aa63..452d77d 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -10,14 +10,12 @@
#include <memory>
#include "core/fxcrt/fx_coordinates.h"
-#include "core/fxcrt/unowned_ptr.h"
#include "fpdfsdk/ipdfsdk_annothandler.h"
class CFX_Matrix;
class CFX_RenderDevice;
class CPDF_Annot;
class CPDFSDK_Annot;
-class CPDFSDK_FormFillEnvironment;
class CPDFSDK_PageView;
class CPDFSDK_WidgetHandler final : public IPDFSDK_AnnotHandler {
@@ -25,8 +23,6 @@
CPDFSDK_WidgetHandler();
~CPDFSDK_WidgetHandler() override;
- void SetFormFillEnvironment(
- CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
bool CanAnswer(CPDFSDK_Annot* pAnnot) override;
std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot,
CPDFSDK_PageView* pPageView) override;
@@ -110,8 +106,6 @@
private:
bool IsFocusableAnnot(const CPDF_Annot::Subtype& annot_type) const;
-
- UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
};
#endif // FPDFSDK_CPDFSDK_WIDGETHANDLER_H_
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
index 7350cb7..6da2e4a 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
@@ -204,9 +204,6 @@
CPDFXFA_WidgetHandler::~CPDFXFA_WidgetHandler() = default;
-void CPDFXFA_WidgetHandler::SetFormFillEnvironment(
- CPDFSDK_FormFillEnvironment* pFormFillEnv) {}
-
bool CPDFXFA_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
CPDFXFA_Widget* pWidget = ToXFAWidget(pAnnot);
return pWidget && pWidget->GetXFAFFWidget();
@@ -233,7 +230,7 @@
DCHECK(pXFAWidget);
bool bIsHighlight = false;
- if (pPageView->GetFormFillEnv()->GetFocusAnnot() != pAnnot)
+ if (GetFormFillEnvironment()->GetFocusAnnot() != pAnnot)
bIsHighlight = true;
CFGAS_GEGraphics gs(pDevice);
@@ -348,12 +345,8 @@
if (!pXFAWidget)
return false;
- CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv();
- if (!pFormFillEnv)
- return false;
-
- auto* pContext =
- static_cast<CPDFXFA_Context*>(pFormFillEnv->GetDocExtension());
+ auto* pContext = static_cast<CPDFXFA_Context*>(
+ GetFormFillEnvironment()->GetDocExtension());
if (!pContext)
return false;
@@ -631,12 +624,8 @@
if (!pAnnot)
return nullptr;
- CPDFSDK_FormFillEnvironment* pFormFillEnv =
- pAnnot->GetPageView()->GetFormFillEnv();
- if (!pFormFillEnv)
- return nullptr;
-
- auto* pDoc = static_cast<CPDFXFA_Context*>(pFormFillEnv->GetDocExtension());
+ auto* pDoc = static_cast<CPDFXFA_Context*>(
+ GetFormFillEnvironment()->GetDocExtension());
if (!pDoc)
return nullptr;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
index 4f42554..47bf3ec 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
@@ -17,7 +17,6 @@
class CFX_Matrix;
class CFX_RenderDevice;
class CPDF_Annot;
-class CPDFSDK_FormFillEnvironment;
class CPDFSDK_Annot;
class CPDFSDK_PageView;
class CXFA_FFWidget;
@@ -29,8 +28,6 @@
~CPDFXFA_WidgetHandler() override;
// IPDFSDK_AnnotHandler:
- void SetFormFillEnvironment(
- CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
bool CanAnswer(CPDFSDK_Annot* pAnnot) override;
std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot,
CPDFSDK_PageView* pPageView) override;
diff --git a/fpdfsdk/ipdfsdk_annothandler.cpp b/fpdfsdk/ipdfsdk_annothandler.cpp
new file mode 100644
index 0000000..3662fbe
--- /dev/null
+++ b/fpdfsdk/ipdfsdk_annothandler.cpp
@@ -0,0 +1,11 @@
+// Copyright 2021 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fpdfsdk/ipdfsdk_annothandler.h"
+
+IPDFSDK_AnnotHandler::IPDFSDK_AnnotHandler() = default;
+
+IPDFSDK_AnnotHandler::~IPDFSDK_AnnotHandler() = default;
diff --git a/fpdfsdk/ipdfsdk_annothandler.h b/fpdfsdk/ipdfsdk_annothandler.h
index 563b1b8..13cf286 100644
--- a/fpdfsdk/ipdfsdk_annothandler.h
+++ b/fpdfsdk/ipdfsdk_annothandler.h
@@ -11,6 +11,8 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/mask.h"
+#include "core/fxcrt/observed_ptr.h"
+#include "core/fxcrt/unowned_ptr.h"
#include "fpdfsdk/cpdfsdk_annot.h"
#include "fpdfsdk/pwl/cpwl_wnd.h"
#include "public/fpdf_fwlevent.h"
@@ -23,10 +25,16 @@
class IPDFSDK_AnnotHandler {
public:
- virtual ~IPDFSDK_AnnotHandler() = default;
+ IPDFSDK_AnnotHandler();
+ virtual ~IPDFSDK_AnnotHandler();
- virtual void SetFormFillEnvironment(
- CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
+ void SetFormFillEnvironment(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pFormFillEnv = pFormFillEnv;
+ }
+ CPDFSDK_FormFillEnvironment* GetFormFillEnvironment() const {
+ return m_pFormFillEnv.Get();
+ }
+
virtual bool CanAnswer(CPDFSDK_Annot* pAnnot) = 0;
virtual std::unique_ptr<CPDFSDK_Annot> NewAnnot(
CPDF_Annot* pAnnot,
@@ -109,6 +117,9 @@
bool selected) = 0;
virtual bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
int index) = 0;
+
+ private:
+ UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
};
#endif // FPDFSDK_IPDFSDK_ANNOTHANDLER_H_