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 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() { |