7#include "fpdfsdk/cpdfsdk_baannot.h"
11#include "constants/annotation_common.h"
12#include "constants/annotation_flags.h"
13#include "constants/form_fields.h"
14#include "core/fpdfapi/parser/cpdf_array.h"
15#include "core/fpdfapi/parser/cpdf_dictionary.h"
16#include "core/fpdfapi/parser/cpdf_name.h"
17#include "core/fpdfapi/parser/cpdf_number.h"
18#include "core/fpdfapi/parser/cpdf_reference.h"
19#include "core/fpdfapi/parser/cpdf_stream.h"
20#include "core/fpdfapi/parser/cpdf_string.h"
21#include "core/fpdfapi/parser/fpdf_parser_decode.h"
22#include "core/fpdfapi/parser/fpdf_parser_utility.h"
23#include "core/fxge/cfx_drawutils.h"
24#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
25#include "fpdfsdk/cpdfsdk_pageview.h"
26#include "third_party/abseil-cpp/absl/types/optional.h"
27#include "third_party/base/check.h"
28#include "third_party/base/containers/contains.h"
31 CPDFSDK_PageView* pPageView)
49 return m_pAnnot->GetAnnotDict();
53 return m_pAnnot->GetMutableAnnotDict();
57 return GetMutableAnnotDict()->GetOrCreateDictFor(pdfium::annotation::kAP);
61 m_pAnnot->ClearCachedAP();
66 return pdfium::Contains(
67 GetPageView()->GetFormFillEnv()->GetFocusableAnnotSubtypes(), annot_type);
71 return m_pAnnot->GetRect();
75 return m_pAnnot->GetSubtype();
81 m_pAnnot->DrawAppearance(GetPageView()->GetPDFPage(), pDevice, mtUser2Device,
90 RetainPtr<CPDF_Dictionary> pDict = GetMutableAnnotDict();
103 GetMutableAnnotDict()->SetNewFor<CPDF_Number>(pdfium::annotation::kF,
104 static_cast<
int>(nFlags));
112 RetainPtr<CPDF_Dictionary> pDict = GetMutableAnnotDict();
121 RetainPtr<CPDF_Dictionary> pAnnotDict = GetMutableAnnotDict();
123 pAnnotDict->GetMutableArrayFor(pdfium::annotation::kBorder);
125 pBorder->SetNewAt<CPDF_Number>(2, nWidth);
128 pAnnotDict->GetOrCreateDictFor(
"BS")->SetNewFor<CPDF_Number>(
"W", nWidth);
133 GetAnnotDict()->GetArrayFor(pdfium::annotation::kBorder);
135 return pBorder->GetIntegerAt(2);
137 RetainPtr<
const CPDF_Dictionary> pBSDict = GetAnnotDict()->GetDictFor(
"BS");
139 return pBSDict->GetIntegerFor(
"W", 1);
146 GetMutableAnnotDict()->GetOrCreateDictFor(
"BS");
147 const char* name =
nullptr;
165 pBSDict->SetNewFor<CPDF_Name>(
"S", name);
169 RetainPtr<
const CPDF_Dictionary> pBSDict = GetAnnotDict()->GetDictFor(
"BS");
171 ByteString sBorderStyle = pBSDict->GetByteStringFor(
"S",
"S");
172 if (sBorderStyle
== "S")
174 if (sBorderStyle
== "D")
176 if (sBorderStyle
== "B")
178 if (sBorderStyle
== "I")
180 if (sBorderStyle
== "U")
185 GetAnnotDict()->GetArrayFor(pdfium::annotation::kBorder);
187 if (pBorder->size() >= 4) {
188 RetainPtr<
const CPDF_Array> pDP = pBorder->GetArrayAt(3);
189 if (pDP && pDP->size() > 0)
220 return CPDF_Action(
nullptr);
224 m_pAnnot->SetPopupAnnotOpenState(bOpenState);
228 std::vector<CFX_FloatRect> rects;
231 absl::optional<CFX_FloatRect> annot_rect = m_pAnnot->GetPopupAnnotRect();
232 if (annot_rect.has_value())
233 rects.push_back(annot_rect.value());
236 for (CFX_FloatRect& rect : rects)
254 if (m_pAnnot->GetSubtype() == CPDF_Annot::Subtype::POPUP)
273 this !=
GetPageView()->GetFormFillEnv()->GetFocusAnnot()) {
304 const CFX_PointF& point) {
309 const CFX_PointF& point) {
314 const CFX_PointF& point) {
319 const CFX_PointF& point) {
324 const CFX_PointF& point,
325 const CFX_Vector& delta) {
330 const CFX_PointF& point) {
335 const CFX_PointF& point) {
344 Mask<FWL_EVENTFLAG> nFlags) {
354 CPDFSDK_FormFillEnvironment* env =
GetPageView()->GetFormFillEnv();
421 if (m_pAnnot->GetSubtype() != CPDF_Annot::Subtype::LINK)
422 return CPDF_Dest(
nullptr);
static void DrawFocusRect(CFX_RenderDevice *render_device, const CFX_Matrix &user_to_device, const CFX_FloatRect &view_bounding_box)
void Inflate(float x, float y)
FX_RECT GetOuterRect() const
virtual int GetLayoutOrder() const
CPDFSDK_Annot(CPDFSDK_PageView *pPageView)
CPDFSDK_PageView * GetPageView() const
const CPDF_Dictionary * GetAnnotDict() const
CPDF_Annot * GetPDFAnnot() const override
CFX_FloatRect GetViewBBox() override
WideString GetAnnotName() const
void SetAnnotName(const WideString &sName)
void ReplaceSelection(const WideString &text) override
bool SetIndexSelected(int index, bool selected) override
bool OnChar(uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags) override
CPDF_Annot::Subtype GetAnnotSubtype() const override
bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point, const CFX_Vector &delta) override
bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
bool IsIndexSelected(int index) override
bool SelectAllText() override
virtual void DrawAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, CPDF_Annot::AppearanceMode mode)
bool DoHitTest(const CFX_PointF &point) override
int GetLayoutOrder() const override
CPDFSDK_BAAnnot(CPDF_Annot *pAnnot, CPDFSDK_PageView *pPageView)
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
void ReplaceAndKeepSelection(const WideString &text) override
BorderStyle GetBorderStyle() const
bool OnSetFocus(Mask< FWL_EVENTFLAG > nFlags) override
int GetBorderWidth() const
void SetBorderStyle(BorderStyle nStyle)
CPDF_Action GetAction() const
void ClearCachedAnnotAP()
void SetFlags(uint32_t nFlags)
CPDFSDK_BAAnnot * AsBAAnnot() override
virtual bool IsAppearanceValid()
WideString GetSelectedText() override
CFX_FloatRect GetRect() const override
bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
CPDF_AAction GetAAction() const
bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
~CPDFSDK_BAAnnot() override
WideString GetText() override
void OnDraw(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, bool bDrawAnnots) override
bool OnRButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
CPDF_Dest GetDestination() const
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags) override
ByteString GetAppState() const
bool IsFocusableAnnot(const CPDF_Annot::Subtype &annot_type) const
uint32_t GetFlags() const
void SetBorderWidth(int nWidth)
bool OnKillFocus(Mask< FWL_EVENTFLAG > nFlags) override
RetainPtr< CPDF_Dictionary > GetMutableAnnotDict()
RetainPtr< CPDF_Dictionary > GetAPDict()
virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT)
void OnMouseEnter(Mask< FWL_EVENTFLAG > nFlags) override
CPDFSDK_Annot::UnsafeInputHandlers * GetUnsafeInputHandlers() override
void OnMouseExit(Mask< FWL_EVENTFLAG > nFlags) override
bool ActionExist(AActionType eType) const
CPDF_Action GetAction(AActionType eType) const
static CPDF_Dest Create(CPDF_Document *pDoc, RetainPtr< const CPDF_Object > pDest)
int GetIntegerFor(const ByteString &key) const
RetainPtr< const CPDF_Dictionary > GetDictFor(const ByteString &key) const
WideString GetUnicodeTextFor(const ByteString &key) const
ByteString GetByteStringFor(const ByteString &key) const
RetainPtr< const CPDF_Object > GetDirectObjectFor(const ByteString &key) const
bool operator==(const char *ptr) const
constexpr uint32_t kNoView
constexpr uint32_t kHidden
constexpr uint32_t kInvisible