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