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
cffl_formfield.h
Go to the documentation of this file.
1// Copyright 2014 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_FORMFILLER_CFFL_FORMFIELD_H_
8#define FPDFSDK_FORMFILLER_CFFL_FORMFIELD_H_
9
10#include <map>
11#include <memory>
12
13#include "core/fpdfdoc/cpdf_aaction.h"
14#include "core/fxcrt/cfx_timer.h"
15#include "core/fxcrt/mask.h"
16#include "core/fxcrt/unowned_ptr.h"
17#include "fpdfsdk/formfiller/cffl_fieldaction.h"
18#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
19#include "fpdfsdk/pwl/cpwl_wnd.h"
20#include "fpdfsdk/pwl/ipwl_fillernotify.h"
21
22class CFFL_PerWindowData;
23class CPDFSDK_PageView;
24class CPDFSDK_Widget;
25
27 public CFX_Timer::CallbackIface {
28 public:
29 CFFL_FormField(CFFL_InteractiveFormFiller* pFormFiller,
30 CPDFSDK_Widget* pWidget);
31 ~CFFL_FormField() override;
32
33 virtual void OnDraw(CPDFSDK_PageView* pPageView,
34 CPDFSDK_Widget* pWidget,
35 CFX_RenderDevice* pDevice,
36 const CFX_Matrix& mtUser2Device);
37 virtual void OnDrawDeactive(CPDFSDK_PageView* pPageView,
38 CPDFSDK_Widget* pWidget,
39 CFX_RenderDevice* pDevice,
40 const CFX_Matrix& mtUser2Device);
41
42 virtual void OnMouseEnter(CPDFSDK_PageView* pPageView);
43 virtual void OnMouseExit(CPDFSDK_PageView* pPageView);
44
45 virtual bool OnLButtonDown(CPDFSDK_PageView* pPageView,
46 CPDFSDK_Widget* pAnnot,
47 Mask<FWL_EVENTFLAG> nFlags,
48 const CFX_PointF& point);
49 virtual bool OnLButtonUp(CPDFSDK_PageView* pPageView,
50 CPDFSDK_Widget* pAnnot,
51 Mask<FWL_EVENTFLAG> nFlags,
52 const CFX_PointF& point);
53 virtual bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
54 Mask<FWL_EVENTFLAG> nFlags,
55 const CFX_PointF& point);
56 virtual bool OnMouseMove(CPDFSDK_PageView* pPageView,
57 Mask<FWL_EVENTFLAG> nFlags,
58 const CFX_PointF& point);
59 virtual bool OnMouseWheel(CPDFSDK_PageView* pPageView,
60 Mask<FWL_EVENTFLAG> nFlags,
61 const CFX_PointF& point,
62 const CFX_Vector& delta);
63 virtual bool OnRButtonDown(CPDFSDK_PageView* pPageView,
64 Mask<FWL_EVENTFLAG> nFlags,
65 const CFX_PointF& point);
66 virtual bool OnRButtonUp(CPDFSDK_PageView* pPageView,
67 Mask<FWL_EVENTFLAG> nFlags,
68 const CFX_PointF& point);
69
70 virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlags);
71 virtual bool OnChar(CPDFSDK_Widget* pAnnot,
72 uint32_t nChar,
73 Mask<FWL_EVENTFLAG> nFlags);
74 virtual bool SetIndexSelected(int index, bool selected);
75 virtual bool IsIndexSelected(int index);
76
77 FX_RECT GetViewBBox(const CPDFSDK_PageView* pPageView);
78
79 WideString GetText();
80 WideString GetSelectedText();
81 void ReplaceAndKeepSelection(const WideString& text);
82 void ReplaceSelection(const WideString& text);
83 bool SelectAllText();
84
85 bool CanUndo();
86 bool CanRedo();
87 bool Undo();
88 bool Redo();
89
90 void SetFocusForAnnot(CPDFSDK_Widget* pWidget, Mask<FWL_EVENTFLAG> nFlag);
91 void KillFocusForAnnot(Mask<FWL_EVENTFLAG> nFlag);
92
93 // CFX_Timer::CallbackIface:
94 void OnTimerFired() override;
95
96 // CPWL_Wnd::ProviderIface:
98 const IPWL_FillerNotify::PerWindowData* pAttached) override;
99 void OnSetFocusForEdit(CPWL_Edit* pEdit) override;
100
101 virtual void GetActionData(const CPDFSDK_PageView* pPageView,
103 CFFL_FieldAction& fa);
104 virtual void SetActionData(const CPDFSDK_PageView* pPageView,
106 const CFFL_FieldAction& fa);
109 const CPWL_Wnd::CreateParams& cp,
110 std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData) = 0;
111 virtual void SavePWLWindowState(const CPDFSDK_PageView* pPageView);
113 const CPDFSDK_PageView* pPageView);
114 virtual bool IsDataChanged(const CPDFSDK_PageView* pPageView);
115 virtual void SaveData(const CPDFSDK_PageView* pPageView);
116#ifdef PDF_ENABLE_XFA
117 virtual bool IsFieldFull(const CPDFSDK_PageView* pPageView);
118#endif // PDF_ENABLE_XFA
119
121 CFX_FloatRect GetFocusBox(const CPDFSDK_PageView* pPageView);
124 CFX_PointF FFLtoPWL(const CFX_PointF& point);
125 CFX_PointF PWLtoFFL(const CFX_PointF& point);
126 bool CommitData(const CPDFSDK_PageView* pPageView, Mask<FWL_EVENTFLAG> nFlag);
127 void DestroyPWLWindow(const CPDFSDK_PageView* pPageView);
128 void EscapeFiller(CPDFSDK_PageView* pPageView, bool bDestroyPWLWindow);
129
130 bool IsValid() const;
132
133 CPDFSDK_PageView* GetCurPageView();
134 void SetChangeMark();
135
136 CPDFSDK_Widget* GetSDKWidget() const { return m_pWidget; }
137
138 CFFL_PerWindowData* GetPerPWLWindowData(const CPDFSDK_PageView* pPageView);
139 void ResetPWLWindowForValueAge(const CPDFSDK_PageView* pPageView,
140 CPDFSDK_Widget* pWidget,
141 uint32_t nValueAge);
142
143 protected:
147
148 virtual CPWL_Wnd* ResetPWLWindow(const CPDFSDK_PageView* pPageView);
149 virtual CPWL_Wnd* RestorePWLWindow(const CPDFSDK_PageView* pPageView);
150
151 CPWL_Wnd* GetPWLWindow(const CPDFSDK_PageView* pPageView) const;
152 CPWL_Wnd* CreateOrUpdatePWLWindow(const CPDFSDK_PageView* pPageView);
153 CPWL_Wnd* ResetPWLWindowForValueAgeInternal(const CPDFSDK_PageView* pPageView,
154 CPDFSDK_Widget* pWidget,
155 uint32_t nValueAge);
156
157 // If the inheriting widget has its own fontmap and a PWL_Edit widget that
158 // access that fontmap then you have to call DestroyWindows before destroying
159 // the font map in order to not get a use-after-free.
160 //
161 // The font map should be stored somewhere more appropriate so it will live
162 // until the PWL_Edit is done with it. pdfium:566
163 void DestroyWindows();
164
165 void InvalidateRect(const FX_RECT& rect);
166
167 bool m_bValid = false;
168 UnownedPtr<CFFL_InteractiveFormFiller> const m_pFormFiller;
169 UnownedPtr<CPDFSDK_Widget> m_pWidget;
172};
173
174#endif // FPDFSDK_FORMFILLER_CFFL_FORMFIELD_H_
std::map< const CPDFSDK_PageView *, std::unique_ptr< CPWL_Wnd > > m_Maps
CFX_PointF FFLtoPWL(const CFX_PointF &point)
virtual void RecreatePWLWindowFromSavedState(const CPDFSDK_PageView *pPageView)
CPWL_Wnd * ResetPWLWindowForValueAgeInternal(const CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, uint32_t nValueAge)
CFX_FloatRect PWLtoFFL(const CFX_FloatRect &rect)
CFX_FloatRect GetFocusBox(const CPDFSDK_PageView *pPageView)
virtual bool OnChar(CPDFSDK_Widget *pAnnot, uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags)
void InvalidateRect(const FX_RECT &rect)
WideString GetSelectedText()
CPWL_Wnd * GetPWLWindow(const CPDFSDK_PageView *pPageView) const
virtual bool OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
CFX_FloatRect FFLtoPWL(const CFX_FloatRect &rect)
virtual std::unique_ptr< CPWL_Wnd > NewPWLWindow(const CPWL_Wnd::CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData)=0
CPWL_Wnd * CreateOrUpdatePWLWindow(const CPDFSDK_PageView *pPageView)
std::unique_ptr< CFX_Timer > m_pTimer
void EscapeFiller(CPDFSDK_PageView *pPageView, bool bDestroyPWLWindow)
void OnSetFocusForEdit(CPWL_Edit *pEdit) override
virtual CPWL_Wnd::CreateParams GetCreateParam()
void ReplaceSelection(const WideString &text)
virtual bool SetIndexSelected(int index, bool selected)
CPDFSDK_PageView * GetCurPageView()
virtual bool OnLButtonDblClk(CPDFSDK_PageView *pPageView, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
bool CommitData(const CPDFSDK_PageView *pPageView, Mask< FWL_EVENTFLAG > nFlag)
CFX_Matrix GetCurMatrix()
virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags)
CFX_FloatRect GetPDFAnnotRect() const
void SetFocusForAnnot(CPDFSDK_Widget *pWidget, Mask< FWL_EVENTFLAG > nFlag)
virtual void GetActionData(const CPDFSDK_PageView *pPageView, CPDF_AAction::AActionType type, CFFL_FieldAction &fa)
~CFFL_FormField() override
virtual bool OnMouseMove(CPDFSDK_PageView *pPageView, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
CFFL_FormField(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
void OnTimerFired() override
virtual bool IsIndexSelected(int index)
virtual bool OnMouseWheel(CPDFSDK_PageView *pPageView, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point, const CFX_Vector &delta)
UnownedPtr< CFFL_InteractiveFormFiller > const m_pFormFiller
virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device)
CFFL_PerWindowData * GetPerPWLWindowData(const CPDFSDK_PageView *pPageView)
virtual bool OnRButtonUp(CPDFSDK_PageView *pPageView, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
CPDFSDK_Widget * GetSDKWidget() const
void ReplaceAndKeepSelection(const WideString &text)
virtual void SetActionData(const CPDFSDK_PageView *pPageView, CPDF_AAction::AActionType type, const CFFL_FieldAction &fa)
CFX_Matrix GetWindowMatrix(const IPWL_FillerNotify::PerWindowData *pAttached) override
void KillFocusForAnnot(Mask< FWL_EVENTFLAG > nFlag)
UnownedPtr< CPDFSDK_Widget > m_pWidget
virtual void OnMouseExit(CPDFSDK_PageView *pPageView)
virtual bool OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
virtual CPWL_Wnd * RestorePWLWindow(const CPDFSDK_PageView *pPageView)
virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device)
virtual void OnMouseEnter(CPDFSDK_PageView *pPageView)
virtual bool IsDataChanged(const CPDFSDK_PageView *pPageView)
FX_RECT GetViewBBox(const CPDFSDK_PageView *pPageView)
virtual CPWL_Wnd * ResetPWLWindow(const CPDFSDK_PageView *pPageView)
virtual void SavePWLWindowState(const CPDFSDK_PageView *pPageView)
virtual bool OnRButtonDown(CPDFSDK_PageView *pPageView, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
void ResetPWLWindowForValueAge(const CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, uint32_t nValueAge)
virtual void SaveData(const CPDFSDK_PageView *pPageView)
CFX_PointF PWLtoFFL(const CFX_PointF &point)
void DestroyPWLWindow(const CPDFSDK_PageView *pPageView)
bool IsValid() const
WideString GetText()
FX_RECT GetOuterRect() const
static constexpr int32_t kInvalidTimerID
Definition cfx_timer.h:21
IPDF_Page * GetPage()
static bool OnKillFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
CPDFSDK_PageView * GetPageView() const
static bool OnSetFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
void KillTimer(int32_t nTimerID) override
void SubmitForm(pdfium::span< const uint8_t > form_data, const WideString &URL)
CFX_Timer::HandlerIface * GetTimerHandler() override
CPDFSDK_PageView * GetPageViewAtIndex(int nIndex)
void Invalidate(IPDF_Page *page, const FX_RECT &rect) override
IPDF_JSPLATFORM * GetJSPlatform() const
void DoActionResetForm(const CPDF_Action &action)
void OnCalculate(ObservedPtr< CPDFSDK_Annot > &pAnnot) override
CPDFSDK_PageView * GetPageView(IPDF_Page *pUnderlyingPage) override
void DoActionNamed(const CPDF_Action &action)
CPDFSDK_FormFillEnvironment(CPDF_Document *pDoc, FPDF_FORMFILLINFO *pFFinfo)
bool DoActionSubmitForm(const CPDF_Action &action)
CPDFSDK_InteractiveForm * GetInteractiveForm()
void OutputSelectedRect(CFFL_FormField *pFormField, const CFX_FloatRect &rect) override
CPDFSDK_Annot * GetFocusAnnot() const override
bool DoActionField(const CPDF_Action &action, CPDF_AAction::AActionType type, CPDF_FormField *pFormField, CFFL_FieldAction *data)
void DoGoToAction(int nPageIndex, int zoomMode, pdfium::span< float > fPosArray)
bool DoActionJavaScript(const CPDF_Action &JsAction, WideString csJSName)
void InvalidateRect(CPDFSDK_Widget *widget, const CFX_FloatRect &rect) override
bool DoActionHide(const CPDF_Action &action)
void ExecuteNamedAction(const ByteString &namedAction)
bool DoActionDestination(const CPDF_Dest &dest)
void DoActionURI(const CPDF_Action &action, Mask< FWL_EVENTFLAG > modifiers)
void SetCursor(IPWL_FillerNotify::CursorStyle nCursorType) override
bool DoActionLink(const CPDF_Action &action, CPDF_AAction::AActionType type, Mask< FWL_EVENTFLAG > modifiers)
bool DoActionDocument(const CPDF_Action &action, CPDF_AAction::AActionType eType)
CPDFSDK_PageView * GetOrCreatePageView(IPDF_Page *pUnderlyingPage) override
void OnSetFieldInputFocus(const WideString &text) override
void DoActionGoTo(const CPDF_Action &action)
bool KillFocusAnnot(Mask< FWL_EVENTFLAG > nFlags)
void UpdateAllViews(CPDFSDK_Annot *pAnnot)
bool DoActionPage(const CPDF_Action &action, CPDF_AAction::AActionType eType)
int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) override
void OnFormat(ObservedPtr< CPDFSDK_Annot > &pAnnot) override
void DoActionNoJs(const CPDF_Action &action, CPDF_AAction::AActionType type)
void DoURIAction(const ByteString &bsURI, Mask< FWL_EVENTFLAG > modifiers)
void RemovePageView(IPDF_Page *pUnderlyingPage)
bool SetFocusAnnot(ObservedPtr< CPDFSDK_Annot > &pAnnot) override
bool DoActionFieldJavaScript(const CPDF_Action &JsAction, CPDF_AAction::AActionType type, CPDF_FormField *pFormField, CFFL_FieldAction *data)
FPDF_FORMFILLINFO * GetFormFillInfo() const
bool HasPermissions(uint32_t flags) const override
bool DoActionDocOpen(const CPDF_Action &action)
bool DoAction_SubmitForm(const CPDF_Action &action)
bool DoAction_Hide(const CPDF_Action &action)
void DoAction_ResetForm(const CPDF_Action &action)
CPDF_InteractiveForm * GetInteractiveForm() const
bool IsValidSDKAnnot(const CPDFSDK_Annot *p) const
bool IsBeingDestroyed() const
bool IsLocked() const
FormFieldType GetFieldType() const
static bool IsUserInput(AActionType type)
CPDF_Dest GetDest(CPDF_Document *pDoc) const
Type GetType() const
ByteString GetURI(const CPDF_Document *pDoc) const
const CPDF_Dictionary * GetDict() const
Definition cpdf_action.h:51
WideString GetJavaScript() const
ByteString GetNamedAction() const
int GetDestPageIndex(CPDF_Document *pDoc) const
Definition cpdf_dest.cpp:53
int GetZoomMode() const
Definition cpdf_dest.cpp:81
RetainPtr< const CPDF_Array > GetArrayFor(const ByteString &key) const
RetainPtr< const CPDF_Dictionary > GetFieldDict() const
CPDF_FormField * GetFieldByDict(const CPDF_Dictionary *pFieldDict) const
virtual void OnField_MouseEnter(bool bModifier, bool bShift, CPDF_FormField *pTarget)=0
virtual void OnField_Validate(WideString *strChange, const WideString &strChangeEx, bool bKeyDown, bool bModifier, bool bShift, CPDF_FormField *pTarget, WideString *Value, bool *bRc)=0
virtual void OnField_Keystroke(WideString *strChange, const WideString &strChangeEx, bool KeyDown, bool bModifier, int *nSelEnd, int *nSelStart, bool bShift, CPDF_FormField *pTarget, WideString *Value, bool bWillCommit, bool bFieldFull, bool *bRc)=0
virtual void OnDoc_DidSave()=0
virtual void OnDoc_WillClose()=0
virtual void OnField_MouseDown(bool bModifier, bool bShift, CPDF_FormField *pTarget)=0
virtual void OnPage_InView()=0
virtual void OnField_Focus(bool bModifier, bool bShift, CPDF_FormField *pTarget, WideString *Value)=0
virtual void OnPage_Close()=0
virtual void OnDoc_WillPrint()=0
virtual void OnDoc_WillSave()=0
virtual void OnField_MouseExit(bool bModifier, bool bShift, CPDF_FormField *pTarget)=0
virtual void OnField_MouseUp(bool bModifier, bool bShift, CPDF_FormField *pTarget)=0
virtual void OnDoc_DidPrint()=0
virtual void OnDoc_Open(const WideString &strTargetName)=0
virtual void OnPage_Open()=0
virtual void OnPage_OutView()=0
virtual void OnField_Blur(bool bModifier, bool bShift, CPDF_FormField *pTarget, WideString *Value)=0
IJS_EventContext * Get() const
Definition ijs_runtime.h:41
ScopedEventContext(IJS_Runtime *pRuntime)
const char * c_str() const
Definition bytestring.h:76
bool IsEmpty() const
Definition widestring.h:118
ByteString ToUTF16LE() const
FormFieldType
FPDF_WIDESTRING AsFPDFWideString(ByteString *bsUTF16LE)
#define FXCT_NWSE
#define FXCT_HAND
#define FXCT_VBEAM
#define FXCT_HBEAM
#define FXCT_NESW
#define FXCT_ARROW
void(* FFI_OutputSelectedRect)(struct _FPDF_FORMFILLINFO *pThis, FPDF_PAGE page, double left, double top, double right, double bottom)
void(* Doc_submitForm)(struct _IPDF_JsPlatform *pThis, void *formData, int length, FPDF_WIDESTRING URL)
int(* Doc_getFilePath)(struct _IPDF_JsPlatform *pThis, void *filePath, int length)