OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cpdfsdk_interform.h" | 7 #include "fpdfsdk/cpdfsdk_interform.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 28 matching lines...) Expand all Loading... |
39 #ifdef PDF_ENABLE_XFA | 39 #ifdef PDF_ENABLE_XFA |
40 #include "fpdfsdk/cpdfsdk_xfawidget.h" | 40 #include "fpdfsdk/cpdfsdk_xfawidget.h" |
41 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" | 41 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" |
42 #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" | 42 #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" |
43 #include "xfa/fxfa/cxfa_eventparam.h" | 43 #include "xfa/fxfa/cxfa_eventparam.h" |
44 #include "xfa/fxfa/xfa_ffdocview.h" | 44 #include "xfa/fxfa/xfa_ffdocview.h" |
45 #include "xfa/fxfa/xfa_ffwidget.h" | 45 #include "xfa/fxfa/xfa_ffwidget.h" |
46 #include "xfa/fxfa/xfa_ffwidgethandler.h" | 46 #include "xfa/fxfa/xfa_ffwidgethandler.h" |
47 #endif // PDF_ENABLE_XFA | 47 #endif // PDF_ENABLE_XFA |
48 | 48 |
49 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) | 49 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) |
50 : m_pDocument(pDocument), | 50 : m_pFormFillEnv(pFormFillEnv), |
51 m_pInterForm(new CPDF_InterForm(m_pDocument->GetPDFDocument())), | 51 m_pInterForm(new CPDF_InterForm( |
| 52 m_pFormFillEnv->GetSDKDocument()->GetPDFDocument())), |
52 #ifdef PDF_ENABLE_XFA | 53 #ifdef PDF_ENABLE_XFA |
53 m_bXfaCalculate(TRUE), | 54 m_bXfaCalculate(TRUE), |
54 m_bXfaValidationsEnabled(TRUE), | 55 m_bXfaValidationsEnabled(TRUE), |
55 #endif // PDF_ENABLE_XFA | 56 #endif // PDF_ENABLE_XFA |
56 m_bCalculate(TRUE), | 57 m_bCalculate(TRUE), |
57 m_bBusy(FALSE), | 58 m_bBusy(FALSE), |
58 m_iHighlightAlpha(0) { | 59 m_iHighlightAlpha(0) { |
59 m_pInterForm->SetFormNotify(this); | 60 m_pInterForm->SetFormNotify(this); |
60 for (int i = 0; i < kNumFieldTypes; ++i) | 61 for (int i = 0; i < kNumFieldTypes; ++i) |
61 m_bNeedHightlight[i] = FALSE; | 62 m_bNeedHightlight[i] = FALSE; |
(...skipping 29 matching lines...) Expand all Loading... |
91 CPDFSDK_Widget* pWidget = nullptr; | 92 CPDFSDK_Widget* pWidget = nullptr; |
92 const auto it = m_Map.find(pControl); | 93 const auto it = m_Map.find(pControl); |
93 if (it != m_Map.end()) | 94 if (it != m_Map.end()) |
94 pWidget = it->second; | 95 pWidget = it->second; |
95 if (pWidget) | 96 if (pWidget) |
96 return pWidget; | 97 return pWidget; |
97 if (!createIfNeeded) | 98 if (!createIfNeeded) |
98 return nullptr; | 99 return nullptr; |
99 | 100 |
100 CPDF_Dictionary* pControlDict = pControl->GetWidget(); | 101 CPDF_Dictionary* pControlDict = pControl->GetWidget(); |
101 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); | 102 CPDF_Document* pDocument = m_pFormFillEnv->GetSDKDocument()->GetPDFDocument(); |
102 CPDFSDK_PageView* pPage = nullptr; | 103 CPDFSDK_PageView* pPage = nullptr; |
103 | 104 |
104 if (CPDF_Dictionary* pPageDict = pControlDict->GetDictFor("P")) { | 105 if (CPDF_Dictionary* pPageDict = pControlDict->GetDictFor("P")) { |
105 int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum()); | 106 int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum()); |
106 if (nPageIndex >= 0) | 107 if (nPageIndex >= 0) |
107 pPage = m_pDocument->GetPageView(nPageIndex); | 108 pPage = m_pFormFillEnv->GetSDKDocument()->GetPageView(nPageIndex); |
108 } | 109 } |
109 | 110 |
110 if (!pPage) { | 111 if (!pPage) { |
111 int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict); | 112 int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict); |
112 if (nPageIndex >= 0) | 113 if (nPageIndex >= 0) |
113 pPage = m_pDocument->GetPageView(nPageIndex); | 114 pPage = m_pFormFillEnv->GetSDKDocument()->GetPageView(nPageIndex); |
114 } | 115 } |
115 | 116 |
116 if (!pPage) | 117 if (!pPage) |
117 return nullptr; | 118 return nullptr; |
118 | 119 |
119 return static_cast<CPDFSDK_Widget*>(pPage->GetAnnotByDict(pControlDict)); | 120 return static_cast<CPDFSDK_Widget*>(pPage->GetAnnotByDict(pControlDict)); |
120 } | 121 } |
121 | 122 |
122 void CPDFSDK_InterForm::GetWidgets( | 123 void CPDFSDK_InterForm::GetWidgets( |
123 const CFX_WideString& sFieldName, | 124 const CFX_WideString& sFieldName, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 FX_BOOL bSynchronizeElse) { | 215 FX_BOOL bSynchronizeElse) { |
215 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 216 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
216 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 217 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
217 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) | 218 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) |
218 pWidget->Synchronize(bSynchronizeElse); | 219 pWidget->Synchronize(bSynchronizeElse); |
219 } | 220 } |
220 } | 221 } |
221 #endif // PDF_ENABLE_XFA | 222 #endif // PDF_ENABLE_XFA |
222 | 223 |
223 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { | 224 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { |
224 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); | 225 if (!m_pFormFillEnv->IsJSInitiated()) |
225 ASSERT(pEnv); | |
226 if (!pEnv->IsJSInitiated()) | |
227 return; | 226 return; |
228 | 227 |
229 if (m_bBusy) | 228 if (m_bBusy) |
230 return; | 229 return; |
231 | 230 |
232 m_bBusy = TRUE; | 231 m_bBusy = TRUE; |
233 | 232 |
234 if (!IsCalculateEnabled()) { | 233 if (!IsCalculateEnabled()) { |
235 m_bBusy = FALSE; | 234 m_bBusy = FALSE; |
236 return; | 235 return; |
237 } | 236 } |
238 | 237 |
239 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 238 IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); |
240 pRuntime->SetReaderDocument(m_pDocument); | 239 pRuntime->SetReaderDocument(m_pFormFillEnv->GetSDKDocument()); |
241 | 240 |
242 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 241 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
243 for (int i = 0; i < nSize; i++) { | 242 for (int i = 0; i < nSize; i++) { |
244 CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i); | 243 CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i); |
245 if (!pField) | 244 if (!pField) |
246 continue; | 245 continue; |
247 | 246 |
248 int nType = pField->GetFieldType(); | 247 int nType = pField->GetFieldType(); |
249 if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD) | 248 if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD) |
250 continue; | 249 continue; |
(...skipping 23 matching lines...) Expand all Loading... |
274 if (bRet && bRC && sValue.Compare(sOldValue) != 0) | 273 if (bRet && bRC && sValue.Compare(sOldValue) != 0) |
275 pField->SetValue(sValue, TRUE); | 274 pField->SetValue(sValue, TRUE); |
276 } | 275 } |
277 | 276 |
278 m_bBusy = FALSE; | 277 m_bBusy = FALSE; |
279 } | 278 } |
280 | 279 |
281 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, | 280 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, |
282 FX_BOOL& bFormatted) { | 281 FX_BOOL& bFormatted) { |
283 CFX_WideString sValue = pFormField->GetValue(); | 282 CFX_WideString sValue = pFormField->GetValue(); |
284 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); | 283 if (!m_pFormFillEnv->IsJSInitiated()) { |
285 ASSERT(pEnv); | |
286 if (!pEnv->IsJSInitiated()) { | |
287 bFormatted = FALSE; | 284 bFormatted = FALSE; |
288 return sValue; | 285 return sValue; |
289 } | 286 } |
290 | 287 |
291 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 288 IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); |
292 pRuntime->SetReaderDocument(m_pDocument); | 289 pRuntime->SetReaderDocument(m_pFormFillEnv->GetSDKDocument()); |
293 | 290 |
294 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX && | 291 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX && |
295 pFormField->CountSelectedItems() > 0) { | 292 pFormField->CountSelectedItems() > 0) { |
296 int index = pFormField->GetSelectedIndex(0); | 293 int index = pFormField->GetSelectedIndex(0); |
297 if (index >= 0) | 294 if (index >= 0) |
298 sValue = pFormField->GetOptionLabel(index); | 295 sValue = pFormField->GetOptionLabel(index); |
299 } | 296 } |
300 | 297 |
301 bFormatted = FALSE; | 298 bFormatted = FALSE; |
302 | 299 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 pWidget->ResetAppearance(sValue, bValueChanged); | 332 pWidget->ResetAppearance(sValue, bValueChanged); |
336 } | 333 } |
337 } | 334 } |
338 | 335 |
339 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { | 336 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { |
340 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 337 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
341 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 338 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
342 ASSERT(pFormCtrl); | 339 ASSERT(pFormCtrl); |
343 | 340 |
344 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) { | 341 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) { |
345 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); | |
346 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 342 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
347 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, false); | 343 CPDFSDK_PageView* pPageView = |
348 FX_RECT rcBBox = | 344 m_pFormFillEnv->GetSDKDocument()->GetPageView(pPage, false); |
349 pEnv->GetInteractiveFormFiller()->GetViewBBox(pPageView, pWidget); | 345 FX_RECT rcBBox = m_pFormFillEnv->GetInteractiveFormFiller()->GetViewBBox( |
| 346 pPageView, pWidget); |
350 | 347 |
351 pEnv->Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, | 348 m_pFormFillEnv->Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, |
352 rcBBox.bottom); | 349 rcBBox.bottom); |
353 } | 350 } |
354 } | 351 } |
355 } | 352 } |
356 | 353 |
357 FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, | 354 FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, |
358 const CFX_WideString& csValue) { | 355 const CFX_WideString& csValue) { |
359 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 356 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
360 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke)) | 357 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke)) |
361 return TRUE; | 358 return TRUE; |
362 | 359 |
363 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); | 360 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); |
364 if (!action.GetDict()) | 361 if (!action.GetDict()) |
365 return TRUE; | 362 return TRUE; |
366 | 363 |
367 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); | 364 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); |
368 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | |
369 PDFSDK_FieldAction fa; | 365 PDFSDK_FieldAction fa; |
370 fa.bModifier = pEnv->IsCTRLKeyDown(0); | 366 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); |
371 fa.bShift = pEnv->IsSHIFTKeyDown(0); | 367 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); |
372 fa.sValue = csValue; | 368 fa.sValue = csValue; |
373 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, | 369 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, |
374 m_pDocument, pFormField, fa); | 370 m_pFormFillEnv->GetSDKDocument(), |
| 371 pFormField, fa); |
375 return fa.bRC; | 372 return fa.bRC; |
376 } | 373 } |
377 | 374 |
378 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, | 375 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, |
379 const CFX_WideString& csValue) { | 376 const CFX_WideString& csValue) { |
380 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 377 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
381 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) | 378 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) |
382 return TRUE; | 379 return TRUE; |
383 | 380 |
384 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); | 381 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); |
385 if (!action.GetDict()) | 382 if (!action.GetDict()) |
386 return TRUE; | 383 return TRUE; |
387 | 384 |
388 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); | 385 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); |
389 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | |
390 PDFSDK_FieldAction fa; | 386 PDFSDK_FieldAction fa; |
391 fa.bModifier = pEnv->IsCTRLKeyDown(0); | 387 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); |
392 fa.bShift = pEnv->IsSHIFTKeyDown(0); | 388 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); |
393 fa.sValue = csValue; | 389 fa.sValue = csValue; |
394 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, | 390 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, |
395 m_pDocument, pFormField, fa); | 391 m_pFormFillEnv->GetSDKDocument(), |
| 392 pFormField, fa); |
396 return fa.bRC; | 393 return fa.bRC; |
397 } | 394 } |
398 | 395 |
399 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { | 396 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { |
400 ASSERT(action.GetDict()); | 397 ASSERT(action.GetDict()); |
401 | 398 |
402 CPDF_ActionFields af(&action); | 399 CPDF_ActionFields af(&action); |
403 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 400 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
404 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 401 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
405 | 402 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 return FALSE; | 449 return FALSE; |
453 | 450 |
454 return SubmitForm(sDestination, FALSE); | 451 return SubmitForm(sDestination, FALSE); |
455 } | 452 } |
456 | 453 |
457 FX_BOOL CPDFSDK_InterForm::SubmitFields( | 454 FX_BOOL CPDFSDK_InterForm::SubmitFields( |
458 const CFX_WideString& csDestination, | 455 const CFX_WideString& csDestination, |
459 const std::vector<CPDF_FormField*>& fields, | 456 const std::vector<CPDF_FormField*>& fields, |
460 bool bIncludeOrExclude, | 457 bool bIncludeOrExclude, |
461 bool bUrlEncoded) { | 458 bool bUrlEncoded) { |
462 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); | |
463 | |
464 CFX_ByteTextBuf textBuf; | 459 CFX_ByteTextBuf textBuf; |
465 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); | 460 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); |
466 | 461 |
467 uint8_t* pBuffer = textBuf.GetBuffer(); | 462 uint8_t* pBuffer = textBuf.GetBuffer(); |
468 FX_STRSIZE nBufSize = textBuf.GetLength(); | 463 FX_STRSIZE nBufSize = textBuf.GetLength(); |
469 | 464 |
470 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) | 465 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) |
471 return FALSE; | 466 return FALSE; |
472 | 467 |
473 pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); | 468 m_pFormFillEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); |
474 return TRUE; | 469 return TRUE; |
475 } | 470 } |
476 | 471 |
477 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, | 472 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, |
478 CFX_WideString csTxtFile) { | 473 CFX_WideString csTxtFile) { |
479 return TRUE; | 474 return TRUE; |
480 } | 475 } |
481 | 476 |
482 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, | 477 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, |
483 FX_STRSIZE& nBufSize) { | 478 FX_STRSIZE& nBufSize) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 pBuf = FX_Alloc(uint8_t, nBufSize); | 513 pBuf = FX_Alloc(uint8_t, nBufSize); |
519 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); | 514 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); |
520 return TRUE; | 515 return TRUE; |
521 } | 516 } |
522 | 517 |
523 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( | 518 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( |
524 const std::vector<CPDF_FormField*>& fields, | 519 const std::vector<CPDF_FormField*>& fields, |
525 bool bIncludeOrExclude, | 520 bool bIncludeOrExclude, |
526 CFX_ByteTextBuf& textBuf) { | 521 CFX_ByteTextBuf& textBuf) { |
527 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( | 522 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( |
528 m_pDocument->GetPath().AsStringC(), fields, bIncludeOrExclude, false)); | 523 m_pFormFillEnv->GetSDKDocument()->GetPath().AsStringC(), fields, |
| 524 bIncludeOrExclude, false)); |
529 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; | 525 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; |
530 } | 526 } |
531 | 527 |
532 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( | 528 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( |
533 const CFX_WideString& sFileExt) { | 529 const CFX_WideString& sFileExt) { |
534 return L""; | 530 return L""; |
535 } | 531 } |
536 | 532 |
537 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, | 533 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, |
538 FX_BOOL bUrlEncoded) { | 534 FX_BOOL bUrlEncoded) { |
539 if (sDestination.IsEmpty()) | 535 if (sDestination.IsEmpty()) |
540 return FALSE; | 536 return FALSE; |
541 | 537 |
542 if (!m_pDocument || !m_pInterForm) | 538 if (!m_pFormFillEnv || !m_pFormFillEnv->GetSDKDocument() || !m_pInterForm) |
543 return FALSE; | 539 return FALSE; |
544 | 540 |
545 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); | 541 CFX_WideString wsPDFFilePath = m_pFormFillEnv->GetSDKDocument()->GetPath(); |
546 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); | |
547 CFDF_Document* pFDFDoc = | 542 CFDF_Document* pFDFDoc = |
548 m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC(), false); | 543 m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC(), false); |
549 if (!pFDFDoc) | 544 if (!pFDFDoc) |
550 return FALSE; | 545 return FALSE; |
551 | 546 |
552 CFX_ByteTextBuf FdfBuffer; | 547 CFX_ByteTextBuf FdfBuffer; |
553 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); | 548 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); |
554 delete pFDFDoc; | 549 delete pFDFDoc; |
555 if (!bRet) | 550 if (!bRet) |
556 return FALSE; | 551 return FALSE; |
557 | 552 |
558 uint8_t* pBuffer = FdfBuffer.GetBuffer(); | 553 uint8_t* pBuffer = FdfBuffer.GetBuffer(); |
559 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 554 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); |
560 | 555 |
561 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) | 556 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) |
562 return FALSE; | 557 return FALSE; |
563 | 558 |
564 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 559 m_pFormFillEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); |
565 | 560 |
566 if (bUrlEncoded) | 561 if (bUrlEncoded) |
567 FX_Free(pBuffer); | 562 FX_Free(pBuffer); |
568 | 563 |
569 return TRUE; | 564 return TRUE; |
570 } | 565 } |
571 | 566 |
572 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { | 567 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { |
573 CFDF_Document* pFDF = | 568 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( |
574 m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsStringC(), false); | 569 m_pFormFillEnv->GetSDKDocument()->GetPath().AsStringC(), false); |
575 if (!pFDF) | 570 if (!pFDF) |
576 return FALSE; | 571 return FALSE; |
577 | 572 |
578 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | 573 FX_BOOL bRet = pFDF->WriteBuf(textBuf); |
579 delete pFDF; | 574 delete pFDF; |
580 | 575 |
581 return bRet; | 576 return bRet; |
582 } | 577 } |
583 | 578 |
584 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { | 579 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 } | 716 } |
722 } | 717 } |
723 | 718 |
724 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { | 719 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { |
725 if (nFieldType < 0 || nFieldType > kNumFieldTypes) | 720 if (nFieldType < 0 || nFieldType > kNumFieldTypes) |
726 return FXSYS_RGB(255, 255, 255); | 721 return FXSYS_RGB(255, 255, 255); |
727 if (nFieldType == 0) | 722 if (nFieldType == 0) |
728 return m_aHighlightColor[0]; | 723 return m_aHighlightColor[0]; |
729 return m_aHighlightColor[nFieldType - 1]; | 724 return m_aHighlightColor[nFieldType - 1]; |
730 } | 725 } |
OLD | NEW |