Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: fpdfsdk/fpdfxfa/cpdfxfa_context.cpp

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfxfa/cpdfxfa_context.h ('k') | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/cpdfxfa_context.h" 7 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
8 8
9 #include "core/fpdfapi/parser/cpdf_document.h" 9 #include "core/fpdfapi/parser/cpdf_document.h"
10 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" 10 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 71 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
72 // The layout data can have pointers back into the script context. That 72 // The layout data can have pointers back into the script context. That
73 // context will be different if the form fill environment closes, so, force 73 // context will be different if the form fill environment closes, so, force
74 // the layout data to clear. 74 // the layout data to clear.
75 if (m_pXFADoc && m_pXFADoc->GetXFADoc()) 75 if (m_pXFADoc && m_pXFADoc->GetXFADoc())
76 m_pXFADoc->GetXFADoc()->ClearLayoutData(); 76 m_pXFADoc->GetXFADoc()->ClearLayoutData();
77 77
78 m_pFormFillEnv = pFormFillEnv; 78 m_pFormFillEnv = pFormFillEnv;
79 } 79 }
80 80
81 FX_BOOL CPDFXFA_Context::LoadXFADoc() { 81 bool CPDFXFA_Context::LoadXFADoc() {
82 m_nLoadStatus = FXFA_LOADSTATUS_LOADING; 82 m_nLoadStatus = FXFA_LOADSTATUS_LOADING;
83 83
84 if (!m_pPDFDoc) 84 if (!m_pPDFDoc)
85 return FALSE; 85 return false;
86 86
87 m_XFAPageList.RemoveAll(); 87 m_XFAPageList.RemoveAll();
88 88
89 CXFA_FFApp* pApp = GetXFAApp(); 89 CXFA_FFApp* pApp = GetXFAApp();
90 if (!pApp) 90 if (!pApp)
91 return FALSE; 91 return false;
92 92
93 m_pXFADoc.reset(pApp->CreateDoc(&m_DocEnv, m_pPDFDoc.get())); 93 m_pXFADoc.reset(pApp->CreateDoc(&m_DocEnv, m_pPDFDoc.get()));
94 if (!m_pXFADoc) { 94 if (!m_pXFADoc) {
95 SetLastError(FPDF_ERR_XFALOAD); 95 SetLastError(FPDF_ERR_XFALOAD);
96 return FALSE; 96 return false;
97 } 97 }
98 98
99 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); 99 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler();
100 if (!pDocHandler) { 100 if (!pDocHandler) {
101 SetLastError(FPDF_ERR_XFALOAD); 101 SetLastError(FPDF_ERR_XFALOAD);
102 return FALSE; 102 return false;
103 } 103 }
104 104
105 m_pXFADoc->StartLoad(); 105 m_pXFADoc->StartLoad();
106 int iStatus = m_pXFADoc->DoLoad(nullptr); 106 int iStatus = m_pXFADoc->DoLoad(nullptr);
107 if (iStatus != XFA_PARSESTATUS_Done) { 107 if (iStatus != XFA_PARSESTATUS_Done) {
108 CloseXFADoc(); 108 CloseXFADoc();
109 SetLastError(FPDF_ERR_XFALOAD); 109 SetLastError(FPDF_ERR_XFALOAD);
110 return FALSE; 110 return false;
111 } 111 }
112 m_pXFADoc->StopLoad(); 112 m_pXFADoc->StopLoad();
113 m_pXFADoc->GetXFADoc()->InitScriptContext(GetJSERuntime()); 113 m_pXFADoc->GetXFADoc()->InitScriptContext(GetJSERuntime());
114 114
115 if (m_pXFADoc->GetDocType() == XFA_DOCTYPE_Dynamic) 115 if (m_pXFADoc->GetDocType() == XFA_DOCTYPE_Dynamic)
116 m_iDocType = DOCTYPE_DYNAMIC_XFA; 116 m_iDocType = DOCTYPE_DYNAMIC_XFA;
117 else 117 else
118 m_iDocType = DOCTYPE_STATIC_XFA; 118 m_iDocType = DOCTYPE_STATIC_XFA;
119 119
120 m_pXFADocView = m_pXFADoc->CreateDocView(XFA_DOCVIEW_View); 120 m_pXFADocView = m_pXFADoc->CreateDocView(XFA_DOCVIEW_View);
121 if (m_pXFADocView->StartLayout() < 0) { 121 if (m_pXFADocView->StartLayout() < 0) {
122 CloseXFADoc(); 122 CloseXFADoc();
123 SetLastError(FPDF_ERR_XFALAYOUT); 123 SetLastError(FPDF_ERR_XFALAYOUT);
124 return FALSE; 124 return false;
125 } 125 }
126 126
127 m_pXFADocView->DoLayout(nullptr); 127 m_pXFADocView->DoLayout(nullptr);
128 m_pXFADocView->StopLayout(); 128 m_pXFADocView->StopLayout();
129 m_nLoadStatus = FXFA_LOADSTATUS_LOADED; 129 m_nLoadStatus = FXFA_LOADSTATUS_LOADED;
130 130
131 return TRUE; 131 return true;
132 } 132 }
133 133
134 int CPDFXFA_Context::GetPageCount() const { 134 int CPDFXFA_Context::GetPageCount() const {
135 if (!m_pPDFDoc && !m_pXFADoc) 135 if (!m_pPDFDoc && !m_pXFADoc)
136 return 0; 136 return 0;
137 137
138 switch (m_iDocType) { 138 switch (m_iDocType) {
139 case DOCTYPE_PDF: 139 case DOCTYPE_PDF:
140 case DOCTYPE_STATIC_XFA: 140 case DOCTYPE_STATIC_XFA:
141 if (m_pPDFDoc) 141 if (m_pPDFDoc)
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 return XFA_IDNo; 297 return XFA_IDNo;
298 case 4: 298 case 4:
299 return XFA_IDYes; 299 return XFA_IDYes;
300 } 300 }
301 return XFA_IDYes; 301 return XFA_IDYes;
302 } 302 }
303 303
304 CFX_WideString CPDFXFA_Context::Response(const CFX_WideString& wsQuestion, 304 CFX_WideString CPDFXFA_Context::Response(const CFX_WideString& wsQuestion,
305 const CFX_WideString& wsTitle, 305 const CFX_WideString& wsTitle,
306 const CFX_WideString& wsDefaultAnswer, 306 const CFX_WideString& wsDefaultAnswer,
307 FX_BOOL bMark) { 307 bool bMark) {
308 CFX_WideString wsAnswer; 308 CFX_WideString wsAnswer;
309 if (!m_pFormFillEnv) 309 if (!m_pFormFillEnv)
310 return wsAnswer; 310 return wsAnswer;
311 311
312 int nLength = 2048; 312 int nLength = 2048;
313 char* pBuff = new char[nLength]; 313 char* pBuff = new char[nLength];
314 nLength = m_pFormFillEnv->JS_appResponse(wsQuestion.c_str(), wsTitle.c_str(), 314 nLength = m_pFormFillEnv->JS_appResponse(wsQuestion.c_str(), wsTitle.c_str(),
315 wsDefaultAnswer.c_str(), nullptr, 315 wsDefaultAnswer.c_str(), nullptr,
316 bMark, pBuff, nLength); 316 bMark, pBuff, nLength);
317 if (nLength > 0) { 317 if (nLength > 0) {
318 nLength = nLength > 2046 ? 2046 : nLength; 318 nLength = nLength > 2046 ? 2046 : nLength;
319 pBuff[nLength] = 0; 319 pBuff[nLength] = 0;
320 pBuff[nLength + 1] = 0; 320 pBuff[nLength + 1] = 0;
321 wsAnswer = CFX_WideString::FromUTF16LE( 321 wsAnswer = CFX_WideString::FromUTF16LE(
322 reinterpret_cast<const unsigned short*>(pBuff), 322 reinterpret_cast<const unsigned short*>(pBuff),
323 nLength / sizeof(unsigned short)); 323 nLength / sizeof(unsigned short));
324 } 324 }
325 delete[] pBuff; 325 delete[] pBuff;
326 return wsAnswer; 326 return wsAnswer;
327 } 327 }
328 328
329 IFX_SeekableReadStream* CPDFXFA_Context::DownloadURL( 329 IFX_SeekableReadStream* CPDFXFA_Context::DownloadURL(
330 const CFX_WideString& wsURL) { 330 const CFX_WideString& wsURL) {
331 return m_pFormFillEnv ? m_pFormFillEnv->DownloadFromURL(wsURL.c_str()) 331 return m_pFormFillEnv ? m_pFormFillEnv->DownloadFromURL(wsURL.c_str())
332 : nullptr; 332 : nullptr;
333 } 333 }
334 334
335 FX_BOOL CPDFXFA_Context::PostRequestURL(const CFX_WideString& wsURL, 335 bool CPDFXFA_Context::PostRequestURL(const CFX_WideString& wsURL,
336 const CFX_WideString& wsData, 336 const CFX_WideString& wsData,
337 const CFX_WideString& wsContentType, 337 const CFX_WideString& wsContentType,
338 const CFX_WideString& wsEncode, 338 const CFX_WideString& wsEncode,
339 const CFX_WideString& wsHeader, 339 const CFX_WideString& wsHeader,
340 CFX_WideString& wsResponse) { 340 CFX_WideString& wsResponse) {
341 if (!m_pFormFillEnv) 341 if (!m_pFormFillEnv)
342 return FALSE; 342 return false;
343 343
344 wsResponse = m_pFormFillEnv->PostRequestURL( 344 wsResponse = m_pFormFillEnv->PostRequestURL(
345 wsURL.c_str(), wsData.c_str(), wsContentType.c_str(), wsEncode.c_str(), 345 wsURL.c_str(), wsData.c_str(), wsContentType.c_str(), wsEncode.c_str(),
346 wsHeader.c_str()); 346 wsHeader.c_str());
347 return TRUE; 347 return true;
348 } 348 }
349 349
350 FX_BOOL CPDFXFA_Context::PutRequestURL(const CFX_WideString& wsURL, 350 bool CPDFXFA_Context::PutRequestURL(const CFX_WideString& wsURL,
351 const CFX_WideString& wsData, 351 const CFX_WideString& wsData,
352 const CFX_WideString& wsEncode) { 352 const CFX_WideString& wsEncode) {
353 return m_pFormFillEnv && 353 return m_pFormFillEnv &&
354 m_pFormFillEnv->PutRequestURL(wsURL.c_str(), wsData.c_str(), 354 m_pFormFillEnv->PutRequestURL(wsURL.c_str(), wsData.c_str(),
355 wsEncode.c_str()); 355 wsEncode.c_str());
356 } 356 }
357 357
358 void CPDFXFA_Context::LoadString(int32_t iStringID, CFX_WideString& wsString) { 358 void CPDFXFA_Context::LoadString(int32_t iStringID, CFX_WideString& wsString) {
359 switch (iStringID) { 359 switch (iStringID) {
360 case XFA_IDS_ValidateFailed: 360 case XFA_IDS_ValidateFailed:
361 wsString = L"%s validation failed"; 361 wsString = L"%s validation failed";
362 return; 362 return;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 return; 451 return;
452 } 452 }
453 } 453 }
454 454
455 IFWL_AdapterTimerMgr* CPDFXFA_Context::GetTimerMgr() { 455 IFWL_AdapterTimerMgr* CPDFXFA_Context::GetTimerMgr() {
456 CXFA_FWLAdapterTimerMgr* pAdapter = nullptr; 456 CXFA_FWLAdapterTimerMgr* pAdapter = nullptr;
457 if (m_pFormFillEnv) 457 if (m_pFormFillEnv)
458 pAdapter = new CXFA_FWLAdapterTimerMgr(m_pFormFillEnv); 458 pAdapter = new CXFA_FWLAdapterTimerMgr(m_pFormFillEnv);
459 return pAdapter; 459 return pAdapter;
460 } 460 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfxfa/cpdfxfa_context.h ('k') | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698