7#ifndef PDF_ANNOTATION_COLLECTION_H
8#define PDF_ANNOTATION_COLLECTION_H
10#include "PdfAnnotation.h"
17 class PODOFO_API PdfAnnotationCollection final
20 friend class PdfAnnotation;
23 PdfAnnotationCollection(PdfPage& page);
26 template <
typename TAnnotation>
27 TAnnotation& CreateAnnot(
const Rect& rect);
29 PdfAnnotation& CreateAnnot(PdfAnnotationType annotType,
const Rect& rect);
31 PdfAnnotation& GetAnnotAt(
unsigned index);
33 const PdfAnnotation& GetAnnotAt(
unsigned index)
const;
35 PdfAnnotation& GetAnnot(
const PdfReference& ref);
37 const PdfAnnotation& GetAnnot(
const PdfReference& ref)
const;
39 void RemoveAnnotAt(
unsigned index);
41 void RemoveAnnot(
const PdfReference& ref);
43 unsigned GetCount()
const;
46 using AnnotationList = std::vector<std::unique_ptr<PdfAnnotation>>;
48 template <
typename TObject,
typename TListIterator>
51 friend class PdfAnnotationCollection;
53 using difference_type = void;
54 using value_type = TObject*;
56 using reference = void;
57 using iterator_category = std::forward_iterator_tag;
61 Iterator(
const TListIterator& iterator) : m_iterator(iterator) { }
63 Iterator(
const Iterator&) =
default;
64 Iterator& operator=(
const Iterator&) =
default;
65 bool operator==(
const Iterator& rhs)
const
67 return m_iterator == rhs.m_iterator;
69 bool operator!=(
const Iterator& rhs)
const
71 return m_iterator != rhs.m_iterator;
73 Iterator& operator++()
78 Iterator operator++(
int)
84 value_type operator*()
86 return m_iterator->get();
88 value_type operator->()
90 return m_iterator->get();
93 TListIterator m_iterator;
96 using iterator = Iterator<PdfAnnotation, AnnotationList::iterator>;
97 using const_iterator = Iterator<const PdfAnnotation, AnnotationList::const_iterator>;
102 const_iterator begin()
const;
103 const_iterator end()
const;
106 PdfAnnotation& addAnnotation(std::unique_ptr<PdfAnnotation>&& annot);
107 PdfArray* getAnnotationsArray()
const;
108 void initAnnotations();
109 PdfAnnotation& getAnnotAt(
unsigned index)
const;
110 PdfAnnotation& getAnnot(
const PdfReference& ref)
const;
111 void fixIndices(
unsigned index);
114 using AnnotationMap = std::map<PdfReference, unsigned>;
117 AnnotationList m_Annots;
118 std::unique_ptr<AnnotationMap> m_annotMap;
120 PdfArray* m_annotArray;
123 template<
typename TAnnotation>
124 TAnnotation& PdfAnnotationCollection::CreateAnnot(
const Rect& rect)
126 return static_cast<TAnnotation&
>(CreateAnnot(PdfAnnotation::GetAnnotationType<TAnnotation>(), rect));
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition basetypes.h:16