summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fxcrt/observable.h3
-rw-r--r--fpdfsdk/cpdfsdk_annothandlermgr.cpp20
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.cpp2
-rw-r--r--fpdfsdk/cpdfsdk_xfawidgethandler.cpp24
-rw-r--r--fpdfsdk/formfiller/cffl_interactiveformfiller.cpp32
5 files changed, 41 insertions, 40 deletions
diff --git a/core/fxcrt/observable.h b/core/fxcrt/observable.h
index e118dc898b..3205bc09df 100644
--- a/core/fxcrt/observable.h
+++ b/core/fxcrt/observable.h
@@ -46,6 +46,7 @@ class Observable {
ASSERT(m_pObservable);
m_pObservable = nullptr;
}
+ bool HasObservable() const { return !!m_pObservable; }
ObservedPtr& operator=(const ObservedPtr& that) {
Reset(that.Get());
return *this;
@@ -54,7 +55,7 @@ class Observable {
return m_pObservable == that.m_pObservable;
}
bool operator!=(const ObservedPtr& that) const { return !(*this == that); }
- explicit operator bool() const { return !!m_pObservable; }
+ explicit operator bool() const { return HasObservable(); }
T* Get() const { return m_pObservable; }
T& operator*() const { return *m_pObservable; }
T* operator->() const { return m_pObservable; }
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index 3dc3f09a07..ac22fe2d7b 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -130,7 +130,7 @@ bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
return GetAnnotHandler(pAnnot->Get())
->OnLButtonDown(pPageView, pAnnot, nFlags, point);
}
@@ -140,7 +140,7 @@ bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
return GetAnnotHandler(pAnnot->Get())
->OnLButtonUp(pPageView, pAnnot, nFlags, point);
}
@@ -150,7 +150,7 @@ bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
return GetAnnotHandler(pAnnot->Get())
->OnMouseMove(pPageView, pAnnot, nFlags, point);
}
@@ -161,7 +161,7 @@ bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(
uint32_t nFlags,
short zDelta,
const CFX_PointF& point) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
return GetAnnotHandler(pAnnot->Get())
->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
}
@@ -171,7 +171,7 @@ bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
return GetAnnotHandler(pAnnot->Get())
->OnRButtonDown(pPageView, pAnnot, nFlags, point);
}
@@ -181,7 +181,7 @@ bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
return GetAnnotHandler(pAnnot->Get())
->OnRButtonUp(pPageView, pAnnot, nFlags, point);
}
@@ -190,7 +190,7 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(
CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
GetAnnotHandler(pAnnot->Get())->OnMouseEnter(pPageView, pAnnot, nFlag);
}
@@ -198,7 +198,7 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(
CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
GetAnnotHandler(pAnnot->Get())->OnMouseExit(pPageView, pAnnot, nFlag);
}
@@ -233,14 +233,14 @@ bool CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot,
bool CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
return GetAnnotHandler(pAnnot->Get())->OnSetFocus(pAnnot, nFlag);
}
bool CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
- ASSERT(*pAnnot);
+ ASSERT(pAnnot->HasObservable());
return GetAnnotHandler(pAnnot->Get())->OnKillFocus(pAnnot, nFlag);
}
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index 155fcc0455..52dfb526eb 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -646,7 +646,7 @@ bool CPDFSDK_FormFillEnvironment::SetFocusAnnot(
return true;
if (m_pFocusAnnot && !KillFocusAnnot(0))
return false;
- if (!*pAnnot)
+ if (!pAnnot->HasObservable())
return false;
CPDFSDK_PageView* pPageView = (*pAnnot)->GetPageView();
diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
index 75a5c12ba2..1660f86af3 100644
--- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
@@ -180,7 +180,7 @@ bool CPDFSDK_XFAWidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
pWidgetHandler->OnMouseEnter((*pAnnot)->GetXFAWidget());
@@ -189,7 +189,7 @@ void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
void CPDFSDK_XFAWidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -200,7 +200,7 @@ bool CPDFSDK_XFAWidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return false;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -212,7 +212,7 @@ bool CPDFSDK_XFAWidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return false;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -225,7 +225,7 @@ bool CPDFSDK_XFAWidgetHandler::OnLButtonDblClk(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return false;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -237,7 +237,7 @@ bool CPDFSDK_XFAWidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return false;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -250,7 +250,7 @@ bool CPDFSDK_XFAWidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
uint32_t nFlags,
short zDelta,
const CFX_PointF& point) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return false;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -262,7 +262,7 @@ bool CPDFSDK_XFAWidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return false;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -274,7 +274,7 @@ bool CPDFSDK_XFAWidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return false;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -287,7 +287,7 @@ bool CPDFSDK_XFAWidgetHandler::OnRButtonDblClk(
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- if (!pPageView || !(*pAnnot))
+ if (!pPageView || !pAnnot->HasObservable())
return false;
CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get());
@@ -351,9 +351,9 @@ bool CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus(
CPDFSDK_Annot::ObservedPtr* pOldAnnot,
CPDFSDK_Annot::ObservedPtr* pNewAnnot) {
CXFA_FFWidgetHandler* pWidgetHandler = nullptr;
- if (*pOldAnnot)
+ if (pOldAnnot->HasObservable())
pWidgetHandler = GetXFAWidgetHandler(pOldAnnot->Get());
- else if (*pNewAnnot)
+ else if (pNewAnnot->HasObservable())
pWidgetHandler = GetXFAWidgetHandler(pNewAnnot->Get());
if (!pWidgetHandler)
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index cb36de732e..e1d28c86b2 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -130,7 +130,7 @@ void CFFL_InteractiveFormFiller::OnMouseEnter(
fa.bShift = CPDFSDK_FormFillEnvironment::IsSHIFTKeyDown(nFlag);
pWidget->OnAAction(CPDF_AAction::CursorEnter, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return;
if (pWidget->IsAppModified()) {
@@ -163,7 +163,7 @@ void CFFL_InteractiveFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView,
fa.bShift = CPDFSDK_FormFillEnvironment::IsSHIFTKeyDown(nFlag);
pWidget->OnAAction(CPDF_AAction::CursorExit, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return;
if (pWidget->IsAppModified()) {
@@ -199,7 +199,7 @@ bool CFFL_InteractiveFormFiller::OnLButtonDown(
fa.bShift = CPDFSDK_FormFillEnvironment::IsSHIFTKeyDown(nFlags);
pWidget->OnAAction(CPDF_AAction::ButtonDown, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return true;
if (!IsValidAnnot(pPageView, pAnnot->Get()))
@@ -277,7 +277,7 @@ bool CFFL_InteractiveFormFiller::OnButtonUp(CPDFSDK_Annot::ObservedPtr* pAnnot,
fa.bShift = CPDFSDK_FormFillEnvironment::IsSHIFTKeyDown(nFlag);
pWidget->OnAAction(CPDF_AAction::ButtonUp, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget))
+ if (!pAnnot->HasObservable() || !IsValidAnnot(pPageView, pWidget))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
@@ -365,7 +365,7 @@ bool CFFL_InteractiveFormFiller::OnChar(CPDFSDK_Annot* pAnnot,
bool CFFL_InteractiveFormFiller::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return false;
ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
@@ -390,7 +390,7 @@ bool CFFL_InteractiveFormFiller::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa);
pWidget->OnAAction(CPDF_AAction::GetFocus, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return false;
if (pWidget->IsAppModified()) {
@@ -410,7 +410,7 @@ bool CFFL_InteractiveFormFiller::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
bool CFFL_InteractiveFormFiller::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return false;
ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
@@ -419,7 +419,7 @@ bool CFFL_InteractiveFormFiller::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
return true;
pFormFiller->KillFocusForAnnot(pAnnot->Get(), nFlag);
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return false;
if (m_bNotifying)
@@ -441,7 +441,7 @@ bool CFFL_InteractiveFormFiller::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);
pWidget->OnAAction(CPDF_AAction::LoseFocus, &fa, pPageView);
m_bNotifying = false;
- return !!(*pAnnot);
+ return pAnnot->HasObservable();
}
bool CFFL_InteractiveFormFiller::IsVisible(CPDFSDK_Widget* pWidget) {
@@ -656,7 +656,7 @@ bool CFFL_InteractiveFormFiller::OnKeyStrokeCommit(
pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);
pFormFiller->SaveState(pPageView);
pWidget->OnAAction(CPDF_AAction::KeyStroke, &fa, pPageView);
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return true;
m_bNotifying = false;
@@ -687,7 +687,7 @@ bool CFFL_InteractiveFormFiller::OnValidate(CPDFSDK_Annot::ObservedPtr* pAnnot,
pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);
pFormFiller->SaveState(pPageView);
pWidget->OnAAction(CPDF_AAction::Validate, &fa, pPageView);
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return true;
m_bNotifying = false;
@@ -719,7 +719,7 @@ void CFFL_InteractiveFormFiller::OnFormat(CPDFSDK_Annot::ObservedPtr* pAnnot,
CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm();
Optional<WideString> sValue = pInterForm->OnFormat(pWidget->GetFormField());
- if (!(*pAnnot))
+ if (!pAnnot->HasObservable())
return;
if (sValue.has_value()) {
@@ -751,7 +751,7 @@ bool CFFL_InteractiveFormFiller::OnClick(CPDFSDK_Annot::ObservedPtr* pAnnot,
pWidget->OnXFAAAction(PDFSDK_XFA_Click, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget))
+ if (!pAnnot->HasObservable() || !IsValidAnnot(pPageView, pWidget))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
@@ -781,7 +781,7 @@ bool CFFL_InteractiveFormFiller::OnFull(CPDFSDK_Annot::ObservedPtr* pAnnot,
pWidget->OnXFAAAction(PDFSDK_XFA_Full, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget))
+ if (!pAnnot->HasObservable() || !IsValidAnnot(pPageView, pWidget))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
@@ -834,7 +834,7 @@ bool CFFL_InteractiveFormFiller::OnPreOpen(CPDFSDK_Annot::ObservedPtr* pAnnot,
pWidget->OnXFAAAction(PDFSDK_XFA_PreOpen, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget))
+ if (!pAnnot->HasObservable() || !IsValidAnnot(pPageView, pWidget))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;
@@ -865,7 +865,7 @@ bool CFFL_InteractiveFormFiller::OnPostOpen(CPDFSDK_Annot::ObservedPtr* pAnnot,
pWidget->OnXFAAAction(PDFSDK_XFA_PostOpen, &fa, pPageView);
m_bNotifying = false;
- if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget))
+ if (!pAnnot->HasObservable() || !IsValidAnnot(pPageView, pWidget))
return true;
if (nAge == pWidget->GetAppearanceAge())
return false;