| 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_doc.h" | 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // submit | 35 // submit |
| 36 #define FXFA_CONFIG 0x00000001 | 36 #define FXFA_CONFIG 0x00000001 |
| 37 #define FXFA_TEMPLATE 0x00000010 | 37 #define FXFA_TEMPLATE 0x00000010 |
| 38 #define FXFA_LOCALESET 0x00000100 | 38 #define FXFA_LOCALESET 0x00000100 |
| 39 #define FXFA_DATASETS 0x00001000 | 39 #define FXFA_DATASETS 0x00001000 |
| 40 #define FXFA_XMPMETA 0x00010000 | 40 #define FXFA_XMPMETA 0x00010000 |
| 41 #define FXFA_XFDF 0x00100000 | 41 #define FXFA_XFDF 0x00100000 |
| 42 #define FXFA_FORM 0x01000000 | 42 #define FXFA_FORM 0x01000000 |
| 43 #define FXFA_PDF 0x10000000 | 43 #define FXFA_PDF 0x10000000 |
| 44 #define FXFA_XFA_ALL 0x01111111 |
| 44 | 45 |
| 45 #ifndef _WIN32 | 46 #ifndef _WIN32 |
| 46 extern void SetLastError(int err); | 47 extern void SetLastError(int err); |
| 47 extern int GetLastError(); | 48 extern int GetLastError(); |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 50 CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, | 51 CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, |
| 51 CPDFXFA_App* pProvider) | 52 CPDFXFA_App* pProvider) |
| 52 : m_iDocType(DOCTYPE_PDF), | 53 : m_iDocType(DOCTYPE_PDF), |
| 53 m_pPDFDoc(std::move(pPDFDoc)), | 54 m_pPDFDoc(std::move(pPDFDoc)), |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 511 |
| 511 CPDFXFA_Page* pXFAPage = GetPage(pPageView); | 512 CPDFXFA_Page* pXFAPage = GetPage(pPageView); |
| 512 if (!pXFAPage) | 513 if (!pXFAPage) |
| 513 return; | 514 return; |
| 514 | 515 |
| 515 CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage, true); | 516 CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage, true); |
| 516 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) | 517 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) |
| 517 pSdkPageView->DeleteAnnot(pAnnot); | 518 pSdkPageView->DeleteAnnot(pAnnot); |
| 518 } | 519 } |
| 519 | 520 |
| 520 FX_BOOL CPDFXFA_Document::RenderCustomWidget(CXFA_FFWidget* hWidget, | |
| 521 CFX_Graphics* pGS, | |
| 522 CFX_Matrix* pMatrix, | |
| 523 const CFX_RectF& rtUI) { | |
| 524 return FALSE; | |
| 525 } | |
| 526 | |
| 527 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { | 521 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { |
| 528 if (hDoc == m_pXFADoc.get() && m_pSDKDoc) | 522 if (hDoc == m_pXFADoc.get() && m_pSDKDoc) |
| 529 return GetPageCount(); | 523 return GetPageCount(); |
| 530 return 0; | 524 return 0; |
| 531 } | 525 } |
| 532 | 526 |
| 533 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { | 527 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { |
| 534 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 528 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 535 return -1; | 529 return -1; |
| 536 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 530 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 547 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc || | 541 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc || |
| 548 m_iDocType != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || | 542 m_iDocType != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || |
| 549 iCurPage >= m_pSDKDoc->GetPageCount()) { | 543 iCurPage >= m_pSDKDoc->GetPageCount()) { |
| 550 return; | 544 return; |
| 551 } | 545 } |
| 552 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 546 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 553 if (!pEnv) | 547 if (!pEnv) |
| 554 return; | 548 return; |
| 555 pEnv->FFI_SetCurrentPage(this, iCurPage); | 549 pEnv->FFI_SetCurrentPage(this, iCurPage); |
| 556 } | 550 } |
| 551 |
| 557 FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { | 552 FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { |
| 558 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 553 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 559 return FALSE; | 554 return FALSE; |
| 560 if (m_pSDKDoc->GetInterForm()) | 555 if (m_pSDKDoc->GetInterForm()) |
| 561 return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled(); | 556 return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled(); |
| 562 | 557 |
| 563 return FALSE; | 558 return FALSE; |
| 564 } | 559 } |
| 560 |
| 565 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, | 561 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, |
| 566 FX_BOOL bEnabled) { | 562 FX_BOOL bEnabled) { |
| 567 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 563 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 568 return; | 564 return; |
| 569 if (m_pSDKDoc->GetInterForm()) | 565 if (m_pSDKDoc->GetInterForm()) |
| 570 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled); | 566 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled); |
| 571 } | 567 } |
| 572 | 568 |
| 573 void CPDFXFA_Document::GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) { | 569 void CPDFXFA_Document::GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) { |
| 574 if (hDoc != m_pXFADoc.get() || !m_pPDFDoc) | 570 if (hDoc != m_pXFADoc.get() || !m_pPDFDoc) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 pAcc->LoadAllData(pStream); | 671 pAcc->LoadAllData(pStream); |
| 676 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), | 672 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), |
| 677 pAcc->GetSize()); | 673 pAcc->GetSize()); |
| 678 } | 674 } |
| 679 } | 675 } |
| 680 } | 676 } |
| 681 if (!fileWrite.Flush()) { | 677 if (!fileWrite.Flush()) { |
| 682 // Ignoring flush error. | 678 // Ignoring flush error. |
| 683 } | 679 } |
| 684 } | 680 } |
| 685 void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc, | |
| 686 const CFX_WideString& wsFilePath) {} | |
| 687 | 681 |
| 688 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, | 682 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, |
| 689 const CFX_WideString& bsURL, | 683 const CFX_WideString& bsURL, |
| 690 FX_BOOL bAppend) { | 684 FX_BOOL bAppend) { |
| 691 if (hDoc != m_pXFADoc.get()) | 685 if (hDoc != m_pXFADoc.get()) |
| 692 return; | 686 return; |
| 693 | 687 |
| 694 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 688 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
| 695 return; | 689 return; |
| 696 | 690 |
| 697 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 691 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 698 if (!pEnv) | 692 if (!pEnv) |
| 699 return; | 693 return; |
| 700 | 694 |
| 701 CFX_WideStringC str(bsURL.c_str()); | 695 CFX_WideStringC str(bsURL.c_str()); |
| 702 | 696 |
| 703 pEnv->FFI_GotoURL(this, str, bAppend); | 697 pEnv->FFI_GotoURL(this, str, bAppend); |
| 704 } | 698 } |
| 705 | 699 |
| 706 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { | 700 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { |
| 707 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 701 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 708 return FALSE; | 702 return FALSE; |
| 709 if (m_pSDKDoc->GetInterForm()) | 703 if (m_pSDKDoc->GetInterForm()) |
| 710 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); | 704 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); |
| 711 | 705 |
| 712 return TRUE; | 706 return TRUE; |
| 713 } | 707 } |
| 708 |
| 714 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, | 709 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, |
| 715 FX_BOOL bEnabled) { | 710 FX_BOOL bEnabled) { |
| 716 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 711 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 717 return; | 712 return; |
| 718 if (m_pSDKDoc->GetInterForm()) | 713 if (m_pSDKDoc->GetInterForm()) |
| 719 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); | 714 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); |
| 720 } | 715 } |
| 716 |
| 721 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, | 717 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, |
| 722 CXFA_FFWidget* hWidget) { | 718 CXFA_FFWidget* hWidget) { |
| 723 if (hDoc != m_pXFADoc.get()) | 719 if (hDoc != m_pXFADoc.get()) |
| 724 return; | 720 return; |
| 725 | 721 |
| 726 if (!hWidget) { | 722 if (!hWidget) { |
| 727 m_pSDKDoc->SetFocusAnnot(nullptr); | 723 m_pSDKDoc->SetFocusAnnot(nullptr); |
| 728 return; | 724 return; |
| 729 } | 725 } |
| 730 | 726 |
| 731 int pageViewCount = m_pSDKDoc->GetPageViewCount(); | 727 int pageViewCount = m_pSDKDoc->GetPageViewCount(); |
| 732 for (int i = 0; i < pageViewCount; i++) { | 728 for (int i = 0; i < pageViewCount; i++) { |
| 733 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); | 729 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); |
| 734 if (!pPageView) | 730 if (!pPageView) |
| 735 continue; | 731 continue; |
| 736 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); | 732 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); |
| 737 if (pAnnot) { | 733 if (pAnnot) { |
| 738 m_pSDKDoc->SetFocusAnnot(pAnnot); | 734 m_pSDKDoc->SetFocusAnnot(pAnnot); |
| 739 break; | 735 break; |
| 740 } | 736 } |
| 741 } | 737 } |
| 742 } | 738 } |
| 739 |
| 743 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, | 740 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, |
| 744 int32_t nStartPage, | 741 int32_t nStartPage, |
| 745 int32_t nEndPage, | 742 int32_t nEndPage, |
| 746 uint32_t dwOptions) { | 743 uint32_t dwOptions) { |
| 747 if (hDoc != m_pXFADoc.get()) | 744 if (hDoc != m_pXFADoc.get()) |
| 748 return; | 745 return; |
| 749 | 746 |
| 750 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 747 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 751 if (!pEnv || !pEnv->GetFormFillInfo() || | 748 if (!pEnv || !pEnv->GetFormFillInfo() || |
| 752 !pEnv->GetFormFillInfo()->m_pJsPlatform || | 749 !pEnv->GetFormFillInfo()->m_pJsPlatform || |
| 753 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { | 750 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { |
| 754 return; | 751 return; |
| 755 } | 752 } |
| 756 | 753 |
| 757 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( | 754 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( |
| 758 pEnv->GetFormFillInfo()->m_pJsPlatform, | 755 pEnv->GetFormFillInfo()->m_pJsPlatform, |
| 759 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, | 756 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, |
| 760 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, | 757 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, |
| 761 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, | 758 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, |
| 762 dwOptions & XFA_PRINTOPT_PrintAnnot); | 759 dwOptions & XFA_PRINTOPT_PrintAnnot); |
| 763 } | 760 } |
| 764 | 761 |
| 765 int32_t CPDFXFA_Document::AbsPageCountInBatch(CXFA_FFDoc* hDoc) { | |
| 766 return 0; | |
| 767 } | |
| 768 | |
| 769 int32_t CPDFXFA_Document::AbsPageInBatch(CXFA_FFDoc* hDoc, | |
| 770 CXFA_FFWidget* hWidget) { | |
| 771 return 0; | |
| 772 } | |
| 773 | |
| 774 int32_t CPDFXFA_Document::SheetCountInBatch(CXFA_FFDoc* hDoc) { | |
| 775 return 0; | |
| 776 } | |
| 777 | |
| 778 int32_t CPDFXFA_Document::SheetInBatch(CXFA_FFDoc* hDoc, | |
| 779 CXFA_FFWidget* hWidget) { | |
| 780 return 0; | |
| 781 } | |
| 782 | |
| 783 int32_t CPDFXFA_Document::Verify(CXFA_FFDoc* hDoc, | |
| 784 CXFA_Node* pSigNode, | |
| 785 FX_BOOL bUsed) { | |
| 786 return 0; | |
| 787 } | |
| 788 | |
| 789 FX_BOOL CPDFXFA_Document::Sign(CXFA_FFDoc* hDoc, | |
| 790 CXFA_NodeList* pNodeList, | |
| 791 const CFX_WideStringC& wsExpression, | |
| 792 const CFX_WideStringC& wsXMLIdent, | |
| 793 const CFX_WideStringC& wsValue, | |
| 794 FX_BOOL bUsed) { | |
| 795 return 0; | |
| 796 } | |
| 797 | |
| 798 CXFA_NodeList* CPDFXFA_Document::Enumerate(CXFA_FFDoc* hDoc) { | |
| 799 return 0; | |
| 800 } | |
| 801 | |
| 802 FX_BOOL CPDFXFA_Document::Clear(CXFA_FFDoc* hDoc, | |
| 803 CXFA_Node* pSigNode, | |
| 804 FX_BOOL bCleared) { | |
| 805 return 0; | |
| 806 } | |
| 807 | |
| 808 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { | 762 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { |
| 809 if (hDoc != m_pXFADoc.get()) | 763 if (hDoc != m_pXFADoc.get()) |
| 810 return; | 764 return; |
| 811 | 765 |
| 812 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 766 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 813 if (!pEnv) | 767 if (!pEnv) |
| 814 return; | 768 return; |
| 815 | 769 |
| 816 pEnv->FFI_GetURL(this, wsDocURL); | 770 pEnv->FFI_GetURL(this, wsDocURL); |
| 817 } | 771 } |
| 818 | 772 |
| 819 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { | 773 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { |
| 820 if (hDoc != m_pXFADoc.get()) | 774 if (hDoc != m_pXFADoc.get()) |
| 821 return 0; | 775 return 0; |
| 822 if (m_pSDKDoc) { | 776 if (m_pSDKDoc) { |
| 823 if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) { | 777 if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) { |
| 824 FX_COLORREF color = pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA); | 778 FX_COLORREF color = pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA); |
| 825 uint8_t alpha = pInterForm->GetHighlightAlpha(); | 779 uint8_t alpha = pInterForm->GetHighlightAlpha(); |
| 826 FX_ARGB argb = ArgbEncode((int)alpha, color); | 780 FX_ARGB argb = ArgbEncode((int)alpha, color); |
| 827 return argb; | 781 return argb; |
| 828 } | 782 } |
| 829 } | 783 } |
| 830 return 0; | 784 return 0; |
| 831 } | 785 } |
| 832 | 786 |
| 833 FX_BOOL CPDFXFA_Document::_NotifySubmit(FX_BOOL bPrevOrPost) { | 787 FX_BOOL CPDFXFA_Document::NotifySubmit(FX_BOOL bPrevOrPost) { |
| 834 if (bPrevOrPost) | 788 if (bPrevOrPost) |
| 835 return _OnBeforeNotifySumbit(); | 789 return OnBeforeNotifySubmit(); |
| 836 | 790 |
| 837 _OnAfterNotifySumbit(); | 791 OnAfterNotifySubmit(); |
| 838 return TRUE; | 792 return TRUE; |
| 839 } | 793 } |
| 840 | 794 |
| 841 FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() { | 795 FX_BOOL CPDFXFA_Document::OnBeforeNotifySubmit() { |
| 842 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) | 796 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) |
| 843 return TRUE; | 797 return TRUE; |
| 844 | 798 |
| 845 if (!m_pXFADocView) | 799 if (!m_pXFADocView) |
| 846 return TRUE; | 800 return TRUE; |
| 847 | 801 |
| 848 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); | 802 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); |
| 849 if (!pWidgetHandler) | 803 if (!pWidgetHandler) |
| 850 return TRUE; | 804 return TRUE; |
| 851 | 805 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 878 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 832 bs.ReleaseBuffer(len * sizeof(unsigned short)); |
| 879 return FALSE; | 833 return FALSE; |
| 880 } | 834 } |
| 881 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 835 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 882 } | 836 } |
| 883 m_pXFADocView->UpdateDocView(); | 837 m_pXFADocView->UpdateDocView(); |
| 884 } | 838 } |
| 885 return TRUE; | 839 return TRUE; |
| 886 } | 840 } |
| 887 | 841 |
| 888 void CPDFXFA_Document::_OnAfterNotifySumbit() { | 842 void CPDFXFA_Document::OnAfterNotifySubmit() { |
| 889 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) | 843 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) |
| 890 return; | 844 return; |
| 891 | 845 |
| 892 if (!m_pXFADocView) | 846 if (!m_pXFADocView) |
| 893 return; | 847 return; |
| 894 | 848 |
| 895 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); | 849 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); |
| 896 if (!pWidgetHandler) | 850 if (!pWidgetHandler) |
| 897 return; | 851 return; |
| 898 | 852 |
| 899 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( | 853 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( |
| 900 m_pXFADocView->CreateWidgetAccIterator()); | 854 m_pXFADocView->CreateWidgetAccIterator()); |
| 901 if (!pWidgetAccIterator) | 855 if (!pWidgetAccIterator) |
| 902 return; | 856 return; |
| 903 | 857 |
| 904 CXFA_EventParam Param; | 858 CXFA_EventParam Param; |
| 905 Param.m_eType = XFA_EVENT_PostSubmit; | 859 Param.m_eType = XFA_EVENT_PostSubmit; |
| 906 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 860 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 907 while (pWidgetAcc) { | 861 while (pWidgetAcc) { |
| 908 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); | 862 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); |
| 909 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 863 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 910 } | 864 } |
| 911 m_pXFADocView->UpdateDocView(); | 865 m_pXFADocView->UpdateDocView(); |
| 912 } | 866 } |
| 913 | 867 |
| 914 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { | 868 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { |
| 915 if (!_NotifySubmit(TRUE) || !m_pXFADocView) | 869 if (!NotifySubmit(TRUE) || !m_pXFADocView) |
| 916 return FALSE; | 870 return FALSE; |
| 917 m_pXFADocView->UpdateDocView(); | 871 m_pXFADocView->UpdateDocView(); |
| 918 | 872 |
| 919 FX_BOOL ret = _SubmitData(hDoc, submit); | 873 FX_BOOL ret = SubmitDataInternal(hDoc, submit); |
| 920 _NotifySubmit(FALSE); | 874 NotifySubmit(FALSE); |
| 921 return ret; | 875 return ret; |
| 922 } | 876 } |
| 923 | 877 |
| 924 FX_BOOL CPDFXFA_Document::CheckWord(CXFA_FFDoc* hDoc, | |
| 925 const CFX_ByteStringC& sWord) { | |
| 926 return FALSE; | |
| 927 } | |
| 928 | |
| 929 FX_BOOL CPDFXFA_Document::GetSuggestWords( | |
| 930 CXFA_FFDoc* hDoc, | |
| 931 const CFX_ByteStringC& sWord, | |
| 932 std::vector<CFX_ByteString>& sSuggest) { | |
| 933 return FALSE; | |
| 934 } | |
| 935 | |
| 936 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, | 878 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, |
| 937 const CFX_WideString& wsLink) { | 879 const CFX_WideString& wsLink) { |
| 938 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 880 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 939 if (!pEnv) | 881 if (!pEnv) |
| 940 return FALSE; | 882 return FALSE; |
| 941 CFX_ByteString bs = wsLink.UTF16LE_Encode(); | 883 CFX_ByteString bs = wsLink.UTF16LE_Encode(); |
| 942 int len = bs.GetLength() / sizeof(unsigned short); | 884 int len = bs.GetLength() / sizeof(unsigned short); |
| 943 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( | 885 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( |
| 944 0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb"); | 886 0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb"); |
| 945 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 887 bs.ReleaseBuffer(len * sizeof(unsigned short)); |
| 946 | 888 |
| 947 if (!pFileHandler) | 889 if (!pFileHandler) |
| 948 return nullptr; | 890 return nullptr; |
| 949 return new CFPDF_FileStream(pFileHandler); | 891 return new CFPDF_FileStream(pFileHandler); |
| 950 } | 892 } |
| 951 FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, | 893 |
| 952 int fileType, | 894 FX_BOOL CPDFXFA_Document::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, |
| 953 FPDF_DWORD encodeType, | 895 int fileType, |
| 954 FPDF_DWORD flag) { | 896 FPDF_DWORD encodeType, |
| 897 FPDF_DWORD flag) { |
| 955 if (!m_pXFADocView) | 898 if (!m_pXFADocView) |
| 956 return FALSE; | 899 return FALSE; |
| 957 | 900 |
| 958 CFX_ByteString content; | 901 CFX_ByteString content; |
| 959 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 902 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 960 if (!pEnv) | 903 if (!pEnv) |
| 961 return FALSE; | 904 return FALSE; |
| 962 | 905 |
| 963 CFPDF_FileStream fileStream(pFileHandler); | 906 CFPDF_FileStream fileStream(pFileHandler); |
| 964 | 907 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 m_pXFADoc->SavePackage(XFA_HASHCODE_Form, &fileStream, nullptr); | 968 m_pXFADoc->SavePackage(XFA_HASHCODE_Form, &fileStream, nullptr); |
| 1026 } else if (pPrePDFObj->GetString() == "datasets") { | 969 } else if (pPrePDFObj->GetString() == "datasets") { |
| 1027 m_pXFADoc->SavePackage(XFA_HASHCODE_Datasets, &fileStream, nullptr); | 970 m_pXFADoc->SavePackage(XFA_HASHCODE_Datasets, &fileStream, nullptr); |
| 1028 } else { | 971 } else { |
| 1029 // PDF,creator. | 972 // PDF,creator. |
| 1030 } | 973 } |
| 1031 } | 974 } |
| 1032 return TRUE; | 975 return TRUE; |
| 1033 } | 976 } |
| 1034 | 977 |
| 1035 void CPDFXFA_Document::_ClearChangeMark() { | 978 void CPDFXFA_Document::ClearChangeMark() { |
| 1036 if (m_pSDKDoc) | 979 if (m_pSDKDoc) |
| 1037 m_pSDKDoc->ClearChangeMark(); | 980 m_pSDKDoc->ClearChangeMark(); |
| 1038 } | 981 } |
| 1039 | 982 |
| 1040 void CPDFXFA_Document::_ToXFAContentFlags(CFX_WideString csSrcContent, | 983 void CPDFXFA_Document::ToXFAContentFlags(CFX_WideString csSrcContent, |
| 1041 FPDF_DWORD& flag) { | 984 FPDF_DWORD& flag) { |
| 1042 if (csSrcContent.Find(L" config ", 0) != -1) | 985 if (csSrcContent.Find(L" config ", 0) != -1) |
| 1043 flag |= FXFA_CONFIG; | 986 flag |= FXFA_CONFIG; |
| 1044 if (csSrcContent.Find(L" template ", 0) != -1) | 987 if (csSrcContent.Find(L" template ", 0) != -1) |
| 1045 flag |= FXFA_TEMPLATE; | 988 flag |= FXFA_TEMPLATE; |
| 1046 if (csSrcContent.Find(L" localeSet ", 0) != -1) | 989 if (csSrcContent.Find(L" localeSet ", 0) != -1) |
| 1047 flag |= FXFA_LOCALESET; | 990 flag |= FXFA_LOCALESET; |
| 1048 if (csSrcContent.Find(L" datasets ", 0) != -1) | 991 if (csSrcContent.Find(L" datasets ", 0) != -1) |
| 1049 flag |= FXFA_DATASETS; | 992 flag |= FXFA_DATASETS; |
| 1050 if (csSrcContent.Find(L" xmpmeta ", 0) != -1) | 993 if (csSrcContent.Find(L" xmpmeta ", 0) != -1) |
| 1051 flag |= FXFA_XMPMETA; | 994 flag |= FXFA_XMPMETA; |
| 1052 if (csSrcContent.Find(L" xfdf ", 0) != -1) | 995 if (csSrcContent.Find(L" xfdf ", 0) != -1) |
| 1053 flag |= FXFA_XFDF; | 996 flag |= FXFA_XFDF; |
| 1054 if (csSrcContent.Find(L" form ", 0) != -1) | 997 if (csSrcContent.Find(L" form ", 0) != -1) |
| 1055 flag |= FXFA_FORM; | 998 flag |= FXFA_FORM; |
| 1056 if (flag == 0) | 999 if (flag == 0) |
| 1057 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | | 1000 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | |
| 1058 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; | 1001 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; |
| 1059 } | 1002 } |
| 1060 FX_BOOL CPDFXFA_Document::_MailToInfo(CFX_WideString& csURL, | 1003 |
| 1061 CFX_WideString& csToAddress, | 1004 FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, |
| 1062 CFX_WideString& csCCAddress, | 1005 CFX_WideString& csToAddress, |
| 1063 CFX_WideString& csBCCAddress, | 1006 CFX_WideString& csCCAddress, |
| 1064 CFX_WideString& csSubject, | 1007 CFX_WideString& csBCCAddress, |
| 1065 CFX_WideString& csMsg) { | 1008 CFX_WideString& csSubject, |
| 1009 CFX_WideString& csMsg) { |
| 1066 CFX_WideString srcURL = csURL; | 1010 CFX_WideString srcURL = csURL; |
| 1067 srcURL.TrimLeft(); | 1011 srcURL.TrimLeft(); |
| 1068 if (0 != srcURL.Left(7).CompareNoCase(L"mailto:")) | 1012 if (0 != srcURL.Left(7).CompareNoCase(L"mailto:")) |
| 1069 return FALSE; | 1013 return FALSE; |
| 1070 int pos = srcURL.Find(L'?', 0); | 1014 int pos = srcURL.Find(L'?', 0); |
| 1071 CFX_WideString tmp; | 1015 CFX_WideString tmp; |
| 1072 if (pos == -1) { | 1016 if (pos == -1) { |
| 1073 pos = srcURL.Find(L'@', 0); | 1017 pos = srcURL.Find(L'@', 0); |
| 1074 if (pos == -1) | 1018 if (pos == -1) |
| 1075 return FALSE; | 1019 return FALSE; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 srcURL = L""; | 1067 srcURL = L""; |
| 1124 else | 1068 else |
| 1125 srcURL = srcURL.Right(csURL.GetLength() - (pos + 1)); | 1069 srcURL = srcURL.Right(csURL.GetLength() - (pos + 1)); |
| 1126 } | 1070 } |
| 1127 csToAddress.Replace(L",", L";"); | 1071 csToAddress.Replace(L",", L";"); |
| 1128 csCCAddress.Replace(L",", L";"); | 1072 csCCAddress.Replace(L",", L";"); |
| 1129 csBCCAddress.Replace(L",", L";"); | 1073 csBCCAddress.Replace(L",", L";"); |
| 1130 return TRUE; | 1074 return TRUE; |
| 1131 } | 1075 } |
| 1132 | 1076 |
| 1133 FX_BOOL CPDFXFA_Document::_SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { | 1077 FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, |
| 1078 CXFA_Submit submit) { |
| 1134 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1079 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1135 if (!pEnv) | 1080 if (!pEnv) |
| 1136 return FALSE; | 1081 return FALSE; |
| 1137 CFX_WideStringC csURLC; | 1082 CFX_WideStringC csURLC; |
| 1138 submit.GetSubmitTarget(csURLC); | 1083 submit.GetSubmitTarget(csURLC); |
| 1139 CFX_WideString csURL(csURLC); | 1084 CFX_WideString csURL(csURLC); |
| 1140 if (csURL.IsEmpty()) { | 1085 if (csURL.IsEmpty()) { |
| 1141 CFX_WideString ws; | 1086 CFX_WideString ws; |
| 1142 ws.FromLocal("Submit cancelled."); | 1087 ws.FromLocal("Submit cancelled."); |
| 1143 CFX_ByteString bs = ws.UTF16LE_Encode(); | 1088 CFX_ByteString bs = ws.UTF16LE_Encode(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1157 CFX_WideString csContent; | 1102 CFX_WideString csContent; |
| 1158 csContent = csContentC; | 1103 csContent = csContentC; |
| 1159 csContent.TrimLeft(); | 1104 csContent.TrimLeft(); |
| 1160 csContent.TrimRight(); | 1105 csContent.TrimRight(); |
| 1161 CFX_WideString space; | 1106 CFX_WideString space; |
| 1162 space.FromLocal(" "); | 1107 space.FromLocal(" "); |
| 1163 csContent = space + csContent + space; | 1108 csContent = space + csContent + space; |
| 1164 FPDF_DWORD flag = 0; | 1109 FPDF_DWORD flag = 0; |
| 1165 if (submit.IsSubmitEmbedPDF()) | 1110 if (submit.IsSubmitEmbedPDF()) |
| 1166 flag |= FXFA_PDF; | 1111 flag |= FXFA_PDF; |
| 1167 _ToXFAContentFlags(csContent, flag); | 1112 ToXFAContentFlags(csContent, flag); |
| 1168 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); | 1113 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); |
| 1169 fileFlag = FXFA_SAVEAS_XDP; | 1114 fileFlag = FXFA_SAVEAS_XDP; |
| 1170 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); | 1115 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); |
| 1171 break; | 1116 break; |
| 1172 } | 1117 } |
| 1173 case XFA_ATTRIBUTEENUM_Xml: | 1118 case XFA_ATTRIBUTEENUM_Xml: |
| 1174 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); | 1119 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
| 1175 fileFlag = FXFA_SAVEAS_XML; | 1120 fileFlag = FXFA_SAVEAS_XML; |
| 1176 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0); | 1121 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); |
| 1177 break; | 1122 break; |
| 1178 case XFA_ATTRIBUTEENUM_Pdf: | 1123 case XFA_ATTRIBUTEENUM_Pdf: |
| 1179 break; | 1124 break; |
| 1180 case XFA_ATTRIBUTEENUM_Urlencoded: | 1125 case XFA_ATTRIBUTEENUM_Urlencoded: |
| 1181 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); | 1126 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
| 1182 fileFlag = FXFA_SAVEAS_XML; | 1127 fileFlag = FXFA_SAVEAS_XML; |
| 1183 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0); | 1128 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); |
| 1184 break; | 1129 break; |
| 1185 default: | 1130 default: |
| 1186 return false; | 1131 return false; |
| 1187 } | 1132 } |
| 1188 if (!pFileHandler) | 1133 if (!pFileHandler) |
| 1189 return FALSE; | 1134 return FALSE; |
| 1190 if (0 == csURL.Left(7).CompareNoCase(L"mailto:")) { | 1135 if (0 == csURL.Left(7).CompareNoCase(L"mailto:")) { |
| 1191 CFX_WideString csToAddress; | 1136 CFX_WideString csToAddress; |
| 1192 CFX_WideString csCCAddress; | 1137 CFX_WideString csCCAddress; |
| 1193 CFX_WideString csBCCAddress; | 1138 CFX_WideString csBCCAddress; |
| 1194 CFX_WideString csSubject; | 1139 CFX_WideString csSubject; |
| 1195 CFX_WideString csMsg; | 1140 CFX_WideString csMsg; |
| 1196 bRet = _MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, | 1141 bRet = MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, |
| 1197 csMsg); | 1142 csMsg); |
| 1198 if (!bRet) | 1143 if (!bRet) |
| 1199 return FALSE; | 1144 return FALSE; |
| 1200 CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); | 1145 CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); |
| 1201 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); | 1146 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); |
| 1202 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); | 1147 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); |
| 1203 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); | 1148 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); |
| 1204 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); | 1149 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); |
| 1205 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); | 1150 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); |
| 1206 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); | 1151 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); |
| 1207 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); | 1152 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 return FALSE; | 1208 return FALSE; |
| 1264 | 1209 |
| 1265 if (!m_pJSContext) { | 1210 if (!m_pJSContext) { |
| 1266 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); | 1211 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); |
| 1267 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); | 1212 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); |
| 1268 } | 1213 } |
| 1269 | 1214 |
| 1270 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, | 1215 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, |
| 1271 pValue); | 1216 pValue); |
| 1272 } | 1217 } |
| 1273 | |
| 1274 CPDF_Document* CPDFXFA_Document::OpenPDF(CXFA_FFDoc* hDoc, | |
| 1275 IFX_FileRead* pFile, | |
| 1276 FX_BOOL bTakeOverFile) { | |
| 1277 return nullptr; | |
| 1278 } | |
| OLD | NEW |