Fix strings, remove stringify macros, void return types for Consts.h.
[pdfium.git] / fpdfsdk / include / javascript / app.h
index 35ee401..1ab02c5 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#ifndef _APP_H_\r
-#define _APP_H_\r
-\r
-class CJS_Runtime;\r
-\r
-/* ---------------------------- TimerObj ---------------------------- */\r
-\r
-class CJS_Timer;\r
-\r
-class TimerObj : public CJS_EmbedObj\r
-{\r
-public:\r
-       TimerObj(CJS_Object* pJSObject);\r
-       virtual ~TimerObj();\r
-       \r
-public:\r
-       void                    SetTimer(CJS_Timer* pTimer);\r
-       CJS_Timer*              GetTimer() const;\r
-       \r
-private:\r
-       CJS_Timer*              m_pTimer;\r
-};\r
-\r
-class CJS_TimerObj : public CJS_Object\r
-{\r
-public:\r
-       CJS_TimerObj(JSFXObject pObject) : CJS_Object(pObject) {}\r
-       virtual ~CJS_TimerObj(){}\r
-       \r
-       DECLARE_JS_CLASS(CJS_TimerObj);\r
-};\r
-\r
-\r
-// struct APP_MENUITEM_ARRAY;\r
-// \r
-// struct APP_MENUITEM\r
-// {\r
-//     APP_MENUITEM() : oSubMenu(NULL), cName(L""), cReturn(L""), bMarked(false), bEnabled(true)\r
-//     {\r
-//     }\r
-//     CFX_WideString cName;\r
-//     CFX_WideString cReturn;\r
-//     APP_MENUITEM_ARRAY* oSubMenu;\r
-//     bool bMarked;\r
-//     bool bEnabled;\r
-// };\r
-\r
-// struct APP_MENUITEM_ARRAY\r
-// {\r
-//     APP_MENUITEM_ARRAY() : m_hMenu(NULL), pContents(NULL), nSize(0)\r
-//     {\r
-// \r
-//     }\r
-//     APP_MENUITEM * pContents;\r
-//     HMENU m_hMenu;\r
-//     int     nSize;\r
-// };\r
-\r
-// struct APP_MENU;\r
-// struct APP_MENU_ARRAY\r
-// {\r
-//     APP_MENU_ARRAY():\r
-//     pContent(NULL)\r
-//     {\r
-//     }\r
-// \r
-//     APP_MENU* pContent;\r
-// };\r
-\r
-// struct APP_MENU\r
-// {\r
-//     APP_MENU():bSubMenu(false), \r
-//     SubMenuItems(NULL),\r
-//     cwMenuItemName(L""),\r
-//     hMenu(NULL),\r
-//     iSize(0)\r
-//     {\r
-// \r
-//     }\r
-// \r
-//     APP_MENU(CFX_WideString &cwName):\r
-//     cwMenuItemName(cwName),\r
-//     bSubMenu(false),\r
-//     SubMenuItems(NULL),\r
-//     hMenu(NULL),\r
-//     iSize(0)\r
-//     {\r
-// \r
-//     }\r
-//     \r
-//     CFX_WideString cwMenuItemName;\r
-//     bool bSubMenu;  \r
-//     APP_MENU_ARRAY* SubMenuItems;\r
-//     int iSize;\r
-//     HMENU hMenu;\r
-// };\r
-\r
-class app : public CJS_EmbedObj\r
-{\r
-public:\r
-       app(CJS_Object * pJSObject);\r
-       virtual ~app();\r
-\r
-public:\r
-       FX_BOOL                                         activeDocs(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         calculate(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         formsVersion(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         fs(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         fullscreen(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         language(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         media(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         platform(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         runtimeHighlight(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         viewerType(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         viewerVariation(OBJ_PROP_PARAMS);\r
-       FX_BOOL                                         viewerVersion(OBJ_PROP_PARAMS); \r
-\r
-\r
-       FX_BOOL                                         alert(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         beep(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         browseForDoc(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         clearInterval(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         clearTimeOut(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         execDialog(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         execMenuItem(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         findComponent(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         goBack(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         goForward(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         launchURL(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         mailMsg(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         newFDF(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         newDoc(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         openDoc(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         openFDF(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         popUpMenuEx(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         popUpMenu(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         response(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         setInterval(OBJ_METHOD_PARAMS);\r
-       FX_BOOL                                         setTimeOut(OBJ_METHOD_PARAMS);\r
-\r
-private:\r
-//     FX_DWORD                                        AppGetTickCount(); \r
-       void                                            TimerProc(CJS_Timer* pTimer);\r
-       void                                            RunJsScript(CJS_Runtime * pRuntime,const CFX_WideString & wsScript);\r
-//     void                                            ParsePopupMenuObj(APP_MENUITEM * ppMenuItem,JSObject * pObj);\r
-//     void                                            DeleteMenuItems(APP_MENUITEM_ARRAY * pMenuItems);\r
-//     void                                            AddMenuItem(APP_MENUITEM_ARRAY * pMenuItems, HMENU hMenu, MENUITEMINFO MenuItemInfo);\r
-//     void                                            InitMenuItemInfo(MENUITEMINFO& MenuItemInfo);\r
-//     void                                            DestroyPopUpMenu();\r
-\r
-//     void                                            ParserMenuItem(APP_MENU* pHead, const CJS_Parameters&params);\r
-//     void                                            AddItemToMenu(APP_MENU* pHead, HMENU hMenu, MENUITEMINFO MenuItemInfo);\r
-//     void                                            DestroyMenuItems(APP_MENU* pHead);\r
-\r
-public:\r
-       static CFX_WideString           SysPathToPDFPath(const CFX_WideString& sOldPath);\r
-       static CFX_WideString           PDFPathToSysPath(const CFX_WideString& sOldPath);\r
-       static CFX_WideString           RelativePathToSysPath(const CFX_WideString& sOldPath, const CFX_WideString& sFilePath);\r
-\r
-\r
-private:\r
-\r
-       bool                                            m_bCalculate;   \r
-       CJS_Runtime*                            m_pRuntime;\r
-       bool                                            m_bRuntimeHighLight;\r
-\r
-       CFX_ArrayTemplate<CJS_Timer*>   m_aTimer;\r
-//     APP_MENU*                                       m_pMenuHead;\r
-       \r
-public:\r
-//     static CReader_App* s_App;\r
-};\r
-\r
-class CJS_App : public CJS_Object\r
-{\r
-public:\r
-       CJS_App(JSFXObject  pObject) : CJS_Object(pObject) {};\r
-       virtual ~CJS_App(void){};\r
-\r
-       DECLARE_JS_CLASS(CJS_App);\r
-\r
-       JS_STATIC_PROP(activeDocs, app);\r
-       JS_STATIC_PROP(calculate, app);\r
-       JS_STATIC_PROP(formsVersion, app);\r
-       JS_STATIC_PROP(fs, app);\r
-       JS_STATIC_PROP(fullscreen, app);\r
-       JS_STATIC_PROP(language, app);\r
-       JS_STATIC_PROP(media, app);\r
-       JS_STATIC_PROP(platform, app);\r
-       JS_STATIC_PROP(runtimeHighlight, app);\r
-       JS_STATIC_PROP(viewerType, app);\r
-       JS_STATIC_PROP(viewerVariation, app);\r
-       JS_STATIC_PROP(viewerVersion, app);     \r
-\r
-       JS_STATIC_METHOD(alert, app);\r
-       JS_STATIC_METHOD(beep, app);\r
-       JS_STATIC_METHOD(browseForDoc, app);\r
-       JS_STATIC_METHOD(clearInterval, app);\r
-       JS_STATIC_METHOD(clearTimeOut, app);\r
-       JS_STATIC_METHOD(execDialog, app);\r
-       JS_STATIC_METHOD(execMenuItem, app);\r
-       JS_STATIC_METHOD(findComponent, app);\r
-       JS_STATIC_METHOD(goBack, app);\r
-       JS_STATIC_METHOD(goForward, app);\r
-       JS_STATIC_METHOD(launchURL, app);\r
-       JS_STATIC_METHOD(mailMsg, app);\r
-       JS_STATIC_METHOD(newFDF, app);\r
-       JS_STATIC_METHOD(newDoc, app);\r
-       JS_STATIC_METHOD(openDoc, app);\r
-       JS_STATIC_METHOD(openFDF, app);\r
-       JS_STATIC_METHOD(popUpMenuEx, app);\r
-       JS_STATIC_METHOD(popUpMenu, app);\r
-       JS_STATIC_METHOD(response, app);\r
-       JS_STATIC_METHOD(setInterval, app);\r
-       JS_STATIC_METHOD(setTimeOut, app);\r
-\r
-};\r
-\r
-#endif //_APP_H_\r
+// 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);
+  ~TimerObj() override;
+
+ public:
+  void SetTimer(CJS_Timer* pTimer);
+  CJS_Timer* GetTimer() const;
+
+ private:
+  CJS_Timer* m_pTimer;
+};
+
+class CJS_TimerObj : public CJS_Object {
+ public:
+  CJS_TimerObj(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
+  ~CJS_TimerObj() override {}
+
+  DECLARE_JS_CLASS(CJS_TimerObj);
+};
+
+class app : public CJS_EmbedObj {
+ public:
+  app(CJS_Object* pJSObject);
+  ~app() override;
+
+ 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);
+
+  static CFX_WideString SysPathToPDFPath(const CFX_WideString& sOldPath);
+
+ private:
+  // CJS_EmbedObj
+  void TimerProc(CJS_Timer* pTimer) override;
+  void RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript);
+
+  bool m_bCalculate;
+  bool m_bRuntimeHighLight;
+  CFX_ArrayTemplate<CJS_Timer*> m_aTimer;
+};
+
+class CJS_App : public CJS_Object {
+ public:
+  explicit CJS_App(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
+  ~CJS_App() override {}
+
+  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_