summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/include/fpdfdoc/fpdf_doc.h61
-rw-r--r--core/src/fpdfdoc/doc_annot.cpp120
-rw-r--r--core/src/fpdfdoc/doc_form.cpp2
-rw-r--r--fpdfsdk/include/fsdk_baseform.h2
-rw-r--r--fpdfsdk/include/fsdk_define.h2
-rw-r--r--fpdfsdk/include/fsdk_mgr.h6
-rw-r--r--fpdfsdk/src/fpdf_ext.cpp6
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp2
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp24
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp32
10 files changed, 86 insertions, 171 deletions
diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h
index 168d9ebee0..cc5cf08005 100644
--- a/core/include/fpdfdoc/fpdf_doc.h
+++ b/core/include/fpdfdoc/fpdf_doc.h
@@ -394,7 +394,8 @@ class CPDF_Annot : public CFX_PrivateData {
void GetRect(CFX_FloatRect& rect) const;
- CPDF_Dictionary* GetAnnotDict();
+ const CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict; }
+ CPDF_Dictionary* GetAnnotDict() { return m_pAnnotDict; }
FX_BOOL DrawAppearance(const CPDF_Page* pPage,
CFX_RenderDevice* pDevice,
@@ -427,45 +428,18 @@ class CPDF_Annot : public CFX_PrivateData {
class CPDF_AnnotList {
public:
- CPDF_AnnotList(CPDF_Page* pPage);
-
+ explicit CPDF_AnnotList(CPDF_Page* pPage);
~CPDF_AnnotList();
- void GetAnnotMatrix(const CPDF_Dictionary* pAnnotDict,
- const CFX_Matrix* pUser2Device,
- CFX_Matrix& matrix) const;
-
- void GetAnnotRect(const CPDF_Dictionary* pAnnotDict,
- const CFX_Matrix* pUser2Device,
- CPDF_Rect& rtAnnot) const;
-
- void DisplayAnnots(const CPDF_Page* pPage,
- CFX_RenderDevice* pDevice,
- CFX_AffineMatrix* pMatrix,
- FX_BOOL bShowWidget,
- CPDF_RenderOptions* pOptions);
-
void DisplayAnnots(const CPDF_Page* pPage,
CPDF_RenderContext* pContext,
FX_BOOL bPrinting,
CFX_AffineMatrix* pMatrix,
FX_BOOL bShowWidget,
CPDF_RenderOptions* pOptions) {
- DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix,
- bShowWidget ? 3 : 1, pOptions, NULL);
+ DisplayAnnots(pPage, nullptr, pContext, bPrinting, pMatrix,
+ bShowWidget ? 3 : 1, pOptions, nullptr);
}
-
- void DisplayAnnots(const CPDF_Page* pPage,
- CPDF_RenderContext* pContext,
- FX_BOOL bPrinting,
- CFX_AffineMatrix* pMatrix,
- FX_BOOL bShowWidget,
- CPDF_RenderOptions* pOptions,
- FX_RECT* pClipRect) {
- DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix,
- bShowWidget ? 3 : 1, pOptions, pClipRect);
- }
-
void DisplayAnnots(const CPDF_Page* pPage,
CFX_RenderDevice* pDevice,
CPDF_RenderContext* pContext,
@@ -474,24 +448,12 @@ class CPDF_AnnotList {
FX_DWORD dwAnnotFlags,
CPDF_RenderOptions* pOptions,
FX_RECT* pClipRect);
-
- CPDF_Annot* GetAt(int index) { return (CPDF_Annot*)m_AnnotList.GetAt(index); }
-
- int Count() { return m_AnnotList.GetSize(); }
-
- int GetIndex(CPDF_Annot* pAnnot);
-
+ size_t Count() const { return m_AnnotList.size(); }
+ CPDF_Annot* GetAt(size_t index) const { return m_AnnotList[index]; }
+ const std::vector<CPDF_Annot*>& All() const { return m_AnnotList; }
CPDF_Document* GetDocument() const { return m_pDocument; }
protected:
- CFX_PtrArray m_AnnotList;
-
- CPDF_Dictionary* m_pPageDict;
-
- CPDF_Document* m_pDocument;
-
- CFX_PtrArray m_Borders;
-
void DisplayPass(const CPDF_Page* pPage,
CFX_RenderDevice* pDevice,
CPDF_RenderContext* pContext,
@@ -500,8 +462,11 @@ class CPDF_AnnotList {
FX_BOOL bWidget,
CPDF_RenderOptions* pOptions,
FX_RECT* clip_rect);
- friend class CPDF_Annot;
+
+ CPDF_Document* const m_pDocument;
+ std::vector<CPDF_Annot*> m_AnnotList;
};
+
#define COLORTYPE_TRANSPARENT 0
#define COLORTYPE_GRAY 1
#define COLORTYPE_RGB 2
@@ -623,7 +588,7 @@ class CPDF_InterForm : public CFX_PrivateData {
FX_FLOAT pdf_y,
int* z_order) const;
- CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const;
+ CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const;
CPDF_Document* GetDocument() const { return m_pDocument; }
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index d37b1aaadb..ae253a086a 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -8,25 +8,23 @@
#include "../../include/fpdfdoc/fpdf_doc.h"
#include "../../include/fpdfapi/fpdf_pageobj.h"
-CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) {
- ASSERT(pPage != NULL);
- m_pPageDict = pPage->m_pFormDict;
- if (m_pPageDict == NULL) {
+CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
+ : m_pDocument(pPage->m_pDocument) {
+ if (!pPage->m_pFormDict)
return;
- }
- m_pDocument = pPage->m_pDocument;
- CPDF_Array* pAnnots = m_pPageDict->GetArray("Annots");
- if (pAnnots == NULL) {
+
+ CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots");
+ if (!pAnnots)
return;
- }
+
CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
FX_BOOL bRegenerateAP = pAcroForm && pAcroForm->GetBoolean("NeedAppearances");
for (FX_DWORD i = 0; i < pAnnots->GetCount(); ++i) {
CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetElementValue(i));
- if (!pDict) {
+ if (!pDict)
continue;
- }
+
FX_DWORD dwObjNum = pDict->GetObjNum();
if (dwObjNum == 0) {
dwObjNum = m_pDocument->AddIndirectObject(pDict);
@@ -35,24 +33,20 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) {
pAnnots->RemoveAt(i + 1);
pDict = pAnnots->GetDict(i);
}
- CPDF_Annot* pAnnot = new CPDF_Annot(pDict, this);
- m_AnnotList.Add(pAnnot);
+ m_AnnotList.push_back(new CPDF_Annot(pDict, this));
if (bRegenerateAP &&
- pDict->GetConstString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget"))
- if (CPDF_InterForm::UpdatingAPEnabled()) {
- FPDF_GenerateAP(m_pDocument, pDict);
- }
+ pDict->GetConstString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget") &&
+ CPDF_InterForm::UpdatingAPEnabled()) {
+ FPDF_GenerateAP(m_pDocument, pDict);
+ }
}
}
+
CPDF_AnnotList::~CPDF_AnnotList() {
- int i = 0;
- for (i = 0; i < m_AnnotList.GetSize(); ++i) {
- delete (CPDF_Annot*)m_AnnotList[i];
- }
- for (i = 0; i < m_Borders.GetSize(); ++i) {
- delete (CPDF_PageObjects*)m_Borders[i];
- }
+ for (CPDF_Annot* annot : m_AnnotList)
+ delete annot;
}
+
void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage,
CFX_RenderDevice* pDevice,
CPDF_RenderContext* pContext,
@@ -61,34 +55,32 @@ void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage,
FX_BOOL bWidgetPass,
CPDF_RenderOptions* pOptions,
FX_RECT* clip_rect) {
- for (int i = 0; i < m_AnnotList.GetSize(); ++i) {
- CPDF_Annot* pAnnot = (CPDF_Annot*)m_AnnotList[i];
+ for (CPDF_Annot* pAnnot : m_AnnotList) {
FX_BOOL bWidget = pAnnot->GetSubType() == "Widget";
- if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget)) {
+ if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget))
continue;
- }
+
FX_DWORD annot_flags = pAnnot->GetFlags();
- if (annot_flags & ANNOTFLAG_HIDDEN) {
+ if (annot_flags & ANNOTFLAG_HIDDEN)
continue;
- }
- if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) {
+
+ if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0)
continue;
- }
- if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) {
+
+ if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW))
continue;
- }
- if (pOptions != NULL) {
+
+ if (pOptions) {
IPDF_OCContext* pOCContext = pOptions->m_pOCContext;
CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict();
- if (pOCContext != NULL && pAnnotDict != NULL &&
+ if (pOCContext && pAnnotDict &&
!pOCContext->CheckOCGVisible(pAnnotDict->GetDict(FX_BSTRC("OC")))) {
continue;
}
}
CPDF_Rect annot_rect_f;
pAnnot->GetRect(annot_rect_f);
- CFX_Matrix matrix;
- matrix = *pMatrix;
+ CFX_Matrix matrix = *pMatrix;
if (clip_rect) {
annot_rect_f.Transform(&matrix);
FX_RECT annot_rect = annot_rect_f.GetOutterRect();
@@ -105,20 +97,7 @@ void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage,
}
}
}
-void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage,
- CFX_RenderDevice* pDevice,
- CFX_AffineMatrix* pUser2Device,
- FX_BOOL bShowWidget,
- CPDF_RenderOptions* pOptions) {
- FX_RECT clip_rect;
- if (pDevice) {
- clip_rect = pDevice->GetClipBox();
- }
- FX_BOOL bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER ||
- (pOptions && (pOptions->m_Flags & RENDER_PRINTPREVIEW));
- DisplayAnnots(pPage, pDevice, NULL, bPrinting, pUser2Device,
- bShowWidget ? 3 : 1, pOptions, &clip_rect);
-}
+
void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage,
CFX_RenderDevice* pDevice,
CPDF_RenderContext* pContext,
@@ -136,13 +115,7 @@ void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage,
pOptions, pClipRect);
}
}
-int CPDF_AnnotList::GetIndex(CPDF_Annot* pAnnot) {
- for (int i = 0; i < m_AnnotList.GetSize(); ++i)
- if (m_AnnotList[i] == (void*)pAnnot) {
- return i;
- }
- return -1;
-}
+
CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_AnnotList* pList)
: m_pAnnotDict(pDict),
m_pList(pList),
@@ -176,10 +149,6 @@ FX_DWORD CPDF_Annot::GetFlags() const {
return m_pAnnotDict->GetInteger("F");
}
-CPDF_Dictionary* CPDF_Annot::GetAnnotDict() {
- return m_pAnnotDict;
-}
-
CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
CPDF_Annot::AppearanceMode mode) {
CPDF_Dictionary* pAP = pAnnotDict->GetDict("AP");
@@ -217,20 +186,23 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
}
return nullptr;
}
+
CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {
CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode);
- if (pStream == NULL) {
- return NULL;
- }
- CPDF_Form* pForm;
- if (m_APMap.Lookup(pStream, (void*&)pForm)) {
- return pForm;
- }
- pForm = new CPDF_Form(m_pList->m_pDocument, pPage->m_pResources, pStream);
- pForm->ParseContent(NULL, NULL, NULL, NULL);
- m_APMap.SetAt(pStream, pForm);
- return pForm;
+ if (!pStream)
+ return nullptr;
+
+ void* pForm;
+ if (m_APMap.Lookup(pStream, pForm))
+ return static_cast<CPDF_Form*>(pForm);
+
+ CPDF_Form* pNewForm =
+ new CPDF_Form(m_pList->GetDocument(), pPage->m_pResources, pStream);
+ pNewForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
+ m_APMap.SetAt(pStream, pNewForm);
+ return pNewForm;
}
+
static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage,
CPDF_Annot* pAnnot,
CPDF_Annot::AppearanceMode mode,
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index c155b947d9..5cc2a66a89 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -818,7 +818,7 @@ CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
}
CPDF_FormControl* CPDF_InterForm::GetControlByDict(
- CPDF_Dictionary* pWidgetDict) const {
+ const CPDF_Dictionary* pWidgetDict) const {
const auto it = m_ControlMap.find(pWidgetDict);
return it != m_ControlMap.end() ? it->second : nullptr;
}
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index 14c8fefad2..bcba4c831b 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -155,7 +155,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
CPDF_FormField* GetFormField() const;
CPDF_FormControl* GetFormControl() const;
static CPDF_FormControl* GetFormControl(CPDF_InterForm* pInterForm,
- CPDF_Dictionary* pAnnotDict);
+ const CPDF_Dictionary* pAnnotDict);
void DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView);
diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h
index 2faaf01298..f62234af09 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -108,7 +108,7 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext,
IFSDK_PAUSE_Adapter* pause);
void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code);
-void CheckUnSupportAnnot(CPDF_Document* pDoc, CPDF_Annot* pPDFAnnot);
+void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot);
void ProcessParseError(FX_DWORD err_code);
#endif // FPDFSDK_INCLUDE_FSDK_DEFINE_H_
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index bfbbd63ac0..615b585b51 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -538,9 +538,9 @@ class CPDFSDK_PageView final {
CPDF_Matrix* pUser2Device,
CPDF_RenderOptions* pOptions,
FX_RECT* pClip = NULL);
- CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
+ const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
- CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
+ const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
CPDFSDK_Annot* GetFocusAnnot();
void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot, FX_UINT nFlag = 0) {
@@ -578,7 +578,7 @@ class CPDFSDK_PageView final {
double deltaY,
const CPDF_Point& point,
int nFlag);
- FX_BOOL IsValidAnnot(CPDF_Annot* p) const;
+ bool IsValidAnnot(const CPDF_Annot* p) const;
void GetCurrentMatrix(CPDF_Matrix& matrix) { matrix = m_curMatrix; }
void UpdateRects(CFX_RectArray& rects);
void UpdateView(CPDFSDK_Annot* pAnnot);
diff --git a/fpdfsdk/src/fpdf_ext.cpp b/fpdfsdk/src/fpdf_ext.cpp
index 196ac99967..aead361c9a 100644
--- a/fpdfsdk/src/fpdf_ext.cpp
+++ b/fpdfsdk/src/fpdf_ext.cpp
@@ -58,12 +58,12 @@ FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) {
return TRUE;
}
-void CheckUnSupportAnnot(CPDF_Document* pDoc, CPDF_Annot* pPDFAnnot) {
+void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) {
CFX_ByteString cbSubType = pPDFAnnot->GetSubType();
if (cbSubType.Compare("3D") == 0) {
FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT);
} else if (cbSubType.Compare("Screen") == 0) {
- CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
+ const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
CFX_ByteString cbString;
if (pAnnotDict->KeyExist("IT"))
cbString = pAnnotDict->GetString("IT");
@@ -78,7 +78,7 @@ void CheckUnSupportAnnot(CPDF_Document* pDoc, CPDF_Annot* pPDFAnnot) {
} else if (cbSubType.Compare("FileAttachment") == 0) {
FPDF_UnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT);
} else if (cbSubType.Compare("Widget") == 0) {
- CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
+ const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
CFX_ByteString cbString;
if (pAnnotDict->KeyExist("FT")) {
cbString = pAnnotDict->GetString("FT");
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index 8b4168fbf4..531d37247d 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -280,7 +280,7 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
if (!pPage)
return;
CPDF_AnnotList AnnotList(pPage);
- for (int i = 0; i < AnnotList.Count(); i++) {
+ for (size_t i = 0; i < AnnotList.Count(); ++i) {
CPDF_Annot* pAnnot = AnnotList.GetAt(i);
// transformAnnots Rectangle
CPDF_Rect rect;
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 54b607a382..e486310ba2 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -566,37 +566,23 @@ CFX_ByteString CPDFSDK_Widget::GetSubType() const {
}
CPDF_FormField* CPDFSDK_Widget::GetFormField() const {
- ASSERT(m_pInterForm != NULL);
-
- CPDF_FormControl* pCtrl = GetFormControl();
- ASSERT(pCtrl != NULL);
-
- return pCtrl->GetField();
+ return GetFormControl()->GetField();
}
CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const {
- ASSERT(m_pInterForm != NULL);
-
CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm();
- ASSERT(pPDFInterForm != NULL);
-
return pPDFInterForm->GetControlByDict(GetAnnotDict());
}
-CPDF_FormControl* CPDFSDK_Widget::GetFormControl(CPDF_InterForm* pInterForm,
- CPDF_Dictionary* pAnnotDict) {
- ASSERT(pInterForm != NULL);
+CPDF_FormControl* CPDFSDK_Widget::GetFormControl(
+ CPDF_InterForm* pInterForm,
+ const CPDF_Dictionary* pAnnotDict) {
ASSERT(pAnnotDict != NULL);
-
- CPDF_FormControl* pControl = pInterForm->GetControlByDict(pAnnotDict);
-
- return pControl;
+ return pInterForm->GetControlByDict(pAnnotDict);
}
int CPDFSDK_Widget::GetRotate() const {
CPDF_FormControl* pCtrl = GetFormControl();
- ASSERT(pCtrl != NULL);
-
return pCtrl->GetRotation() % 360;
}
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 9bb603d01f..f12e8fb595 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -696,11 +696,9 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
}
}
-CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
- FX_FLOAT pageY) {
- const int nCount = m_pAnnotList->Count();
- for (int i = 0; i < nCount; ++i) {
- CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
+const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
+ FX_FLOAT pageY) {
+ for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) {
CFX_FloatRect annotRect;
pAnnot->GetRect(annotRect);
if (annotRect.Contains(pageX, pageY))
@@ -709,11 +707,9 @@ CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
return nullptr;
}
-CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX,
- FX_FLOAT pageY) {
- const int nCount = m_pAnnotList->Count();
- for (int i = 0; i < nCount; ++i) {
- CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
+const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX,
+ FX_FLOAT pageY) {
+ for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) {
if (pAnnot->GetSubType() == "Widget") {
CFX_FloatRect annotRect;
pAnnot->GetRect(annotRect);
@@ -1051,8 +1047,8 @@ void CPDFSDK_PageView::LoadFXAnnots() {
m_pAnnotList.reset(new CPDF_AnnotList(pPage));
CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
- const int nCount = m_pAnnotList->Count();
- for (int i = 0; i < nCount; i++) {
+ const size_t nCount = m_pAnnotList->Count();
+ for (size_t i = 0; i < nCount; ++i) {
CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot);
@@ -1094,16 +1090,12 @@ int CPDFSDK_PageView::GetPageIndex() {
return -1;
}
-FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const {
+bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const {
if (!p)
- return FALSE;
+ return false;
- const int nCount = m_pAnnotList->Count();
- for (int i = 0; i < nCount; ++i) {
- if (m_pAnnotList->GetAt(i) == p)
- return TRUE;
- }
- return FALSE;
+ const auto& annots = m_pAnnotList->All();
+ return std::find(annots.begin(), annots.end(), p) != annots.end();
}
CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {