summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-30 23:42:33 -0700
committerLei Zhang <thestig@chromium.org>2015-10-30 23:42:33 -0700
commitc88c42f317c0e94c4c7b98949bfe1a495aef07a9 (patch)
tree338bce5904097056be9afc47796ad1ba22f05c53
parent1630dffdc1d554d8f2319e83cdbd7b12f480362d (diff)
downloadpdfium-c88c42f317c0e94c4c7b98949bfe1a495aef07a9.tar.xz
Clean up CPDF_AnnotList.
- Remove dead code - Stop using CFX_PtrArray - Mark more things const - Fix style nits R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1425093003 .
-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 770133b739..a86ae62610 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 bc0edf2fa2..f402aae76f 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -123,7 +123,7 @@ class CPDFSDK_Widget : public CPDFSDK_Annot {
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 6e3c718948..4177f76d72 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -73,7 +73,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 ae4e16368c..7502133dd0 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -292,9 +292,9 @@ class CPDFSDK_PageView final {
void PageView_OnDraw(CFX_RenderDevice* pDevice,
CPDF_Matrix* pUser2Device,
CPDF_RenderOptions* pOptions);
- 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) {
@@ -327,7 +327,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 c0391dfc14..0a5c00a308 100644
--- a/fpdfsdk/src/fpdf_ext.cpp
+++ b/fpdfsdk/src/fpdf_ext.cpp
@@ -57,12 +57,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");
@@ -77,7 +77,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 24a46a7273..c0576ae59c 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -277,7 +277,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 fc45cd931b..e3536e0a19 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -99,37 +99,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 2797bc8f9a..ab6e3cf023 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -635,11 +635,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))
@@ -648,11 +646,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);
@@ -869,9 +865,9 @@ void CPDFSDK_PageView::LoadFXAnnots() {
CPDF_InterForm::EnableUpdateAP(FALSE);
m_pAnnotList.reset(new CPDF_AnnotList(m_page));
CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
- const int nCount = m_pAnnotList->Count();
+ const size_t nCount = m_pAnnotList->Count();
SetLock(TRUE);
- for (int i = 0; i < nCount; ++i) {
+ for (size_t i = 0; i < nCount; ++i) {
CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
CPDF_Document* pDoc = GetPDFDocument();
@@ -914,16 +910,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() {