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 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" | 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" |
8 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 8 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
9 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" | 9 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" |
10 #include "fpdfsdk/include/fsdk_define.h" | 10 #include "fpdfsdk/include/fsdk_define.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 wsVersion = JS_STR_VIEWERVERSION_XFA; | 124 wsVersion = JS_STR_VIEWERVERSION_XFA; |
125 } | 125 } |
126 | 126 |
127 void CPDFXFA_App::Beep(uint32_t dwType) { | 127 void CPDFXFA_App::Beep(uint32_t dwType) { |
128 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 128 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
129 if (pEnv) { | 129 if (pEnv) { |
130 pEnv->JS_appBeep(dwType); | 130 pEnv->JS_appBeep(dwType); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 int32_t CPDFXFA_App::MsgBox(const CFX_WideStringC& wsMessage, | 134 int32_t CPDFXFA_App::MsgBox(const CFX_WideString& wsMessage, |
135 const CFX_WideStringC& wsTitle, | 135 const CFX_WideString& wsTitle, |
136 uint32_t dwIconType, | 136 uint32_t dwIconType, |
137 uint32_t dwButtonType) { | 137 uint32_t dwButtonType) { |
138 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 138 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
139 if (!pEnv) | 139 if (!pEnv) |
140 return -1; | 140 return -1; |
141 | 141 |
142 uint32_t iconType = 0; | 142 uint32_t iconType = 0; |
143 int iButtonType = 0; | 143 int iButtonType = 0; |
144 switch (dwIconType) { | 144 switch (dwIconType) { |
145 case XFA_MBICON_Error: | 145 case XFA_MBICON_Error: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 case 2: | 177 case 2: |
178 return XFA_IDCancel; | 178 return XFA_IDCancel; |
179 case 3: | 179 case 3: |
180 return XFA_IDNo; | 180 return XFA_IDNo; |
181 case 4: | 181 case 4: |
182 return XFA_IDYes; | 182 return XFA_IDYes; |
183 } | 183 } |
184 return XFA_IDYes; | 184 return XFA_IDYes; |
185 } | 185 } |
186 | 186 |
187 void CPDFXFA_App::Response(CFX_WideString& wsAnswer, | 187 CFX_WideString CPDFXFA_App::Response(const CFX_WideString& wsQuestion, |
188 const CFX_WideStringC& wsQuestion, | 188 const CFX_WideString& wsTitle, |
189 const CFX_WideStringC& wsTitle, | 189 const CFX_WideString& wsDefaultAnswer, |
190 const CFX_WideStringC& wsDefaultAnswer, | 190 FX_BOOL bMark) { |
191 FX_BOOL bMark) { | 191 CFX_WideString wsAnswer; |
192 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 192 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
193 if (pEnv) { | 193 if (pEnv) { |
194 int nLength = 2048; | 194 int nLength = 2048; |
195 char* pBuff = new char[nLength]; | 195 char* pBuff = new char[nLength]; |
196 nLength = pEnv->JS_appResponse(wsQuestion.c_str(), wsTitle.c_str(), | 196 nLength = pEnv->JS_appResponse(wsQuestion.c_str(), wsTitle.c_str(), |
197 wsDefaultAnswer.c_str(), NULL, bMark, pBuff, | 197 wsDefaultAnswer.c_str(), NULL, bMark, pBuff, |
198 nLength); | 198 nLength); |
199 if (nLength > 0) { | 199 if (nLength > 0) { |
200 nLength = nLength > 2046 ? 2046 : nLength; | 200 nLength = nLength > 2046 ? 2046 : nLength; |
201 pBuff[nLength] = 0; | 201 pBuff[nLength] = 0; |
202 pBuff[nLength + 1] = 0; | 202 pBuff[nLength + 1] = 0; |
203 wsAnswer = CFX_WideString::FromUTF16LE( | 203 wsAnswer = CFX_WideString::FromUTF16LE( |
204 reinterpret_cast<const unsigned short*>(pBuff), | 204 reinterpret_cast<const unsigned short*>(pBuff), |
205 nLength / sizeof(unsigned short)); | 205 nLength / sizeof(unsigned short)); |
206 } | 206 } |
207 delete[] pBuff; | 207 delete[] pBuff; |
208 } | 208 } |
| 209 return wsAnswer; |
209 } | 210 } |
210 | 211 |
211 int32_t CPDFXFA_App::GetCurDocumentInBatch() { | 212 int32_t CPDFXFA_App::GetCurDocumentInBatch() { |
212 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 213 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
213 if (pEnv) { | 214 if (pEnv) { |
214 return pEnv->FFI_GetCurDocument(); | 215 return pEnv->FFI_GetCurDocument(); |
215 } | 216 } |
216 return 0; | 217 return 0; |
217 } | 218 } |
218 | 219 |
219 int32_t CPDFXFA_App::GetDocumentCountInBatch() { | 220 int32_t CPDFXFA_App::GetDocumentCountInBatch() { |
220 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 221 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
221 if (pEnv) { | 222 if (pEnv) { |
222 return pEnv->FFI_GetDocumentCount(); | 223 return pEnv->FFI_GetDocumentCount(); |
223 } | 224 } |
224 | 225 |
225 return 0; | 226 return 0; |
226 } | 227 } |
227 | 228 |
228 IFX_FileRead* CPDFXFA_App::DownloadURL(const CFX_WideStringC& wsURL) { | 229 IFX_FileRead* CPDFXFA_App::DownloadURL(const CFX_WideString& wsURL) { |
229 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 230 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
230 if (pEnv) { | 231 return pEnv ? pEnv->FFI_DownloadFromURL(wsURL.c_str()) : nullptr; |
231 return pEnv->FFI_DownloadFromURL(wsURL.c_str()); | |
232 } | |
233 return NULL; | |
234 } | 232 } |
235 | 233 |
236 FX_BOOL CPDFXFA_App::PostRequestURL(const CFX_WideStringC& wsURL, | 234 FX_BOOL CPDFXFA_App::PostRequestURL(const CFX_WideString& wsURL, |
237 const CFX_WideStringC& wsData, | 235 const CFX_WideString& wsData, |
238 const CFX_WideStringC& wsContentType, | 236 const CFX_WideString& wsContentType, |
239 const CFX_WideStringC& wsEncode, | 237 const CFX_WideString& wsEncode, |
240 const CFX_WideStringC& wsHeader, | 238 const CFX_WideString& wsHeader, |
241 CFX_WideString& wsResponse) { | 239 CFX_WideString& wsResponse) { |
242 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 240 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
243 if (pEnv) { | 241 if (!pEnv) |
244 wsResponse = pEnv->FFI_PostRequestURL(wsURL.c_str(), wsData.c_str(), | 242 return FALSE; |
245 wsContentType.c_str(), | 243 |
246 wsEncode.c_str(), wsHeader.c_str()); | 244 wsResponse = pEnv->FFI_PostRequestURL(wsURL.c_str(), wsData.c_str(), |
247 return TRUE; | 245 wsContentType.c_str(), wsEncode.c_str(), |
248 } | 246 wsHeader.c_str()); |
249 return FALSE; | 247 return TRUE; |
250 } | 248 } |
251 | 249 |
252 FX_BOOL CPDFXFA_App::PutRequestURL(const CFX_WideStringC& wsURL, | 250 FX_BOOL CPDFXFA_App::PutRequestURL(const CFX_WideString& wsURL, |
253 const CFX_WideStringC& wsData, | 251 const CFX_WideString& wsData, |
254 const CFX_WideStringC& wsEncode) { | 252 const CFX_WideString& wsEncode) { |
255 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 253 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
256 if (pEnv) { | 254 return pEnv && |
257 return pEnv->FFI_PutRequestURL(wsURL.c_str(), wsData.c_str(), | 255 pEnv->FFI_PutRequestURL(wsURL.c_str(), wsData.c_str(), |
258 wsEncode.c_str()); | 256 wsEncode.c_str()); |
259 } | |
260 return FALSE; | |
261 } | 257 } |
262 | 258 |
263 void CPDFXFA_App::LoadString(int32_t iStringID, CFX_WideString& wsString) { | 259 void CPDFXFA_App::LoadString(int32_t iStringID, CFX_WideString& wsString) { |
264 switch (iStringID) { | 260 switch (iStringID) { |
265 case XFA_IDS_ValidateFailed: | 261 case XFA_IDS_ValidateFailed: |
266 wsString = L"%s validate failed"; | 262 wsString = L"%s validate failed"; |
267 return; | 263 return; |
268 case XFA_IDS_CalcOverride: | 264 case XFA_IDS_CalcOverride: |
269 wsString = L"Calculate Override"; | 265 wsString = L"Calculate Override"; |
270 return; | 266 return; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 } | 510 } |
515 } | 511 } |
516 | 512 |
517 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { | 513 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { |
518 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; | 514 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; |
519 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 515 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
520 if (pEnv) | 516 if (pEnv) |
521 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); | 517 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); |
522 return pAdapter; | 518 return pAdapter; |
523 } | 519 } |
OLD | NEW |