OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef _FPDFXFA_APP_H_ | 7 #ifndef FPDFXFA_APP_H_ |
8 #define _FPDFXFA_APP_H_ | 8 #define FPDFXFA_APP_H_ |
9 | 9 |
10 class CPDFXFA_App; | |
11 class IFXJS_Runtime; | 10 class IFXJS_Runtime; |
12 class CJS_RuntimeFactory; | 11 class CJS_RuntimeFactory; |
13 | 12 |
14 class CPDFXFA_App : public IXFA_AppProvider | 13 class CPDFXFA_App : public IXFA_AppProvider |
15 { | 14 { |
16 public: | 15 public: |
17 » CPDFXFA_App(); | 16 static CPDFXFA_App* GetInstance(); |
18 » ~CPDFXFA_App(); | 17 static void ReleaseInstance(); |
19 | 18 |
20 » FX_BOOL»» » » Initialize(); | 19 CPDFXFA_App(); |
20 ~CPDFXFA_App() override; | |
21 | 21 |
22 » IXFA_App*» » » GetXFAApp() { return m_pXFAApp; } | 22 FX_BOOL Initialize(); |
23 IXFA_App* GetXFAApp() { return m_pXFAApp; } | |
23 | 24 |
24 » » » » » » | 25 FX_BOOL AddFormFillEnv(CPDFDoc_Environment* pEnv); |
25 » /*CPDFDoc_Environment*GetFormFillEnv(){ return m_pEnv; }*/ | 26 FX_BOOL RemoveFormFillEnv(CPDFDoc_Environment* pEnv); |
26 » FX_BOOL»» » » AddFormFillEnv(CPDFDoc_Environment* pEnv ); | |
27 » FX_BOOL»» » » RemoveFormFillEnv(CPDFDoc_Environment* p Env); | |
28 | 27 |
29 » FXJSE_HRUNTIME» » GetJSERuntime() { return m_hJSERuntime; } | 28 FXJSE_HRUNTIME GetJSERuntime() { return m_hJSERuntime; } |
29 void ReleaseRuntime(); | |
30 FX_BOOL InitRuntime(FX_BOOL bReset = FALSE) { | |
Lei Zhang
2015/05/27 02:18:40
move impl to .cpp file?
Tom Sepez
2015/05/27 17:07:50
Done.
| |
31 if (bReset) { | |
32 m_bInitRuntime = FALSE; | |
33 return TRUE; | |
34 } | |
35 if (m_bInitRuntime) | |
36 return TRUE; | |
37 m_bInitRuntime = TRUE; | |
38 return FALSE; | |
39 } | |
30 | 40 |
31 » void» » » » ReleaseRuntime(); | 41 CJS_RuntimeFactory* GetRuntimeFactory() {return m_pJSRuntimeFactory;} |
Lei Zhang
2015/05/27 02:18:40
nit: add some spaces
Tom Sepez
2015/05/27 17:07:50
Done.
| |
32 | 42 |
33 » FX_BOOL»» » » InitRuntime(FX_BOOL bReset = FALSE) { | 43 // IFXA_AppProvider: |
34 » » if (bReset) { | 44 void GetAppType(CFX_WideString &wsAppType) override; |
35 » » » m_bInitRuntime = FALSE; | 45 void SetAppType(FX_WSTR wsAppType) override; |
36 » » » return TRUE; | |
37 » » } | |
38 » » if (m_bInitRuntime) | |
39 » » » return TRUE; | |
40 » » m_bInitRuntime = TRUE; | |
41 » » return FALSE; | |
42 » } | |
43 | 46 |
44 » //IFXJS_Runtime*» » GetJSRuntime(); | 47 void GetLanguage(CFX_WideString &wsLanguage) override; |
48 void GetPlatform(CFX_WideString &wsPlatform) override; | |
49 void GetVariation(CFX_WideString &wsVariation) override; | |
50 void GetVersion(CFX_WideString &wsVersion) override; | |
51 void GetFoxitVersion(CFX_WideString &wsFoxitVersion) override { | |
52 wsFoxitVersion = L"7.0"; | |
53 } | |
45 | 54 |
46 » CJS_RuntimeFactory* GetRuntimeFactory() {return m_pJSRuntimeFactory;} | 55 void GetAppName(CFX_WideString& wsName) override; |
56 void GetFoxitAppName(CFX_WideString& wsFoxitName) override { | |
57 wsFoxitName = L"Foxit"; | |
58 } | |
47 | 59 |
48 public: | 60 void Beep(FX_DWORD dwType) override; |
49 » /** | 61 FX_INT32 MsgBox(FX_WSTR wsMessage, FX_WSTR wsTitle, FX_DWORD dwIconType, FX_ DWORD dwButtonType) override; |
50 » *Specifies the name of the client application in which a form currently exists. Such as Exchange-Pro. | 62 void Response(CFX_WideString &wsAnswer, FX_WSTR wsQuestion, FX_WSTR wsTitle, |
51 » */ | 63 FX_WSTR wsDefaultAnswer, FX_BOOL bMark) override; |
52 » virtual void» » GetAppType(CFX_WideString &wsAppType); | |
53 » virtual void» » SetAppType(FX_WSTR wsAppType) ; | |
54 » virtual void» » SetFoxitAppType(FX_WSTR wsFoxitAppType) { return ; } | |
55 » virtual void» » GetFoxitAppType(CFX_WideString &wsFoxitAppType) { return; } | |
56 » virtual void» » GetFoxitAppName(CFX_WideString& wsFoxitName) {ws FoxitName = L"Foxit";} | |
57 » virtual void» » GetFoxitVersion(CFX_WideString &wsFoxitVersion) {wsFoxitVersion = L"7.0";} | |
58 » /** | |
59 » *Returns the language of the running host application. Such as zh_CN | |
60 » */ | |
61 » virtual void» » GetLanguage(CFX_WideString &wsLanguage); | |
62 » /** | |
63 » » *Returns the platform of the machine running the script. Such as WIN | |
64 » */ | |
65 » virtual void» » GetPlatform(CFX_WideString &wsPlatform); | |
66 » /** | |
67 » * Indicates the packaging of the application that is running the script . Such as Full | |
68 » */ | |
69 » virtual void» » GetVariation(CFX_WideString &wsVariation); | |
70 » /** | |
71 » * Indicates the version number of the current application. Such as 9 | |
72 » */ | |
73 » virtual void» » GetVersion(CFX_WideString &wsVersion); | |
74 » //Get application name, such as Phantom | |
75 » virtual void» » GetAppName(CFX_WideString& wsName); | |
76 » /** | |
77 » *Causes the system to play a sound.» | |
78 » * @param[in] dwType The system code for the appropriate sound.0 (Error) 1 (Warning)2 (Question)3 (Status)4 (Default) | |
79 » */ | |
80 » virtual void» » Beep(FX_DWORD dwType); | |
81 » /** | |
82 » * Displays a message box. | |
83 » * @param[in] dwIconType» Icon type, refer to XFA_MBICON. | |
84 » * @param[in] dwButtonType» Button type, refer to XFA_MESSAGEBUTTON. | |
85 » * @return A valid integer representing the value of the button pressed by the user, refer to XFA_ID. | |
86 » */ | |
87 » virtual FX_INT32» MsgBox(FX_WSTR wsMessage, FX_WSTR wsTitle = FX_W STRC(L""), FX_DWORD dwIconType = 0, FX_DWORD dwButtonType = 0); | |
88 » //bMark True (default) Masks the user¡¯s answer with * (asterisks). Fals e Does not mask the user¡¯s answer. | |
89 » virtual void» » Response(CFX_WideString &wsAnswer, FX_WSTR wsQue stion, FX_WSTR wsTitle = FX_WSTRC(L""), FX_WSTR wsDefaultAnswer = FX_WSTRC(L""), FX_BOOL bMark = TRUE); | |
90 » virtual FX_INT32» GetDocumentCountInBatch(); | |
91 » virtual FX_INT32» GetCurDocumentInBatch(); | |
92 » //wsURL http, ftp, such as "http://www.w3.org/TR/REC-xml-names/". | |
93 » virtual IFX_FileRead* DownloadURL(FX_WSTR wsURL); | |
94 » /* | |
95 » * Post data to the given url. | |
96 » * @param[in] wsURL» » » the URL being uploaded. | |
97 » * @param[in] wsData» » » the data being uploaded. | |
98 » * @param[in] wsContentType» the content type of data including text/ html, text/xml, text/plain, multipart/form-data, | |
99 » *» » » » » » » application/x-ww w-form-urlencoded, application/octet-stream, any valid MIME type. | |
100 » * @param[in] wsEncode» » the encode of data including UTF-8, UTF- 16, ISO8859-1, any recognized [IANA]character encoding | |
101 » * @param[in] wsHeader» » any additional HTTP headers to be includ ed in the post. | |
102 » * @param[out] wsResponse» decoded response from server. | |
103 » * @return TRUE Server permitted the post request, FALSE otherwise. | |
104 » */ | |
105 » virtual FX_BOOL»» PostRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX _WSTR wsContentType, | |
106 » » » » » » » » » FX_W STR wsEncode, FX_WSTR wsHeader, CFX_WideString &wsResponse); | |
107 | 64 |
108 » /* | 65 FX_INT32 GetDocumentCountInBatch() override; |
109 » * Put data to the given url. | 66 FX_INT32 GetCurDocumentInBatch() override; |
110 » * @param[in] wsURL» » » the URL being uploaded. | |
111 » * @param[in] wsData» » » the data being uploaded. | |
112 » * @param[in] wsEncode» » the encode of data including UTF-8, UTF- 16, ISO8859-1, any recognized [IANA]character encoding | |
113 » * @return TRUE Server permitted the post request, FALSE otherwise. | |
114 » */ | |
115 » virtual FX_BOOL»» PutRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_ WSTR wsEncode); | |
116 | 67 |
117 » virtual void» » LoadString(FX_INT32 iStringID, CFX_WideString &w sString); | 68 IFX_FileRead* DownloadURL(FX_WSTR wsURL) override; |
118 » virtual»FX_BOOL»» ShowFileDialog(FX_WSTR wsTitle, FX_WSTR wsFilter , CFX_WideStringArray &wsPathArr, FX_BOOL bOpen = TRUE); | 69 FX_BOOL PostRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsContentType, |
119 » virtual IFWL_AdapterTimerMgr* GetTimerMgr(); | 70 FX_WSTR wsEncode, FX_WSTR wsHeader, CFX_WideString &w sResponse) override; |
71 FX_BOOL PutRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsEncode) overr ide; | |
120 | 72 |
121 » CFX_ArrayTemplate<CPDFDoc_Environment*> m_pEnvList; | 73 void LoadString(FX_INT32 iStringID, CFX_WideString &wsString) override; |
74 FX_BOOL ShowFileDialog(FX_WSTR wsTitle, FX_WSTR wsFilter, CFX_WideStringArra y &wsPathArr, FX_BOOL bOpen) override; | |
75 IFWL_AdapterTimerMgr* GetTimerMgr() override; | |
122 | 76 |
123 public: | 77 CFX_ArrayTemplate<CPDFDoc_Environment*> m_pEnvList; |
124 » static CPDFXFA_App* m_pApp; | |
125 | 78 |
126 private: | 79 protected: |
127 » IXFA_App* m_pXFAApp; | 80 static CPDFXFA_App* g_pApp; |
Lei Zhang
2015/05/27 02:18:40
Can this be declared in the .cpp file instead?
Tom Sepez
2015/05/27 17:07:50
I like having the static members rather than plain
| |
128 » IXFA_FontMgr* m_pFontMgr; | |
129 » FXJSE_HRUNTIME m_hJSERuntime; | |
130 » IFXJS_Runtime* m_pJSRuntime; | |
131 » CJS_RuntimeFactory* m_pJSRuntimeFactory; | |
132 | 81 |
133 » CFX_WideString» m_csAppType; | 82 FX_BOOL m_bInitRuntime; |
134 » FX_BOOL»» » m_bInitRuntime; | 83 IXFA_App* m_pXFAApp; |
84 IXFA_FontMgr* m_pFontMgr; | |
85 FXJSE_HRUNTIME m_hJSERuntime; | |
86 IFXJS_Runtime* m_pJSRuntime; | |
87 CJS_RuntimeFactory* m_pJSRuntimeFactory; | |
88 CFX_WideString m_csAppType; | |
135 }; | 89 }; |
136 | 90 |
137 CPDFXFA_App* FPDFXFA_GetApp(); | 91 #endif // FPDFXFA_APP_H_ |
138 void FPDFXFA_ReleaseApp(); | |
139 | |
140 #endif | |
OLD | NEW |