From 19ae17578f99621100a26dac3e2c7c3dbf7c7cd1 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 20 Apr 2015 13:38:38 -0700 Subject: Remove release method from CBA_AnnotItetator. Also remove virtual methods, since this is neither subclassed nor a subclass. BUG=https://code.google.com/p/pdfium/issues/detail?id=140 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1097843003 --- fpdfsdk/include/fsdk_baseform.h | 23 +++++++++-------------- fpdfsdk/src/fsdk_baseform.cpp | 22 +++++++--------------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h index b15fba6475..16a23bfea3 100644 --- a/fpdfsdk/include/fsdk_baseform.h +++ b/fpdfsdk/include/fsdk_baseform.h @@ -261,32 +261,27 @@ private: #define CPDFSDK_Annots CFX_ArrayTemplate #define CPDFSDK_SortAnnots CGW_ArrayTemplate -class CBA_AnnotIterator +class CBA_AnnotIterator { public: CBA_AnnotIterator(CPDFSDK_PageView* pPageView, const CFX_ByteString& sType, const CFX_ByteString& sSubType); - virtual ~CBA_AnnotIterator(); - - virtual CPDFSDK_Annot* GetFirstAnnot(); - virtual CPDFSDK_Annot* GetLastAnnot(); - virtual CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pAnnot); - virtual CPDFSDK_Annot* GetPrevAnnot(CPDFSDK_Annot* pAnnot); - - virtual void Release(){delete this;} - + ~CBA_AnnotIterator(); + + CPDFSDK_Annot* GetFirstAnnot(); + CPDFSDK_Annot* GetLastAnnot(); + CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pAnnot); + CPDFSDK_Annot* GetPrevAnnot(CPDFSDK_Annot* pAnnot); + private: void GenerateResults(); static int CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); static int CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); - static CPDF_Rect GetAnnotRect(CPDFSDK_Annot* pAnnot); - -private: + CPDFSDK_PageView* m_pPageView; CFX_ByteString m_sType; CFX_ByteString m_sSubType; int m_nTabs; - CPDFSDK_Annots m_Annots; }; diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index 6c8069b92a..0c0492d723 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -4,6 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "../../third_party/base/nonstd_unique_ptr.h" #include "../include/fsdk_define.h" #include "../include/fsdk_mgr.h" #include "../include/fsdk_baseannot.h" @@ -1727,22 +1728,13 @@ FX_BOOL CPDFSDK_InterForm::HighlightWidgets() CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const { - ASSERT(pWidget != NULL); - - CBA_AnnotIterator* pIterator = new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", ""); - ASSERT(pIterator != NULL); - - CPDFSDK_Widget* pRet = NULL; - - if (bNext) - pRet = (CPDFSDK_Widget*)pIterator->GetNextAnnot(pWidget); - else - pRet = (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget); - - pIterator->Release(); - - return pRet; + nonstd::unique_ptr pIterator( + new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "")); + if (bNext) { + return (CPDFSDK_Widget*)pIterator->GetNextAnnot(pWidget); + } + return (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget); } CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const -- cgit v1.2.3