Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_annot.h
Go to the documentation of this file.
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 CORE_FPDFDOC_CPDF_ANNOT_H_
8#define CORE_FPDFDOC_CPDF_ANNOT_H_
9
10#include <stddef.h>
11#include <stdint.h>
12
13#include <map>
14#include <memory>
15
16#include "core/fpdfapi/parser/cpdf_stream.h"
17#include "core/fxcrt/bytestring.h"
18#include "core/fxcrt/fx_coordinates.h"
19#include "core/fxcrt/maybe_owned.h"
20#include "core/fxcrt/retain_ptr.h"
21#include "core/fxcrt/unowned_ptr.h"
22#include "third_party/abseil-cpp/absl/types/optional.h"
23
25class CPDF_Array;
26class CPDF_Dictionary;
27class CPDF_Document;
28class CPDF_Form;
29class CPDF_Page;
31
33 public:
35 enum class Subtype : uint8_t {
36 UNKNOWN = 0,
37 TEXT,
38 LINK,
40 LINE,
41 SQUARE,
42 CIRCLE,
43 POLYGON,
49 STAMP,
50 CARET,
51 INK,
52 POPUP,
54 SOUND,
55 MOVIE,
56 WIDGET,
57 SCREEN,
59 TRAPNET,
61 THREED,
64 REDACT
65 };
66
67 static Subtype StringToAnnotSubtype(const ByteString& sSubtype);
68 static ByteString AnnotSubtypeToString(Subtype nSubtype);
69 static CFX_FloatRect RectFromQuadPointsArray(const CPDF_Array* pArray,
70 size_t nIndex);
72 const CPDF_Dictionary* pAnnotDict);
73 static CFX_FloatRect RectFromQuadPoints(const CPDF_Dictionary* pAnnotDict,
74 size_t nIndex);
75 static size_t QuadPointCount(const CPDF_Array* pArray);
76
77 CPDF_Annot(RetainPtr<CPDF_Dictionary> pDict, CPDF_Document* pDocument);
78 ~CPDF_Annot();
79
80 Subtype GetSubtype() const;
81 uint32_t GetFlags() const;
82 CFX_FloatRect GetRect() const;
83 const CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict.Get(); }
84 RetainPtr<CPDF_Dictionary> GetMutableAnnotDict() { return m_pAnnotDict; }
85
86 bool IsHidden() const;
87
88 bool DrawAppearance(CPDF_Page* pPage,
89 CFX_RenderDevice* pDevice,
90 const CFX_Matrix& mtUser2Device,
91 AppearanceMode mode);
92 bool DrawInContext(CPDF_Page* pPage,
93 CPDF_RenderContext* pContext,
94 const CFX_Matrix& mtUser2Device,
95 AppearanceMode mode);
96
97 void ClearCachedAP();
98 void DrawBorder(CFX_RenderDevice* pDevice, const CFX_Matrix* pUser2Device);
99 CPDF_Form* GetAPForm(CPDF_Page* pPage, AppearanceMode mode);
100 void SetOpenState(bool bOpenState) { m_bOpenState = bOpenState; }
101 void SetPopupAnnotOpenState(bool bOpenState);
103 void SetPopupAnnot(CPDF_Annot* pAnnot) { m_pPopupAnnot = pAnnot; }
104
105 private:
106 void GenerateAPIfNeeded();
107 bool ShouldGenerateAP() const;
108 bool ShouldDrawAnnotation() const;
109
110 CFX_FloatRect RectForDrawing() const;
111
112 RetainPtr<CPDF_Dictionary> const m_pAnnotDict;
113 UnownedPtr<CPDF_Document> const m_pDocument;
114 std::map<RetainPtr<CPDF_Stream>, std::unique_ptr<CPDF_Form>> m_APMap;
115 // If non-null, then this is not a popup annotation.
116 UnownedPtr<CPDF_Annot> m_pPopupAnnot;
117 const Subtype m_nSubtype;
118 const bool m_bIsTextMarkupAnnotation;
119 // |m_bOpenState| is only set for popup annotations.
120 bool m_bOpenState = false;
121 bool m_bHasGeneratedAP;
122};
123
124// Get the AP in an annotation dict for a given appearance mode.
125// If |eMode| is not Normal and there is not AP for that mode, falls back to
126// the Normal AP.
127RetainPtr<CPDF_Stream> GetAnnotAP(CPDF_Dictionary* pAnnotDict,
129
130// Get the AP in an annotation dict for a given appearance mode.
131// No fallbacks to Normal like in GetAnnotAP.
132RetainPtr<CPDF_Stream> GetAnnotAPNoFallback(CPDF_Dictionary* pAnnotDict,
134
135#endif // CORE_FPDFDOC_CPDF_ANNOT_H_
float Left() const
constexpr CFX_FloatRect()=default
float Top() const
void Deflate(float x, float y)
void Union(const CFX_FloatRect &other_rect)
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src)
void Rotate(float fRadian)
void Concat(const CFX_Matrix &right)
void AppendFloatRect(const CFX_FloatRect &rect)
Definition cfx_path.cpp:305
bool DrawPath(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_GraphStateData *pGraphState, uint32_t fill_color, uint32_t stroke_color, const CFX_FillRenderOptions &fill_options)
DeviceType GetDeviceType() const
uint32_t GetFlags() const
static CFX_FloatRect RectFromQuadPoints(const CPDF_Dictionary *pAnnotDict, size_t nIndex)
CPDF_Form * GetAPForm(CPDF_Page *pPage, AppearanceMode mode)
bool DrawInContext(CPDF_Page *pPage, CPDF_RenderContext *pContext, const CFX_Matrix &mtUser2Device, AppearanceMode mode)
static ByteString AnnotSubtypeToString(Subtype nSubtype)
static CFX_FloatRect RectFromQuadPointsArray(const CPDF_Array *pArray, size_t nIndex)
static size_t QuadPointCount(const CPDF_Array *pArray)
absl::optional< CFX_FloatRect > GetPopupAnnotRect() const
Subtype GetSubtype() const
const CPDF_Dictionary * GetAnnotDict() const
Definition cpdf_annot.h:83
void ClearCachedAP()
static Subtype StringToAnnotSubtype(const ByteString &sSubtype)
void SetOpenState(bool bOpenState)
Definition cpdf_annot.h:100
CFX_FloatRect GetRect() const
CPDF_Annot(RetainPtr< CPDF_Dictionary > pDict, CPDF_Document *pDocument)
bool IsHidden() const
bool DrawAppearance(CPDF_Page *pPage, CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, AppearanceMode mode)
RetainPtr< CPDF_Dictionary > GetMutableAnnotDict()
Definition cpdf_annot.h:84
void DrawBorder(CFX_RenderDevice *pDevice, const CFX_Matrix *pUser2Device)
static CFX_FloatRect BoundingRectFromQuadPoints(const CPDF_Dictionary *pAnnotDict)
void SetPopupAnnot(CPDF_Annot *pAnnot)
Definition cpdf_annot.h:103
void SetPopupAnnotOpenState(bool bOpenState)
bool KeyExist(const ByteString &key) const
RetainPtr< CPDF_Stream > GetMutableStreamFor(const ByteString &key)
ByteString GetByteStringFor(const ByteString &key) const
CPDF_Document * GetDocument() const override
Definition cpdf_page.cpp:51
int GetPageRotation() const
CPDF_PageImageCache * GetPageImageCache()
Definition cpdf_page.h:83
void AppendLayer(CPDF_PageObjectHolder *pObjectHolder, const CFX_Matrix &mtObject2Device)
void Render(CFX_RenderDevice *pDevice, const CPDF_PageObject *pStopObj, const CPDF_RenderOptions *pOptions, const CFX_Matrix *pLastMatrix)
bool operator==(const char *ptr) const
ByteString & operator=(ByteString &&that) noexcept
bool IsEmpty() const
Definition bytestring.h:119
CharType operator[](const size_t index) const
Definition bytestring.h:150
RetainPtr< CPDF_Stream > GetAnnotAPNoFallback(CPDF_Dictionary *pAnnotDict, CPDF_Annot::AppearanceMode eMode)
RetainPtr< CPDF_Stream > GetAnnotAP(CPDF_Dictionary *pAnnotDict, CPDF_Annot::AppearanceMode eMode)
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition fx_dib.h:118
#define FXSYS_PI
Definition fx_system.h:43
constexpr uint32_t kNoView
constexpr uint32_t kHidden
constexpr uint32_t kNoRotate
constexpr uint32_t kPrint