Fix strings, remove stringify macros, void return types for Consts.h.
[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   ~TimerObj() override;
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(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
34   ~CJS_TimerObj() override {}
35
36   DECLARE_JS_CLASS(CJS_TimerObj);
37 };
38
39 class app : public CJS_EmbedObj {
40  public:
41   app(CJS_Object* pJSObject);
42   ~app() override;
43
44  public:
45   FX_BOOL activeDocs(IFXJS_Context* cc,
46                      CJS_PropValue& vp,
47                      CFX_WideString& sError);
48   FX_BOOL calculate(IFXJS_Context* cc,
49                     CJS_PropValue& vp,
50                     CFX_WideString& sError);
51   FX_BOOL formsVersion(IFXJS_Context* cc,
52                        CJS_PropValue& vp,
53                        CFX_WideString& sError);
54   FX_BOOL fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
55   FX_BOOL fullscreen(IFXJS_Context* cc,
56                      CJS_PropValue& vp,
57                      CFX_WideString& sError);
58   FX_BOOL language(IFXJS_Context* cc,
59                    CJS_PropValue& vp,
60                    CFX_WideString& sError);
61   FX_BOOL media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
62   FX_BOOL platform(IFXJS_Context* cc,
63                    CJS_PropValue& vp,
64                    CFX_WideString& sError);
65   FX_BOOL runtimeHighlight(IFXJS_Context* cc,
66                            CJS_PropValue& vp,
67                            CFX_WideString& sError);
68   FX_BOOL viewerType(IFXJS_Context* cc,
69                      CJS_PropValue& vp,
70                      CFX_WideString& sError);
71   FX_BOOL viewerVariation(IFXJS_Context* cc,
72                           CJS_PropValue& vp,
73                           CFX_WideString& sError);
74   FX_BOOL viewerVersion(IFXJS_Context* cc,
75                         CJS_PropValue& vp,
76                         CFX_WideString& sError);
77
78   FX_BOOL alert(IFXJS_Context* cc,
79                 const CJS_Parameters& params,
80                 CJS_Value& vRet,
81                 CFX_WideString& sError);
82   FX_BOOL beep(IFXJS_Context* cc,
83                const CJS_Parameters& params,
84                CJS_Value& vRet,
85                CFX_WideString& sError);
86   FX_BOOL browseForDoc(IFXJS_Context* cc,
87                        const CJS_Parameters& params,
88                        CJS_Value& vRet,
89                        CFX_WideString& sError);
90   FX_BOOL clearInterval(IFXJS_Context* cc,
91                         const CJS_Parameters& params,
92                         CJS_Value& vRet,
93                         CFX_WideString& sError);
94   FX_BOOL clearTimeOut(IFXJS_Context* cc,
95                        const CJS_Parameters& params,
96                        CJS_Value& vRet,
97                        CFX_WideString& sError);
98   FX_BOOL execDialog(IFXJS_Context* cc,
99                      const CJS_Parameters& params,
100                      CJS_Value& vRet,
101                      CFX_WideString& sError);
102   FX_BOOL execMenuItem(IFXJS_Context* cc,
103                        const CJS_Parameters& params,
104                        CJS_Value& vRet,
105                        CFX_WideString& sError);
106   FX_BOOL findComponent(IFXJS_Context* cc,
107                         const CJS_Parameters& params,
108                         CJS_Value& vRet,
109                         CFX_WideString& sError);
110   FX_BOOL goBack(IFXJS_Context* cc,
111                  const CJS_Parameters& params,
112                  CJS_Value& vRet,
113                  CFX_WideString& sError);
114   FX_BOOL goForward(IFXJS_Context* cc,
115                     const CJS_Parameters& params,
116                     CJS_Value& vRet,
117                     CFX_WideString& sError);
118   FX_BOOL launchURL(IFXJS_Context* cc,
119                     const CJS_Parameters& params,
120                     CJS_Value& vRet,
121                     CFX_WideString& sError);
122   FX_BOOL mailMsg(IFXJS_Context* cc,
123                   const CJS_Parameters& params,
124                   CJS_Value& vRet,
125                   CFX_WideString& sError);
126   FX_BOOL newFDF(IFXJS_Context* cc,
127                  const CJS_Parameters& params,
128                  CJS_Value& vRet,
129                  CFX_WideString& sError);
130   FX_BOOL newDoc(IFXJS_Context* cc,
131                  const CJS_Parameters& params,
132                  CJS_Value& vRet,
133                  CFX_WideString& sError);
134   FX_BOOL openDoc(IFXJS_Context* cc,
135                   const CJS_Parameters& params,
136                   CJS_Value& vRet,
137                   CFX_WideString& sError);
138   FX_BOOL openFDF(IFXJS_Context* cc,
139                   const CJS_Parameters& params,
140                   CJS_Value& vRet,
141                   CFX_WideString& sError);
142   FX_BOOL popUpMenuEx(IFXJS_Context* cc,
143                       const CJS_Parameters& params,
144                       CJS_Value& vRet,
145                       CFX_WideString& sError);
146   FX_BOOL popUpMenu(IFXJS_Context* cc,
147                     const CJS_Parameters& params,
148                     CJS_Value& vRet,
149                     CFX_WideString& sError);
150   FX_BOOL response(IFXJS_Context* cc,
151                    const CJS_Parameters& params,
152                    CJS_Value& vRet,
153                    CFX_WideString& sError);
154   FX_BOOL setInterval(IFXJS_Context* cc,
155                       const CJS_Parameters& params,
156                       CJS_Value& vRet,
157                       CFX_WideString& sError);
158   FX_BOOL setTimeOut(IFXJS_Context* cc,
159                      const CJS_Parameters& params,
160                      CJS_Value& vRet,
161                      CFX_WideString& sError);
162
163   static CFX_WideString SysPathToPDFPath(const CFX_WideString& sOldPath);
164
165  private:
166   // CJS_EmbedObj
167   void TimerProc(CJS_Timer* pTimer) override;
168   void RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript);
169
170   bool m_bCalculate;
171   bool m_bRuntimeHighLight;
172   CFX_ArrayTemplate<CJS_Timer*> m_aTimer;
173 };
174
175 class CJS_App : public CJS_Object {
176  public:
177   explicit CJS_App(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
178   ~CJS_App() override {}
179
180   DECLARE_JS_CLASS(CJS_App);
181
182   JS_STATIC_PROP(activeDocs, app);
183   JS_STATIC_PROP(calculate, app);
184   JS_STATIC_PROP(formsVersion, app);
185   JS_STATIC_PROP(fs, app);
186   JS_STATIC_PROP(fullscreen, app);
187   JS_STATIC_PROP(language, app);
188   JS_STATIC_PROP(media, app);
189   JS_STATIC_PROP(platform, app);
190   JS_STATIC_PROP(runtimeHighlight, app);
191   JS_STATIC_PROP(viewerType, app);
192   JS_STATIC_PROP(viewerVariation, app);
193   JS_STATIC_PROP(viewerVersion, app);
194
195   JS_STATIC_METHOD(alert, app);
196   JS_STATIC_METHOD(beep, app);
197   JS_STATIC_METHOD(browseForDoc, app);
198   JS_STATIC_METHOD(clearInterval, app);
199   JS_STATIC_METHOD(clearTimeOut, app);
200   JS_STATIC_METHOD(execDialog, app);
201   JS_STATIC_METHOD(execMenuItem, app);
202   JS_STATIC_METHOD(findComponent, app);
203   JS_STATIC_METHOD(goBack, app);
204   JS_STATIC_METHOD(goForward, app);
205   JS_STATIC_METHOD(launchURL, app);
206   JS_STATIC_METHOD(mailMsg, app);
207   JS_STATIC_METHOD(newFDF, app);
208   JS_STATIC_METHOD(newDoc, app);
209   JS_STATIC_METHOD(openDoc, app);
210   JS_STATIC_METHOD(openFDF, app);
211   JS_STATIC_METHOD(popUpMenuEx, app);
212   JS_STATIC_METHOD(popUpMenu, app);
213   JS_STATIC_METHOD(response, app);
214   JS_STATIC_METHOD(setInterval, app);
215   JS_STATIC_METHOD(setTimeOut, app);
216 };
217
218 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_APP_H_