clang-format all pdfium code.
[pdfium.git] / fpdfsdk / include / javascript / app.h
1 // Copyright 2014 PDFium Authors. All rights reserved.
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_INCLUDE_JAVASCRIPT_APP_H_
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_APP_H_
9
10 #include "JS_Define.h"
11
12 class CJS_Runtime;
13
14 /* ---------------------------- TimerObj ---------------------------- */
15
16 class CJS_Timer;
17
18 class TimerObj : public CJS_EmbedObj {
19  public:
20   TimerObj(CJS_Object* pJSObject);
21   virtual ~TimerObj();
22
23  public:
24   void SetTimer(CJS_Timer* pTimer);
25   CJS_Timer* GetTimer() const;
26
27  private:
28   CJS_Timer* m_pTimer;
29 };
30
31 class CJS_TimerObj : public CJS_Object {
32  public:
33   CJS_TimerObj(JSFXObject pObject) : CJS_Object(pObject) {}
34   virtual ~CJS_TimerObj() {}
35
36   DECLARE_JS_CLASS(CJS_TimerObj);
37 };
38
39 // struct APP_MENUITEM_ARRAY;
40 //
41 // struct APP_MENUITEM
42 // {
43 //      APP_MENUITEM() : oSubMenu(NULL), cName(L""), cReturn(L""),
44 // bMarked(false), bEnabled(true)
45 //      {
46 //      }
47 //      CFX_WideString cName;
48 //      CFX_WideString cReturn;
49 //      APP_MENUITEM_ARRAY* oSubMenu;
50 //      bool bMarked;
51 //      bool bEnabled;
52 // };
53
54 // struct APP_MENUITEM_ARRAY
55 // {
56 //      APP_MENUITEM_ARRAY() : m_hMenu(NULL), pContents(NULL), nSize(0)
57 //      {
58 //
59 //      }
60 //      APP_MENUITEM * pContents;
61 //      HMENU m_hMenu;
62 //      int     nSize;
63 // };
64
65 // struct APP_MENU;
66 // struct APP_MENU_ARRAY
67 // {
68 //      APP_MENU_ARRAY():
69 //     pContent(NULL)
70 //      {
71 //      }
72 //
73 //      APP_MENU* pContent;
74 // };
75
76 // struct APP_MENU
77 // {
78 //      APP_MENU():bSubMenu(false),
79 //      SubMenuItems(NULL),
80 //      cwMenuItemName(L""),
81 //      hMenu(NULL),
82 //      iSize(0)
83 //      {
84 //
85 //      }
86 //
87 //      APP_MENU(CFX_WideString &cwName):
88 //      cwMenuItemName(cwName),
89 //      bSubMenu(false),
90 //      SubMenuItems(NULL),
91 //      hMenu(NULL),
92 //      iSize(0)
93 //      {
94 //
95 //      }
96 //
97 //      CFX_WideString cwMenuItemName;
98 //      bool bSubMenu;
99 //      APP_MENU_ARRAY* SubMenuItems;
100 //      int iSize;
101 //      HMENU hMenu;
102 // };
103
104 class app : public CJS_EmbedObj {
105  public:
106   app(CJS_Object* pJSObject);
107   virtual ~app();
108
109  public:
110   FX_BOOL activeDocs(IFXJS_Context* cc,
111                      CJS_PropValue& vp,
112                      CFX_WideString& sError);
113   FX_BOOL calculate(IFXJS_Context* cc,
114                     CJS_PropValue& vp,
115                     CFX_WideString& sError);
116   FX_BOOL formsVersion(IFXJS_Context* cc,
117                        CJS_PropValue& vp,
118                        CFX_WideString& sError);
119   FX_BOOL fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
120   FX_BOOL fullscreen(IFXJS_Context* cc,
121                      CJS_PropValue& vp,
122                      CFX_WideString& sError);
123   FX_BOOL language(IFXJS_Context* cc,
124                    CJS_PropValue& vp,
125                    CFX_WideString& sError);
126   FX_BOOL media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
127   FX_BOOL platform(IFXJS_Context* cc,
128                    CJS_PropValue& vp,
129                    CFX_WideString& sError);
130   FX_BOOL runtimeHighlight(IFXJS_Context* cc,
131                            CJS_PropValue& vp,
132                            CFX_WideString& sError);
133   FX_BOOL viewerType(IFXJS_Context* cc,
134                      CJS_PropValue& vp,
135                      CFX_WideString& sError);
136   FX_BOOL viewerVariation(IFXJS_Context* cc,
137                           CJS_PropValue& vp,
138                           CFX_WideString& sError);
139   FX_BOOL viewerVersion(IFXJS_Context* cc,
140                         CJS_PropValue& vp,
141                         CFX_WideString& sError);
142
143   FX_BOOL alert(IFXJS_Context* cc,
144                 const CJS_Parameters& params,
145                 CJS_Value& vRet,
146                 CFX_WideString& sError);
147   FX_BOOL beep(IFXJS_Context* cc,
148                const CJS_Parameters& params,
149                CJS_Value& vRet,
150                CFX_WideString& sError);
151   FX_BOOL browseForDoc(IFXJS_Context* cc,
152                        const CJS_Parameters& params,
153                        CJS_Value& vRet,
154                        CFX_WideString& sError);
155   FX_BOOL clearInterval(IFXJS_Context* cc,
156                         const CJS_Parameters& params,
157                         CJS_Value& vRet,
158                         CFX_WideString& sError);
159   FX_BOOL clearTimeOut(IFXJS_Context* cc,
160                        const CJS_Parameters& params,
161                        CJS_Value& vRet,
162                        CFX_WideString& sError);
163   FX_BOOL execDialog(IFXJS_Context* cc,
164                      const CJS_Parameters& params,
165                      CJS_Value& vRet,
166                      CFX_WideString& sError);
167   FX_BOOL execMenuItem(IFXJS_Context* cc,
168                        const CJS_Parameters& params,
169                        CJS_Value& vRet,
170                        CFX_WideString& sError);
171   FX_BOOL findComponent(IFXJS_Context* cc,
172                         const CJS_Parameters& params,
173                         CJS_Value& vRet,
174                         CFX_WideString& sError);
175   FX_BOOL goBack(IFXJS_Context* cc,
176                  const CJS_Parameters& params,
177                  CJS_Value& vRet,
178                  CFX_WideString& sError);
179   FX_BOOL goForward(IFXJS_Context* cc,
180                     const CJS_Parameters& params,
181                     CJS_Value& vRet,
182                     CFX_WideString& sError);
183   FX_BOOL launchURL(IFXJS_Context* cc,
184                     const CJS_Parameters& params,
185                     CJS_Value& vRet,
186                     CFX_WideString& sError);
187   FX_BOOL mailMsg(IFXJS_Context* cc,
188                   const CJS_Parameters& params,
189                   CJS_Value& vRet,
190                   CFX_WideString& sError);
191   FX_BOOL newFDF(IFXJS_Context* cc,
192                  const CJS_Parameters& params,
193                  CJS_Value& vRet,
194                  CFX_WideString& sError);
195   FX_BOOL newDoc(IFXJS_Context* cc,
196                  const CJS_Parameters& params,
197                  CJS_Value& vRet,
198                  CFX_WideString& sError);
199   FX_BOOL openDoc(IFXJS_Context* cc,
200                   const CJS_Parameters& params,
201                   CJS_Value& vRet,
202                   CFX_WideString& sError);
203   FX_BOOL openFDF(IFXJS_Context* cc,
204                   const CJS_Parameters& params,
205                   CJS_Value& vRet,
206                   CFX_WideString& sError);
207   FX_BOOL popUpMenuEx(IFXJS_Context* cc,
208                       const CJS_Parameters& params,
209                       CJS_Value& vRet,
210                       CFX_WideString& sError);
211   FX_BOOL popUpMenu(IFXJS_Context* cc,
212                     const CJS_Parameters& params,
213                     CJS_Value& vRet,
214                     CFX_WideString& sError);
215   FX_BOOL response(IFXJS_Context* cc,
216                    const CJS_Parameters& params,
217                    CJS_Value& vRet,
218                    CFX_WideString& sError);
219   FX_BOOL setInterval(IFXJS_Context* cc,
220                       const CJS_Parameters& params,
221                       CJS_Value& vRet,
222                       CFX_WideString& sError);
223   FX_BOOL setTimeOut(IFXJS_Context* cc,
224                      const CJS_Parameters& params,
225                      CJS_Value& vRet,
226                      CFX_WideString& sError);
227
228  private:
229   //    FX_DWORD                                        AppGetTickCount();
230   void TimerProc(CJS_Timer* pTimer);
231   void RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript);
232   //    void                                            ParsePopupMenuObj(APP_MENUITEM *
233   //ppMenuItem,JSObject * pObj);
234   //    void                                            DeleteMenuItems(APP_MENUITEM_ARRAY *
235   //pMenuItems);
236   //    void                                            AddMenuItem(APP_MENUITEM_ARRAY * pMenuItems, HMENU
237   // hMenu, MENUITEMINFO MenuItemInfo);
238   //    void                                            InitMenuItemInfo(MENUITEMINFO&
239   // MenuItemInfo);
240   //    void                                            DestroyPopUpMenu();
241
242   //    void                                            ParserMenuItem(APP_MENU* pHead, const
243   // CJS_Parameters&params);
244   //    void                                            AddItemToMenu(APP_MENU* pHead, HMENU hMenu,
245   // MENUITEMINFO MenuItemInfo);
246   //    void                                            DestroyMenuItems(APP_MENU*
247   // pHead);
248
249  public:
250   static CFX_WideString SysPathToPDFPath(const CFX_WideString& sOldPath);
251
252  private:
253   bool m_bCalculate;
254   bool m_bRuntimeHighLight;
255
256   CFX_ArrayTemplate<CJS_Timer*> m_aTimer;
257   //    APP_MENU*                                       m_pMenuHead;
258
259  public:
260   //    static CReader_App* s_App;
261 };
262
263 class CJS_App : public CJS_Object {
264  public:
265   CJS_App(JSFXObject pObject) : CJS_Object(pObject){};
266   virtual ~CJS_App(void){};
267
268   DECLARE_JS_CLASS(CJS_App);
269
270   JS_STATIC_PROP(activeDocs, app);
271   JS_STATIC_PROP(calculate, app);
272   JS_STATIC_PROP(formsVersion, app);
273   JS_STATIC_PROP(fs, app);
274   JS_STATIC_PROP(fullscreen, app);
275   JS_STATIC_PROP(language, app);
276   JS_STATIC_PROP(media, app);
277   JS_STATIC_PROP(platform, app);
278   JS_STATIC_PROP(runtimeHighlight, app);
279   JS_STATIC_PROP(viewerType, app);
280   JS_STATIC_PROP(viewerVariation, app);
281   JS_STATIC_PROP(viewerVersion, app);
282
283   JS_STATIC_METHOD(alert, app);
284   JS_STATIC_METHOD(beep, app);
285   JS_STATIC_METHOD(browseForDoc, app);
286   JS_STATIC_METHOD(clearInterval, app);
287   JS_STATIC_METHOD(clearTimeOut, app);
288   JS_STATIC_METHOD(execDialog, app);
289   JS_STATIC_METHOD(execMenuItem, app);
290   JS_STATIC_METHOD(findComponent, app);
291   JS_STATIC_METHOD(goBack, app);
292   JS_STATIC_METHOD(goForward, app);
293   JS_STATIC_METHOD(launchURL, app);
294   JS_STATIC_METHOD(mailMsg, app);
295   JS_STATIC_METHOD(newFDF, app);
296   JS_STATIC_METHOD(newDoc, app);
297   JS_STATIC_METHOD(openDoc, app);
298   JS_STATIC_METHOD(openFDF, app);
299   JS_STATIC_METHOD(popUpMenuEx, app);
300   JS_STATIC_METHOD(popUpMenu, app);
301   JS_STATIC_METHOD(response, app);
302   JS_STATIC_METHOD(setInterval, app);
303   JS_STATIC_METHOD(setTimeOut, app);
304 };
305
306 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_APP_H_