Index: fpdfsdk/src/fsdk_mgr.cpp |
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp |
index 4cf05a2d79d35ee4a15f047a4531c8b7e53c40a7..58acf22c06ba83aaf501f5d4491a205519debba0 100644 |
--- a/fpdfsdk/src/fsdk_mgr.cpp |
+++ b/fpdfsdk/src/fsdk_mgr.cpp |
@@ -19,7 +19,8 @@ |
class CFX_SystemHandler : public IFX_SystemHandler { |
public: |
- CFX_SystemHandler(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv), m_nCharSet(-1) {} |
+ explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv) |
+ : m_pEnv(pEnv), m_nCharSet(-1) {} |
~CFX_SystemHandler() override {} |
public: |
@@ -643,8 +644,7 @@ CPDFSDK_PageView::~CPDFSDK_PageView() { |
} |
m_fxAnnotArray.RemoveAll(); |
- delete m_pAnnotList; |
- m_pAnnotList = NULL; |
+ m_pAnnotList.reset(); |
m_page->RemovePrivateData((void*)m_page); |
if (m_bTakeOverPage) { |
@@ -658,9 +658,9 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
m_curMatrix = *pUser2Device; |
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
- CPDFSDK_AnnotIterator annotIterator(this, TRUE); |
+ CPDFSDK_AnnotIterator annotIterator(this, true); |
int index = -1; |
- while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) { |
+ while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(&index)) { |
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); |
} |
@@ -668,7 +668,7 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
FX_FLOAT pageY) { |
- int nCount = m_pAnnotList->Count(); |
+ int nCount = CountAnnots(); |
for (int i = 0; i < nCount; i++) { |
CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
CFX_FloatRect annotRect; |
@@ -676,13 +676,13 @@ CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
if (annotRect.Contains(pageX, pageY)) |
return pAnnot; |
} |
- return NULL; |
+ return nullptr; |
} |
CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, |
FX_FLOAT pageY) { |
- int nCount = m_pAnnotList->Count(); |
- for (int i = 0; i < nCount; i++) { |
+ int nCount = CountAnnots(); |
+ for (int i = 0; i < nCount; ++i) { |
CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
if (pAnnot->GetSubType() == "Widget") { |
CFX_FloatRect annotRect; |
@@ -691,17 +691,17 @@ CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, |
return pAnnot; |
} |
} |
- return NULL; |
+ return nullptr; |
} |
CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
FX_FLOAT pageY) { |
- CPDFSDK_AnnotIterator annotIterator(this, FALSE); |
+ CPDFSDK_AnnotIterator annotIterator(this, false); |
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
CPDFSDK_Annot* pSDKAnnot = NULL; |
int index = -1; |
- while ((pSDKAnnot = annotIterator.Next(index))) { |
+ while ((pSDKAnnot = annotIterator.Next(&index))) { |
CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
if (rc.Contains(pageX, pageY)) |
return pSDKAnnot; |
@@ -712,12 +712,12 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
FX_FLOAT pageY) { |
- CPDFSDK_AnnotIterator annotIterator(this, FALSE); |
+ CPDFSDK_AnnotIterator annotIterator(this, false); |
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
CPDFSDK_Annot* pSDKAnnot = NULL; |
int index = -1; |
- while ((pSDKAnnot = annotIterator.Next(index))) { |
+ while ((pSDKAnnot = annotIterator.Next(&index))) { |
if (pSDKAnnot->GetType() == "Widget") { |
pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
CPDF_Point point(pageX, pageY); |
@@ -778,7 +778,7 @@ CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
return NULL; |
} |
-int CPDFSDK_PageView::CountAnnots() { |
+int CPDFSDK_PageView::CountAnnots() const { |
return m_pAnnotList->Count(); |
} |
@@ -918,11 +918,11 @@ void CPDFSDK_PageView::LoadFXAnnots() { |
FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
// Disable the default AP construction. |
CPDF_InterForm::EnableUpdateAP(FALSE); |
- m_pAnnotList = new CPDF_AnnotList(m_page); |
+ m_pAnnotList.reset(new CPDF_AnnotList(m_page)); |
CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
- int nCount = m_pAnnotList->Count(); |
+ int nCount = CountAnnots(); |
SetLock(TRUE); |
- for (int i = 0; i < nCount; i++) { |
+ for (int i = 0; i < nCount; ++i) { |
CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
CPDF_Document* pDoc = GetPDFDocument(); |
@@ -969,11 +969,12 @@ int CPDFSDK_PageView::GetPageIndex() { |
return -1; |
} |
-FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p) { |
- if (p == NULL) |
+FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p) const { |
+ if (!p) |
return FALSE; |
- int iCount = m_pAnnotList->Count(); |
- for (int i = 0; i < iCount; i++) { |
+ |
+ int nCount = CountAnnots(); |
+ for (int i = 0; i < nCount; ++i) { |
if (m_pAnnotList->GetAt(i) == p) |
return TRUE; |
} |