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
ijs_runtime.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 FXJS_IJS_RUNTIME_H_
8#define FXJS_IJS_RUNTIME_H_
9
10#include <memory>
11
12#include "core/fxcrt/fx_memory.h"
13#include "core/fxcrt/unowned_ptr.h"
14#include "core/fxcrt/widestring.h"
15#include "third_party/abseil-cpp/absl/types/optional.h"
16
17class CJS_Runtime;
18class CPDFSDK_FormFillEnvironment;
20
21// Owns the FJXS objects needed to actually execute JS, if possible. This
22// virtual interface is backed by either an actual JS runtime, or a stub,
23// when JS is not present.
25 public:
26 struct JS_Error {
27 int line;
28 int column;
29 WideString exception;
30
31 JS_Error(int line, int column, const WideString& exception);
32 };
33
35 public:
36 FX_STACK_ALLOCATED();
37
38 explicit ScopedEventContext(IJS_Runtime* pRuntime);
40
41 IJS_EventContext* Get() const { return m_pContext; }
42 IJS_EventContext* operator->() const { return m_pContext; }
43
44 private:
45 UnownedPtr<IJS_Runtime> const m_pRuntime;
46 UnownedPtr<IJS_EventContext> m_pContext;
47 };
48
49 static void Initialize(unsigned int slot, void* isolate, void* platform);
50 static void Destroy();
52 CPDFSDK_FormFillEnvironment* pFormFillEnv);
53
54 virtual ~IJS_Runtime();
55
56 virtual CJS_Runtime* AsCJSRuntime() = 0;
58 virtual void ReleaseEventContext(IJS_EventContext* pContext) = 0;
59 virtual CPDFSDK_FormFillEnvironment* GetFormFillEnv() const = 0;
60 virtual absl::optional<JS_Error> ExecuteScript(const WideString& script) = 0;
61
62 protected:
63 IJS_Runtime() = default;
64};
65
66#endif // FXJS_IJS_RUNTIME_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_Format(CPDF_FormField *pTarget, WideString *Value)=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 ~IJS_EventContext()=default
virtual void OnPage_InView()=0
virtual void OnField_Focus(bool bModifier, bool bShift, CPDF_FormField *pTarget, WideString *Value)=0
virtual void OnField_Calculate(CPDF_FormField *pSource, CPDF_FormField *pTarget, WideString *Value, bool *bRc)=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 OnExternal_Exec()=0
virtual void OnDoc_Open(const WideString &strTargetName)=0
virtual void OnPage_Open()=0
virtual void OnPage_OutView()=0
virtual absl::optional< IJS_Runtime::JS_Error > RunScript(const WideString &script)=0
virtual void OnField_Blur(bool bModifier, bool bShift, CPDF_FormField *pTarget, WideString *Value)=0
IJS_EventContext * Get() const
Definition ijs_runtime.h:41
IJS_EventContext * operator->() const
Definition ijs_runtime.h:42
ScopedEventContext(IJS_Runtime *pRuntime)
virtual ~IJS_Runtime()
IJS_Runtime()=default
virtual absl::optional< JS_Error > ExecuteScript(const WideString &script)=0
static std::unique_ptr< IJS_Runtime > Create(CPDFSDK_FormFillEnvironment *pFormFillEnv)
virtual IJS_EventContext * NewEventContext()=0
static void Initialize(unsigned int slot, void *isolate, void *platform)
virtual CJS_Runtime * AsCJSRuntime()=0
static void Destroy()
virtual CPDFSDK_FormFillEnvironment * GetFormFillEnv() const =0
virtual void ReleaseEventContext(IJS_EventContext *pContext)=0
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
CFFL_FieldAction(const CFFL_FieldAction &other)=delete
JS_Error(int line, int column, const WideString &exception)
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)