Translate to CPDFSDK_Widget before invoking CFFL.
Prevent CFFL from seeing the CPDFSDK_Annot superclass, since CFFL
can't do anything with it anyways. This also gives the widget
handler some purpose other than just proxying a call to CFFL.
There's a small penalty in making a second observer to get type
correctness. Theoretically we should be able to get rid of this
since we've got leftmost superclasses and casting wouldn't have
to compute new addresses.
Change-Id: I5cfa728bb9498c35e7e5ae5af50c88304f534354
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85411
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index dff2596..039e4bc 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -71,9 +71,9 @@
void CPDFSDK_WidgetHandler::ReleaseAnnot(
std::unique_ptr<CPDFSDK_Annot> pAnnot) {
DCHECK(pAnnot);
- GetFormFillEnvironment()->GetInteractiveFormFiller()->OnDelete(pAnnot.get());
-
std::unique_ptr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.release()));
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->OnDelete(pWidget.get());
+
CPDFSDK_InteractiveForm* pForm = pWidget->GetInteractiveForm();
CPDF_FormControl* pControl = pWidget->GetFormControl();
pForm->RemoveMap(pControl);
@@ -95,84 +95,84 @@
void CPDFSDK_WidgetHandler::OnMouseEnter(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlag) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
if (!pWidget->IsSignatureWidget()) {
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseEnter(
- pAnnot->GetPageView(), pAnnot, nFlag);
+ pWidget->GetPageView(), pWidget, nFlag);
}
}
void CPDFSDK_WidgetHandler::OnMouseExit(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlag) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
if (!pWidget->IsSignatureWidget()) {
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseExit(
- pAnnot->GetPageView(), pAnnot, nFlag);
+ pWidget->GetPageView(), pWidget, nFlag);
}
}
bool CPDFSDK_WidgetHandler::OnLButtonDown(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonDown(
- pAnnot->GetPageView(), pAnnot, nFlags, point);
+ pWidget->GetPageView(), pWidget, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnLButtonUp(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonUp(
- pAnnot->GetPageView(), pAnnot, nFlags, point);
+ pWidget->GetPageView(), pWidget, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonDblClk(
- pAnnot->GetPageView(), pAnnot, nFlags, point);
+ pWidget->GetPageView(), pWidget, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnMouseMove(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseMove(
- pAnnot->GetPageView(), pAnnot, nFlags, point);
+ pWidget->GetPageView(), pWidget, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnMouseWheel(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point,
const CFX_Vector& delta) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseWheel(
- pAnnot->GetPageView(), pAnnot, nFlags, point, delta);
+ pWidget->GetPageView(), pWidget, nFlags, point, delta);
}
bool CPDFSDK_WidgetHandler::OnRButtonDown(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnRButtonDown(
- pAnnot->GetPageView(), pAnnot, nFlags, point);
+ pWidget->GetPageView(), pWidget, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnRButtonUp(ObservedPtr<CPDFSDK_Annot>& pAnnot,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnRButtonUp(
- pAnnot->GetPageView(), pAnnot, nFlags, point);
+ pWidget->GetPageView(), pWidget, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnRButtonDblClk(ObservedPtr<CPDFSDK_Annot>& pAnnot,
@@ -187,7 +187,7 @@
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnChar(
- pAnnot, nChar, nFlags);
+ pWidget, nChar, nFlags);
}
bool CPDFSDK_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
@@ -196,7 +196,7 @@
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnKeyDown(
- pAnnot, nKeyCode, nFlag);
+ pWidget, nKeyCode, nFlag);
}
bool CPDFSDK_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
@@ -239,10 +239,10 @@
if (!IsFocusableAnnot(pAnnot->GetPDFAnnot()->GetSubtype()))
return false;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return pWidget->IsSignatureWidget() ||
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnSetFocus(
- pAnnot, nFlag);
+ pWidget, nFlag);
}
bool CPDFSDK_WidgetHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot,
@@ -250,27 +250,27 @@
if (!IsFocusableAnnot(pAnnot->GetPDFAnnot()->GetSubtype()))
return false;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return pWidget->IsSignatureWidget() ||
GetFormFillEnvironment()->GetInteractiveFormFiller()->OnKillFocus(
- pAnnot, nFlag);
+ pWidget, nFlag);
}
bool CPDFSDK_WidgetHandler::SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot,
int index,
bool selected) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->SetIndexSelected(
- pAnnot, index, selected);
+ pWidget, index, selected);
}
bool CPDFSDK_WidgetHandler::IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot,
int index) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
+ ObservedPtr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.Get()));
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->IsIndexSelected(
- pAnnot, index);
+ pWidget, index);
}
CFX_FloatRect CPDFSDK_WidgetHandler::GetViewBBox(CPDFSDK_Annot* pAnnot) {
@@ -280,7 +280,7 @@
return CFX_FloatRect(
GetFormFillEnvironment()->GetInteractiveFormFiller()->GetViewBBox(
- pAnnot->GetPageView(), pAnnot));
+ pWidget->GetPageView(), pWidget));
}
WideString CPDFSDK_WidgetHandler::GetText(CPDFSDK_Annot* pAnnot) {
@@ -288,7 +288,7 @@
if (pWidget->IsSignatureWidget())
return WideString();
- return GetFormFillEnvironment()->GetInteractiveFormFiller()->GetText(pAnnot);
+ return GetFormFillEnvironment()->GetInteractiveFormFiller()->GetText(pWidget);
}
WideString CPDFSDK_WidgetHandler::GetSelectedText(CPDFSDK_Annot* pAnnot) {
@@ -297,7 +297,7 @@
return WideString();
return GetFormFillEnvironment()->GetInteractiveFormFiller()->GetSelectedText(
- pAnnot);
+ pWidget);
}
void CPDFSDK_WidgetHandler::ReplaceSelection(CPDFSDK_Annot* pAnnot,
@@ -306,39 +306,39 @@
if (pWidget->IsSignatureWidget())
return;
- GetFormFillEnvironment()->GetInteractiveFormFiller()->ReplaceSelection(pAnnot,
- text);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->ReplaceSelection(
+ pWidget, text);
}
bool CPDFSDK_WidgetHandler::SelectAllText(CPDFSDK_Annot* pAnnot) {
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
return !pWidget->IsSignatureWidget() &&
GetFormFillEnvironment()->GetInteractiveFormFiller()->SelectAllText(
- pAnnot);
+ pWidget);
}
bool CPDFSDK_WidgetHandler::CanUndo(CPDFSDK_Annot* pAnnot) {
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
return !pWidget->IsSignatureWidget() &&
- GetFormFillEnvironment()->GetInteractiveFormFiller()->CanUndo(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->CanUndo(pWidget);
}
bool CPDFSDK_WidgetHandler::CanRedo(CPDFSDK_Annot* pAnnot) {
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
return !pWidget->IsSignatureWidget() &&
- GetFormFillEnvironment()->GetInteractiveFormFiller()->CanRedo(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->CanRedo(pWidget);
}
bool CPDFSDK_WidgetHandler::Undo(CPDFSDK_Annot* pAnnot) {
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
return !pWidget->IsSignatureWidget() &&
- GetFormFillEnvironment()->GetInteractiveFormFiller()->Undo(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->Undo(pWidget);
}
bool CPDFSDK_WidgetHandler::Redo(CPDFSDK_Annot* pAnnot) {
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
return !pWidget->IsSignatureWidget() &&
- GetFormFillEnvironment()->GetInteractiveFormFiller()->Redo(pAnnot);
+ GetFormFillEnvironment()->GetInteractiveFormFiller()->Redo(pWidget);
}
bool CPDFSDK_WidgetHandler::HitTest(CPDFSDK_Annot* pAnnot,
diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp
index 59c2ea6..5584402 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.cpp
+++ b/fpdfsdk/formfiller/cffl_checkbox.cpp
@@ -51,7 +51,7 @@
CPDFSDK_PageView* pPageView = pWidget->GetPageView();
DCHECK(pPageView);
- ObservedPtr<CPDFSDK_Annot> pObserved(m_pWidget.Get());
+ ObservedPtr<CPDFSDK_Widget> pObserved(m_pWidget.Get());
if (m_pFormFiller->OnButtonUp(pObserved, pPageView, nFlags)) {
if (!pObserved)
m_pWidget = nullptr;
diff --git a/fpdfsdk/formfiller/cffl_formfield.cpp b/fpdfsdk/formfiller/cffl_formfield.cpp
index c67f0ec..603552d 100644
--- a/fpdfsdk/formfiller/cffl_formfield.cpp
+++ b/fpdfsdk/formfiller/cffl_formfield.cpp
@@ -464,7 +464,7 @@
if (!IsDataChanged(pPageView))
return true;
- ObservedPtr<CPDFSDK_Annot> pObserved(m_pWidget.Get());
+ ObservedPtr<CPDFSDK_Widget> pObserved(m_pWidget.Get());
if (!m_pFormFiller->OnKeyStrokeCommit(pObserved, pPageView, nFlag)) {
if (!pObserved)
return false;
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index 91f17c4..8d7cc1e 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -33,20 +33,20 @@
CFFL_InteractiveFormFiller::~CFFL_InteractiveFormFiller() = default;
-bool CFFL_InteractiveFormFiller::Annot_HitTest(const CPDFSDK_Annot* pAnnot,
+bool CFFL_InteractiveFormFiller::Annot_HitTest(const CPDFSDK_Widget* pWidget,
const CFX_PointF& point) {
- return pAnnot->GetRect().Contains(point);
+ return pWidget->GetRect().Contains(point);
}
FX_RECT CFFL_InteractiveFormFiller::GetViewBBox(
const CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {
- if (CFFL_FormField* pFormField = GetFormField(pAnnot))
+ CPDFSDK_Widget* pWidget) {
+ if (CFFL_FormField* pFormField = GetFormField(pWidget))
return pFormField->GetViewBBox(pPageView);
DCHECK(pPageView);
- CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
+ CPDF_Annot* pPDFAnnot = pWidget->GetPDFAnnot();
CFX_FloatRect rcWin = pPDFAnnot->GetRect();
if (!rcWin.IsEmpty()) {
rcWin.Inflate(1, 1);
@@ -56,18 +56,17 @@
}
void CFFL_InteractiveFormFiller::OnDraw(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
+ CPDFSDK_Widget* pWidget,
CFX_RenderDevice* pDevice,
const CFX_Matrix& mtUser2Device) {
DCHECK(pPageView);
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
if (!IsVisible(pWidget))
return;
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+ CFFL_FormField* pFormField = GetFormField(pWidget);
if (pFormField && pFormField->IsValid()) {
pFormField->OnDraw(pPageView, pWidget, pDevice, mtUser2Device);
- if (m_pCallbackIface->GetFocusAnnot() != pAnnot)
+ if (m_pCallbackIface->GetFocusAnnot() != pWidget)
return;
CFX_FloatRect rcFocus = pFormField->GetFocusBox(pPageView);
@@ -90,17 +89,15 @@
pWidget->DrawShadow(pDevice, pPageView);
}
-void CFFL_InteractiveFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) {
- UnregisterFormField(pAnnot);
+void CFFL_InteractiveFormFiller::OnDelete(CPDFSDK_Widget* pWidget) {
+ UnregisterFormField(pWidget);
}
void CFFL_InteractiveFormFiller::OnMouseEnter(
CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlag) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (pWidget->GetAAction(CPDF_AAction::kCursorEnter).GetDict()) {
uint32_t nValueAge = pWidget->GetValueAge();
pWidget->ClearAppModified();
@@ -114,26 +111,26 @@
fa.bShift = CPWL_Wnd::IsSHIFTKeyDown(nFlag);
pWidget->OnAAction(CPDF_AAction::kCursorEnter, &fa, pPageView);
}
- if (!pAnnot)
+ if (!pWidget)
return;
if (pWidget->IsAppModified()) {
- CFFL_FormField* pFormField = GetFormField(pWidget);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
if (pFormField)
- pFormField->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ pFormField->ResetPWLWindowForValueAge(pPageView, pWidget.Get(),
+ nValueAge);
}
}
}
- if (CFFL_FormField* pFormField = GetOrCreateFormField(pAnnot.Get()))
+ if (CFFL_FormField* pFormField = GetOrCreateFormField(pWidget.Get()))
pFormField->OnMouseEnter(pPageView);
}
-void CFFL_InteractiveFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
- Mask<FWL_EVENTFLAG> nFlag) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
+void CFFL_InteractiveFormFiller::OnMouseExit(
+ CPDFSDK_PageView* pPageView,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ Mask<FWL_EVENTFLAG> nFlag) {
if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (pWidget->GetAAction(CPDF_AAction::kCursorExit).GetDict()) {
uint32_t nValueAge = pWidget->GetValueAge();
pWidget->ClearAppModified();
@@ -147,29 +144,29 @@
fa.bShift = CPWL_Wnd::IsSHIFTKeyDown(nFlag);
pWidget->OnAAction(CPDF_AAction::kCursorExit, &fa, pPageView);
}
- if (!pAnnot)
+ if (!pWidget)
return;
if (pWidget->IsAppModified()) {
- CFFL_FormField* pFormField = GetFormField(pWidget);
- if (pFormField)
- pFormField->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
+ if (pFormField) {
+ pFormField->ResetPWLWindowForValueAge(pPageView, pWidget.Get(),
+ nValueAge);
+ }
}
}
}
- if (CFFL_FormField* pFormField = GetFormField(pAnnot.Get()))
+ if (CFFL_FormField* pFormField = GetFormField(pWidget.Get()))
pFormField->OnMouseExit(pPageView);
}
bool CFFL_InteractiveFormFiller::OnLButtonDown(
CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
- if (Annot_HitTest(pAnnot.Get(), point) &&
+ if (Annot_HitTest(pWidget.Get(), point) &&
pWidget->GetAAction(CPDF_AAction::kButtonDown).GetDict()) {
uint32_t nValueAge = pWidget->GetValueAge();
pWidget->ClearAppModified();
@@ -183,38 +180,37 @@
fa.bShift = CPWL_Wnd::IsSHIFTKeyDown(nFlags);
pWidget->OnAAction(CPDF_AAction::kButtonDown, &fa, pPageView);
}
- if (!pAnnot)
+ if (!pWidget)
return true;
- if (!IsValidAnnot(pPageView, pAnnot.Get()))
+ if (!IsValidAnnot(pPageView, pWidget.Get()))
return true;
if (pWidget->IsAppModified()) {
- CFFL_FormField* pFormField = GetFormField(pWidget);
- if (pFormField)
- pFormField->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
+ if (pFormField) {
+ pFormField->ResetPWLWindowForValueAge(pPageView, pWidget.Get(),
+ nValueAge);
+ }
}
}
}
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
return pFormField &&
- pFormField->OnLButtonDown(pPageView, ToCPDFSDKWidget(pAnnot.Get()),
- nFlags, point);
+ pFormField->OnLButtonDown(pPageView, pWidget.Get(), nFlags, point);
}
-bool CFFL_InteractiveFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
- Mask<FWL_EVENTFLAG> nFlags,
- const CFX_PointF& point) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
-
+bool CFFL_InteractiveFormFiller::OnLButtonUp(
+ CPDFSDK_PageView* pPageView,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) {
bool bSetFocus;
switch (pWidget->GetFieldType()) {
case FormFieldType::kPushButton:
case FormFieldType::kCheckBox:
case FormFieldType::kRadioButton: {
- FX_RECT bbox = GetViewBBox(pPageView, pAnnot.Get());
+ FX_RECT bbox = GetViewBBox(pPageView, pWidget.Get());
bSetFocus =
bbox.Contains(static_cast<int>(point.x), static_cast<int>(point.y));
break;
@@ -223,31 +219,32 @@
bSetFocus = true;
break;
}
- if (bSetFocus)
- m_pCallbackIface->SetFocusAnnot(pAnnot);
+ if (bSetFocus) {
+ ObservedPtr<CPDFSDK_Annot> pObserved(pWidget.Get());
+ m_pCallbackIface->SetFocusAnnot(pObserved);
+ }
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
bool bRet = pFormField &&
- pFormField->OnLButtonUp(pPageView, ToCPDFSDKWidget(pAnnot.Get()),
- nFlags, point);
- if (m_pCallbackIface->GetFocusAnnot() != pAnnot.Get())
+ pFormField->OnLButtonUp(pPageView, pWidget.Get(), nFlags, point);
+ if (m_pCallbackIface->GetFocusAnnot() != pWidget.Get())
return bRet;
- if (OnButtonUp(pAnnot, pPageView, nFlags) || !pAnnot)
+ if (OnButtonUp(pWidget, pPageView, nFlags) || !pWidget)
return true;
#ifdef PDF_ENABLE_XFA
- if (OnClick(pAnnot, pPageView, nFlags) || !pAnnot)
+ if (OnClick(pWidget, pPageView, nFlags) || !pWidget)
return true;
#endif // PDF_ENABLE_XFA
return bRet;
}
-bool CFFL_InteractiveFormFiller::OnButtonUp(ObservedPtr<CPDFSDK_Annot>& pAnnot,
- const CPDFSDK_PageView* pPageView,
- Mask<FWL_EVENTFLAG> nFlag) {
+bool CFFL_InteractiveFormFiller::OnButtonUp(
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ const CPDFSDK_PageView* pPageView,
+ Mask<FWL_EVENTFLAG> nFlag) {
if (m_bNotifying)
return false;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (!pWidget->GetAAction(CPDF_AAction::kButtonUp).GetDict())
return false;
@@ -263,124 +260,112 @@
fa.bShift = CPWL_Wnd::IsSHIFTKeyDown(nFlag);
pWidget->OnAAction(CPDF_AAction::kButtonUp, &fa, pPageView);
}
- if (!pAnnot || !IsValidAnnot(pPageView, pWidget))
+ if (!pWidget || !IsValidAnnot(pPageView, pWidget.Get()))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
- CFFL_FormField* pFormField = GetFormField(pWidget);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
if (pFormField)
- pFormField->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ pFormField->ResetPWLWindowForValueAge(pPageView, pWidget.Get(), nValueAge);
return true;
}
bool CFFL_InteractiveFormFiller::SetIndexSelected(
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
int index,
bool selected) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
-
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
return pFormField && pFormField->SetIndexSelected(index, selected);
}
bool CFFL_InteractiveFormFiller::IsIndexSelected(
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
int index) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
-
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
return pFormField && pFormField->IsIndexSelected(index);
}
bool CFFL_InteractiveFormFiller::OnLButtonDblClk(
CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
return pFormField && pFormField->OnLButtonDblClk(pPageView, nFlags, point);
}
-bool CFFL_InteractiveFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
- Mask<FWL_EVENTFLAG> nFlags,
- const CFX_PointF& point) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetOrCreateFormField(pAnnot.Get());
+bool CFFL_InteractiveFormFiller::OnMouseMove(
+ CPDFSDK_PageView* pPageView,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) {
+ CFFL_FormField* pFormField = GetOrCreateFormField(pWidget.Get());
return pFormField && pFormField->OnMouseMove(pPageView, nFlags, point);
}
bool CFFL_InteractiveFormFiller::OnMouseWheel(
CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point,
const CFX_Vector& delta) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
return pFormField &&
pFormField->OnMouseWheel(pPageView, nFlags, point, delta);
}
bool CFFL_InteractiveFormFiller::OnRButtonDown(
CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
return pFormField && pFormField->OnRButtonDown(pPageView, nFlags, point);
}
-bool CFFL_InteractiveFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
- Mask<FWL_EVENTFLAG> nFlags,
- const CFX_PointF& point) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+bool CFFL_InteractiveFormFiller::OnRButtonUp(
+ CPDFSDK_PageView* pPageView,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) {
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
return pFormField && pFormField->OnRButtonUp(pPageView, nFlags, point);
}
-bool CFFL_InteractiveFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot,
+bool CFFL_InteractiveFormFiller::OnKeyDown(CPDFSDK_Widget* pWidget,
FWL_VKEYCODE nKeyCode,
Mask<FWL_EVENTFLAG> nFlags) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
-
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+ CFFL_FormField* pFormField = GetFormField(pWidget);
return pFormField && pFormField->OnKeyDown(nKeyCode, nFlags);
}
-bool CFFL_InteractiveFormFiller::OnChar(CPDFSDK_Annot* pAnnot,
+bool CFFL_InteractiveFormFiller::OnChar(CPDFSDK_Widget* pWidget,
uint32_t nChar,
Mask<FWL_EVENTFLAG> nFlags) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
if (nChar == pdfium::ascii::kTab)
return true;
- CFFL_FormField* pFormField = GetFormField(pAnnot);
- return pFormField &&
- pFormField->OnChar(ToCPDFSDKWidget(pAnnot), nChar, nFlags);
+ CFFL_FormField* pFormField = GetFormField(pWidget);
+ return pFormField && pFormField->OnChar(pWidget, nChar, nFlags);
}
-bool CFFL_InteractiveFormFiller::OnSetFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot,
- Mask<FWL_EVENTFLAG> nFlag) {
- if (!pAnnot)
+bool CFFL_InteractiveFormFiller::OnSetFocus(
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ Mask<FWL_EVENTFLAG> nFlag) {
+ if (!pWidget)
return false;
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (pWidget->GetAAction(CPDF_AAction::kGetFocus).GetDict()) {
uint32_t nValueAge = pWidget->GetValueAge();
pWidget->ClearAppModified();
- CFFL_FormField* pFormField = GetOrCreateFormField(pWidget);
+ CFFL_FormField* pFormField = GetOrCreateFormField(pWidget.Get());
if (!pFormField)
return false;
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+ CPDFSDK_PageView* pPageView = pWidget->GetPageView();
DCHECK(pPageView);
{
AutoRestorer<bool> restorer(&m_bNotifying);
@@ -392,41 +377,42 @@
pFormField->GetActionData(pPageView, CPDF_AAction::kGetFocus, fa);
pWidget->OnAAction(CPDF_AAction::kGetFocus, &fa, pPageView);
}
- if (!pAnnot)
+ if (!pWidget)
return false;
if (pWidget->IsAppModified()) {
- CFFL_FormField* pFiller = GetFormField(pWidget);
- if (pFiller)
- pFiller->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ CFFL_FormField* pFiller = GetFormField(pWidget.Get());
+ if (pFiller) {
+ pFiller->ResetPWLWindowForValueAge(pPageView, pWidget.Get(),
+ nValueAge);
+ }
}
}
}
- if (CFFL_FormField* pFormField = GetOrCreateFormField(pAnnot.Get()))
- pFormField->SetFocusForAnnot(ToCPDFSDKWidget(pAnnot.Get()), nFlag);
+ if (CFFL_FormField* pFormField = GetOrCreateFormField(pWidget.Get()))
+ pFormField->SetFocusForAnnot(pWidget.Get(), nFlag);
return true;
}
-bool CFFL_InteractiveFormFiller::OnKillFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot,
- Mask<FWL_EVENTFLAG> nFlag) {
- if (!pAnnot)
+bool CFFL_InteractiveFormFiller::OnKillFocus(
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ Mask<FWL_EVENTFLAG> nFlag) {
+ if (!pWidget)
return false;
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot.Get());
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
if (!pFormField)
return true;
pFormField->KillFocusForAnnot(nFlag);
- if (!pAnnot)
+ if (!pWidget)
return false;
if (m_bNotifying)
return true;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (!pWidget->GetAAction(CPDF_AAction::kLoseFocus).GetDict())
return true;
@@ -444,7 +430,7 @@
pFormField->GetActionData(pPageView, CPDF_AAction::kLoseFocus, fa);
pWidget->OnAAction(CPDF_AAction::kLoseFocus, &fa, pPageView);
}
- return !!pAnnot;
+ return !!pWidget;
}
bool CFFL_InteractiveFormFiller::IsVisible(CPDFSDK_Widget* pWidget) {
@@ -468,18 +454,17 @@
}
CFFL_FormField* CFFL_InteractiveFormFiller::GetFormField(
- CPDFSDK_Annot* pAnnot) {
- auto it = m_Map.find(pAnnot);
+ CPDFSDK_Widget* pWidget) {
+ auto it = m_Map.find(pWidget);
return it != m_Map.end() ? it->second.get() : nullptr;
}
CFFL_FormField* CFFL_InteractiveFormFiller::GetOrCreateFormField(
- CPDFSDK_Annot* pAnnot) {
- CFFL_FormField* result = GetFormField(pAnnot);
+ CPDFSDK_Widget* pWidget) {
+ CFFL_FormField* result = GetFormField(pWidget);
if (result)
return result;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
std::unique_ptr<CFFL_FormField> pFormField;
switch (pWidget->GetFieldType()) {
case FormFieldType::kPushButton:
@@ -506,64 +491,57 @@
}
result = pFormField.get();
- m_Map[pAnnot] = std::move(pFormField);
+ m_Map[pWidget] = std::move(pFormField);
return result;
}
-WideString CFFL_InteractiveFormFiller::GetText(CPDFSDK_Annot* pAnnot) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+WideString CFFL_InteractiveFormFiller::GetText(CPDFSDK_Widget* pWidget) {
+ CFFL_FormField* pFormField = GetFormField(pWidget);
return pFormField ? pFormField->GetText() : WideString();
}
-WideString CFFL_InteractiveFormFiller::GetSelectedText(CPDFSDK_Annot* pAnnot) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+WideString CFFL_InteractiveFormFiller::GetSelectedText(
+ CPDFSDK_Widget* pWidget) {
+ CFFL_FormField* pFormField = GetFormField(pWidget);
return pFormField ? pFormField->GetSelectedText() : WideString();
}
-void CFFL_InteractiveFormFiller::ReplaceSelection(CPDFSDK_Annot* pAnnot,
+void CFFL_InteractiveFormFiller::ReplaceSelection(CPDFSDK_Widget* pWidget,
const WideString& text) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+ CFFL_FormField* pFormField = GetFormField(pWidget);
if (!pFormField)
return;
pFormField->ReplaceSelection(text);
}
-bool CFFL_InteractiveFormFiller::SelectAllText(CPDFSDK_Annot* pAnnot) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot);
- return pAnnot && pFormField->SelectAllText();
+bool CFFL_InteractiveFormFiller::SelectAllText(CPDFSDK_Widget* pWidget) {
+ CFFL_FormField* pFormField = GetFormField(pWidget);
+ return pFormField && pFormField->SelectAllText();
}
-bool CFFL_InteractiveFormFiller::CanUndo(CPDFSDK_Annot* pAnnot) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+bool CFFL_InteractiveFormFiller::CanUndo(CPDFSDK_Widget* pWidget) {
+ CFFL_FormField* pFormField = GetFormField(pWidget);
return pFormField && pFormField->CanUndo();
}
-bool CFFL_InteractiveFormFiller::CanRedo(CPDFSDK_Annot* pAnnot) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+bool CFFL_InteractiveFormFiller::CanRedo(CPDFSDK_Widget* pWidget) {
+ CFFL_FormField* pFormField = GetFormField(pWidget);
return pFormField && pFormField->CanRedo();
}
-bool CFFL_InteractiveFormFiller::Undo(CPDFSDK_Annot* pAnnot) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+bool CFFL_InteractiveFormFiller::Undo(CPDFSDK_Widget* pWidget) {
+ CFFL_FormField* pFormField = GetFormField(pWidget);
return pFormField && pFormField->Undo();
}
-bool CFFL_InteractiveFormFiller::Redo(CPDFSDK_Annot* pAnnot) {
- DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
- CFFL_FormField* pFormField = GetFormField(pAnnot);
+bool CFFL_InteractiveFormFiller::Redo(CPDFSDK_Widget* pWidget) {
+ CFFL_FormField* pFormField = GetFormField(pWidget);
return pFormField && pFormField->Redo();
}
-void CFFL_InteractiveFormFiller::UnregisterFormField(CPDFSDK_Annot* pAnnot) {
- auto it = m_Map.find(pAnnot);
+void CFFL_InteractiveFormFiller::UnregisterFormField(CPDFSDK_Widget* pWidget) {
+ auto it = m_Map.find(pWidget);
if (it == m_Map.end())
return;
@@ -632,13 +610,12 @@
}
bool CFFL_InteractiveFormFiller::OnKeyStrokeCommit(
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag) {
if (m_bNotifying)
return true;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (!pWidget->GetAAction(CPDF_AAction::kKeyStroke).GetDict())
return true;
@@ -655,24 +632,24 @@
fa.bKeyDown = true;
fa.bRC = true;
- CFFL_FormField* pFormField = GetFormField(pWidget);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
pFormField->GetActionData(pPageView, CPDF_AAction::kKeyStroke, fa);
pFormField->SavePWLWindowState(pPageView);
pWidget->OnAAction(CPDF_AAction::kKeyStroke, &fa, pPageView);
- if (!pAnnot)
+ if (!pWidget)
return true;
return fa.bRC;
}
-bool CFFL_InteractiveFormFiller::OnValidate(ObservedPtr<CPDFSDK_Annot>& pAnnot,
- const CPDFSDK_PageView* pPageView,
- Mask<FWL_EVENTFLAG> nFlag) {
+bool CFFL_InteractiveFormFiller::OnValidate(
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ const CPDFSDK_PageView* pPageView,
+ Mask<FWL_EVENTFLAG> nFlag) {
if (m_bNotifying)
return true;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (!pWidget->GetAAction(CPDF_AAction::kValidate).GetDict())
return true;
@@ -688,40 +665,42 @@
fa.bKeyDown = true;
fa.bRC = true;
- CFFL_FormField* pFormField = GetFormField(pWidget);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
pFormField->GetActionData(pPageView, CPDF_AAction::kValidate, fa);
pFormField->SavePWLWindowState(pPageView);
pWidget->OnAAction(CPDF_AAction::kValidate, &fa, pPageView);
- if (!pAnnot)
+ if (!pWidget)
return true;
return fa.bRC;
}
void CFFL_InteractiveFormFiller::OnCalculate(
- ObservedPtr<CPDFSDK_Annot>& pAnnot) {
+ ObservedPtr<CPDFSDK_Widget>& pWidget) {
if (m_bNotifying)
return;
- m_pCallbackIface->OnCalculate(pAnnot);
+ ObservedPtr<CPDFSDK_Annot> pObserved(pWidget.Get());
+ m_pCallbackIface->OnCalculate(pObserved);
}
-void CFFL_InteractiveFormFiller::OnFormat(ObservedPtr<CPDFSDK_Annot>& pAnnot) {
+void CFFL_InteractiveFormFiller::OnFormat(
+ ObservedPtr<CPDFSDK_Widget>& pWidget) {
if (m_bNotifying)
return;
- m_pCallbackIface->OnFormat(pAnnot);
+ ObservedPtr<CPDFSDK_Annot> pObserved(pWidget.Get());
+ m_pCallbackIface->OnFormat(pObserved);
}
#ifdef PDF_ENABLE_XFA
-bool CFFL_InteractiveFormFiller::OnClick(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+bool CFFL_InteractiveFormFiller::OnClick(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag) {
if (m_bNotifying)
return false;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (!pWidget->HasXFAAAction(PDFSDK_XFA_Click))
return false;
@@ -737,24 +716,23 @@
pWidget->OnXFAAAction(PDFSDK_XFA_Click, &fa, pPageView);
}
- if (!pAnnot || !IsValidAnnot(pPageView, pWidget))
+ if (!pWidget || !IsValidAnnot(pPageView, pWidget.Get()))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
- CFFL_FormField* pFormField = GetFormField(pWidget);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
if (pFormField)
- pFormField->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ pFormField->ResetPWLWindowForValueAge(pPageView, pWidget.Get(), nValueAge);
return false;
}
-bool CFFL_InteractiveFormFiller::OnFull(ObservedPtr<CPDFSDK_Widget>& pAnnot,
+bool CFFL_InteractiveFormFiller::OnFull(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag) {
if (m_bNotifying)
return false;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (!pWidget->HasXFAAAction(PDFSDK_XFA_Full))
return false;
@@ -769,24 +747,23 @@
fa.bShift = CPWL_Wnd::IsSHIFTKeyDown(nFlag);
pWidget->OnXFAAAction(PDFSDK_XFA_Full, &fa, pPageView);
}
- if (!pAnnot || !IsValidAnnot(pPageView, pWidget))
+ if (!pWidget || !IsValidAnnot(pPageView, pWidget.Get()))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
- CFFL_FormField* pFormField = GetFormField(pWidget);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
if (pFormField)
- pFormField->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ pFormField->ResetPWLWindowForValueAge(pPageView, pWidget.Get(), nValueAge);
return true;
}
-bool CFFL_InteractiveFormFiller::OnPreOpen(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+bool CFFL_InteractiveFormFiller::OnPreOpen(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag) {
if (m_bNotifying)
return false;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (!pWidget->HasXFAAAction(PDFSDK_XFA_PreOpen))
return false;
@@ -801,24 +778,24 @@
fa.bShift = CPWL_Wnd::IsSHIFTKeyDown(nFlag);
pWidget->OnXFAAAction(PDFSDK_XFA_PreOpen, &fa, pPageView);
}
- if (!pAnnot || !IsValidAnnot(pPageView, pWidget))
+ if (!pWidget || !IsValidAnnot(pPageView, pWidget.Get()))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
- CFFL_FormField* pFormField = GetFormField(pWidget);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
if (pFormField)
- pFormField->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ pFormField->ResetPWLWindowForValueAge(pPageView, pWidget.Get(), nValueAge);
return true;
}
-bool CFFL_InteractiveFormFiller::OnPostOpen(ObservedPtr<CPDFSDK_Annot>& pAnnot,
- const CPDFSDK_PageView* pPageView,
- Mask<FWL_EVENTFLAG> nFlag) {
+bool CFFL_InteractiveFormFiller::OnPostOpen(
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
+ const CPDFSDK_PageView* pPageView,
+ Mask<FWL_EVENTFLAG> nFlag) {
if (m_bNotifying)
return false;
- CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
if (!pWidget->HasXFAAAction(PDFSDK_XFA_PostOpen))
return false;
@@ -833,23 +810,23 @@
fa.bShift = CPWL_Wnd::IsSHIFTKeyDown(nFlag);
pWidget->OnXFAAAction(PDFSDK_XFA_PostOpen, &fa, pPageView);
}
- if (!pAnnot || !IsValidAnnot(pPageView, pWidget))
+ if (!pWidget || !IsValidAnnot(pPageView, pWidget.Get()))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
- CFFL_FormField* pFormField = GetFormField(pWidget);
+ CFFL_FormField* pFormField = GetFormField(pWidget.Get());
if (pFormField)
- pFormField->ResetPWLWindowForValueAge(pPageView, pWidget, nValueAge);
+ pFormField->ResetPWLWindowForValueAge(pPageView, pWidget.Get(), nValueAge);
return true;
}
#endif // PDF_ENABLE_XFA
// static
bool CFFL_InteractiveFormFiller::IsValidAnnot(const CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {
- return pPageView && pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
+ CPDFSDK_Widget* pWidget) {
+ return pPageView && pPageView->IsValidAnnot(pWidget->GetPDFAnnot());
}
std::pair<bool, bool> CFFL_InteractiveFormFiller::OnBeforeKeyStroke(
@@ -940,7 +917,7 @@
auto* pData = static_cast<const CFFL_PerWindowData*>(pAttached);
DCHECK(pData->GetWidget());
- ObservedPtr<CPDFSDK_Annot> pObserved(pData->GetWidget());
+ ObservedPtr<CPDFSDK_Widget> pObserved(pData->GetWidget());
return OnPreOpen(pObserved, pData->GetPageView(), nFlag) || !pObserved;
#else
return false;
@@ -954,7 +931,7 @@
auto* pData = static_cast<const CFFL_PerWindowData*>(pAttached);
DCHECK(pData->GetWidget());
- ObservedPtr<CPDFSDK_Annot> pObserved(pData->GetWidget());
+ ObservedPtr<CPDFSDK_Widget> pObserved(pData->GetWidget());
return OnPostOpen(pObserved, pData->GetPageView(), nFlag) || !pObserved;
#else
return false;
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.h b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
index 33f014d..074228e 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.h
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
@@ -50,102 +50,103 @@
~CFFL_InteractiveFormFiller() override;
CallbackIface* GetCallbackIface() { return m_pCallbackIface.Get(); }
- bool Annot_HitTest(const CPDFSDK_Annot* pAnnot, const CFX_PointF& point);
- FX_RECT GetViewBBox(const CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot);
+ bool Annot_HitTest(const CPDFSDK_Widget* pWidget, const CFX_PointF& point);
+ FX_RECT GetViewBBox(const CPDFSDK_PageView* pPageView,
+ CPDFSDK_Widget* pWidget);
void OnDraw(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
+ CPDFSDK_Widget* pWidget,
CFX_RenderDevice* pDevice,
const CFX_Matrix& mtUser2Device);
- void OnDelete(CPDFSDK_Annot* pAnnot);
+ void OnDelete(CPDFSDK_Widget* pWidget);
void OnMouseEnter(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlag);
void OnMouseExit(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlag);
bool OnLButtonDown(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point);
bool OnLButtonUp(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point);
bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point);
bool OnMouseMove(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point);
bool OnMouseWheel(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point,
const CFX_Vector& delta);
bool OnRButtonDown(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point);
bool OnRButtonUp(CPDFSDK_PageView* pPageView,
- ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point);
- bool OnKeyDown(CPDFSDK_Annot* pAnnot,
+ bool OnKeyDown(CPDFSDK_Widget* pWidget,
FWL_VKEYCODE nKeyCode,
Mask<FWL_EVENTFLAG> nFlags);
- bool OnChar(CPDFSDK_Annot* pAnnot,
+ bool OnChar(CPDFSDK_Widget* pWidget,
uint32_t nChar,
Mask<FWL_EVENTFLAG> nFlags);
- bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ bool OnSetFocus(ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlag);
- bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ bool OnKillFocus(ObservedPtr<CPDFSDK_Widget>& pWidget,
Mask<FWL_EVENTFLAG> nFlag);
- CFFL_FormField* GetFormFieldForTesting(CPDFSDK_Annot* pAnnot) {
+ CFFL_FormField* GetFormFieldForTesting(CPDFSDK_Widget* pAnnot) {
return GetFormField(pAnnot);
}
- WideString GetText(CPDFSDK_Annot* pAnnot);
- WideString GetSelectedText(CPDFSDK_Annot* pAnnot);
- void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text);
- bool SelectAllText(CPDFSDK_Annot* pAnnot);
+ WideString GetText(CPDFSDK_Widget* pWidget);
+ WideString GetSelectedText(CPDFSDK_Widget* pWidget);
+ void ReplaceSelection(CPDFSDK_Widget* pWidget, const WideString& text);
+ bool SelectAllText(CPDFSDK_Widget* pWidget);
- bool CanUndo(CPDFSDK_Annot* pAnnot);
- bool CanRedo(CPDFSDK_Annot* pAnnot);
- bool Undo(CPDFSDK_Annot* pAnnot);
- bool Redo(CPDFSDK_Annot* pAnnot);
+ bool CanUndo(CPDFSDK_Widget* pWidget);
+ bool CanRedo(CPDFSDK_Widget* pWidget);
+ bool Undo(CPDFSDK_Widget* pWidget);
+ bool Redo(CPDFSDK_Widget* pWidget);
static bool IsVisible(CPDFSDK_Widget* pWidget);
static bool IsReadOnly(CPDFSDK_Widget* pWidget);
static bool IsValidAnnot(const CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot);
+ CPDFSDK_Widget* pWidget);
- bool OnKeyStrokeCommit(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ bool OnKeyStrokeCommit(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag);
- bool OnValidate(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ bool OnValidate(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag);
- void OnCalculate(ObservedPtr<CPDFSDK_Annot>& pAnnot);
- void OnFormat(ObservedPtr<CPDFSDK_Annot>& pAnnot);
- bool OnButtonUp(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ void OnCalculate(ObservedPtr<CPDFSDK_Widget>& pWidget);
+ void OnFormat(ObservedPtr<CPDFSDK_Widget>& pWidget);
+ bool OnButtonUp(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag);
- bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ bool SetIndexSelected(ObservedPtr<CPDFSDK_Widget>& pWidget,
int index,
bool selected);
- bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>& pAnnot, int index);
+ bool IsIndexSelected(ObservedPtr<CPDFSDK_Widget>& pWidget, int index);
private:
using WidgetToFormFillerMap =
- std::map<CPDFSDK_Annot*, std::unique_ptr<CFFL_FormField>>;
+ std::map<CPDFSDK_Widget*, std::unique_ptr<CFFL_FormField>>;
// IPWL_FillerNotify:
void QueryWherePopup(const IPWL_SystemHandler::PerWindowData* pAttached,
@@ -168,25 +169,25 @@
Mask<FWL_EVENTFLAG> nFlag) override;
#ifdef PDF_ENABLE_XFA
- void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, bool bSameField, bool bNext);
- bool OnClick(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ void SetFocusAnnotTab(CPDFSDK_Widget* pWidget, bool bSameField, bool bNext);
+ bool OnClick(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag);
bool OnFull(ObservedPtr<CPDFSDK_Widget>& pAnnot,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag);
- bool OnPreOpen(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ bool OnPreOpen(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag);
- bool OnPostOpen(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ bool OnPostOpen(ObservedPtr<CPDFSDK_Widget>& pWidget,
const CPDFSDK_PageView* pPageView,
Mask<FWL_EVENTFLAG> nFlag);
#endif // PDF_ENABLE_XFA
bool IsFillingAllowed(CPDFSDK_Widget* pWidget) const;
- CFFL_FormField* GetFormField(CPDFSDK_Annot* pAnnot);
- CFFL_FormField* GetOrCreateFormField(CPDFSDK_Annot* pAnnot);
- void UnregisterFormField(CPDFSDK_Annot* pAnnot);
+ CFFL_FormField* GetFormField(CPDFSDK_Widget* pAnnot);
+ CFFL_FormField* GetOrCreateFormField(CPDFSDK_Widget* pWidget);
+ void UnregisterFormField(CPDFSDK_Widget* pWidget);
UnownedPtr<CallbackIface> const m_pCallbackIface;
WidgetToFormFillerMap m_Map;
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp
index 402a1c5..e9788fc 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.cpp
+++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp
@@ -51,7 +51,7 @@
CPDFSDK_PageView* pPageView = pWidget->GetPageView();
DCHECK(pPageView);
- ObservedPtr<CPDFSDK_Annot> pObserved(m_pWidget.Get());
+ ObservedPtr<CPDFSDK_Widget> pObserved(m_pWidget.Get());
if (m_pFormFiller->OnButtonUp(pObserved, pPageView, nFlags) ||
!pObserved) {
return true;
diff --git a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
index e79fbbe..cf8c2c0 100644
--- a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
@@ -50,11 +50,11 @@
ASSERT_EQ(pAnnotReadOnly, pLastAnnot);
}
- void FormFillerAndWindowSetup(CPDFSDK_Annot* pAnnotCombobox) {
+ void FormFillerAndWindowSetup(CPDFSDK_Widget* pAnnotCombobox) {
CFFL_InteractiveFormFiller* pInteractiveFormFiller =
m_pFormFillEnv->GetInteractiveFormFiller();
{
- ObservedPtr<CPDFSDK_Annot> pObserved(pAnnotCombobox);
+ ObservedPtr<CPDFSDK_Widget> pObserved(pAnnotCombobox);
EXPECT_TRUE(pInteractiveFormFiller->OnSetFocus(pObserved, {}));
}
diff --git a/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp b/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
index fe44647..b48d9ca 100644
--- a/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
@@ -55,11 +55,11 @@
ASSERT_EQ(password_annot, pLastAnnot);
}
- void FormFillerAndWindowSetup(CPDFSDK_Annot* pAnnotTextField) {
+ void FormFillerAndWindowSetup(CPDFSDK_Widget* pAnnotTextField) {
CFFL_InteractiveFormFiller* pInteractiveFormFiller =
m_pFormFillEnv->GetInteractiveFormFiller();
{
- ObservedPtr<CPDFSDK_Annot> pObserved(pAnnotTextField);
+ ObservedPtr<CPDFSDK_Widget> pObserved(pAnnotTextField);
EXPECT_TRUE(pInteractiveFormFiller->OnSetFocus(pObserved, {}));
}
diff --git a/fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp b/fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp
index 31f366e..9479eca 100644
--- a/fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "fpdfsdk/cpdfsdk_annot.h"
#include "fpdfsdk/cpdfsdk_annotiterator.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
+#include "fpdfsdk/cpdfsdk_widget.h"
#include "fpdfsdk/formfiller/cffl_formfield.h"
#include "fpdfsdk/pwl/cpwl_special_button.h"
#include "fpdfsdk/pwl/cpwl_wnd.h"
@@ -34,44 +34,47 @@
{CPDF_Annot::Subtype::WIDGET});
// Read only check box.
- annot_readonly_checkbox_ = it.GetFirstAnnot();
- ASSERT_TRUE(annot_readonly_checkbox_);
+ widget_readonly_checkbox_ = ToCPDFSDKWidget(it.GetFirstAnnot());
+ ASSERT_TRUE(widget_readonly_checkbox_);
ASSERT_EQ(CPDF_Annot::Subtype::WIDGET,
- annot_readonly_checkbox_->GetAnnotSubtype());
+ widget_readonly_checkbox_->GetAnnotSubtype());
// Check box.
- annot_checkbox_ = it.GetNextAnnot(annot_readonly_checkbox_);
- ASSERT_TRUE(annot_checkbox_);
- ASSERT_EQ(CPDF_Annot::Subtype::WIDGET, annot_checkbox_->GetAnnotSubtype());
+ widget_checkbox_ =
+ ToCPDFSDKWidget(it.GetNextAnnot(widget_readonly_checkbox_));
+ ASSERT_TRUE(widget_checkbox_);
+ ASSERT_EQ(CPDF_Annot::Subtype::WIDGET, widget_checkbox_->GetAnnotSubtype());
// Read only radio button.
- annot_readonly_radiobutton_ = it.GetNextAnnot(annot_checkbox_);
- ASSERT_TRUE(annot_readonly_radiobutton_);
+ widget_readonly_radiobutton_ =
+ ToCPDFSDKWidget(it.GetNextAnnot(widget_checkbox_));
+ ASSERT_TRUE(widget_readonly_radiobutton_);
ASSERT_EQ(CPDF_Annot::Subtype::WIDGET,
- annot_readonly_radiobutton_->GetAnnotSubtype());
+ widget_readonly_radiobutton_->GetAnnotSubtype());
// Tabbing three times from read only radio button to unselected normal
// radio button.
- annot_radiobutton_ = annot_readonly_radiobutton_;
- ASSERT_TRUE(annot_radiobutton_);
+ widget_radiobutton_ = widget_readonly_radiobutton_;
+ ASSERT_TRUE(widget_radiobutton_);
for (int i = 0; i < 3; i++) {
- annot_radiobutton_ = it.GetNextAnnot(annot_radiobutton_);
- ASSERT_TRUE(annot_radiobutton_);
+ widget_radiobutton_ =
+ ToCPDFSDKWidget(it.GetNextAnnot(widget_radiobutton_));
+ ASSERT_TRUE(widget_radiobutton_);
}
ASSERT_EQ(CPDF_Annot::Subtype::WIDGET,
- annot_radiobutton_->GetAnnotSubtype());
+ widget_radiobutton_->GetAnnotSubtype());
}
- void FormFillerAndWindowSetup(CPDFSDK_Annot* annot) {
+ void FormFillerAndWindowSetup(CPDFSDK_Widget* widget) {
CFFL_InteractiveFormFiller* interactive_formfiller =
formfill_env_->GetInteractiveFormFiller();
{
- ObservedPtr<CPDFSDK_Annot> observed(annot);
+ ObservedPtr<CPDFSDK_Widget> observed(widget);
EXPECT_TRUE(interactive_formfiller->OnSetFocus(observed, {}));
}
- form_filler_ = interactive_formfiller->GetFormFieldForTesting(annot);
+ form_filler_ = interactive_formfiller->GetFormFieldForTesting(widget);
ASSERT_TRUE(form_filler_);
window_ = form_filler_->CreateOrUpdatePWLWindow(
@@ -79,15 +82,15 @@
ASSERT_TRUE(window_);
}
- CPDFSDK_Annot* GetCPDFSDKAnnotCheckBox() const { return annot_checkbox_; }
- CPDFSDK_Annot* GetCPDFSDKAnnotReadOnlyCheckBox() const {
- return annot_readonly_checkbox_;
+ CPDFSDK_Widget* GetCPDFSDKWidgetCheckBox() const { return widget_checkbox_; }
+ CPDFSDK_Widget* GetCPDFSDKWidgetReadOnlyCheckBox() const {
+ return widget_readonly_checkbox_;
}
- CPDFSDK_Annot* GetCPDFSDKAnnotRadioButton() const {
- return annot_radiobutton_;
+ CPDFSDK_Widget* GetCPDFSDKWidgetRadioButton() const {
+ return widget_radiobutton_;
}
- CPDFSDK_Annot* GetCPDFSDKAnnotReadOnlyRadioButton() const {
- return annot_readonly_radiobutton_;
+ CPDFSDK_Widget* GetCPDFSDKWidgetReadOnlyRadioButton() const {
+ return widget_readonly_radiobutton_;
}
CPDFSDK_FormFillEnvironment* GetCPDFSDKFormFillEnv() const {
return formfill_env_;
@@ -97,48 +100,48 @@
private:
FPDF_PAGE page_;
CFFL_FormField* form_filler_;
- CPDFSDK_Annot* annot_checkbox_;
- CPDFSDK_Annot* annot_readonly_checkbox_;
- CPDFSDK_Annot* annot_radiobutton_;
- CPDFSDK_Annot* annot_readonly_radiobutton_;
+ CPDFSDK_Widget* widget_checkbox_;
+ CPDFSDK_Widget* widget_readonly_checkbox_;
+ CPDFSDK_Widget* widget_radiobutton_;
+ CPDFSDK_Widget* widget_readonly_radiobutton_;
CPDFSDK_FormFillEnvironment* formfill_env_;
CPWL_Wnd* window_;
};
TEST_F(CPWLSpecialButtonEmbedderTest, EnterOnReadOnlyCheckBox) {
- FormFillerAndWindowSetup(GetCPDFSDKAnnotReadOnlyCheckBox());
+ FormFillerAndWindowSetup(GetCPDFSDKWidgetReadOnlyCheckBox());
CPWL_CheckBox* check_box = static_cast<CPWL_CheckBox*>(GetWindow());
EXPECT_TRUE(check_box->IsChecked());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
- GetCPDFSDKAnnotReadOnlyCheckBox(), '\r', {}));
+ GetCPDFSDKWidgetReadOnlyCheckBox(), '\r', {}));
EXPECT_TRUE(check_box->IsChecked());
}
TEST_F(CPWLSpecialButtonEmbedderTest, EnterOnCheckBox) {
- FormFillerAndWindowSetup(GetCPDFSDKAnnotCheckBox());
+ FormFillerAndWindowSetup(GetCPDFSDKWidgetCheckBox());
CPWL_CheckBox* check_box = static_cast<CPWL_CheckBox*>(GetWindow());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
- GetCPDFSDKAnnotCheckBox(), '\r', {}));
+ GetCPDFSDKWidgetCheckBox(), '\r', {}));
EXPECT_TRUE(check_box->IsChecked());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
- GetCPDFSDKAnnotCheckBox(), '\r', {}));
+ GetCPDFSDKWidgetCheckBox(), '\r', {}));
EXPECT_FALSE(check_box->IsChecked());
}
TEST_F(CPWLSpecialButtonEmbedderTest, EnterOnReadOnlyRadioButton) {
- FormFillerAndWindowSetup(GetCPDFSDKAnnotReadOnlyRadioButton());
+ FormFillerAndWindowSetup(GetCPDFSDKWidgetReadOnlyRadioButton());
CPWL_RadioButton* radio_button = static_cast<CPWL_RadioButton*>(GetWindow());
EXPECT_FALSE(radio_button->IsChecked());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
- GetCPDFSDKAnnotReadOnlyRadioButton(), '\r', {}));
+ GetCPDFSDKWidgetReadOnlyRadioButton(), '\r', {}));
EXPECT_FALSE(radio_button->IsChecked());
}
TEST_F(CPWLSpecialButtonEmbedderTest, EnterOnRadioButton) {
- FormFillerAndWindowSetup(GetCPDFSDKAnnotRadioButton());
+ FormFillerAndWindowSetup(GetCPDFSDKWidgetRadioButton());
CPWL_RadioButton* radio_button = static_cast<CPWL_RadioButton*>(GetWindow());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
- GetCPDFSDKAnnotRadioButton(), '\r', {}));
+ GetCPDFSDKWidgetRadioButton(), '\r', {}));
EXPECT_TRUE(radio_button->IsChecked());
}