1 // Copyright 2016 The PDFium Authors 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 #ifndef FPDFSDK_CPDFSDK_ANNOTITERATOR_H_ 8 #define FPDFSDK_CPDFSDK_ANNOTITERATOR_H_ 9 10 #include <vector> 11 12 #include "core/fpdfdoc/cpdf_annot.h" 13 #include "core/fxcrt/fx_coordinates.h" 14 #include "core/fxcrt/span.h" 15 #include "core/fxcrt/unowned_ptr.h" 16 17 class CPDFSDK_Annot; 18 class CPDFSDK_PageView; 19 20 class CPDFSDK_AnnotIterator { 21 public: 22 CPDFSDK_AnnotIterator( 23 CPDFSDK_PageView* pPageView, 24 const std::vector<CPDF_Annot::Subtype>& subtypes_to_iterate); 25 ~CPDFSDK_AnnotIterator(); 26 27 CPDFSDK_Annot* GetFirstAnnot(); 28 CPDFSDK_Annot* GetLastAnnot(); 29 CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pAnnot); 30 CPDFSDK_Annot* GetPrevAnnot(CPDFSDK_Annot* pAnnot); 31 32 private: 33 enum class TabOrder : uint8_t { kStructure = 0, kRow, kColumn }; 34 35 static TabOrder GetTabOrder(CPDFSDK_PageView* pPageView); 36 37 void GenerateResults(); 38 void CollectAnnots(std::vector<UnownedPtr<CPDFSDK_Annot>>* pArray); 39 CFX_FloatRect AddToAnnotsList(std::vector<UnownedPtr<CPDFSDK_Annot>>& sa, 40 size_t idx); 41 void AddSelectedToAnnots(std::vector<UnownedPtr<CPDFSDK_Annot>>& sa, 42 pdfium::span<const size_t> aSelect); 43 44 UnownedPtr<CPDFSDK_PageView> const m_pPageView; 45 const std::vector<CPDF_Annot::Subtype> m_subtypes; 46 const TabOrder m_eTabOrder; 47 std::vector<UnownedPtr<CPDFSDK_Annot>> m_Annots; 48 }; 49 50 #endif // FPDFSDK_CPDFSDK_ANNOTITERATOR_H_ 51