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/check.h"
17#include "core/fxcrt/retain_ptr.h"
18#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
19#include "fpdfsdk/cpdfsdk_helpers.h"
20#include "fpdfsdk/cpdfsdk_interactiveform.h"
21#include "fpdfsdk/cpdfsdk_pageview.h"
22#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
23#include "fpdfsdk/fpdfxfa/cpdfxfa_page.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;
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())
410 ByteString csTitle = pInfoDict->GetByteStringFor(
"Title");
416 if (hDoc != m_pContext->GetXFADoc())
425 pInfoDict->SetNewFor<CPDF_String>(
"Title", wsTitle.AsStringView());
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;
443 if (wsFilePath.IsEmpty()) {
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())
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) {
506 WideString wPath = WideString::FromUTF16LE(bs.unsigned_span());
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());
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();
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;
662 srcURL.TrimWhitespaceFront();
663 if (!srcURL.Left(7).EqualsASCIINoCase(
"mailto:")) {
666 auto pos = srcURL.Find(L'?');
669 if (!pos.has_value()) {
670 pos = srcURL.Find(L'@');
671 if (!pos.has_value())
674 tmp = srcURL.Right(csURL.GetLength() - 7);
676 tmp = srcURL.Left(pos.value());
677 tmp = tmp.Right(tmp.GetLength() - 7);
679 tmp.TrimWhitespace();
680 csToAddress = std::move(tmp);
683 srcURL = srcURL.Right(srcURL.GetLength() - (pos.value() + 1));
684 while (!srcURL.IsEmpty()) {
685 srcURL.TrimWhitespace();
686 pos = srcURL.Find(L'&');
687 WideString tmp = (!pos.has_value()) ? srcURL : srcURL.Left(pos.value());
688 tmp.TrimWhitespace();
689 if (tmp.GetLength() >= 3 && tmp.Left(3).EqualsASCIINoCase(
"cc=")) {
690 tmp = tmp.Right(tmp.GetLength() - 3);
691 if (!csCCAddress.IsEmpty())
694 }
else if (tmp.GetLength() >= 4 && tmp.Left(4).EqualsASCIINoCase(
"bcc=")) {
695 tmp = tmp.Right(tmp.GetLength() - 4);
696 if (!csBCCAddress.IsEmpty())
697 csBCCAddress += L';';
699 }
else if (tmp.GetLength() >= 8 &&
700 tmp.Left(8).EqualsASCIINoCase(
"subject=")) {
701 tmp = tmp.Right(tmp.GetLength() - 8);
703 }
else if (tmp.GetLength() >= 5 && tmp.Left(5).EqualsASCIINoCase(
"body=")) {
704 tmp = tmp.Right(tmp.GetLength() - 5);
707 srcURL = pos.has_value()
708 ? srcURL.Right(csURL.GetLength() - (pos.value() + 1))
711 csToAddress.Replace(L",", L";");
712 csCCAddress.Replace(L",", L";");
713 csBCCAddress.Replace(L",", L";");
717bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
719 FPDF_DWORD encodeType,
721 if (!m_pContext->GetXFADocView())
724 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
728 CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
729 RetainPtr<IFX_SeekableStream> fileStream = MakeSeekableStream(pFileHandler);
730 if (fileType == FXFA_SAVEAS_XML) {
731 fileStream->WriteString(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
733 ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Data)),
738 if (fileType != FXFA_SAVEAS_XDP)
742 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
743 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
745 if (!m_pContext->GetPDFDoc()) {
750 const CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
756 RetainPtr<
const CPDF_Dictionary> pAcroForm = pRoot->GetDictFor(
"AcroForm");
762 RetainPtr<
const CPDF_Array> pArray = ToArray(pAcroForm->GetObjectFor(
"XFA"));
768 for (size_t i = 1; i < pArray->size(); i += 2) {
769 RetainPtr<
const CPDF_Object> pPDFObj = pArray->GetObjectAt(i);
770 RetainPtr<
const CPDF_Object> pPrePDFObj = pArray->GetObjectAt(i - 1);
771 if (!pPrePDFObj->IsString())
773 if (!pPDFObj->IsReference())
776 RetainPtr<
const CPDF_Object> pDirectObj = pPDFObj->GetDirect();
777 if (!pDirectObj->IsStream())
779 ByteString bsType = pPrePDFObj->GetString();
780 if (bsType ==
"config" && !(flag & FXFA_CONFIG))
782 if (bsType ==
"template" && !(flag & FXFA_TEMPLATE))
784 if (bsType ==
"localeSet" && !(flag & FXFA_LOCALESET))
786 if (bsType ==
"datasets" && !(flag & FXFA_DATASETS))
788 if (bsType ==
"xmpmeta" && !(flag & FXFA_XMPMETA))
790 if (bsType ==
"xfdf" && !(flag & FXFA_XFDF))
792 if (bsType ==
"form" && !(flag & FXFA_FORM))
795 if (bsType ==
"form") {
797 ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)),
799 }
else if (pPrePDFObj->GetString() ==
"datasets") {
801 ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Datasets)),
808void CPDFXFA_DocEnvironment::ToXFAContentFlags(WideString csSrcContent,
810 if (csSrcContent.Contains(L" config "))
812 if (csSrcContent.Contains(L" template "))
813 flag |= FXFA_TEMPLATE;
814 if (csSrcContent.Contains(L" localeSet "))
815 flag |= FXFA_LOCALESET;
816 if (csSrcContent.Contains(L" datasets "))
817 flag |= FXFA_DATASETS;
818 if (csSrcContent.Contains(L" xmpmeta "))
819 flag |= FXFA_XMPMETA;
820 if (csSrcContent.Contains(L" xfdf "))
822 if (csSrcContent.Contains(L" form "))
825 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
826 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
830bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
831 if (!m_pContext->ContainsXFAForm())
834 CXFA_FFDocView* docView = m_pContext->GetXFADocView();
838 CXFA_FFWidgetHandler* pWidgetHandler = docView->GetWidgetHandler();
842 auto it = docView->CreateReadyNodeIterator();
844 CXFA_EventParam Param;
845 Param.m_eType = XFA_EVENT_PreSubmit;
846 while (CXFA_Node* pNode = it->MoveToNext())
847 pWidgetHandler->ProcessEvent(pNode, &Param);
850 it = docView->CreateReadyNodeIterator();
854 (
void)it->MoveToNext();
855 CXFA_Node* pNode = it->MoveToNext();
858 if (pNode->ProcessValidate(docView, -1) == XFA_EventError::kError) {
859 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
863 pFormFillEnv->JS_appAlert(WideString::FromDefANSI(IDS_XFA_Validate_Input),
864 WideString(), JSPLATFORM_ALERT_BUTTON_OK,
865 JSPLATFORM_ALERT_ICON_WARNING);
868 pNode = it->MoveToNext();
871 docView->UpdateDocView();
875void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() {
876 if (!m_pContext->ContainsXFAForm())
879 if (!m_pContext->GetXFADocView())
882 CXFA_FFWidgetHandler* pWidgetHandler =
883 m_pContext->GetXFADocView()->GetWidgetHandler();
887 auto it = m_pContext->GetXFADocView()->CreateReadyNodeIterator();
891 CXFA_EventParam Param;
892 Param.m_eType = XFA_EVENT_PostSubmit;
893 CXFA_Node* pNode = it->MoveToNext();
895 pWidgetHandler->ProcessEvent(pNode, &Param);
896 pNode = it->MoveToNext();
898 m_pContext->GetXFADocView()->UpdateDocView();
901bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc,
902 CXFA_Submit* submit) {
903 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
907 WideString csURL = submit->GetSubmitTarget();
908 if (csURL.IsEmpty()) {
909 pFormFillEnv->JS_appAlert(WideString::FromDefANSI(
"Submit cancelled."),
910 WideString(), JSPLATFORM_ALERT_BUTTON_OK,
911 JSPLATFORM_ALERT_ICON_ASTERISK);
915 FPDF_FILEHANDLER* pFileHandler =
nullptr;
917 switch (submit->GetSubmitFormat()) {
918 case XFA_AttributeValue::Xdp: {
919 WideString csContent = submit->GetSubmitXDPContent();
920 csContent.TrimWhitespace();
922 WideString space = WideString::FromDefANSI(
" ");
923 csContent = space + csContent + space;
925 if (submit->IsSubmitEmbedPDF())
928 ToXFAContentFlags(csContent, flag);
929 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XDP,
nullptr,
"wb");
930 fileFlag = FXFA_SAVEAS_XDP;
931 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag);
934 case XFA_AttributeValue::Xml:
935 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML,
nullptr,
"wb");
936 fileFlag = FXFA_SAVEAS_XML;
937 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL);
939 case XFA_AttributeValue::Pdf:
941 case XFA_AttributeValue::Urlencoded:
942 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML,
nullptr,
"wb");
943 fileFlag = FXFA_SAVEAS_XML;
944 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL);
952 if (csURL.Left(7).EqualsASCIINoCase(
"mailto:")) {
953 WideString csToAddress;
954 WideString csCCAddress;
955 WideString csBCCAddress;
956 WideString csSubject;
958 if (!MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject,
962 ByteString bsTo = WideString(csToAddress).ToUTF16LE();
963 ByteString bsCC = WideString(csCCAddress).ToUTF16LE();
964 ByteString bsBcc = WideString(csBCCAddress).ToUTF16LE();
965 ByteString bsSubject = WideString(csSubject).ToUTF16LE();
966 ByteString bsMsg = WideString(csMsg).ToUTF16LE();
967 pFormFillEnv->EmailTo(pFileHandler, AsFPDFWideString(&bsTo),
968 AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC),
969 AsFPDFWideString(&bsBcc), AsFPDFWideString(&bsMsg));
974 ByteString bs = csURL.ToUTF16LE();
975 pFormFillEnv->UploadTo(pFileHandler, fileFlag, AsFPDFWideString(&bs));
fxcrt::ByteString ByteString
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 *)
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
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,...)
ByteString & operator=(ByteString &&that) noexcept
ByteString ToUTF8() const
static WideString FromDefANSI(ByteStringView str)
ByteString ToUTF16LE() const
CXFA_Node * ToNode(CXFA_Object *pObj)
CFX_PTemplate< float > CFX_PointF
fxcrt::WideString WideString