7#include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h"
11#include "core/fpdfapi/parser/cpdf_array.h"
12#include "core/fpdfapi/parser/cpdf_dictionary.h"
13#include "core/fpdfapi/parser/cpdf_stream.h"
14#include "core/fpdfapi/parser/cpdf_stream_acc.h"
15#include "core/fpdfapi/parser/cpdf_string.h"
16#include "core/fxcrt/retain_ptr.h"
17#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
18#include "fpdfsdk/cpdfsdk_helpers.h"
19#include "fpdfsdk/cpdfsdk_interactiveform.h"
20#include "fpdfsdk/cpdfsdk_pageview.h"
21#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
22#include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
23#include "third_party/base/check.h"
24#include "xfa/fxfa/cxfa_ffdocview.h"
25#include "xfa/fxfa/cxfa_ffwidget.h"
26#include "xfa/fxfa/cxfa_ffwidgethandler.h"
27#include "xfa/fxfa/cxfa_readynodeiterator.h"
28#include "xfa/fxfa/parser/cxfa_node.h"
29#include "xfa/fxfa/parser/cxfa_submit.h"
31#define IDS_XFA_Validate_Input
32 "At least one required field was empty. Please fill in the required "
33 "fields\r\n(highlighted) before continuing."
36#define FXFA_CONFIG 0x00000001
37#define FXFA_TEMPLATE 0x00000010
38#define FXFA_LOCALESET 0x00000100
39#define FXFA_DATASETS 0x00001000
40#define FXFA_XMPMETA 0x00010000
41#define FXFA_XFDF 0x00100000
42#define FXFA_FORM 0x01000000
43#define FXFA_PDF 0x10000000
44#define FXFA_XFA_ALL 0x01111111
48static_assert(FXFA_PAGEVIEWEVENT_POSTADDED ==
49 static_cast<
int>(CXFA_FFDoc::PageViewEvent::kPostAdded),
50 "kPostAdded mismatch");
51static_assert(FXFA_PAGEVIEWEVENT_POSTREMOVED ==
52 static_cast<
int>(CXFA_FFDoc::PageViewEvent::kPostRemoved),
53 "kPostRemoved mismatch");
63 if (hDoc == m_pContext->GetXFADoc() && m_pContext->GetFormFillEnv())
64 m_pContext->GetFormFillEnv()->SetChangeMark();
69 if (!m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
72 if (m_pContext->GetFormType() != FormType::kXFAFull)
75 RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pPageView);
79 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
89 if (!hWidget || !pRtAnchor || !m_pContext->GetXFADoc() ||
90 !m_pContext->GetFormFillEnv() || !m_pContext->GetXFADocView())
93 if (m_pContext->GetFormType() != FormType::kXFAFull)
96 CXFA_FFWidgetHandler* pWidgetHandler =
97 m_pContext->GetXFADocView()->GetWidgetHandler();
105 RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pPageView);
109 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
114 pFormFillEnv->DisplayCaret(pPage.Get(), bVisible, rcCaret
.left, rcCaret
.top,
130 RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pXFAPageView);
134 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
138 FS_RECTF page_view_rect = pFormFillEnv->GetPageViewRect(pPage.Get());
141 int space_available_below_anchor;
142 int space_available_above_anchor;
146 space_available_below_anchor =
147 static_cast<
int>(page_view_rect.bottom - rtAnchor
.bottom());
148 space_available_above_anchor =
149 static_cast<
int>(rtAnchor
.top - page_view_rect.top);
151 if (rtAnchor
.left < page_view_rect.left)
152 pPopupRect
->left += page_view_rect.left - rtAnchor
.left;
153 if (rtAnchor
.right() > page_view_rect.right)
158 space_available_below_anchor =
159 static_cast<
int>(page_view_rect.right - rtAnchor
.right());
160 space_available_above_anchor =
161 static_cast<
int>(rtAnchor
.left - page_view_rect.left);
163 if (rtAnchor
.bottom() > page_view_rect.bottom)
165 if (rtAnchor
.top < page_view_rect.top)
166 pPopupRect
->left -= page_view_rect.top - rtAnchor
.top;
170 space_available_below_anchor =
171 static_cast<
int>(rtAnchor
.top - page_view_rect.top);
172 space_available_above_anchor =
173 static_cast<
int>(page_view_rect.bottom - rtAnchor
.bottom());
175 if (rtAnchor
.right() > page_view_rect.right)
177 if (rtAnchor
.left < page_view_rect.left)
178 pPopupRect
->left -= page_view_rect.left - rtAnchor
.left;
182 space_available_below_anchor =
183 static_cast<
int>(rtAnchor
.left - page_view_rect.left);
184 space_available_above_anchor =
185 static_cast<
int>(page_view_rect.right - rtAnchor
.right());
187 if (rtAnchor
.top < page_view_rect.top)
188 pPopupRect
->left += page_view_rect.top - rtAnchor
.top;
189 if (rtAnchor
.bottom() > page_view_rect.bottom)
196 if (space_available_below_anchor <= 0 && space_available_above_anchor <= 0)
200 bool draw_below_anchor;
201 if (space_available_below_anchor <= 0)
202 draw_below_anchor =
false;
203 else if (space_available_above_anchor <= 0)
204 draw_below_anchor =
true;
205 else if (space_available_below_anchor > space_available_above_anchor)
206 draw_below_anchor =
true;
208 draw_below_anchor =
false;
210 int space_available = (draw_below_anchor ? space_available_below_anchor
211 : space_available_above_anchor);
215 if (space_available < fMinPopup)
216 popup_height = fMinPopup;
217 else if (space_available > fMaxPopup)
218 popup_height = fMaxPopup;
220 popup_height =
static_cast<
float>(space_available);
225 if (draw_below_anchor)
228 pPopupRect
->top = -popup_height;
233 if (draw_below_anchor)
236 pPopupRect
->top = -popup_height;
248 const CFX_PointF& ptPopup) {
256 RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pXFAPageView);
260 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
265 if (hWidget->CanUndo())
266 menuFlag |= FXFA_MENU_UNDO;
267 if (hWidget->CanRedo())
268 menuFlag |= FXFA_MENU_REDO;
269 if (hWidget->CanPaste())
270 menuFlag |= FXFA_MENU_PASTE;
271 if (hWidget->CanCopy())
272 menuFlag |= FXFA_MENU_COPY;
273 if (hWidget->CanCut())
274 menuFlag |= FXFA_MENU_CUT;
275 if (hWidget->CanSelectAll())
276 menuFlag |= FXFA_MENU_SELECTALL;
278 return pFormFillEnv->PopupMenu(pPage.Get(), menuFlag, ptPopup);
283 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
287 if (m_pContext->GetLoadStatus() == CPDFXFA_Context::LoadStatus::kLoading ||
288 m_pContext->GetLoadStatus() == CPDFXFA_Context::LoadStatus::kClosing ||
289 eEvent != CXFA_FFDoc::PageViewEvent::kStopLayout) {
292 int nNewCount = m_pContext->GetPageCount();
293 if (nNewCount == m_pContext->GetOriginalPageCount())
300 for (
int i = 0; i < m_pContext->GetOriginalPageCount(); ++i) {
301 RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(i);
305 m_pContext->GetFormFillEnv()->RemovePageView(pPage.Get());
306 pPage->SetXFAPageViewIndex(i);
309 int flag = (nNewCount < m_pContext->GetOriginalPageCount())
310 ? FXFA_PAGEVIEWEVENT_POSTREMOVED
311 : FXFA_PAGEVIEWEVENT_POSTADDED;
312 int count = abs(nNewCount - m_pContext->GetOriginalPageCount());
313 m_pContext->SetOriginalPageCount(nNewCount);
314 pFormFillEnv->PageEvent(count, flag);
318 if (m_pContext->GetFormType() != FormType::kXFAFull)
325 RetainPtr<CPDFXFA_Page> pXFAPage = m_pContext->GetXFAPage(pPageView);
329 auto* formfill = m_pContext->GetFormFillEnv();
330 formfill->GetOrCreatePageView(pXFAPage.Get())->AddAnnotForFFWidget(hWidget);
334 if (m_pContext->GetFormType() != FormType::kXFAFull)
341 RetainPtr<CPDFXFA_Page> pXFAPage = m_pContext->GetXFAPage(pPageView);
345 CPDFSDK_PageView* pSdkPageView =
346 m_pContext->GetFormFillEnv()->GetOrCreatePageView(pXFAPage.Get());
347 pSdkPageView->DeleteAnnotForFFWidget(hWidget);
351 if (hDoc == m_pContext->GetXFADoc() && m_pContext->GetFormFillEnv())
352 return m_pContext->GetPageCount();
357 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
360 if (m_pContext->GetFormType() != FormType::kXFAFull)
363 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
364 return pFormFillEnv ? pFormFillEnv->GetCurrentPageIndex() : -1;
369 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv() ||
370 !m_pContext->ContainsExtensionForm() || iCurPage < 0 ||
371 iCurPage >= m_pContext->GetFormFillEnv()->GetPageCount()) {
375 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
379 pFormFillEnv->SetCurrentPage(iCurPage);
384 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
386 auto* pForm = m_pContext->GetFormFillEnv()->GetInteractiveForm();
387 return pForm->IsXfaCalculateEnabled();
392 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
394 m_pContext->GetFormFillEnv()->GetInteractiveForm()->XfaEnableCalculate(
399 if (hDoc != m_pContext->GetXFADoc())
406 RetainPtr<
const CPDF_Dictionary> pInfoDict = pPDFDoc->GetInfo();
410 ByteString csTitle = pInfoDict->GetByteStringFor(
"Title");
415 const WideString& wsTitle) {
416 if (hDoc != m_pContext->GetXFADoc())
423 RetainPtr<CPDF_Dictionary> pInfoDict = pPDFDoc->GetInfo();
425 pInfoDict->SetNewFor<CPDF_String>(
"Title", wsTitle.AsStringView());
429 const WideString& wsFilePath,
431 if (hDoc != m_pContext->GetXFADoc())
434 if (!m_pContext->ContainsExtensionForm())
437 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
441 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
449 WideString filepath = pFormFillEnv->JS_fieldBrowse();
452 FPDF_FILEHANDLER* pFileHandler = pFormFillEnv->OpenFile(
453 bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, AsFPDFWideString(&bs),
"wb");
458 if (fileType == FXFA_SAVEAS_XML) {
459 fileWrite->WriteString(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
460 CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
463 }
else if (fileType == FXFA_SAVEAS_XDP) {
464 if (!m_pContext->GetPDFDoc())
467 const CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
471 RetainPtr<
const CPDF_Dictionary> pAcroForm = pRoot->GetDictFor(
"AcroForm");
476 ToArray(pAcroForm->GetObjectFor(
"XFA"));
480 for (size_t i = 1; i < pArray->size(); i += 2) {
483 if (!pPrePDFObj->IsString())
485 if (!pPDFObj->IsReference())
488 RetainPtr<
const CPDF_Stream> pStream = ToStream(pPDFObj->GetDirect());
491 if (pPrePDFObj->GetString() ==
"form") {
492 CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
498 if (pPrePDFObj->GetString() ==
"datasets") {
499 CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
505 if (i == pArray->size() - 1) {
508 static const char kFormat[] =
509 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
511 fileWrite->WriteString(content.AsStringView());
513 auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(
std::move(pStream));
514 pAcc->LoadAllDataFiltered();
515 fileWrite->WriteBlock(pAcc->GetSpan());
522 const WideString& wsURL) {
523 if (hDoc != m_pContext->GetXFADoc())
526 if (m_pContext->GetFormType() != FormType::kXFAFull)
529 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
533 pFormFillEnv->GotoURL(wsURL);
538 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
541 auto* pForm = m_pContext->GetFormFillEnv()->GetInteractiveForm();
542 return pForm->IsXfaValidationsEnabled();
547 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
550 m_pContext->GetFormFillEnv()->GetInteractiveForm()->XfaSetValidationsEnabled(
556 if (hDoc != m_pContext->GetXFADoc())
561 m_pContext->GetFormFillEnv()->SetFocusAnnot(pNull);
565 int pageViewCount = m_pContext->GetFormFillEnv()->GetPageViewCount();
566 for (
int i = 0; i < pageViewCount; i++) {
567 CPDFSDK_PageView* pPageView =
568 m_pContext->GetFormFillEnv()->GetPageViewAtIndex(i);
572 ObservedPtr<
CPDFSDK_Annot> pAnnot(pPageView->GetAnnotForFFWidget(hWidget));
574 m_pContext->GetFormFillEnv()->SetFocusAnnot(pAnnot);
584 if (hDoc != m_pContext->GetXFADoc())
587 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
606 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
609 CPDFSDK_InteractiveForm* pForm =
610 m_pContext->GetFormFillEnv()->GetInteractiveForm();
611 return AlphaAndColorRefToArgb(pForm->GetHighlightAlpha(),
612 pForm->GetHighlightColor(FormFieldType::kXFA));
617 if (hDoc != m_pContext->GetXFADoc())
620 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
625 return m_pContext->GetXMLDoc();
630 const WideString& wsLink) {
631 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
636 FPDF_FILEHANDLER* pFileHandler =
641 return MakeSeekableStream(pFileHandler);
644#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED
645bool CPDFXFA_DocEnvironment::Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) {
646 if (!OnBeforeNotifySubmit() || !m_pContext->GetXFADocView())
649 m_pContext->GetXFADocView()->UpdateDocView();
650 bool ret = SubmitInternal(hDoc, submit);
651 OnAfterNotifySubmit();
655bool CPDFXFA_DocEnvironment::MailToInfo(WideString& csURL,
656 WideString& csToAddress,
657 WideString& csCCAddress,
658 WideString& csBCCAddress,
659 WideString& csSubject,
661 WideString srcURL = csURL;
663 if (srcURL.Left(7).CompareNoCase(L"mailto:") != 0)
666 auto pos = srcURL.Find(L'?');
670 if (!pos.has_value()) {
671 pos = srcURL.Find(L'@');
672 if (!pos.has_value())
675 tmp = srcURL.Right(csURL.GetLength() - 7);
677 tmp = srcURL.Left(pos.value());
678 tmp = tmp.Right(tmp.GetLength() - 7);
681 csToAddress = std::move(tmp);
684 srcURL = srcURL.Right(srcURL.GetLength() - (pos.value() + 1));
685 while (!srcURL.IsEmpty()) {
687 pos = srcURL.Find(L'&');
688 WideString tmp = (!pos.has_value()) ? srcURL : srcURL.Left(pos.value());
690 if (tmp.GetLength() >= 3 && tmp.Left(3).CompareNoCase(L"cc=") == 0) {
691 tmp = tmp.Right(tmp.GetLength() - 3);
692 if (!csCCAddress.IsEmpty())
695 }
else if (tmp.GetLength() >= 4 &&
696 tmp.Left(4).CompareNoCase(L"bcc=") == 0) {
697 tmp = tmp.Right(tmp.GetLength() - 4);
698 if (!csBCCAddress.IsEmpty())
699 csBCCAddress += L';';
701 }
else if (tmp.GetLength() >= 8 &&
702 tmp.Left(8).CompareNoCase(L"subject=") == 0) {
703 tmp = tmp.Right(tmp.GetLength() - 8);
705 }
else if (tmp.GetLength() >= 5 &&
706 tmp.Left(5).CompareNoCase(L"body=") == 0) {
707 tmp = tmp.Right(tmp.GetLength() - 5);
710 srcURL = pos.has_value()
711 ? srcURL.Right(csURL.GetLength() - (pos.value() + 1))
714 csToAddress.Replace(L",", L";");
715 csCCAddress.Replace(L",", L";");
716 csBCCAddress.Replace(L",", L";");
720bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
722 FPDF_DWORD encodeType,
724 if (!m_pContext->GetXFADocView())
727 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
731 CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
732 RetainPtr<IFX_SeekableStream> fileStream = MakeSeekableStream(pFileHandler);
733 if (fileType == FXFA_SAVEAS_XML) {
734 fileStream->WriteString(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
736 ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Data)),
741 if (fileType != FXFA_SAVEAS_XDP)
745 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
746 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
748 if (!m_pContext->GetPDFDoc()) {
753 const CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
759 RetainPtr<
const CPDF_Dictionary> pAcroForm = pRoot->GetDictFor(
"AcroForm");
765 RetainPtr<
const CPDF_Array> pArray = ToArray(pAcroForm->GetObjectFor(
"XFA"));
771 for (size_t i = 1; i < pArray->size(); i += 2) {
772 RetainPtr<
const CPDF_Object> pPDFObj = pArray->GetObjectAt(i);
773 RetainPtr<
const CPDF_Object> pPrePDFObj = pArray->GetObjectAt(i - 1);
774 if (!pPrePDFObj->IsString())
776 if (!pPDFObj->IsReference())
779 RetainPtr<
const CPDF_Object> pDirectObj = pPDFObj->GetDirect();
780 if (!pDirectObj->IsStream())
782 ByteString bsType = pPrePDFObj->GetString();
783 if (bsType ==
"config" && !(flag & FXFA_CONFIG))
785 if (bsType ==
"template" && !(flag & FXFA_TEMPLATE))
787 if (bsType ==
"localeSet" && !(flag & FXFA_LOCALESET))
789 if (bsType ==
"datasets" && !(flag & FXFA_DATASETS))
791 if (bsType ==
"xmpmeta" && !(flag & FXFA_XMPMETA))
793 if (bsType ==
"xfdf" && !(flag & FXFA_XFDF))
795 if (bsType ==
"form" && !(flag & FXFA_FORM))
798 if (bsType ==
"form") {
800 ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)),
802 }
else if (pPrePDFObj->GetString() ==
"datasets") {
804 ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Datasets)),
811void CPDFXFA_DocEnvironment::ToXFAContentFlags(WideString csSrcContent,
813 if (csSrcContent.Contains(L" config "))
815 if (csSrcContent.Contains(L" template "))
816 flag |= FXFA_TEMPLATE;
817 if (csSrcContent.Contains(L" localeSet "))
818 flag |= FXFA_LOCALESET;
819 if (csSrcContent.Contains(L" datasets "))
820 flag |= FXFA_DATASETS;
821 if (csSrcContent.Contains(L" xmpmeta "))
822 flag |= FXFA_XMPMETA;
823 if (csSrcContent.Contains(L" xfdf "))
825 if (csSrcContent.Contains(L" form "))
828 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
829 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
833bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
834 if (!m_pContext->ContainsXFAForm())
837 CXFA_FFDocView* docView = m_pContext->GetXFADocView();
841 CXFA_FFWidgetHandler* pWidgetHandler = docView->GetWidgetHandler();
845 auto it = docView->CreateReadyNodeIterator();
847 CXFA_EventParam Param;
848 Param.m_eType = XFA_EVENT_PreSubmit;
849 while (CXFA_Node* pNode = it->MoveToNext())
850 pWidgetHandler->ProcessEvent(pNode, &Param);
853 it = docView->CreateReadyNodeIterator();
857 (
void)it->MoveToNext();
858 CXFA_Node* pNode = it->MoveToNext();
861 if (pNode->ProcessValidate(docView, -1) == XFA_EventError::kError) {
862 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
866 pFormFillEnv->JS_appAlert(WideString::FromDefANSI(IDS_XFA_Validate_Input),
867 WideString(), JSPLATFORM_ALERT_BUTTON_OK,
868 JSPLATFORM_ALERT_ICON_WARNING);
871 pNode = it->MoveToNext();
874 docView->UpdateDocView();
878void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() {
879 if (!m_pContext->ContainsXFAForm())
882 if (!m_pContext->GetXFADocView())
885 CXFA_FFWidgetHandler* pWidgetHandler =
886 m_pContext->GetXFADocView()->GetWidgetHandler();
890 auto it = m_pContext->GetXFADocView()->CreateReadyNodeIterator();
894 CXFA_EventParam Param;
895 Param.m_eType = XFA_EVENT_PostSubmit;
896 CXFA_Node* pNode = it->MoveToNext();
898 pWidgetHandler->ProcessEvent(pNode, &Param);
899 pNode = it->MoveToNext();
901 m_pContext->GetXFADocView()->UpdateDocView();
904bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc,
905 CXFA_Submit* submit) {
906 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
910 WideString csURL = submit->GetSubmitTarget();
911 if (csURL.IsEmpty()) {
912 pFormFillEnv->JS_appAlert(WideString::FromDefANSI(
"Submit cancelled."),
913 WideString(), JSPLATFORM_ALERT_BUTTON_OK,
914 JSPLATFORM_ALERT_ICON_ASTERISK);
918 FPDF_FILEHANDLER* pFileHandler =
nullptr;
920 switch (submit->GetSubmitFormat()) {
921 case XFA_AttributeValue::Xdp: {
922 WideString csContent = submit->GetSubmitXDPContent();
925 WideString space = WideString::FromDefANSI(
" ");
926 csContent = space + csContent + space;
928 if (submit->IsSubmitEmbedPDF())
931 ToXFAContentFlags(csContent, flag);
932 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XDP,
nullptr,
"wb");
933 fileFlag = FXFA_SAVEAS_XDP;
934 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag);
937 case XFA_AttributeValue::Xml:
938 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML,
nullptr,
"wb");
939 fileFlag = FXFA_SAVEAS_XML;
940 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL);
942 case XFA_AttributeValue::Pdf:
944 case XFA_AttributeValue::Urlencoded:
945 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML,
nullptr,
"wb");
946 fileFlag = FXFA_SAVEAS_XML;
947 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL);
955 if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) {
956 WideString csToAddress;
957 WideString csCCAddress;
958 WideString csBCCAddress;
959 WideString csSubject;
961 if (!MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject,
965 ByteString bsTo = WideString(csToAddress).ToUTF16LE();
966 ByteString bsCC = WideString(csCCAddress).ToUTF16LE();
967 ByteString bsBcc = WideString(csBCCAddress).ToUTF16LE();
968 ByteString bsSubject = WideString(csSubject).ToUTF16LE();
969 ByteString bsMsg = WideString(csMsg).ToUTF16LE();
970 pFormFillEnv->EmailTo(pFileHandler, AsFPDFWideString(&bsTo),
971 AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC),
972 AsFPDFWideString(&bsBcc), AsFPDFWideString(&bsMsg));
977 ByteString bs = csURL.ToUTF16LE();
978 pFormFillEnv->UploadTo(pFileHandler, fileFlag, AsFPDFWideString(&bs));
CFX_FloatRect ToFloatRect() const
bool IsValidationsEnabled(const CXFA_FFDoc *hDoc) const override
void DisplayCaret(CXFA_FFWidget *hWidget, bool bVisible, const CFX_RectF *pRtAnchor) override
~CPDFXFA_DocEnvironment() override
void InvalidateRect(CXFA_FFPageView *pPageView, const CFX_RectF &rt) override
void SetCalculationsEnabled(CXFA_FFDoc *hDoc, bool bEnabled) override
bool IsCalculationsEnabled(const CXFA_FFDoc *hDoc) const override
void WidgetPostAdd(CXFA_FFWidget *hWidget) override
void Print(CXFA_FFDoc *hDoc, int32_t nStartPage, int32_t nEndPage, Mask< XFA_PrintOpt > dwOptions) override
void ExportData(CXFA_FFDoc *hDoc, const WideString &wsFilePath, bool bXDP) override
RetainPtr< IFX_SeekableReadStream > OpenLinkedFile(CXFA_FFDoc *hDoc, const WideString &wsLink) override
int32_t GetCurrentPage(const CXFA_FFDoc *hDoc) const override
void SetFocusWidget(CXFA_FFDoc *hDoc, CXFA_FFWidget *hWidget) override
FX_ARGB GetHighlightColor(const CXFA_FFDoc *hDoc) const override
void SetCurrentPage(CXFA_FFDoc *hDoc, int32_t iCurPage) override
IJS_Runtime * GetIJSRuntime(const CXFA_FFDoc *hDoc) const override
CFX_XMLDocument * GetXMLDoc() const override
void SetChangeMark(CXFA_FFDoc *hDoc) override
void GotoURL(CXFA_FFDoc *hDoc, const WideString &bsURL) override
void SetTitle(CXFA_FFDoc *hDoc, const WideString &wsTitle) override
int32_t CountPages(const CXFA_FFDoc *hDoc) const override
bool PopupMenu(CXFA_FFWidget *hWidget, const CFX_PointF &ptPopup) override
void SetValidationsEnabled(CXFA_FFDoc *hDoc, bool bEnabled) override
void OnPageViewEvent(CXFA_FFPageView *pPageView, CXFA_FFDoc::PageViewEvent eEvent) override
WideString GetTitle(const CXFA_FFDoc *hDoc) const override
void WidgetPreRemove(CXFA_FFWidget *hWidget) override
bool GetPopupPos(CXFA_FFWidget *hWidget, float fMinPopup, float fMaxPopup, const CFX_RectF &rtAnchor, CFX_RectF *pPopupRect) override
CPDFXFA_DocEnvironment(CPDFXFA_Context *)
CXFA_Object * GetXFAObject(XFA_HashCode wsNodeNameHash)
bool SavePackage(CXFA_Node *pNode, const RetainPtr< IFX_SeekableStream > &pFile)
CXFA_Document * GetXFADoc() const
int32_t GetRotate() const
static ByteString Format(const char *pFormat,...)
const char * c_str() const
ByteString & operator=(ByteString &&that) noexcept
ByteString ToUTF8() const
static WideString FromDefANSI(ByteStringView str)
static WideString FromUTF16LE(pdfium::span< const uint8_t > data)
ByteString ToUTF16LE() const
CXFA_Node * ToNode(CXFA_Object *pObj)