From 522d77db501ab7ae33f7d17e4ab456232ca5a70c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Sat, 28 Jul 2018 00:00:25 +0000 Subject: Add CPDSDK_Annot::AsBAAnnot() checked downcast method XFA introduces some additional subclasses, so it doesn't hurt to be sure in all cases before making a static cast. Change-Id: I7447ca58be0b57201b39ba40a3fc5f47505cee58 Reviewed-on: https://pdfium-review.googlesource.com/39013 Commit-Queue: Lei Zhang Reviewed-by: Lei Zhang --- fpdfsdk/cpdfsdk_annot.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'fpdfsdk/cpdfsdk_annot.h') diff --git a/fpdfsdk/cpdfsdk_annot.h b/fpdfsdk/cpdfsdk_annot.h index 459c6d0233..708a223a50 100644 --- a/fpdfsdk/cpdfsdk_annot.h +++ b/fpdfsdk/cpdfsdk_annot.h @@ -20,6 +20,7 @@ class CFX_Matrix; class CFX_RenderDevice; class CPDF_Page; class CPDF_RenderOptions; +class CPDFSDK_BAAnnot; class CPDFSDK_PageView; #ifdef PDF_ENABLE_XFA @@ -31,6 +32,8 @@ class CPDFSDK_Annot : public Observable { explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView); virtual ~CPDFSDK_Annot(); + virtual CPDFSDK_BAAnnot* AsBAAnnot(); + #ifdef PDF_ENABLE_XFA virtual bool IsXFAField(); virtual CXFA_FFWidget* GetXFAWidget() const; @@ -57,4 +60,8 @@ class CPDFSDK_Annot : public Observable { UnownedPtr const m_pPageView; }; +inline CPDFSDK_BAAnnot* ToBAAnnot(CPDFSDK_Annot* pAnnot) { + return pAnnot ? pAnnot->AsBAAnnot() : nullptr; +} + #endif // FPDFSDK_CPDFSDK_ANNOT_H_ -- cgit v1.2.3