| 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 | 8 |
| 9 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" | 9 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" |
| 10 #include "fpdfsdk/include/cpdfdoc_environment.h" | 10 #include "fpdfsdk/include/cpdfsdk_environment.h" |
| 11 #include "fpdfsdk/include/fsdk_define.h" | 11 #include "fpdfsdk/include/fsdk_define.h" |
| 12 #include "xfa/fxbarcode/include/BC_Library.h" | 12 #include "xfa/fxbarcode/include/BC_Library.h" |
| 13 #include "xfa/fxfa/include/xfa_ffapp.h" | 13 #include "xfa/fxfa/include/xfa_ffapp.h" |
| 14 #include "xfa/fxfa/include/xfa_fontmgr.h" | 14 #include "xfa/fxfa/include/xfa_fontmgr.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 CPDFXFA_App* g_pApp = nullptr; | 18 CPDFXFA_App* g_pApp = nullptr; |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (!m_pIsolate) | 54 if (!m_pIsolate) |
| 55 return FALSE; | 55 return FALSE; |
| 56 | 56 |
| 57 m_pXFAApp.reset(new CXFA_FFApp(this)); | 57 m_pXFAApp.reset(new CXFA_FFApp(this)); |
| 58 m_pXFAApp->SetDefaultFontMgr( | 58 m_pXFAApp->SetDefaultFontMgr( |
| 59 std::unique_ptr<CXFA_DefFontMgr>(new CXFA_DefFontMgr)); | 59 std::unique_ptr<CXFA_DefFontMgr>(new CXFA_DefFontMgr)); |
| 60 | 60 |
| 61 return TRUE; | 61 return TRUE; |
| 62 } | 62 } |
| 63 | 63 |
| 64 FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv) { | 64 FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFSDK_Environment* pEnv) { |
| 65 if (!pEnv) | 65 if (!pEnv) |
| 66 return FALSE; | 66 return FALSE; |
| 67 | 67 |
| 68 m_pEnvList.Add(pEnv); | 68 m_pEnvList.Add(pEnv); |
| 69 return TRUE; | 69 return TRUE; |
| 70 } | 70 } |
| 71 | 71 |
| 72 FX_BOOL CPDFXFA_App::RemoveFormFillEnv(CPDFDoc_Environment* pEnv) { | 72 FX_BOOL CPDFXFA_App::RemoveFormFillEnv(CPDFSDK_Environment* pEnv) { |
| 73 if (!pEnv) | 73 if (!pEnv) |
| 74 return FALSE; | 74 return FALSE; |
| 75 | 75 |
| 76 int nFind = m_pEnvList.Find(pEnv); | 76 int nFind = m_pEnvList.Find(pEnv); |
| 77 if (nFind != -1) { | 77 if (nFind != -1) { |
| 78 m_pEnvList.RemoveAt(nFind); | 78 m_pEnvList.RemoveAt(nFind); |
| 79 return TRUE; | 79 return TRUE; |
| 80 } | 80 } |
| 81 | 81 |
| 82 return FALSE; | 82 return FALSE; |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CPDFXFA_App::GetAppType(CFX_WideString& wsAppType) { | 85 void CPDFXFA_App::GetAppType(CFX_WideString& wsAppType) { |
| 86 wsAppType = m_csAppType; | 86 wsAppType = m_csAppType; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void CPDFXFA_App::GetAppName(CFX_WideString& wsName) { | 89 void CPDFXFA_App::GetAppName(CFX_WideString& wsName) { |
| 90 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 90 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 91 if (pEnv) { | 91 if (pEnv) { |
| 92 wsName = pEnv->FFI_GetAppName(); | 92 wsName = pEnv->FFI_GetAppName(); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 void CPDFXFA_App::SetAppType(const CFX_WideStringC& wsAppType) { | 96 void CPDFXFA_App::SetAppType(const CFX_WideStringC& wsAppType) { |
| 97 m_csAppType = wsAppType; | 97 m_csAppType = wsAppType; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void CPDFXFA_App::GetLanguage(CFX_WideString& wsLanguage) { | 100 void CPDFXFA_App::GetLanguage(CFX_WideString& wsLanguage) { |
| 101 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 101 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 102 if (pEnv) { | 102 if (pEnv) { |
| 103 wsLanguage = pEnv->FFI_GetLanguage(); | 103 wsLanguage = pEnv->FFI_GetLanguage(); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 void CPDFXFA_App::GetPlatform(CFX_WideString& wsPlatform) { | 107 void CPDFXFA_App::GetPlatform(CFX_WideString& wsPlatform) { |
| 108 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 108 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 109 if (pEnv) { | 109 if (pEnv) { |
| 110 wsPlatform = pEnv->FFI_GetPlatform(); | 110 wsPlatform = pEnv->FFI_GetPlatform(); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void CPDFXFA_App::GetVariation(CFX_WideString& wsVariation) { | 114 void CPDFXFA_App::GetVariation(CFX_WideString& wsVariation) { |
| 115 wsVariation = JS_STR_VIEWERVARIATION; | 115 wsVariation = JS_STR_VIEWERVARIATION; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void CPDFXFA_App::GetVersion(CFX_WideString& wsVersion) { | 118 void CPDFXFA_App::GetVersion(CFX_WideString& wsVersion) { |
| 119 wsVersion = JS_STR_VIEWERVERSION_XFA; | 119 wsVersion = JS_STR_VIEWERVERSION_XFA; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void CPDFXFA_App::Beep(uint32_t dwType) { | 122 void CPDFXFA_App::Beep(uint32_t dwType) { |
| 123 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 123 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 124 if (pEnv) { | 124 if (pEnv) { |
| 125 pEnv->JS_appBeep(dwType); | 125 pEnv->JS_appBeep(dwType); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 int32_t CPDFXFA_App::MsgBox(const CFX_WideString& wsMessage, | 129 int32_t CPDFXFA_App::MsgBox(const CFX_WideString& wsMessage, |
| 130 const CFX_WideString& wsTitle, | 130 const CFX_WideString& wsTitle, |
| 131 uint32_t dwIconType, | 131 uint32_t dwIconType, |
| 132 uint32_t dwButtonType) { | 132 uint32_t dwButtonType) { |
| 133 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 133 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 134 if (!pEnv) | 134 if (!pEnv) |
| 135 return -1; | 135 return -1; |
| 136 | 136 |
| 137 uint32_t iconType = 0; | 137 uint32_t iconType = 0; |
| 138 int iButtonType = 0; | 138 int iButtonType = 0; |
| 139 switch (dwIconType) { | 139 switch (dwIconType) { |
| 140 case XFA_MBICON_Error: | 140 case XFA_MBICON_Error: |
| 141 iconType |= 0; | 141 iconType |= 0; |
| 142 break; | 142 break; |
| 143 case XFA_MBICON_Warning: | 143 case XFA_MBICON_Warning: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return XFA_IDYes; | 177 return XFA_IDYes; |
| 178 } | 178 } |
| 179 return XFA_IDYes; | 179 return XFA_IDYes; |
| 180 } | 180 } |
| 181 | 181 |
| 182 CFX_WideString CPDFXFA_App::Response(const CFX_WideString& wsQuestion, | 182 CFX_WideString CPDFXFA_App::Response(const CFX_WideString& wsQuestion, |
| 183 const CFX_WideString& wsTitle, | 183 const CFX_WideString& wsTitle, |
| 184 const CFX_WideString& wsDefaultAnswer, | 184 const CFX_WideString& wsDefaultAnswer, |
| 185 FX_BOOL bMark) { | 185 FX_BOOL bMark) { |
| 186 CFX_WideString wsAnswer; | 186 CFX_WideString wsAnswer; |
| 187 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 187 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 188 if (pEnv) { | 188 if (pEnv) { |
| 189 int nLength = 2048; | 189 int nLength = 2048; |
| 190 char* pBuff = new char[nLength]; | 190 char* pBuff = new char[nLength]; |
| 191 nLength = pEnv->JS_appResponse(wsQuestion.c_str(), wsTitle.c_str(), | 191 nLength = pEnv->JS_appResponse(wsQuestion.c_str(), wsTitle.c_str(), |
| 192 wsDefaultAnswer.c_str(), nullptr, bMark, | 192 wsDefaultAnswer.c_str(), nullptr, bMark, |
| 193 pBuff, nLength); | 193 pBuff, nLength); |
| 194 if (nLength > 0) { | 194 if (nLength > 0) { |
| 195 nLength = nLength > 2046 ? 2046 : nLength; | 195 nLength = nLength > 2046 ? 2046 : nLength; |
| 196 pBuff[nLength] = 0; | 196 pBuff[nLength] = 0; |
| 197 pBuff[nLength + 1] = 0; | 197 pBuff[nLength + 1] = 0; |
| 198 wsAnswer = CFX_WideString::FromUTF16LE( | 198 wsAnswer = CFX_WideString::FromUTF16LE( |
| 199 reinterpret_cast<const unsigned short*>(pBuff), | 199 reinterpret_cast<const unsigned short*>(pBuff), |
| 200 nLength / sizeof(unsigned short)); | 200 nLength / sizeof(unsigned short)); |
| 201 } | 201 } |
| 202 delete[] pBuff; | 202 delete[] pBuff; |
| 203 } | 203 } |
| 204 return wsAnswer; | 204 return wsAnswer; |
| 205 } | 205 } |
| 206 | 206 |
| 207 int32_t CPDFXFA_App::GetCurDocumentInBatch() { | 207 int32_t CPDFXFA_App::GetCurDocumentInBatch() { |
| 208 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 208 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 209 if (pEnv) { | 209 if (pEnv) { |
| 210 return pEnv->FFI_GetCurDocument(); | 210 return pEnv->FFI_GetCurDocument(); |
| 211 } | 211 } |
| 212 return 0; | 212 return 0; |
| 213 } | 213 } |
| 214 | 214 |
| 215 int32_t CPDFXFA_App::GetDocumentCountInBatch() { | 215 int32_t CPDFXFA_App::GetDocumentCountInBatch() { |
| 216 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 216 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 217 if (pEnv) { | 217 if (pEnv) { |
| 218 return pEnv->FFI_GetDocumentCount(); | 218 return pEnv->FFI_GetDocumentCount(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 return 0; | 221 return 0; |
| 222 } | 222 } |
| 223 | 223 |
| 224 IFX_FileRead* CPDFXFA_App::DownloadURL(const CFX_WideString& wsURL) { | 224 IFX_FileRead* CPDFXFA_App::DownloadURL(const CFX_WideString& wsURL) { |
| 225 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 225 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 226 return pEnv ? pEnv->FFI_DownloadFromURL(wsURL.c_str()) : nullptr; | 226 return pEnv ? pEnv->FFI_DownloadFromURL(wsURL.c_str()) : nullptr; |
| 227 } | 227 } |
| 228 | 228 |
| 229 FX_BOOL CPDFXFA_App::PostRequestURL(const CFX_WideString& wsURL, | 229 FX_BOOL CPDFXFA_App::PostRequestURL(const CFX_WideString& wsURL, |
| 230 const CFX_WideString& wsData, | 230 const CFX_WideString& wsData, |
| 231 const CFX_WideString& wsContentType, | 231 const CFX_WideString& wsContentType, |
| 232 const CFX_WideString& wsEncode, | 232 const CFX_WideString& wsEncode, |
| 233 const CFX_WideString& wsHeader, | 233 const CFX_WideString& wsHeader, |
| 234 CFX_WideString& wsResponse) { | 234 CFX_WideString& wsResponse) { |
| 235 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 235 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 236 if (!pEnv) | 236 if (!pEnv) |
| 237 return FALSE; | 237 return FALSE; |
| 238 | 238 |
| 239 wsResponse = pEnv->FFI_PostRequestURL(wsURL.c_str(), wsData.c_str(), | 239 wsResponse = pEnv->FFI_PostRequestURL(wsURL.c_str(), wsData.c_str(), |
| 240 wsContentType.c_str(), wsEncode.c_str(), | 240 wsContentType.c_str(), wsEncode.c_str(), |
| 241 wsHeader.c_str()); | 241 wsHeader.c_str()); |
| 242 return TRUE; | 242 return TRUE; |
| 243 } | 243 } |
| 244 | 244 |
| 245 FX_BOOL CPDFXFA_App::PutRequestURL(const CFX_WideString& wsURL, | 245 FX_BOOL CPDFXFA_App::PutRequestURL(const CFX_WideString& wsURL, |
| 246 const CFX_WideString& wsData, | 246 const CFX_WideString& wsData, |
| 247 const CFX_WideString& wsEncode) { | 247 const CFX_WideString& wsEncode) { |
| 248 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 248 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 249 return pEnv && | 249 return pEnv && |
| 250 pEnv->FFI_PutRequestURL(wsURL.c_str(), wsData.c_str(), | 250 pEnv->FFI_PutRequestURL(wsURL.c_str(), wsData.c_str(), |
| 251 wsEncode.c_str()); | 251 wsEncode.c_str()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void CPDFXFA_App::LoadString(int32_t iStringID, CFX_WideString& wsString) { | 254 void CPDFXFA_App::LoadString(int32_t iStringID, CFX_WideString& wsString) { |
| 255 switch (iStringID) { | 255 switch (iStringID) { |
| 256 case XFA_IDS_ValidateFailed: | 256 case XFA_IDS_ValidateFailed: |
| 257 wsString = L"%s validation failed"; | 257 wsString = L"%s validation failed"; |
| 258 return; | 258 return; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 L"%s, click Ignore."; | 343 L"%s, click Ignore."; |
| 344 return; | 344 return; |
| 345 case XFA_IDS_ValidateError: | 345 case XFA_IDS_ValidateError: |
| 346 wsString = L"The value you entered for %s is invalid."; | 346 wsString = L"The value you entered for %s is invalid."; |
| 347 return; | 347 return; |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | 350 |
| 351 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { | 351 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { |
| 352 CXFA_FWLAdapterTimerMgr* pAdapter = nullptr; | 352 CXFA_FWLAdapterTimerMgr* pAdapter = nullptr; |
| 353 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 353 CPDFSDK_Environment* pEnv = m_pEnvList.GetAt(0); |
| 354 if (pEnv) | 354 if (pEnv) |
| 355 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); | 355 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); |
| 356 return pAdapter; | 356 return pAdapter; |
| 357 } | 357 } |
| OLD | NEW |