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
cjs_document.h
Go to the documentation of this file.
1// Copyright 2017 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_CJS_DOCUMENT_H_
8#define FXJS_CJS_DOCUMENT_H_
9
10#include <list>
11#include <memory>
12#include <vector>
13
14#include "core/fxcrt/observed_ptr.h"
15#include "fxjs/cjs_object.h"
16#include "fxjs/js_define.h"
17#include "third_party/base/containers/span.h"
18
19class CPDFSDK_InteractiveForm;
21struct CJS_DelayData;
22
23class CJS_Document final : public CJS_Object, public Observable {
24 public:
25 static uint32_t GetObjDefnID();
26 static void DefineJSObjects(CFXJS_Engine* pEngine);
27
28 CJS_Document(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
29 ~CJS_Document() override;
30
31 void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv);
32 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const {
33 return m_pFormFillEnv.Get();
34 }
35 void AddDelayData(std::unique_ptr<CJS_DelayData> pData);
36 void DoFieldDelay(const WideString& sFieldName, int nControlIndex);
37
38 JS_STATIC_PROP(ADBE, ADBE, CJS_Document)
39 JS_STATIC_PROP(author, author, CJS_Document)
40 JS_STATIC_PROP(baseURL, base_URL, CJS_Document)
41 JS_STATIC_PROP(bookmarkRoot, bookmark_root, CJS_Document)
42 JS_STATIC_PROP(calculate, calculate, CJS_Document)
43 JS_STATIC_PROP(Collab, collab, CJS_Document)
44 JS_STATIC_PROP(creationDate, creation_date, CJS_Document)
45 JS_STATIC_PROP(creator, creator, CJS_Document)
46 JS_STATIC_PROP(delay, delay, CJS_Document)
47 JS_STATIC_PROP(dirty, dirty, CJS_Document)
48 JS_STATIC_PROP(documentFileName, document_file_name, CJS_Document)
49 JS_STATIC_PROP(external, external, CJS_Document)
50 JS_STATIC_PROP(filesize, filesize, CJS_Document)
51 JS_STATIC_PROP(icons, icons, CJS_Document)
52 JS_STATIC_PROP(info, info, CJS_Document)
53 JS_STATIC_PROP(keywords, keywords, CJS_Document)
54 JS_STATIC_PROP(layout, layout, CJS_Document)
55 JS_STATIC_PROP(media, media, CJS_Document)
56 JS_STATIC_PROP(modDate, mod_date, CJS_Document)
57 JS_STATIC_PROP(mouseX, mouse_x, CJS_Document)
58 JS_STATIC_PROP(mouseY, mouse_y, CJS_Document)
59 JS_STATIC_PROP(numFields, num_fields, CJS_Document)
60 JS_STATIC_PROP(numPages, num_pages, CJS_Document)
61 JS_STATIC_PROP(pageNum, page_num, CJS_Document)
62 JS_STATIC_PROP(pageWindowRect, page_window_rect, CJS_Document)
63 JS_STATIC_PROP(path, path, CJS_Document)
64 JS_STATIC_PROP(producer, producer, CJS_Document)
65 JS_STATIC_PROP(subject, subject, CJS_Document)
66 JS_STATIC_PROP(title, title, CJS_Document)
67 JS_STATIC_PROP(URL, URL, CJS_Document)
68 JS_STATIC_PROP(zoom, zoom, CJS_Document)
69 JS_STATIC_PROP(zoomType, zoom_type, CJS_Document)
70
71 JS_STATIC_METHOD(addAnnot, CJS_Document)
72 JS_STATIC_METHOD(addField, CJS_Document)
73 JS_STATIC_METHOD(addLink, CJS_Document)
74 JS_STATIC_METHOD(addIcon, CJS_Document)
75 JS_STATIC_METHOD(calculateNow, CJS_Document)
76 JS_STATIC_METHOD(closeDoc, CJS_Document)
77 JS_STATIC_METHOD(createDataObject, CJS_Document)
78 JS_STATIC_METHOD(deletePages, CJS_Document)
79 JS_STATIC_METHOD(exportAsText, CJS_Document)
80 JS_STATIC_METHOD(exportAsFDF, CJS_Document)
81 JS_STATIC_METHOD(exportAsXFDF, CJS_Document)
82 JS_STATIC_METHOD(extractPages, CJS_Document)
83 JS_STATIC_METHOD(getAnnot, CJS_Document)
84 JS_STATIC_METHOD(getAnnots, CJS_Document)
85 JS_STATIC_METHOD(getAnnot3D, CJS_Document)
86 JS_STATIC_METHOD(getAnnots3D, CJS_Document)
87 JS_STATIC_METHOD(getField, CJS_Document)
88 JS_STATIC_METHOD(getIcon, CJS_Document)
89 JS_STATIC_METHOD(getLinks, CJS_Document)
90 JS_STATIC_METHOD(getNthFieldName, CJS_Document)
91 JS_STATIC_METHOD(getOCGs, CJS_Document)
92 JS_STATIC_METHOD(getPageBox, CJS_Document)
93 JS_STATIC_METHOD(getPageNthWord, CJS_Document)
94 JS_STATIC_METHOD(getPageNthWordQuads, CJS_Document)
95 JS_STATIC_METHOD(getPageNumWords, CJS_Document)
96 JS_STATIC_METHOD(getPrintParams, CJS_Document)
97 JS_STATIC_METHOD(getURL, CJS_Document)
98 JS_STATIC_METHOD(gotoNamedDest, CJS_Document)
99 JS_STATIC_METHOD(importAnFDF, CJS_Document)
100 JS_STATIC_METHOD(importAnXFDF, CJS_Document)
101 JS_STATIC_METHOD(importTextData, CJS_Document)
102 JS_STATIC_METHOD(insertPages, CJS_Document)
103 JS_STATIC_METHOD(mailDoc, CJS_Document)
104 JS_STATIC_METHOD(mailForm, CJS_Document)
105 JS_STATIC_METHOD(print, CJS_Document)
106 JS_STATIC_METHOD(removeField, CJS_Document)
107 JS_STATIC_METHOD(replacePages, CJS_Document)
108 JS_STATIC_METHOD(removeIcon, CJS_Document)
109 JS_STATIC_METHOD(resetForm, CJS_Document)
110 JS_STATIC_METHOD(saveAs, CJS_Document)
111 JS_STATIC_METHOD(submitForm, CJS_Document)
112 JS_STATIC_METHOD(syncAnnotScan, CJS_Document)
113
114 private:
115 static uint32_t ObjDefnID;
116 static const char kName[];
117 static const JSPropertySpec PropertySpecs[];
118 static const JSMethodSpec MethodSpecs[];
119
120 CJS_Result get_ADBE(CJS_Runtime* pRuntime);
121 CJS_Result set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
122
123 CJS_Result get_author(CJS_Runtime* pRuntime);
124 CJS_Result set_author(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
125
126 CJS_Result get_base_URL(CJS_Runtime* pRuntime);
127 CJS_Result set_base_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
128
129 CJS_Result get_bookmark_root(CJS_Runtime* pRuntime);
130 CJS_Result set_bookmark_root(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
131
132 CJS_Result get_calculate(CJS_Runtime* pRuntime);
133 CJS_Result set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
134
135 CJS_Result get_collab(CJS_Runtime* pRuntime);
136 CJS_Result set_collab(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
137
138 CJS_Result get_creation_date(CJS_Runtime* pRuntime);
139 CJS_Result set_creation_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
140
141 CJS_Result get_creator(CJS_Runtime* pRuntime);
142 CJS_Result set_creator(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
143
144 CJS_Result get_delay(CJS_Runtime* pRuntime);
145 CJS_Result set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
146
147 CJS_Result get_dirty(CJS_Runtime* pRuntime);
148 CJS_Result set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
149
150 CJS_Result get_document_file_name(CJS_Runtime* pRuntime);
151 CJS_Result set_document_file_name(CJS_Runtime* pRuntime,
152 v8::Local<v8::Value> vp);
153
154 CJS_Result get_external(CJS_Runtime* pRuntime);
155 CJS_Result set_external(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
156
157 CJS_Result get_filesize(CJS_Runtime* pRuntime);
158 CJS_Result set_filesize(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
159
160 CJS_Result get_icons(CJS_Runtime* pRuntime);
161 CJS_Result set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
162
163 CJS_Result get_info(CJS_Runtime* pRuntime);
164 CJS_Result set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
165
166 CJS_Result get_keywords(CJS_Runtime* pRuntime);
167 CJS_Result set_keywords(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
168
169 CJS_Result get_layout(CJS_Runtime* pRuntime);
170 CJS_Result set_layout(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
171
172 CJS_Result get_media(CJS_Runtime* pRuntime);
173 CJS_Result set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
174
175 CJS_Result get_mod_date(CJS_Runtime* pRuntime);
176 CJS_Result set_mod_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
177
178 CJS_Result get_mouse_x(CJS_Runtime* pRuntime);
179 CJS_Result set_mouse_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
180
181 CJS_Result get_mouse_y(CJS_Runtime* pRuntime);
182 CJS_Result set_mouse_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
183
184 CJS_Result get_num_fields(CJS_Runtime* pRuntime);
185 CJS_Result set_num_fields(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
186
187 CJS_Result get_num_pages(CJS_Runtime* pRuntime);
188 CJS_Result set_num_pages(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
189
190 CJS_Result get_page_num(CJS_Runtime* pRuntime);
191 CJS_Result set_page_num(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
192
193 CJS_Result get_page_window_rect(CJS_Runtime* pRuntime);
194 CJS_Result set_page_window_rect(CJS_Runtime* pRuntime,
195 v8::Local<v8::Value> vp);
196
197 CJS_Result get_path(CJS_Runtime* pRuntime);
198 CJS_Result set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
199
200 CJS_Result get_producer(CJS_Runtime* pRuntime);
201 CJS_Result set_producer(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
202
203 CJS_Result get_subject(CJS_Runtime* pRuntime);
204 CJS_Result set_subject(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
205
206 CJS_Result get_title(CJS_Runtime* pRuntime);
207 CJS_Result set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
208
209 CJS_Result get_zoom(CJS_Runtime* pRuntime);
210 CJS_Result set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
211
212 CJS_Result get_zoom_type(CJS_Runtime* pRuntime);
213 CJS_Result set_zoom_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
214
215 CJS_Result get_URL(CJS_Runtime* pRuntime);
216 CJS_Result set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
217
218 CJS_Result addAnnot(CJS_Runtime* pRuntime,
219 pdfium::span<v8::Local<v8::Value>> params);
220 CJS_Result addField(CJS_Runtime* pRuntime,
221 pdfium::span<v8::Local<v8::Value>> params);
222 CJS_Result addLink(CJS_Runtime* pRuntime,
223 pdfium::span<v8::Local<v8::Value>> params);
224 CJS_Result addIcon(CJS_Runtime* pRuntime,
225 pdfium::span<v8::Local<v8::Value>> params);
226 CJS_Result calculateNow(CJS_Runtime* pRuntime,
227 pdfium::span<v8::Local<v8::Value>> params);
228 CJS_Result closeDoc(CJS_Runtime* pRuntime,
229 pdfium::span<v8::Local<v8::Value>> params);
230 CJS_Result createDataObject(CJS_Runtime* pRuntime,
231 pdfium::span<v8::Local<v8::Value>> params);
232 CJS_Result deletePages(CJS_Runtime* pRuntime,
233 pdfium::span<v8::Local<v8::Value>> params);
234 CJS_Result exportAsText(CJS_Runtime* pRuntime,
235 pdfium::span<v8::Local<v8::Value>> params);
236 CJS_Result exportAsFDF(CJS_Runtime* pRuntime,
237 pdfium::span<v8::Local<v8::Value>> params);
238 CJS_Result exportAsXFDF(CJS_Runtime* pRuntime,
239 pdfium::span<v8::Local<v8::Value>> params);
240 CJS_Result extractPages(CJS_Runtime* pRuntime,
241 pdfium::span<v8::Local<v8::Value>> params);
242 CJS_Result getAnnot(CJS_Runtime* pRuntime,
243 pdfium::span<v8::Local<v8::Value>> params);
244 CJS_Result getAnnots(CJS_Runtime* pRuntime,
245 pdfium::span<v8::Local<v8::Value>> params);
246 CJS_Result getAnnot3D(CJS_Runtime* pRuntime,
247 pdfium::span<v8::Local<v8::Value>> params);
248 CJS_Result getAnnots3D(CJS_Runtime* pRuntime,
249 pdfium::span<v8::Local<v8::Value>> params);
250 CJS_Result getField(CJS_Runtime* pRuntime,
251 pdfium::span<v8::Local<v8::Value>> params);
252 CJS_Result getIcon(CJS_Runtime* pRuntime,
253 pdfium::span<v8::Local<v8::Value>> params);
254 CJS_Result getLinks(CJS_Runtime* pRuntime,
255 pdfium::span<v8::Local<v8::Value>> params);
256 CJS_Result getNthFieldName(CJS_Runtime* pRuntime,
257 pdfium::span<v8::Local<v8::Value>> params);
258 CJS_Result getOCGs(CJS_Runtime* pRuntime,
259 pdfium::span<v8::Local<v8::Value>> params);
260 CJS_Result getPageBox(CJS_Runtime* pRuntime,
261 pdfium::span<v8::Local<v8::Value>> params);
262 CJS_Result getPageNthWord(CJS_Runtime* pRuntime,
263 pdfium::span<v8::Local<v8::Value>> params);
264 CJS_Result getPageNthWordQuads(CJS_Runtime* pRuntime,
265 pdfium::span<v8::Local<v8::Value>> params);
266 CJS_Result getPageNumWords(CJS_Runtime* pRuntime,
267 pdfium::span<v8::Local<v8::Value>> params);
268 CJS_Result getPrintParams(CJS_Runtime* pRuntime,
269 pdfium::span<v8::Local<v8::Value>> params);
270 CJS_Result getURL(CJS_Runtime* pRuntime,
271 pdfium::span<v8::Local<v8::Value>> params);
272 CJS_Result gotoNamedDest(CJS_Runtime* pRuntime,
273 pdfium::span<v8::Local<v8::Value>> params);
274 CJS_Result importAnFDF(CJS_Runtime* pRuntime,
275 pdfium::span<v8::Local<v8::Value>> params);
276 CJS_Result importAnXFDF(CJS_Runtime* pRuntime,
277 pdfium::span<v8::Local<v8::Value>> params);
278 CJS_Result importTextData(CJS_Runtime* pRuntime,
279 pdfium::span<v8::Local<v8::Value>> params);
280 CJS_Result insertPages(CJS_Runtime* pRuntime,
281 pdfium::span<v8::Local<v8::Value>> params);
282 CJS_Result mailForm(CJS_Runtime* pRuntime,
283 pdfium::span<v8::Local<v8::Value>> params);
284 CJS_Result print(CJS_Runtime* pRuntime,
285 pdfium::span<v8::Local<v8::Value>> params);
286 CJS_Result removeField(CJS_Runtime* pRuntime,
287 pdfium::span<v8::Local<v8::Value>> params);
288 CJS_Result replacePages(CJS_Runtime* pRuntime,
289 pdfium::span<v8::Local<v8::Value>> params);
290 CJS_Result resetForm(CJS_Runtime* pRuntime,
291 pdfium::span<v8::Local<v8::Value>> params);
292 CJS_Result saveAs(CJS_Runtime* pRuntime,
293 pdfium::span<v8::Local<v8::Value>> params);
294 CJS_Result submitForm(CJS_Runtime* pRuntime,
295 pdfium::span<v8::Local<v8::Value>> params);
296 CJS_Result syncAnnotScan(CJS_Runtime* pRuntime,
297 pdfium::span<v8::Local<v8::Value>> params);
298 CJS_Result mailDoc(CJS_Runtime* pRuntime,
299 pdfium::span<v8::Local<v8::Value>> params);
300 CJS_Result removeIcon(CJS_Runtime* pRuntime,
301 pdfium::span<v8::Local<v8::Value>> params);
302
303 CJS_Result getPropertyInternal(CJS_Runtime* pRuntime,
304 const ByteString& propName);
305
306 CPDF_InteractiveForm* GetCoreInteractiveForm();
307 CPDFSDK_InteractiveForm* GetSDKInteractiveForm();
308
309 WideString m_cwBaseURL;
310 ObservedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
311 std::list<std::unique_ptr<CJS_DelayData>> m_DelayData;
312 // Needs to be a std::list for iterator stability.
313 std::list<WideString> m_IconNames;
314 bool m_bDelay = false;
315};
316
317#endif // FXJS_CJS_DOCUMENT_H_
@ FXJSOBJTYPE_STATIC
static void DefineJSObjects(CFXJS_Engine *pEngine)
Definition cjs_app.cpp:87
static WideString SysPathToPDFPath(const WideString &sOldPath)
Definition cjs_app.cpp:501
void CancelProc(GlobalTimer *pTimer)
Definition cjs_app.cpp:399
static uint32_t GetObjDefnID()
Definition cjs_app.cpp:82
~CJS_App() override
void TimerProc(GlobalTimer *pTimer)
Definition cjs_app.cpp:393
CJS_App(v8::Local< v8::Object > pObject, CJS_Runtime *pRuntime)
Definition cjs_app.cpp:94
void DoFieldDelay(const WideString &sFieldName, int nControlIndex)
CJS_Document(v8::Local< v8::Object > pObject, CJS_Runtime *pRuntime)
void SetFormFillEnv(CPDFSDK_FormFillEnvironment *pFormFillEnv)
~CJS_Document() override
void AddDelayData(std::unique_ptr< CJS_DelayData > pData)
static uint32_t GetObjDefnID()
CPDFSDK_FormFillEnvironment * GetFormFillEnv() const
static void DefineJSObjects(CFXJS_Engine *pEngine)
static void DefineProps(CFXJS_Engine *pEngine, uint32_t nObjDefnID, pdfium::span< const JSPropertySpec > consts)
static void DefineMethods(CFXJS_Engine *pEngine, uint32_t nObjDefnID, pdfium::span< const JSMethodSpec > consts)
static CJS_Result Success()
Definition cjs_result.h:27
static CJS_Result Failure(JSMessage id)
Definition cjs_result.h:34
void BeginBlock()
Definition cjs_runtime.h:47
void EndBlock()
Definition cjs_runtime.h:48
bool IsBlocking() const
Definition cjs_runtime.h:49
CPDFSDK_FormFillEnvironment * GetFormFillEnv() const override
CPDFSDK_InteractiveForm * GetInteractiveForm()
CPDF_Document::Extension * GetDocExtension() const
bool KillFocusAnnot(Mask< FWL_EVENTFLAG > nFlags)
virtual bool ContainsExtensionForm() const =0
uint32_t GetTimeOut() const
CJS_Runtime * GetRuntime() const
WideString GetJScript() const
bool IsOneShot() const
static void Cancel(int32_t nTimerID)
virtual void OnExternal_Exec()=0
IJS_EventContext * operator->() const
Definition ijs_runtime.h:42
WideString & operator=(WideString &&that) noexcept
WideString & operator+=(const wchar_t *str)
WideString & operator+=(wchar_t ch)
bool IsEmpty() const
Definition widestring.h:118
static WideString FromUTF16LE(pdfium::span< const uint8_t > data)
WideString & operator=(const wchar_t *str)
#define JSPLATFORM_BEEP_DEFAULT
#define JSPLATFORM_ALERT_BUTTON_DEFAULT
#define JSPLATFORM_ALERT_ICON_DEFAULT
#define JS_STATIC_METHOD(method_name, class_name)
Definition js_define.h:155
#define JS_STATIC_PROP(err_name, prop_name, class_name)
Definition js_define.h:141
JSMessage
@ kParamTooLongError
@ kObjectTypeError
@ kNotSupportedError
@ kInvalidInputError
WideString JSGetStringFromID(JSMessage msg)