diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.cpp | 11 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widgethandler.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_xfawidget.h | 5 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_xfawidgethandler.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_button.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_checkbox.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_formfiller.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_wnd.cpp | 27 |
10 files changed, 30 insertions, 33 deletions
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp index 649d3bbd2e..da342865cb 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp +++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp @@ -699,7 +699,7 @@ bool CPDFSDK_FormFillEnvironment::KillFocusAnnot(uint32_t nFlag) { } if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) { - CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pFocusAnnot.Get()); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pFocusAnnot.Get()); FormFieldType fieldType = pWidget->GetFieldType(); if (fieldType == FormFieldType::kTextField || fieldType == FormFieldType::kComboBox) { diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 9d646b6574..3cfc84dfd9 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -111,10 +111,8 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, auto pIterator = pdfium::MakeUnique<CPDFSDK_AnnotIterator>( pWidget->GetPageView(), CPDF_Annot::Subtype::WIDGET); - if (bNext) - return static_cast<CPDFSDK_Widget*>(pIterator->GetNextAnnot(pWidget)); - - return static_cast<CPDFSDK_Widget*>(pIterator->GetPrevAnnot(pWidget)); + return ToCPDFSDKWidget(bNext ? pIterator->GetNextAnnot(pWidget) + : pIterator->GetPrevAnnot(pWidget)); } CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { @@ -144,10 +142,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { pPage = m_pFormFillEnv->GetPageView(nPageIndex); } - if (!pPage) - return nullptr; - - return static_cast<CPDFSDK_Widget*>(pPage->GetAnnotByDict(pControlDict)); + return pPage ? ToCPDFSDKWidget(pPage->GetAnnotByDict(pControlDict)) : nullptr; } void CPDFSDK_InterForm::GetWidgets( diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index 12ae17372a..22f5d3933a 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp @@ -77,11 +77,10 @@ CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CXFA_FFWidget* hWidget, void CPDFSDK_WidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { ASSERT(pAnnot); - if (m_pFormFiller) m_pFormFiller->OnDelete(pAnnot); - std::unique_ptr<CPDFSDK_Widget> pWidget(static_cast<CPDFSDK_Widget*>(pAnnot)); + std::unique_ptr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot)); CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); CPDF_FormControl* pControl = pWidget->GetFormControl(); pInterForm->RemoveMap(pControl); @@ -222,7 +221,7 @@ void CPDFSDK_WidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) { if (pAnnot->IsSignatureWidget()) return; - CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); if (!pWidget->IsAppearanceValid()) pWidget->ResetAppearance(nullptr, false); diff --git a/fpdfsdk/cpdfsdk_xfawidget.h b/fpdfsdk/cpdfsdk_xfawidget.h index d2635eb4e1..5db9f8d066 100644 --- a/fpdfsdk/cpdfsdk_xfawidget.h +++ b/fpdfsdk/cpdfsdk_xfawidget.h @@ -36,4 +36,9 @@ class CPDFSDK_XFAWidget : public CPDFSDK_Annot { UnownedPtr<CXFA_FFWidget> m_hXFAWidget; }; +inline CPDFSDK_XFAWidget* ToXFAWidget(CPDFSDK_Annot* pAnnot) { + return pAnnot && pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET + ? static_cast<CPDFSDK_XFAWidget*>(pAnnot) : nullptr; +} + #endif // FPDFSDK_CPDFSDK_XFAWIDGET_H_ diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp index 1a8ec69ba2..a395eef038 100644 --- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp +++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp @@ -70,7 +70,7 @@ void CPDFSDK_XFAWidgetHandler::OnDraw(CPDFSDK_PageView* pPageView, void CPDFSDK_XFAWidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} void CPDFSDK_XFAWidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { - CPDFSDK_XFAWidget* pWidget = static_cast<CPDFSDK_XFAWidget*>(pAnnot); + CPDFSDK_XFAWidget* pWidget = ToXFAWidget(pAnnot); CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); pInterForm->RemoveXFAMap(pWidget->GetXFAWidget()); diff --git a/fpdfsdk/formfiller/cffl_button.cpp b/fpdfsdk/formfiller/cffl_button.cpp index dab0045373..ea2315d5a6 100644 --- a/fpdfsdk/formfiller/cffl_button.cpp +++ b/fpdfsdk/formfiller/cffl_button.cpp @@ -64,7 +64,7 @@ void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, CFX_RenderDevice* pDevice, const CFX_Matrix& mtUser2Device) { ASSERT(pPageView); - CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); CPDF_FormControl* pCtrl = pWidget->GetFormControl(); if (pCtrl->GetHighlightingMode() != CPDF_FormControl::Push) { pWidget->DrawAppearance(pDevice, mtUser2Device, CPDF_Annot::Normal, diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp index e9c72efd39..57119c5c31 100644 --- a/fpdfsdk/formfiller/cffl_checkbox.cpp +++ b/fpdfsdk/formfiller/cffl_checkbox.cpp @@ -61,7 +61,7 @@ bool CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot, CPWL_CheckBox* pWnd = GetCheckBox(pPageView, true); if (pWnd) { - CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); pWnd->SetCheck(!pWidget->IsChecked()); } @@ -83,7 +83,7 @@ bool CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView* pPageView, CPWL_CheckBox* pWnd = GetCheckBox(pPageView, true); if (pWnd) { - CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); pWnd->SetCheck(!pWidget->IsChecked()); } diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 94592e719f..85f53469e3 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -291,7 +291,7 @@ bool CFFL_FormFiller::Redo(CPDFSDK_Annot* pAnnot) { } void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { - auto* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); IPDF_Page* pPage = pWidget->GetPage(); CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, true); if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true)) diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index d73aaf93b3..c1cc355156 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -58,7 +58,7 @@ void CFFL_InteractiveFormFiller::OnDraw(CPDFSDK_PageView* pPageView, CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { ASSERT(pPageView); - CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); if (!IsVisible(pWidget)) return; @@ -66,7 +66,6 @@ void CFFL_InteractiveFormFiller::OnDraw(CPDFSDK_PageView* pPageView, if (pFormFiller && pFormFiller->IsValid()) { pFormFiller->OnDraw(pPageView, pAnnot, pDevice, *pUser2Device); pAnnot->GetPDFPage(); - if (m_pFormFillEnv->GetFocusAnnot() != pAnnot) return; diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp index 8782e85a14..a561b2de60 100644 --- a/fpdfsdk/pwl/cpwl_wnd.cpp +++ b/fpdfsdk/pwl/cpwl_wnd.cpp @@ -277,33 +277,32 @@ void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, } bool CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) { - ObservedPtr thisObserved(this); - if (!IsValid()) + if (!IsValid()) return true; + ObservedPtr thisObserved(this); CFX_FloatRect rcRefresh = pRect ? *pRect : GetWindowRect(); - if (!HasFlag(PWS_NOREFRESHCLIP)) { CFX_FloatRect rcClip = GetClipRect(); - if (!rcClip.IsEmpty()) { + if (!rcClip.IsEmpty()) rcRefresh.Intersect(rcClip); - } } CFX_FloatRect rcWin = PWLtoWnd(rcRefresh); rcWin.Inflate(1, 1); rcWin.Normalize(); - if (CFX_SystemHandler* pSH = GetSystemHandler()) { - if (CPDFSDK_Widget* widget = static_cast<CPDFSDK_Widget*>( - m_CreationParams.pAttachedWidget.Get())) { - pSH->InvalidateRect(widget, rcWin); - if (!thisObserved) - return false; - } - } + CFX_SystemHandler* pSH = GetSystemHandler(); + if (!pSH) + return true; - return true; + CPDFSDK_Widget* widget = + ToCPDFSDKWidget(m_CreationParams.pAttachedWidget.Get()); + if (!widget) + return true; + + pSH->InvalidateRect(widget, rcWin); + return !!thisObserved; } #define PWL_IMPLEMENT_KEY_METHOD(key_method_name) \ |