summaryrefslogtreecommitdiff
path: root/fpdfsdk/include/javascript/app.h
blob: 221a7c1d8910ae784afc9e70e64f938213590cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef FPDFSDK_INCLUDE_JAVASCRIPT_APP_H_
#define FPDFSDK_INCLUDE_JAVASCRIPT_APP_H_

#include "JS_Define.h"

class CJS_Runtime;

/* ---------------------------- TimerObj ---------------------------- */

class CJS_Timer;

class TimerObj : public CJS_EmbedObj {
 public:
  TimerObj(CJS_Object* pJSObject);
  virtual ~TimerObj();

 public:
  void SetTimer(CJS_Timer* pTimer);
  CJS_Timer* GetTimer() const;

 private:
  CJS_Timer* m_pTimer;
};

class CJS_TimerObj : public CJS_Object {
 public:
  CJS_TimerObj(JSFXObject pObject) : CJS_Object(pObject) {}
  virtual ~CJS_TimerObj() {}

  DECLARE_JS_CLASS(CJS_TimerObj);
};

// struct APP_MENUITEM_ARRAY;
//
// struct APP_MENUITEM
// {
// 	APP_MENUITEM() : oSubMenu(NULL), cName(L""), cReturn(L""),
// bMarked(false), bEnabled(true)
// 	{
// 	}
// 	CFX_WideString cName;
// 	CFX_WideString cReturn;
// 	APP_MENUITEM_ARRAY* oSubMenu;
// 	bool bMarked;
// 	bool bEnabled;
// };

// struct APP_MENUITEM_ARRAY
// {
// 	APP_MENUITEM_ARRAY() : m_hMenu(NULL), pContents(NULL), nSize(0)
// 	{
//
// 	}
// 	APP_MENUITEM * pContents;
// 	HMENU m_hMenu;
// 	int	nSize;
// };

// struct APP_MENU;
// struct APP_MENU_ARRAY
// {
// 	APP_MENU_ARRAY():
//     pContent(NULL)
// 	{
// 	}
//
// 	APP_MENU* pContent;
// };

// struct APP_MENU
// {
// 	APP_MENU():bSubMenu(false),
// 	SubMenuItems(NULL),
// 	cwMenuItemName(L""),
// 	hMenu(NULL),
// 	iSize(0)
// 	{
//
// 	}
//
// 	APP_MENU(CFX_WideString &cwName):
// 	cwMenuItemName(cwName),
// 	bSubMenu(false),
// 	SubMenuItems(NULL),
// 	hMenu(NULL),
// 	iSize(0)
// 	{
//
// 	}
//
// 	CFX_WideString cwMenuItemName;
// 	bool bSubMenu;
// 	APP_MENU_ARRAY* SubMenuItems;
// 	int iSize;
// 	HMENU hMenu;
// };

class app : public CJS_EmbedObj {
 public:
  app(CJS_Object* pJSObject);
  virtual ~app();

 public:
  FX_BOOL activeDocs(IFXJS_Context* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError);
  FX_BOOL calculate(IFXJS_Context* cc,
                    CJS_PropValue& vp,
                    CFX_WideString& sError);
  FX_BOOL formsVersion(IFXJS_Context* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError);
  FX_BOOL fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
  FX_BOOL fullscreen(IFXJS_Context* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError);
  FX_BOOL language(IFXJS_Context* cc,
                   CJS_PropValue& vp,
                   CFX_WideString& sError);
  FX_BOOL media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
  FX_BOOL platform(IFXJS_Context* cc,
                   CJS_PropValue& vp,
                   CFX_WideString& sError);
  FX_BOOL runtimeHighlight(IFXJS_Context* cc,
                           CJS_PropValue& vp,
                           CFX_WideString& sError);
  FX_BOOL viewerType(IFXJS_Context* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError);
  FX_BOOL viewerVariation(IFXJS_Context* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError);
  FX_BOOL viewerVersion(IFXJS_Context* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError);

