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
cpdfsdk_widget.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 FPDFSDK_CPDFSDK_WIDGET_H_
8#define FPDFSDK_CPDFSDK_WIDGET_H_
9
10#include "core/fpdfdoc/cpdf_aaction.h"
11#include "core/fpdfdoc/cpdf_action.h"
12#include "core/fpdfdoc/cpdf_annot.h"
13#include "core/fpdfdoc/cpdf_formfield.h"
14#include "core/fxcrt/fx_coordinates.h"
15#include "core/fxcrt/unowned_ptr.h"
16#include "core/fxcrt/widestring.h"
17#include "core/fxge/cfx_color.h"
18#include "fpdfsdk/cpdfsdk_baannot.h"
19#include "third_party/abseil-cpp/absl/types/optional.h"
20
21class CFFL_InteractiveFormFiller;
23class CPDF_Annot;
25class CPDF_FormField;
26class CPDFSDK_FormFillEnvironment;
27class CPDFSDK_InteractiveForm;
28class CPDFSDK_PageView;
29struct CFFL_FieldAction;
30
31#ifdef PDF_ENABLE_XFA
32class CXFA_FFWidget;
33class CXFA_FFWidgetHandler;
34
35enum PDFSDK_XFAAActionType {
36 PDFSDK_XFA_Click = 0,
37 PDFSDK_XFA_Full,
38 PDFSDK_XFA_PreOpen,
39 PDFSDK_XFA_PostOpen
40};
41#endif // PDF_ENABLE_XFA
42
43class CPDFSDK_Widget final : public CPDFSDK_BAAnnot {
44 public:
45 enum ValueChanged : bool { kValueUnchanged = false, kValueChanged = true };
46
48 CPDFSDK_PageView* pPageView,
49 CPDFSDK_InteractiveForm* pInteractiveForm);
50 ~CPDFSDK_Widget() override;
51
52 // CPDFSDK_BAAnnot:
53 void OnLoad() override;
55 bool IsAppearanceValid() override;
56 int GetLayoutOrder() const override;
57 void OnDraw(CFX_RenderDevice* pDevice,
58 const CFX_Matrix& mtUser2Device,
59 bool bDrawAnnots) override;
60 bool DoHitTest(const CFX_PointF& point) override;
61 CFX_FloatRect GetViewBBox() override;
62 bool CanUndo() override;
63 bool CanRedo() override;
64 bool Undo() override;
65 bool Redo() override;
66 WideString GetText() override;
67 WideString GetSelectedText() override;
68 void ReplaceAndKeepSelection(const WideString& text) override;
69 void ReplaceSelection(const WideString& text) override;
70 bool SelectAllText() override;
71 bool SetIndexSelected(int index, bool selected) override;
72 bool IsIndexSelected(int index) override;
73 void DrawAppearance(CFX_RenderDevice* pDevice,
74 const CFX_Matrix& mtUser2Device,
75 CPDF_Annot::AppearanceMode mode) override;
76
77 bool IsSignatureWidget() const;
78 void SetRect(const CFX_FloatRect& rect);
80 int GetFieldFlags() const;
81 int GetRotate() const;
82
86 float GetFontSize() const;
87
88 int GetSelectedIndex(int nIndex) const;
89 WideString GetValue() const;
90 WideString GetExportValue() const;
91 WideString GetOptionLabel(int nIndex) const;
92 WideString GetSelectExportText(int nIndex) const;
93
94 int CountOptions() const;
95 bool IsOptionSelected(int nIndex) const;
96 int GetTopVisibleIndex() const;
97 bool IsChecked() const;
98 int GetAlignment() const;
99 int GetMaxLen() const;
100
101 void SetCheck(bool bChecked);
102 void SetValue(const WideString& sValue);
103 void SetOptionSelection(int index);
104 void ClearSelection();
105 void SetTopVisibleIndex(int index);
106
107#ifdef PDF_ENABLE_XFA
108 CXFA_FFWidget* GetMixXFAWidget() const;
109 bool HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) const;
110 bool OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT,
111 CFFL_FieldAction* data,
112 const CPDFSDK_PageView* pPageView);
113 void Synchronize(bool bSynchronizeElse);
114 // TODO(thestig): Figure out if the parameter should be used or removed.
115 void ResetXFAAppearance(ValueChanged bValueChanged);
116#endif // PDF_ENABLE_XFA
117
118 void ResetAppearance(absl::optional<WideString> sValue,
119 ValueChanged bValueChanged);
121 void UpdateField();
123
125 CFFL_FieldAction* data,
126 const CPDFSDK_PageView* pPageView);
127
130
131 void DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView);
132
133 void SetAppModified();
134 void ClearAppModified();
135 bool IsAppModified() const;
136
137 uint32_t GetAppearanceAge() const { return m_nAppearanceAge; }
138 uint32_t GetValueAge() const { return m_nValueAge; }
139
141 bool IsPushHighlighted() const;
142 CFX_Matrix GetMatrix() const;
148
149 private:
150 // CPDFSDK_Annot::UnsafeInputHandlers:
151 void OnMouseEnter(Mask<FWL_EVENTFLAG> nFlags) override;
152 void OnMouseExit(Mask<FWL_EVENTFLAG> nFlags) override;
153 bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlags,
154 const CFX_PointF& point) override;
155 bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlags,
156 const CFX_PointF& point) override;
157 bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlags,
158 const CFX_PointF& point) override;
159 bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlags,
160 const CFX_PointF& point) override;
161 bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlags,
162 const CFX_PointF& point,
163 const CFX_Vector& delta) override;
164 bool OnRButtonDown(Mask<FWL_EVENTFLAG> nFlags,
165 const CFX_PointF& point) override;
166 bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlags,
167 const CFX_PointF& point) override;
168 bool OnChar(uint32_t nChar, Mask<FWL_EVENTFLAG> nFlags) override;
169 bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlags) override;
170 bool OnSetFocus(Mask<FWL_EVENTFLAG> nFlags) override;
171 bool OnKillFocus(Mask<FWL_EVENTFLAG> nFlags) override;
172
173 CFFL_InteractiveFormFiller* GetInteractiveFormFiller();
174
175#ifdef PDF_ENABLE_XFA
176 CXFA_FFWidgetHandler* GetXFAWidgetHandler() const;
177 CXFA_FFWidget* GetGroupMixXFAWidget() const;
178 WideString GetName() const;
179 bool HandleXFAAAction(CPDF_AAction::AActionType type,
180 CFFL_FieldAction* data,
181 CPDFSDK_FormFillEnvironment* pFormFillEnv);
182#endif // PDF_ENABLE_XFA
183
184 UnownedPtr<CPDFSDK_InteractiveForm> const m_pInteractiveForm;
185 bool m_bAppModified = false;
186 uint32_t m_nAppearanceAge = 0;
187 uint32_t m_nValueAge = 0;
188};
189
190inline CPDFSDK_Widget* ToCPDFSDKWidget(CPDFSDK_Annot* pAnnot) {
191 return pAnnot && pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET
192 ? static_cast<CPDFSDK_Widget*>(pAnnot)
193 : nullptr;
194}
195
196#endif // FPDFSDK_CPDFSDK_WIDGET_H_
CPDFSDK_AnnotIterator(CPDFSDK_PageView *pPageView, const std::vector< CPDF_Annot::Subtype > &subtypes_to_iterate)
CPDFSDK_Annot * GetNextAnnot(CPDFSDK_Annot *pAnnot)
CPDFSDK_Annot * GetPrevAnnot(CPDFSDK_Annot *pAnnot)
virtual CPDF_Annot::Subtype GetAnnotSubtype() const =0
virtual CPDF_Annot * GetPDFAnnot() const
CPDF_Page * GetPDFPage() const
void SetOptionSelection(int index)
WideString GetValue() const
bool CanUndo() override
int GetMaxLen() const
WideString GetSelectExportText(int nIndex) const
CPDF_FormField * GetFormField() const
bool IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode) const
void SetRect(const CFX_FloatRect &rect)
bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
WideString GetSelectedText() override
int GetSelectedIndex(int nIndex) const
int GetAlignment() const
bool OnAAction(CPDF_AAction::AActionType type, CFFL_FieldAction *data, const CPDFSDK_PageView *pPageView)
int GetTopVisibleIndex() const
bool Undo() override
bool IsIndexSelected(int index) override
bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
CFX_Matrix GetMatrix() const
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
void ResetAppearance(absl::optional< WideString > sValue, ValueChanged bValueChanged)
bool IsSignatureWidget() const
bool CanRedo() override
uint32_t GetValueAge() const
bool IsChecked() const
bool IsOptionSelected(int nIndex) const
void SetCheck(bool bChecked)
absl::optional< WideString > OnFormat()
int GetRotate() const
void OnMouseExit(Mask< FWL_EVENTFLAG > nFlags) override
int GetFieldFlags() const
int CountOptions() const
void ReplaceSelection(const WideString &text) override
void DrawShadow(CFX_RenderDevice *pDevice, CPDFSDK_PageView *pPageView)
CFX_FloatRect GetViewBBox() override
bool SetIndexSelected(int index, bool selected) override
bool OnSetFocus(Mask< FWL_EVENTFLAG > nFlags) override
void ReplaceAndKeepSelection(const WideString &text) override
bool IsAppearanceValid() override
absl::optional< FX_COLORREF > GetTextColor() const
WideString GetOptionLabel(int nIndex) const
CPDF_FormControl * GetFormControl() const
void SetTopVisibleIndex(int index)
void DrawAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, CPDF_Annot::AppearanceMode mode) override
bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point, const CFX_Vector &delta) override
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags) override
CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT) override
bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
CFX_FloatRect GetRotatedRect() const
bool IsAppModified() const
int GetLayoutOrder() const override
void OnMouseEnter(Mask< FWL_EVENTFLAG > nFlags) override
float GetFontSize() const
absl::optional< FX_COLORREF > GetBorderColor() const
absl::optional< FX_COLORREF > GetFillColor() const
~CPDFSDK_Widget() override
bool OnKillFocus(Mask< FWL_EVENTFLAG > nFlags) override
uint32_t GetAppearanceAge() const
void SetValue(const WideString &sValue)
CFX_Color GetFillPWLColor() const
void OnDraw(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, bool bDrawAnnots) override
bool SelectAllText() override
CFX_FloatRect GetClientRect() const
WideString GetText() override
CFX_Color GetTextPWLColor() const
bool IsPushHighlighted() const
CPDFSDK_Widget(CPDF_Annot *pAnnot, CPDFSDK_PageView *pPageView, CPDFSDK_InteractiveForm *pInteractiveForm)
bool OnRButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
WideString GetExportValue() const
CFX_Color GetBorderPWLColor() const
bool DoHitTest(const CFX_PointF &point) override
bool OnChar(uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags) override
FormFieldType GetFieldType() const
void OnLoad() override
bool Redo() override
CFX_FloatRect GetRect() const
bool operator==(const char *ptr) const
FormFieldType
CPDFSDK_Widget * ToCPDFSDKWidget(CPDFSDK_Annot *pAnnot)