7#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
15#include "core/fpdfapi/page/cpdf_annotcontext.h"
16#include "core/fpdfapi/parser/cpdf_array.h"
17#include "core/fpdfapi/parser/cpdf_dictionary.h"
18#include "core/fpdfdoc/cpdf_nametree.h"
19#include "core/fxcrt/data_vector.h"
20#include "core/fxcrt/stl_util.h"
21#include "fpdfsdk/cpdfsdk_helpers.h"
22#include "fpdfsdk/cpdfsdk_interactiveform.h"
23#include "fpdfsdk/cpdfsdk_pageview.h"
24#include "fpdfsdk/cpdfsdk_widget.h"
25#include "fpdfsdk/formfiller/cffl_formfield.h"
26#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
27#include "fxjs/ijs_event_context.h"
28#include "fxjs/ijs_runtime.h"
29#include "third_party/base/check.h"
30#include "third_party/base/containers/contains.h"
31#include "third_party/base/notreached.h"
32#include "third_party/base/numerics/safe_conversions.h"
35#include "fpdfsdk/fpdfxfa/cpdfxfa_widget.h"
40 "kArrow value mismatch");
43 "kNEWS value mismatch");
46 "kNWSE value mismatch");
49 "kVBeam value mismatch");
52 "HBeam value mismatch");
55 "kHand value mismatch");
61 return reinterpret_cast<FPDF_WIDESTRING>(
62 bsUTF16LE->GetBuffer(bsUTF16LE->GetLength()).data());
67 FPDF_FORMFILLINFO* pFFinfo)
76 m_bBeingDestroyed =
true;
86 m_pInteractiveFormFiller.reset();
88 if (m_pInfo && m_pInfo->Release)
89 m_pInfo->Release(m_pInfo);
100 CFX_PointF left_top = device2page.Transform(CFX_PointF(rect.left, rect.top));
101 CFX_PointF right_bottom =
102 device2page.Transform(CFX_PointF(rect.right, rect.bottom));
104 CFX_FloatRect rcPDF(left_top.x, right_bottom.y, right_bottom.x, left_top.y);
112 if (!m_pInfo || !m_pInfo->FFI_OutputSelectedRect)
118 CFX_PointF ptA = pFormField->PWLtoFFL(CFX_PointF(rect.left, rect.bottom));
119 CFX_PointF ptB = pFormField->PWLtoFFL(CFX_PointF(rect.right, rect.top));
120 m_pInfo->FFI_OutputSelectedRect(m_pInfo, pPage, ptA.x, ptB.y, ptB.x, ptA.y);
129CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetCurrentView() {
130 IPDF_Page* pPage = GetCurrentPage();
131 return pPage ? GetOrCreatePageView(pPage) :
nullptr;
134IPDF_Page* CPDFSDK_FormFillEnvironment::GetCurrentPage()
const {
135 if (m_pInfo && m_pInfo->FFI_GetCurrentPage) {
136 return IPDFPageFromFPDFPage(m_pInfo->FFI_GetCurrentPage(
137 m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc)));
142WideString CPDFSDK_FormFillEnvironment::GetLanguage() {
144 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_GetLanguage)
147 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo,
nullptr, 0);
148 if (nRequiredLen <= 0)
151 DataVector<uint8_t> pBuff(nRequiredLen);
153 m_pInfo->FFI_GetLanguage(m_pInfo, pBuff.data(), nRequiredLen);
154 if (nActualLen <= 0 || nActualLen > nRequiredLen)
157 return WideString::FromUTF16LE(
158 {pBuff.data(),
static_cast<size_t>(nActualLen)});
164WideString CPDFSDK_FormFillEnvironment::GetPlatform() {
166 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_GetPlatform)
169 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo,
nullptr, 0);
170 if (nRequiredLen <= 0)
173 DataVector<uint8_t> pBuff(nRequiredLen);
175 m_pInfo->FFI_GetPlatform(m_pInfo, pBuff.data(), nRequiredLen);
176 if (nActualLen <= 0 || nActualLen > nRequiredLen)
179 return WideString::FromUTF16LE(
180 {pBuff.data(),
static_cast<size_t>(nActualLen)});
186int CPDFSDK_FormFillEnvironment::JS_appAlert(
const WideString& Msg,
187 const WideString& Title,
190 IPDF_JSPLATFORM* js_platform = GetJSPlatform();
191 if (!js_platform || !js_platform->app_alert)
194 ByteString bsMsg = Msg.ToUTF16LE();
195 ByteString bsTitle = Title.ToUTF16LE();
196 return js_platform->app_alert(js_platform, AsFPDFWideString(&bsMsg),
197 AsFPDFWideString(&bsTitle), Type, Icon);
200int CPDFSDK_FormFillEnvironment::JS_appResponse(
201 const WideString& Question,
202 const WideString& Title,
203 const WideString& Default,
204 const WideString& Label,
206 pdfium::span<uint8_t> response) {
207 IPDF_JSPLATFORM* js_platform = GetJSPlatform();
208 if (!js_platform || !js_platform->app_response)
211 ByteString bsQuestion = Question.ToUTF16LE();
212 ByteString bsTitle = Title.ToUTF16LE();
213 ByteString bsDefault = Default.ToUTF16LE();
214 ByteString bsLabel = Label.ToUTF16LE();
215 return js_platform->app_response(
216 js_platform, AsFPDFWideString(&bsQuestion), AsFPDFWideString(&bsTitle),
217 AsFPDFWideString(&bsDefault), AsFPDFWideString(&bsLabel), bPassword,
218 response.data(), pdfium::base::checked_cast<
int>(response.size()));
221void CPDFSDK_FormFillEnvironment::JS_appBeep(
int nType) {
222 IPDF_JSPLATFORM* js_platform = GetJSPlatform();
223 if (!js_platform || !js_platform->app_beep)
226 js_platform->app_beep(js_platform, nType);
229WideString CPDFSDK_FormFillEnvironment::JS_fieldBrowse() {
230 IPDF_JSPLATFORM* js_platform = GetJSPlatform();
231 if (!js_platform || !js_platform->Field_browse)
234 const int nRequiredLen = js_platform->Field_browse(js_platform,
nullptr, 0);
235 if (nRequiredLen <= 0)
238 DataVector<uint8_t> pBuff(nRequiredLen);
239 const int nActualLen =
240 js_platform->Field_browse(js_platform, pBuff.data(), nRequiredLen);
241 if (nActualLen <= 0 || nActualLen > nRequiredLen)
245 pBuff.resize(nActualLen - 1);
248 return WideString::FromDefANSI(ByteStringView(pBuff));
251void CPDFSDK_FormFillEnvironment::JS_docmailForm(
252 pdfium::span<
const uint8_t> mailData,
254 const WideString& To,
255 const WideString& Subject,
256 const WideString& CC,
257 const WideString& BCC,
258 const WideString& Msg) {
259 IPDF_JSPLATFORM* js_platform = GetJSPlatform();
260 if (!js_platform || !js_platform->Doc_mail)
263 ByteString bsTo = To.ToUTF16LE();
264 ByteString bsSubject = Subject.ToUTF16LE();
265 ByteString bsCC = CC.ToUTF16LE();
266 ByteString bsBcc = BCC.ToUTF16LE();
267 ByteString bsMsg = Msg.ToUTF16LE();
268 js_platform->Doc_mail(js_platform,
const_cast<uint8_t*>(mailData.data()),
269 pdfium::base::checked_cast<
int>(mailData.size()), bUI,
270 AsFPDFWideString(&bsTo), AsFPDFWideString(&bsSubject),
271 AsFPDFWideString(&bsCC), AsFPDFWideString(&bsBcc),
272 AsFPDFWideString(&bsMsg));
275void CPDFSDK_FormFillEnvironment::JS_docprint(FPDF_BOOL bUI,
279 FPDF_BOOL bShrinkToFit,
280 FPDF_BOOL bPrintAsImage,
282 FPDF_BOOL bAnnotations) {
283 IPDF_JSPLATFORM* js_platform = GetJSPlatform();
284 if (!js_platform || !js_platform->Doc_print)
287 js_platform->Doc_print(js_platform, bUI, nStart, nEnd, bSilent, bShrinkToFit,
288 bPrintAsImage, bReverse, bAnnotations);
291void CPDFSDK_FormFillEnvironment::JS_docgotoPage(
int nPageNum) {
292 IPDF_JSPLATFORM* js_platform = GetJSPlatform();
293 if (!js_platform || !js_platform->Doc_gotoPage)
296 js_platform->Doc_gotoPage(js_platform, nPageNum);
299WideString CPDFSDK_FormFillEnvironment::JS_docGetFilePath() {
300 return GetFilePath();
309 const int nRequiredLen =
311 if (nRequiredLen <= 0)
314 DataVector<uint8_t> pBuff(nRequiredLen);
315 const int nActualLen =
316 js_platform->Doc_getFilePath(js_platform, pBuff.data(), nRequiredLen);
317 if (nActualLen <= 0 || nActualLen > nRequiredLen)
321 pBuff.resize(nActualLen - 1);
324 return WideString::FromDefANSI(ByteStringView(pBuff));
328 pdfium::span<
const uint8_t> form_data,
329 const WideString& URL) {
336 js_platform
, const_cast<uint8_t*>(form_data.data())
,
342 m_pIJSRuntime = IJS_Runtime::Create(
this);
343 return m_pIJSRuntime.get();
348 if (m_pInfo && m_pInfo->FFI_Invalidate) {
349 m_pInfo->FFI_Invalidate(m_pInfo, FPDFPageFromIPDFPage(page), rect.left,
350 rect.top, rect.right, rect.bottom);
356 if (m_pInfo && m_pInfo->FFI_SetCursor)
357 m_pInfo->FFI_SetCursor(m_pInfo,
static_cast<
int>(nCursorType));
360int CPDFSDK_FormFillEnvironment::
SetTimer(
int uElapse,
361 TimerCallback lpTimerFunc) {
362 if (m_pInfo && m_pInfo->FFI_SetTimer)
363 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc);
367void CPDFSDK_FormFillEnvironment::
KillTimer(
int nTimerID) {
368 if (m_pInfo && m_pInfo->FFI_KillTimer)
369 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID);
373 if (m_pInfo && m_pInfo->FFI_OnChange)
374 m_pInfo->FFI_OnChange(m_pInfo);
378 const ByteString& namedAction) {
379 if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction)
380 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction.c_str());
384 OnSetFieldInputFocusInternal(text,
true);
387void CPDFSDK_FormFillEnvironment::OnSetFieldInputFocusInternal(
388 const WideString& text,
390 if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) {
391 size_t nCharacters = text.GetLength();
393 auto* pBuffer =
reinterpret_cast<
const unsigned short*>(bsUTFText
.c_str());
394 m_pInfo->FFI_SetTextFieldFocus(
395 m_pInfo, pBuffer, pdfium::base::checked_cast<FPDF_DWORD>(nCharacters),
402 CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
404 m_pInteractiveForm->OnCalculate(pWidget->GetFormField());
408 CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
411 absl::optional<WideString> sValue =
412 m_pInteractiveForm->OnFormat(pWidget->GetFormField());
416 if (sValue.has_value()) {
417 m_pInteractiveForm->ResetFieldAppearance(pWidget->GetFormField(), sValue);
418 m_pInteractiveForm->UpdateField(pWidget->GetFormField());
422void CPDFSDK_FormFillEnvironment::
DoURIAction(
const ByteString& bsURI,
423 Mask<FWL_EVENTFLAG> modifiers) {
427 if (m_pInfo->version >= 2 && m_pInfo->FFI_DoURIActionWithKeyboardModifier) {
428 m_pInfo->FFI_DoURIActionWithKeyboardModifier(m_pInfo, bsURI.c_str(),
429 modifiers.UncheckedValue());
433 if (m_pInfo->FFI_DoURIAction)
434 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI.c_str());
439 pdfium::span<
float> fPosArray) {
440 if (m_pInfo && m_pInfo->FFI_DoGoToAction) {
441 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray.data(),
442 fxcrt::CollectionSize<
int>(fPosArray));
447int CPDFSDK_FormFillEnvironment::GetPageViewCount()
const {
448 return fxcrt::CollectionSize<
int>(m_PageMap);
451void CPDFSDK_FormFillEnvironment::DisplayCaret(IPDF_Page* page,
457 if (m_pInfo && m_pInfo->version >= 2 && m_pInfo->FFI_DisplayCaret) {
458 m_pInfo->FFI_DisplayCaret(m_pInfo, FPDFPageFromIPDFPage(page), bVisible,
459 left, top, right, bottom);
463int CPDFSDK_FormFillEnvironment::GetCurrentPageIndex()
const {
464 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_GetCurrentPageIndex)
466 return m_pInfo->FFI_GetCurrentPageIndex(
467 m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc));
470void CPDFSDK_FormFillEnvironment::SetCurrentPage(
int iCurPage) {
471 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_SetCurrentPage)
473 m_pInfo->FFI_SetCurrentPage(m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc),
477void CPDFSDK_FormFillEnvironment::GotoURL(
const WideString& wsURL) {
478 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_GotoURL)
481 ByteString bsTo = wsURL.ToUTF16LE();
482 m_pInfo->FFI_GotoURL(m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc),
483 AsFPDFWideString(&bsTo));
486FS_RECTF CPDFSDK_FormFillEnvironment::GetPageViewRect(IPDF_Page* page) {
487 FS_RECTF rect = {0.0f, 0.0f, 0.0f, 0.0f};
488 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_GetPageViewRect)
495 m_pInfo->FFI_GetPageViewRect(m_pInfo, FPDFPageFromIPDFPage(page), &left, &top,
498 rect.left =
static_cast<
float>(left);
499 rect.top =
static_cast<
float>(top);
500 rect.bottom =
static_cast<
float>(bottom);
501 rect.right =
static_cast<
float>(right);
505bool CPDFSDK_FormFillEnvironment::PopupMenu(IPDF_Page* page,
507 const CFX_PointF& pt) {
508 return m_pInfo && m_pInfo->version >= 2 && m_pInfo->FFI_PopupMenu &&
509 m_pInfo->FFI_PopupMenu(m_pInfo, FPDFPageFromIPDFPage(page),
nullptr,
510 menuFlag, pt.x, pt.y);
513void CPDFSDK_FormFillEnvironment::EmailTo(FPDF_FILEHANDLER* fileHandler,
515 FPDF_WIDESTRING pSubject,
517 FPDF_WIDESTRING pBcc,
518 FPDF_WIDESTRING pMsg) {
519 if (m_pInfo && m_pInfo->version >= 2 && m_pInfo->FFI_EmailTo)
520 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg);
523void CPDFSDK_FormFillEnvironment::UploadTo(FPDF_FILEHANDLER* fileHandler,
525 FPDF_WIDESTRING uploadTo) {
526 if (m_pInfo && m_pInfo->version >= 2 && m_pInfo->FFI_UploadTo)
527 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo);
530FPDF_FILEHANDLER* CPDFSDK_FormFillEnvironment::OpenFile(
int fileType,
531 FPDF_WIDESTRING wsURL,
533 if (m_pInfo && m_pInfo->version >= 2 && m_pInfo->FFI_OpenFile)
534 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode);
538RetainPtr<IFX_SeekableReadStream> CPDFSDK_FormFillEnvironment::DownloadFromURL(
539 const WideString& url) {
540 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_DownloadFromURL)
543 ByteString bstrURL = url.ToUTF16LE();
544 FPDF_FILEHANDLER* fileHandler =
545 m_pInfo->FFI_DownloadFromURL(m_pInfo, AsFPDFWideString(&bstrURL));
547 return MakeSeekableStream(fileHandler);
550WideString CPDFSDK_FormFillEnvironment::PostRequestURL(
551 const WideString& wsURL,
552 const WideString& wsData,
553 const WideString& wsContentType,
554 const WideString& wsEncode,
555 const WideString& wsHeader) {
556 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_PostRequestURL)
559 ByteString bsURL = wsURL.ToUTF16LE();
560 ByteString bsData = wsData.ToUTF16LE();
561 ByteString bsContentType = wsContentType.ToUTF16LE();
562 ByteString bsEncode = wsEncode.ToUTF16LE();
563 ByteString bsHeader = wsHeader.ToUTF16LE();
566 FPDF_BStr_Init(&response);
567 m_pInfo->FFI_PostRequestURL(
568 m_pInfo, AsFPDFWideString(&bsURL), AsFPDFWideString(&bsData),
569 AsFPDFWideString(&bsContentType), AsFPDFWideString(&bsEncode),
570 AsFPDFWideString(&bsHeader), &response);
573 WideString::FromUTF16LE({
reinterpret_cast<
const uint8_t*>(response.str),
574 static_cast<size_t>(response.len)});
576 FPDF_BStr_Clear(&response);
580FPDF_BOOL CPDFSDK_FormFillEnvironment::PutRequestURL(
581 const WideString& wsURL,
582 const WideString& wsData,
583 const WideString& wsEncode) {
584 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_PutRequestURL)
587 ByteString bsURL = wsURL.ToUTF16LE();
588 ByteString bsData = wsData.ToUTF16LE();
589 ByteString bsEncode = wsEncode.ToUTF16LE();
591 return m_pInfo->FFI_PutRequestURL(m_pInfo, AsFPDFWideString(&bsURL),
592 AsFPDFWideString(&bsData),
593 AsFPDFWideString(&bsEncode));
596void CPDFSDK_FormFillEnvironment::PageEvent(
int iPageCount,
597 uint32_t dwEventType)
const {
598 if (m_pInfo && m_pInfo->version >= 2 && m_pInfo->FFI_PageEvent)
599 m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType);
604 for (
auto& it : m_PageMap) {
605 if (it.second->IsValidSDKAnnot(GetFocusAnnot())) {
606 ObservedPtr<CPDFSDK_PageView> pObserved(it.second.get());
620 auto pNew =
std::make_unique<CPDFSDK_PageView>(
this, pUnderlyingPage);
621 CPDFSDK_PageView* pPageView = pNew.get();
622 m_PageMap[pUnderlyingPage] = std::move(pNew);
631 auto it = m_PageMap.find(pUnderlyingPage);
632 return it != m_PageMap.end() ? it->second.get() :
nullptr;
645 auto name_tree = CPDF_NameTree::Create(m_pCPDFDoc,
"JavaScript");
649 size_t count = name_tree->GetCount();
650 for (size_t i = 0; i < count; ++i) {
652 CPDF_Action action(ToDictionary(name_tree->LookupValueAndName(i, &name)));
658 const CPDF_Dictionary* pRoot = m_pCPDFDoc->GetRoot();
668 if (pOpenAction->IsArray())
671 RetainPtr<
const CPDF_Dictionary> pDict = ToDictionary(pOpenAction);
680 auto it = m_PageMap.find(pUnderlyingPage);
681 if (it == m_PageMap.end())
684 CPDFSDK_PageView* pPageView = it->second.get();
705IPDF_Page* CPDFSDK_FormFillEnvironment::GetPage(
int nIndex)
const {
706 if (!m_pInfo || !m_pInfo->FFI_GetPage)
708 return IPDFPageFromFPDFPage(m_pInfo->FFI_GetPage(
709 m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc), nIndex));
713 if (!m_pInteractiveForm)
714 m_pInteractiveForm = std::make_unique<CPDFSDK_InteractiveForm>(
this);
715 return m_pInteractiveForm.get();
719 for (
const auto& it : m_PageMap) {
720 ObservedPtr<CPDFSDK_PageView> pObserved(it.second.get());
722 pObserved->UpdateView(pAnnot);
730 return m_pFocusAnnot.Get();
735 if (m_bBeingDestroyed)
737 if (m_pFocusAnnot == pAnnot)
739 if (m_pFocusAnnot && !KillFocusAnnot({}))
743 if (!pAnnot->GetPageView()->IsValid())
750 CPDFXFA_Widget* pXFAWidget = pAnnot->AsXFAWidget();
751 if (pXFAWidget && pXFAWidget->OnChangedFocus())
764 m_pFocusAnnot.Reset(pAnnot.Get());
768 SendOnFocusChange(pAnnot);
777 m_pFocusAnnot.Reset();
780 m_pFocusAnnot.Reset(pFocusAnnot.Get());
789 CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pFocusAnnot.Get());
793 OnSetFieldInputFocusInternal(WideString
(),
false);
796 return !m_pFocusAnnot;
801 return pExtension ? pExtension->GetPageCount() : m_pCPDFDoc->GetPageCount();
805 return !!(m_pCPDFDoc->GetUserPermissions(
true) & flags);
808void CPDFSDK_FormFillEnvironment::SendOnFocusChange(
810 if (!m_pInfo || m_pInfo->version < 2 || !m_pInfo->FFI_OnFocusChange)
814 if (pAnnot->AsXFAWidget())
817 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
826 pAnnot->GetPDFAnnot()->GetMutableAnnotDict();
828 FPDF_ANNOTATION fpdf_annot =
829 FPDFAnnotationFromCPDFAnnotContext(focused_annot.get());
831 m_pInfo->FFI_OnFocusChange(m_pInfo, fpdf_annot, pPageView->GetPageIndex());
835 std::set<
const CPDF_Dictionary*> visited;
836 return ExecuteDocumentOpenAction(action, &visited);
841 WideString csJSName) {
845 RunDocumentOpenJavaScript(csJSName, swJS);
862 RunFieldJavaScript(pFormField, type, data, swJS);
871 Mask<FWL_EVENTFLAG> modifiers) {
891 std::vector<
float> positions = dest.GetScrollPositionArray();
899 std::set<
const CPDF_Dictionary*> visited;
900 return ExecuteDocumentPageAction(action, eType, &visited);
906 std::set<
const CPDF_Dictionary*> visited;
907 return ExecuteDocumentPageAction(action, eType, &visited);
914 std::set<
const CPDF_Dictionary*> visited;
915 return ExecuteFieldAction(action, type, pFormField, data, &visited);
918bool CPDFSDK_FormFillEnvironment::ExecuteDocumentOpenAction(
920 std::set<
const CPDF_Dictionary*>* visited) {
921 const CPDF_Dictionary* pDict = action
.GetDict();
922 if (pdfium::Contains(*visited, pDict))
925 visited->insert(pDict);
931 RunDocumentOpenJavaScript(WideString
(), swJS);
937 for (size_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
938 CPDF_Action subaction = action.GetSubAction(i);
939 if (!ExecuteDocumentOpenAction(subaction, visited))
946bool CPDFSDK_FormFillEnvironment::ExecuteDocumentPageAction(
949 std::set<
const CPDF_Dictionary*>* visited) {
950 const CPDF_Dictionary* pDict = action
.GetDict();
951 if (pdfium::Contains(*visited, pDict))
954 visited->insert(pDict);
960 RunDocumentPageJavaScript(type, swJS);
966 for (size_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
967 CPDF_Action subaction = action.GetSubAction(i);
968 if (!ExecuteDocumentPageAction(subaction, type, visited))
975bool CPDFSDK_FormFillEnvironment::IsValidField(
976 const CPDF_Dictionary* pFieldDict) {
984bool CPDFSDK_FormFillEnvironment::ExecuteFieldAction(
989 std::set<
const CPDF_Dictionary*>* visited) {
990 const CPDF_Dictionary* pDict = action
.GetDict();
991 if (pdfium::Contains(*visited, pDict))
994 visited->insert(pDict);
1000 RunFieldJavaScript(pFormField, type, data, swJS);
1009 for (size_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
1010 CPDF_Action subaction = action.GetSubAction(i);
1011 if (!ExecuteFieldAction(subaction, type, pFormField, data, visited))
1042 NOTREACHED_NORETURN();
1062 DCHECK(action.GetDict());
1065 DCHECK(pPDFDocument);
1072 Mask<FWL_EVENTFLAG> modifiers) {
1073 DCHECK(action.GetDict());
1078 DCHECK(action.GetDict());
1082void CPDFSDK_FormFillEnvironment::RunFieldJavaScript(
1086 const WideString& script) {
1087 DCHECK(type != CPDF_AAction::kCalculate);
1088 DCHECK(type != CPDF_AAction::kFormat);
1121 pFormField
, &data->sValue
, &data
->bRC);
1124 NOTREACHED_NORETURN();
1129void CPDFSDK_FormFillEnvironment::RunDocumentOpenJavaScript(
1130 const WideString& sScriptName,
1131 const WideString& script) {
1137void CPDFSDK_FormFillEnvironment::RunDocumentPageJavaScript(
1139 const WideString& script) {
1170 NOTREACHED_NORETURN();
1195void CPDFSDK_FormFillEnvironment::RunScript(
const WideString& script,
1196 const RunScriptCallback& cb) {
1199 pContext->RunScript(script);
FX_RECT GetOuterRect() const
static constexpr int32_t kInvalidTimerID
static bool OnKillFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
CPDFSDK_PageView * GetPageView() const
static bool OnSetFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
bool IsValidSDKAnnot(const CPDFSDK_Annot *p) const
bool IsBeingDestroyed() const
static bool IsUserInput(AActionType type)
CPDF_Dest GetDest(CPDF_Document *pDoc) const
ByteString GetURI(const CPDF_Document *pDoc) const
const CPDF_Dictionary * GetDict() const
WideString GetJavaScript() const
ByteString GetNamedAction() const
int GetDestPageIndex(CPDF_Document *pDoc) const
RetainPtr< const CPDF_Array > GetArrayFor(const ByteString &key) const
virtual void OnField_MouseEnter(bool bModifier, bool bShift, CPDF_FormField *pTarget)=0
virtual void OnField_Validate(WideString *strChange, const WideString &strChangeEx, bool bKeyDown, bool bModifier, bool bShift, CPDF_FormField *pTarget, WideString *Value, bool *bRc)=0
virtual void OnField_Keystroke(WideString *strChange, const WideString &strChangeEx, bool KeyDown, bool bModifier, int *nSelEnd, int *nSelStart, bool bShift, CPDF_FormField *pTarget, WideString *Value, bool bWillCommit, bool bFieldFull, bool *bRc)=0
virtual void OnDoc_DidSave()=0
virtual void OnDoc_WillClose()=0
virtual void OnField_MouseDown(bool bModifier, bool bShift, CPDF_FormField *pTarget)=0
virtual void OnPage_InView()=0
virtual void OnField_Focus(bool bModifier, bool bShift, CPDF_FormField *pTarget, WideString *Value)=0
virtual void OnPage_Close()=0
virtual void OnDoc_WillPrint()=0
virtual void OnDoc_WillSave()=0
virtual void OnField_MouseExit(bool bModifier, bool bShift, CPDF_FormField *pTarget)=0
virtual void OnField_MouseUp(bool bModifier, bool bShift, CPDF_FormField *pTarget)=0
virtual void OnDoc_DidPrint()=0
virtual void OnDoc_Open(const WideString &strTargetName)=0
virtual void OnPage_Open()=0
virtual void OnPage_OutView()=0
virtual void OnField_Blur(bool bModifier, bool bShift, CPDF_FormField *pTarget, WideString *Value)=0
IJS_EventContext * Get() const
ScopedEventContext(IJS_Runtime *pRuntime)
const char * c_str() const
ByteString ToUTF16LE() const