  FX_BOOL alert(IFXJS_Context* cc,
                const CJS_Parameters& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
  FX_BOOL beep(IFXJS_Context* cc,
               const CJS_Parameters& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
  FX_BOOL browseForDoc(IFXJS_Context* cc,
                       const CJS_Parameters& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError);
  FX_BOOL clearInterval(IFXJS_Context* cc,
                        const CJS_Parameters& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError);
  FX_BOOL clearTimeOut(IFXJS_Context* cc,
                       const CJS_Parameters& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError);
  FX_BOOL execDialog(IFXJS_Context* cc,
                     const CJS_Parameters& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
  FX_BOOL execMenuItem(IFXJS_Context* cc,
                       const CJS_Parameters& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError);
  FX_BOOL findComponent(IFXJS_Context* cc,
                        const CJS_Parameters& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError);
  FX_BOOL goBack(IFXJS_Context* cc,
                 const CJS_Parameters& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
  FX_BOOL goForward(IFXJS_Context* cc,
                    const CJS_Parameters& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
  FX_BOOL launchURL(IFXJS_Context* cc,
                    const CJS_Parameters& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
  FX_BOOL mailMsg(IFXJS_Context* cc,
                  const CJS_Parameters& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
  FX_BOOL newFDF(IFXJS_Context* cc,
                 const CJS_Parameters& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
  FX_BOOL newDoc(IFXJS_Context* cc,
                 const CJS_Parameters& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
  FX_BOOL openDoc(IFXJS_Context* cc,
                  const CJS_Parameters& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
  FX_BOOL openFDF(IFXJS_Context* cc,
                  const CJS_Parameters& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
  FX_BOOL popUpMenuEx(IFXJS_Context* cc,
                      const CJS_Parameters& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
  FX_BOOL popUpMenu(IFXJS_Context* cc,
                    const CJS_Parameters& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
  FX_BOOL response(IFXJS_Context* cc,
                   const CJS_Parameters& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);
  FX_BOOL setInterval(IFXJS_Context* cc,
                      const CJS_Parameters& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
  FX_BOOL setTimeOut(IFXJS_Context* cc,
                     const CJS_Parameters& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);

 private:
  //	FX_DWORD					AppGetTickCount();
  void TimerProc(CJS_Timer* pTimer);
  void RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript);
  //	void						ParsePopupMenuObj(APP_MENUITEM *
  //ppMenuItem,JSObject * pObj);
  //	void						DeleteMenuItems(APP_MENUITEM_ARRAY *
  //pMenuItems);
  // 	void						AddMenuItem(APP_MENUITEM_ARRAY * pMenuItems, HMENU
  // hMenu, MENUITEMINFO MenuItemInfo);
  // 	void						InitMenuItemInfo(MENUITEMINFO&
  // MenuItemInfo);
  // 	void						DestroyPopUpMenu();

  // 	void						ParserMenuItem(APP_MENU* pHead, const
  // CJS_Parameters&params);
  // 	void						AddItemToMenu(APP_MENU* pHead, HMENU hMenu,
  // MENUITEMINFO MenuItemInfo);
  // 	void						DestroyMenuItems(APP_MENU*
  // pHead);

 public:
  static CFX_WideString SysPathToPDFPath(const CFX_WideString& sOldPath);

 private:
  bool m_bCalculate;
  bool m_bRuntimeHighLight;

  CFX_ArrayTemplate<CJS_Timer*> m_aTimer;
  //	APP_MENU*					m_pMenuHead;

 public:
  //	static CReader_App* s_App;
};

class CJS_App : public CJS_Object {
 public:
  CJS_App(JSFXObject pObject) : CJS_Object(pObject){};
  virtual ~CJS_App(void){};

  DECLARE_JS_CLASS(CJS_App);

  JS_STATIC_PROP(activeDocs, app);
  JS_STATIC_PROP(calculate, app);
  JS_STATIC_PROP(formsVersion, app);
  JS_STATIC_PROP(fs, app);
  JS_STATIC_PROP(fullscreen, app);
  JS_STATIC_PROP(language, app);
  JS_STATIC_PROP(media, app);
  JS_STATIC_PROP(platform, app);
  JS_STATIC_PROP(runtimeHighlight, app);
  JS_STATIC_PROP(viewerType, app);
  JS_STATIC_PROP(viewerVariation, app);
  JS_STATIC_PROP(viewerVersion, app);

  JS_STATIC_METHOD(alert, app);
  JS_STATIC_METHOD(beep, app);
  JS_STATIC_METHOD(browseForDoc, app);
  JS_STATIC_METHOD(clearInterval, app);
  JS_STATIC_METHOD(clearTimeOut, app);
  JS_STATIC_METHOD(execDialog, app);
  JS_STATIC_METHOD(execMenuItem, app);
  JS_STATIC_METHOD(findComponent, app);
  JS_STATIC_METHOD(goBack, app);
  JS_STATIC_METHOD(goForward, app);
  JS_STATIC_METHOD(launchURL, app);
  JS_STATIC_METHOD(mailMsg, app);
  JS_STATIC_METHOD(newFDF, app);
  JS_STATIC_METHOD(newDoc, app);
  JS_STATIC_METHOD(openDoc, app);
  JS_STATIC_METHOD(openFDF, app);
  JS_STATIC_METHOD(popUpMenuEx, app);
  JS_STATIC_METHOD(popUpMenu, app);
  JS_STATIC_METHOD(response, app);
  JS_STATIC_METHOD(setInterval, app);
  JS_STATIC_METHOD(setTimeOut, app);
};

#endif  // FPDFSDK_INCLUDE_JAVASCRIPT_APP_H_