diff options
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r-- | fpdfsdk/src/fpdf_ext.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfeditpage.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_baseform.cpp | 24 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_mgr.cpp | 32 |
4 files changed, 21 insertions, 43 deletions
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() { |