summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_annotiterator.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-11 14:03:54 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-11 14:03:54 -0800
commitd805eec52f6ac574918748c4270873e7e5cde596 (patch)
tree3dec3245638de8600bd9a213887be92cc53a1d76 /fpdfsdk/cpdfsdk_annotiterator.cpp
parent5e3121beff936df1b0af3749447eeda1666d5d76 (diff)
downloadpdfium-d805eec52f6ac574918748c4270873e7e5cde596.tar.xz
Use observed pointers in CPDFSDK_AnnotIterator.chromium/2979
Rename to CPDFSDK_AnnotIteration, as it is now an ordered set of annots, and not the iterator itself. Review-Url: https://codereview.chromium.org/2626073005
Diffstat (limited to 'fpdfsdk/cpdfsdk_annotiterator.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_annotiterator.cpp54
1 files changed, 0 insertions, 54 deletions
diff --git a/fpdfsdk/cpdfsdk_annotiterator.cpp b/fpdfsdk/cpdfsdk_annotiterator.cpp
deleted file mode 100644
index f2c997b7f1..0000000000
--- a/fpdfsdk/cpdfsdk_annotiterator.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/cpdfsdk_annotiterator.h"
-
-#include <algorithm>
-
-#include "fpdfsdk/cpdfsdk_annot.h"
-#include "fpdfsdk/cpdfsdk_pageview.h"
-
-CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView,
- bool bReverse)
- : m_bReverse(bReverse), m_pos(0) {
- const std::vector<CPDFSDK_Annot*>& annots = pPageView->GetAnnotList();
- m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), annots.rbegin(),
- annots.rend());
- std::stable_sort(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(),
- [](CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) {
- return p1->GetLayoutOrder() < p2->GetLayoutOrder();
- });
-
- CPDFSDK_Annot* pTopMostAnnot = pPageView->GetFocusAnnot();
- if (!pTopMostAnnot)
- return;
-
- auto it = std::find(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(),
- pTopMostAnnot);
- if (it != m_iteratorAnnotList.end()) {
- CPDFSDK_Annot* pReaderAnnot = *it;
- m_iteratorAnnotList.erase(it);
- m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), pReaderAnnot);
- }
-}
-
-CPDFSDK_AnnotIterator::~CPDFSDK_AnnotIterator() {}
-
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot() {
- if (m_pos < m_iteratorAnnotList.size())
- return m_iteratorAnnotList[m_pos++];
- return nullptr;
-}
-
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() {
- if (m_pos < m_iteratorAnnotList.size())
- return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos];
- return nullptr;
-}
-
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() {
- return m_bReverse ? PrevAnnot() : NextAnnot();
-}