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