summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-30 23:55:35 -0700
committerLei Zhang <thestig@chromium.org>2015-10-30 23:55:35 -0700
commit1b700c3c452429dacde3c163a6edb2706f93d4a7 (patch)
tree4efaf4dcec5b28a4d6cac575727dc61356e8a4fe /fpdfsdk
parentde6088db8403e775e2963ce6e0bd55e5356beb73 (diff)
downloadpdfium-1b700c3c452429dacde3c163a6edb2706f93d4a7.tar.xz
Merge to XFA: Clean up CPDF_AnnotList.
- Remove dead code - Stop using CFX_PtrArray - Mark more things const - Fix style nits TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1425093003 . (cherry picked from commit c88c42f317c0e94c4c7b98949bfe1a495aef07a9) Review URL: https://codereview.chromium.org/1430803003 .
Diffstat (limited to 'fpdfsdk')
-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
7 files changed, 26 insertions, 48 deletions
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() {