OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/include/cpdfsdk_annotiterator.h" | 7 #include "fpdfsdk/cpdfsdk_annotiterator.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "fpdfsdk/include/cpdfsdk_annot.h" | 11 #include "fpdfsdk/cpdfsdk_annot.h" |
12 #include "fpdfsdk/include/cpdfsdk_pageview.h" | 12 #include "fpdfsdk/cpdfsdk_pageview.h" |
13 | 13 |
14 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, | 14 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, |
15 bool bReverse) | 15 bool bReverse) |
16 : m_bReverse(bReverse), m_pos(0) { | 16 : m_bReverse(bReverse), m_pos(0) { |
17 const std::vector<CPDFSDK_Annot*>& annots = pPageView->GetAnnotList(); | 17 const std::vector<CPDFSDK_Annot*>& annots = pPageView->GetAnnotList(); |
18 m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), annots.rbegin(), | 18 m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), annots.rbegin(), |
19 annots.rend()); | 19 annots.rend()); |
20 std::stable_sort(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(), | 20 std::stable_sort(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(), |
21 [](CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { | 21 [](CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { |
22 return p1->GetLayoutOrder() < p2->GetLayoutOrder(); | 22 return p1->GetLayoutOrder() < p2->GetLayoutOrder(); |
(...skipping 22 matching lines...) Expand all Loading... |
45 | 45 |
46 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { | 46 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { |
47 if (m_pos < m_iteratorAnnotList.size()) | 47 if (m_pos < m_iteratorAnnotList.size()) |
48 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; | 48 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; |
49 return nullptr; | 49 return nullptr; |
50 } | 50 } |
51 | 51 |
52 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { | 52 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { |
53 return m_bReverse ? PrevAnnot() : NextAnnot(); | 53 return m_bReverse ? PrevAnnot() : NextAnnot(); |
54 } | 54 } |
OLD | NEW |