summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
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 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() {