OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 PDFium Authors. All rights reserved. | |
dsinclair
2017/01/11 21:22:52
2017
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #include "fpdfsdk/cpdfsdk_annotiteration.h" | |
8 | |
9 #include <algorithm> | |
10 #include <utility> | |
11 | |
12 #include "fpdfsdk/cpdfsdk_annot.h" | |
13 #include "fpdfsdk/cpdfsdk_pageview.h" | |
14 | |
15 CPDFSDK_AnnotIteration::CPDFSDK_AnnotIteration(CPDFSDK_PageView* pPageView, | |
16 bool bReverse) { | |
17 // Copying/sorting ObservedPtrs is expensive, so do it once at the end. | |
18 std::vector<CPDFSDK_Annot*> copiedList = pPageView->GetAnnotList(); | |
19 std::stable_sort(copiedList.begin(), copiedList.end(), | |
20 [](const CPDFSDK_Annot* p1, const CPDFSDK_Annot* p2) { | |
21 return p1->GetLayoutOrder() < p2->GetLayoutOrder(); | |
22 }); | |
23 | |
24 CPDFSDK_Annot* pTopMostAnnot = pPageView->GetFocusAnnot(); | |
25 if (pTopMostAnnot) { | |
26 auto it = std::find(copiedList.begin(), copiedList.end(), pTopMostAnnot); | |
27 if (it != copiedList.end()) | |
28 std::swap(*it, *copiedList.begin()); | |
dsinclair
2017/01/11 21:22:52
Do we really want to swap here? Don't we just want
Tom Sepez
2017/01/11 21:34:26
Done.
| |
29 } | |
30 if (bReverse) | |
31 std::reverse(copiedList.begin(), copiedList.end()); | |
32 | |
33 m_List.reserve(copiedList.size()); | |
34 for (const auto& pAnnot : copiedList) | |
35 m_List.emplace_back(pAnnot); | |
36 } | |
37 | |
38 CPDFSDK_AnnotIteration::~CPDFSDK_AnnotIteration() {} | |
OLD | NEW |