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/fpdfxfa/cpdfxfa_docenvironment.h" | 7 #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" |
8 | 8 |
9 #include "core/fpdfapi/parser/cpdf_array.h" | 9 #include "core/fpdfapi/parser/cpdf_array.h" |
10 #include "core/fpdfapi/parser/cpdf_stream_acc.h" | 10 #include "core/fpdfapi/parser/cpdf_stream_acc.h" |
11 #include "core/fpdfapi/parser/cpdf_string.h" | 11 #include "core/fpdfapi/parser/cpdf_string.h" |
12 #include "fpdfsdk/cpdfsdk_document.h" | |
13 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 12 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
14 #include "fpdfsdk/cpdfsdk_interform.h" | 13 #include "fpdfsdk/cpdfsdk_interform.h" |
15 #include "fpdfsdk/cpdfsdk_pageview.h" | 14 #include "fpdfsdk/cpdfsdk_pageview.h" |
16 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" | 15 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" |
17 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" | 16 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" |
18 #include "fpdfsdk/javascript/ijs_runtime.h" | 17 #include "fpdfsdk/javascript/ijs_runtime.h" |
19 #include "xfa/fxfa/xfa_ffdocview.h" | 18 #include "xfa/fxfa/xfa_ffdocview.h" |
20 #include "xfa/fxfa/xfa_ffwidget.h" | 19 #include "xfa/fxfa/xfa_ffwidget.h" |
21 #include "xfa/fxfa/xfa_ffwidgethandler.h" | 20 #include "xfa/fxfa/xfa_ffwidgethandler.h" |
22 | 21 |
(...skipping 17 matching lines...) Expand all Loading... |
40 ASSERT(m_pDocument); | 39 ASSERT(m_pDocument); |
41 } | 40 } |
42 | 41 |
43 CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() { | 42 CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() { |
44 if (m_pJSContext && m_pDocument->GetFormFillEnv()) | 43 if (m_pJSContext && m_pDocument->GetFormFillEnv()) |
45 m_pDocument->GetFormFillEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); | 44 m_pDocument->GetFormFillEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); |
46 } | 45 } |
47 | 46 |
48 void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) { | 47 void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) { |
49 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv()) | 48 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv()) |
50 m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetChangeMark(); | 49 m_pDocument->GetFormFillEnv()->SetChangeMark(); |
51 } | 50 } |
52 | 51 |
53 void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, | 52 void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, |
54 const CFX_RectF& rt, | 53 const CFX_RectF& rt, |
55 uint32_t dwFlags /* = 0 */) { | 54 uint32_t dwFlags /* = 0 */) { |
56 if (!m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 55 if (!m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
57 return; | 56 return; |
58 | 57 |
59 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 58 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
60 return; | 59 return; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 CXFA_FFDocView* pXFADocView = m_pDocument->GetXFADocView(); | 271 CXFA_FFDocView* pXFADocView = m_pDocument->GetXFADocView(); |
273 if (!pXFADocView) | 272 if (!pXFADocView) |
274 return; | 273 return; |
275 | 274 |
276 for (int iPageIter = 0; iPageIter < m_pDocument->GetOriginalPageCount(); | 275 for (int iPageIter = 0; iPageIter < m_pDocument->GetOriginalPageCount(); |
277 iPageIter++) { | 276 iPageIter++) { |
278 CPDFXFA_Page* pPage = m_pDocument->GetXFAPageList()->GetAt(iPageIter); | 277 CPDFXFA_Page* pPage = m_pDocument->GetXFAPageList()->GetAt(iPageIter); |
279 if (!pPage) | 278 if (!pPage) |
280 continue; | 279 continue; |
281 | 280 |
282 m_pDocument->GetFormFillEnv()->GetSDKDocument()->RemovePageView(pPage); | 281 m_pDocument->GetFormFillEnv()->RemovePageView(pPage); |
283 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); | 282 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); |
284 } | 283 } |
285 | 284 |
286 int flag = (nNewCount < m_pDocument->GetOriginalPageCount()) | 285 int flag = (nNewCount < m_pDocument->GetOriginalPageCount()) |
287 ? FXFA_PAGEVIEWEVENT_POSTREMOVED | 286 ? FXFA_PAGEVIEWEVENT_POSTREMOVED |
288 : FXFA_PAGEVIEWEVENT_POSTADDED; | 287 : FXFA_PAGEVIEWEVENT_POSTADDED; |
289 int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount()); | 288 int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount()); |
290 m_pDocument->SetOriginalPageCount(nNewCount); | 289 m_pDocument->SetOriginalPageCount(nNewCount); |
291 pFormFillEnv->PageEvent(count, flag); | 290 pFormFillEnv->PageEvent(count, flag); |
292 } | 291 } |
293 | 292 |
294 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, | 293 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, |
295 CXFA_WidgetAcc* pWidgetData) { | 294 CXFA_WidgetAcc* pWidgetData) { |
296 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) | 295 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) |
297 return; | 296 return; |
298 | 297 |
299 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | 298 CXFA_FFPageView* pPageView = hWidget->GetPageView(); |
300 if (!pPageView) | 299 if (!pPageView) |
301 return; | 300 return; |
302 | 301 |
303 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView); | 302 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView); |
304 if (!pXFAPage) | 303 if (!pXFAPage) |
305 return; | 304 return; |
306 | 305 |
307 m_pDocument->GetFormFillEnv() | 306 m_pDocument->GetFormFillEnv() |
308 ->GetSDKDocument() | |
309 ->GetPageView(pXFAPage, true) | 307 ->GetPageView(pXFAPage, true) |
310 ->AddAnnot(hWidget); | 308 ->AddAnnot(hWidget); |
311 } | 309 } |
312 | 310 |
313 void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, | 311 void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, |
314 CXFA_WidgetAcc* pWidgetData) { | 312 CXFA_WidgetAcc* pWidgetData) { |
315 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) | 313 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) |
316 return; | 314 return; |
317 | 315 |
318 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | 316 CXFA_FFPageView* pPageView = hWidget->GetPageView(); |
319 if (!pPageView) | 317 if (!pPageView) |
320 return; | 318 return; |
321 | 319 |
322 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView); | 320 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView); |
323 if (!pXFAPage) | 321 if (!pXFAPage) |
324 return; | 322 return; |
325 | 323 |
326 CPDFSDK_PageView* pSdkPageView = | 324 CPDFSDK_PageView* pSdkPageView = |
327 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageView(pXFAPage, | 325 m_pDocument->GetFormFillEnv()->GetPageView(pXFAPage, true); |
328 true); | |
329 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) | 326 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) |
330 pSdkPageView->DeleteAnnot(pAnnot); | 327 pSdkPageView->DeleteAnnot(pAnnot); |
331 } | 328 } |
332 | 329 |
333 int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) { | 330 int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) { |
334 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv()) | 331 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv()) |
335 return m_pDocument->GetPageCount(); | 332 return m_pDocument->GetPageCount(); |
336 return 0; | 333 return 0; |
337 } | 334 } |
338 | 335 |
339 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) { | 336 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) { |
340 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 337 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
341 return -1; | 338 return -1; |
342 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 339 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
343 return -1; | 340 return -1; |
344 | 341 |
345 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 342 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
346 if (!pFormFillEnv) | 343 if (!pFormFillEnv) |
347 return -1; | 344 return -1; |
348 | 345 |
349 return pFormFillEnv->GetCurrentPageIndex(this); | 346 return pFormFillEnv->GetCurrentPageIndex(this); |
350 } | 347 } |
351 | 348 |
352 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc, | 349 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc, |
353 int32_t iCurPage) { | 350 int32_t iCurPage) { |
354 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv() || | 351 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv() || |
355 m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || | 352 m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || |
356 iCurPage >= | 353 iCurPage >= m_pDocument->GetFormFillEnv()->GetPageCount()) { |
357 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageCount()) { | |
358 return; | 354 return; |
359 } | 355 } |
360 | 356 |
361 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 357 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
362 if (!pFormFillEnv) | 358 if (!pFormFillEnv) |
363 return; | 359 return; |
364 pFormFillEnv->SetCurrentPage(this, iCurPage); | 360 pFormFillEnv->SetCurrentPage(this, iCurPage); |
365 } | 361 } |
366 | 362 |
367 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { | 363 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { |
368 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 364 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
369 return FALSE; | 365 return FALSE; |
370 if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm()) | 366 if (m_pDocument->GetFormFillEnv()->GetInterForm()) { |
371 return m_pDocument->GetFormFillEnv() | 367 return m_pDocument->GetFormFillEnv() |
372 ->GetSDKDocument() | |
373 ->GetInterForm() | 368 ->GetInterForm() |
374 ->IsXfaCalculateEnabled(); | 369 ->IsXfaCalculateEnabled(); |
| 370 } |
375 return FALSE; | 371 return FALSE; |
376 } | 372 } |
377 | 373 |
378 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, | 374 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, |
379 FX_BOOL bEnabled) { | 375 FX_BOOL bEnabled) { |
380 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 376 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
381 return; | 377 return; |
382 if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm()) | 378 if (m_pDocument->GetFormFillEnv()->GetInterForm()) { |
383 m_pDocument->GetFormFillEnv() | 379 m_pDocument->GetFormFillEnv() |
384 ->GetSDKDocument() | |
385 ->GetInterForm() | 380 ->GetInterForm() |
386 ->XfaEnableCalculate(bEnabled); | 381 ->XfaEnableCalculate(bEnabled); |
| 382 } |
387 } | 383 } |
388 | 384 |
389 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, | 385 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, |
390 CFX_WideString& wsTitle) { | 386 CFX_WideString& wsTitle) { |
391 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc()) | 387 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc()) |
392 return; | 388 return; |
393 | 389 |
394 CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo(); | 390 CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo(); |
395 if (!pInfoDict) | 391 if (!pInfoDict) |
396 return; | 392 return; |
(...skipping 12 matching lines...) Expand all Loading... |
409 pInfoDict->SetFor("Title", new CPDF_String(wsTitle)); | 405 pInfoDict->SetFor("Title", new CPDF_String(wsTitle)); |
410 } | 406 } |
411 | 407 |
412 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, | 408 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, |
413 const CFX_WideString& wsFilePath, | 409 const CFX_WideString& wsFilePath, |
414 FX_BOOL bXDP) { | 410 FX_BOOL bXDP) { |
415 if (hDoc != m_pDocument->GetXFADoc()) | 411 if (hDoc != m_pDocument->GetXFADoc()) |
416 return; | 412 return; |
417 | 413 |
418 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && | 414 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && |
419 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) | 415 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) { |
420 return; | 416 return; |
| 417 } |
421 | 418 |
422 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 419 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
423 if (!pFormFillEnv) | 420 if (!pFormFillEnv) |
424 return; | 421 return; |
425 | 422 |
426 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; | 423 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; |
427 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); | 424 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); |
428 if (wsFilePath.IsEmpty()) { | 425 if (wsFilePath.IsEmpty()) { |
429 if (!pFormFillEnv->GetFormFillInfo() || | 426 if (!pFormFillEnv->GetFormFillInfo() || |
430 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform) | 427 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform) { |
431 return; | 428 return; |
| 429 } |
432 | 430 |
433 CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse(); | 431 CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse(); |
434 bs = filepath.UTF16LE_Encode(); | 432 bs = filepath.UTF16LE_Encode(); |
435 } | 433 } |
436 int len = bs.GetLength(); | 434 int len = bs.GetLength(); |
437 FPDF_FILEHANDLER* pFileHandler = | 435 FPDF_FILEHANDLER* pFileHandler = |
438 pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, | 436 pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, |
439 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); | 437 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); |
440 bs.ReleaseBuffer(len); | 438 bs.ReleaseBuffer(len); |
441 if (!pFileHandler) | 439 if (!pFileHandler) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 if (!pFormFillEnv) | 519 if (!pFormFillEnv) |
522 return; | 520 return; |
523 | 521 |
524 CFX_WideStringC str(bsURL.c_str()); | 522 CFX_WideStringC str(bsURL.c_str()); |
525 pFormFillEnv->GotoURL(this, str); | 523 pFormFillEnv->GotoURL(this, str); |
526 } | 524 } |
527 | 525 |
528 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { | 526 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { |
529 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 527 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
530 return FALSE; | 528 return FALSE; |
531 if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm()) | 529 if (m_pDocument->GetFormFillEnv()->GetInterForm()) { |
532 return m_pDocument->GetFormFillEnv() | 530 return m_pDocument->GetFormFillEnv() |
533 ->GetSDKDocument() | |
534 ->GetInterForm() | 531 ->GetInterForm() |
535 ->IsXfaValidationsEnabled(); | 532 ->IsXfaValidationsEnabled(); |
| 533 } |
536 return TRUE; | 534 return TRUE; |
537 } | 535 } |
538 | 536 |
539 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, | 537 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, |
540 FX_BOOL bEnabled) { | 538 FX_BOOL bEnabled) { |
541 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 539 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
542 return; | 540 return; |
543 if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm()) | 541 if (m_pDocument->GetFormFillEnv()->GetInterForm()) { |
544 m_pDocument->GetFormFillEnv() | 542 m_pDocument->GetFormFillEnv() |
545 ->GetSDKDocument() | |
546 ->GetInterForm() | 543 ->GetInterForm() |
547 ->XfaSetValidationsEnabled(bEnabled); | 544 ->XfaSetValidationsEnabled(bEnabled); |
| 545 } |
548 } | 546 } |
549 | 547 |
550 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc, | 548 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc, |
551 CXFA_FFWidget* hWidget) { | 549 CXFA_FFWidget* hWidget) { |
552 if (hDoc != m_pDocument->GetXFADoc()) | 550 if (hDoc != m_pDocument->GetXFADoc()) |
553 return; | 551 return; |
554 | 552 |
555 if (!hWidget) { | 553 if (!hWidget) { |
556 CPDFSDK_Annot::ObservedPtr pNull; | 554 CPDFSDK_Annot::ObservedPtr pNull; |
557 m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetFocusAnnot(&pNull); | 555 m_pDocument->GetFormFillEnv()->SetFocusAnnot(&pNull); |
558 return; | 556 return; |
559 } | 557 } |
560 | 558 |
561 int pageViewCount = | 559 int pageViewCount = m_pDocument->GetFormFillEnv()->GetPageViewCount(); |
562 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageViewCount(); | |
563 for (int i = 0; i < pageViewCount; i++) { | 560 for (int i = 0; i < pageViewCount; i++) { |
564 CPDFSDK_PageView* pPageView = | 561 CPDFSDK_PageView* pPageView = m_pDocument->GetFormFillEnv()->GetPageView(i); |
565 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageView(i); | |
566 if (!pPageView) | 562 if (!pPageView) |
567 continue; | 563 continue; |
568 | 564 |
569 CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget)); | 565 CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget)); |
570 if (pAnnot) { | 566 if (pAnnot) { |
571 m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetFocusAnnot(&pAnnot); | 567 m_pDocument->GetFormFillEnv()->SetFocusAnnot(&pAnnot); |
572 break; | 568 break; |
573 } | 569 } |
574 } | 570 } |
575 } | 571 } |
576 | 572 |
577 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc, | 573 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc, |
578 int32_t nStartPage, | 574 int32_t nStartPage, |
579 int32_t nEndPage, | 575 int32_t nEndPage, |
580 uint32_t dwOptions) { | 576 uint32_t dwOptions) { |
581 if (hDoc != m_pDocument->GetXFADoc()) | 577 if (hDoc != m_pDocument->GetXFADoc()) |
(...skipping 11 matching lines...) Expand all Loading... |
593 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, | 589 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, |
594 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, | 590 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, |
595 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, | 591 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, |
596 dwOptions & XFA_PRINTOPT_PrintAnnot); | 592 dwOptions & XFA_PRINTOPT_PrintAnnot); |
597 } | 593 } |
598 | 594 |
599 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { | 595 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { |
600 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 596 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
601 return 0; | 597 return 0; |
602 | 598 |
603 CPDFSDK_InterForm* pInterForm = | 599 CPDFSDK_InterForm* pInterForm = m_pDocument->GetFormFillEnv()->GetInterForm(); |
604 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm(); | |
605 if (!pInterForm) | 600 if (!pInterForm) |
606 return 0; | 601 return 0; |
607 | 602 |
608 return ArgbEncode(pInterForm->GetHighlightAlpha(), | 603 return ArgbEncode(pInterForm->GetHighlightAlpha(), |
609 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); | 604 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); |
610 } | 605 } |
611 | 606 |
612 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) { | 607 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) { |
613 if (bPrevOrPost) | 608 if (bPrevOrPost) |
614 return OnBeforeNotifySubmit(); | 609 return OnBeforeNotifySubmit(); |
615 | 610 |
616 OnAfterNotifySubmit(); | 611 OnAfterNotifySubmit(); |
617 return TRUE; | 612 return TRUE; |
618 } | 613 } |
619 | 614 |
620 FX_BOOL CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { | 615 FX_BOOL CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { |
621 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && | 616 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && |
622 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) | 617 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) { |
623 return TRUE; | 618 return TRUE; |
| 619 } |
624 | 620 |
625 if (!m_pDocument->GetXFADocView()) | 621 if (!m_pDocument->GetXFADocView()) |
626 return TRUE; | 622 return TRUE; |
627 | 623 |
628 CXFA_FFWidgetHandler* pWidgetHandler = | 624 CXFA_FFWidgetHandler* pWidgetHandler = |
629 m_pDocument->GetXFADocView()->GetWidgetHandler(); | 625 m_pDocument->GetXFADocView()->GetWidgetHandler(); |
630 if (!pWidgetHandler) | 626 if (!pWidgetHandler) |
631 return TRUE; | 627 return TRUE; |
632 | 628 |
633 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( | 629 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 !m_pDocument->GetFormFillEnv()->GetJSRuntime()) { | 1025 !m_pDocument->GetFormFillEnv()->GetJSRuntime()) { |
1030 return FALSE; | 1026 return FALSE; |
1031 } | 1027 } |
1032 | 1028 |
1033 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 1029 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
1034 if (!m_pJSContext) | 1030 if (!m_pJSContext) |
1035 m_pJSContext = pFormFillEnv->GetJSRuntime()->NewContext(); | 1031 m_pJSContext = pFormFillEnv->GetJSRuntime()->NewContext(); |
1036 | 1032 |
1037 return pFormFillEnv->GetJSRuntime()->GetValueByName(szPropName, pValue); | 1033 return pFormFillEnv->GetJSRuntime()->GetValueByName(szPropName, pValue); |
1038 } | 1034 } |
OLD | NEW |