5#include "public/fpdf_javascript.h"
10#include "core/fpdfapi/parser/cpdf_dictionary.h"
11#include "core/fpdfapi/parser/cpdf_document.h"
12#include "core/fpdfdoc/cpdf_action.h"
13#include "core/fpdfdoc/cpdf_nametree.h"
14#include "core/fxcrt/compiler_specific.h"
15#include "core/fxcrt/numerics/safe_conversions.h"
16#include "fpdfsdk/cpdfsdk_helpers.h"
29 auto name_tree = CPDF_NameTree::Create(doc,
"JavaScript");
30 return name_tree ?
pdfium::checked_cast<
int>(name_tree->GetCount()) : 0;
36 if (!doc || index < 0)
39 auto name_tree = CPDF_NameTree::Create(doc,
"JavaScript");
40 if (!name_tree ||
static_cast<size_t>(index) >= name_tree->GetCount())
45 ToDictionary(name_tree->LookupValueAndName(index, &name));
54 std::optional<
WideString> script = action.MaybeGetJavaScript();
55 if (!script.has_value())
60 js->script = script.value();
61 return FPDFJavaScriptActionFromCPDFJavaScriptAction(js.release());
67 std::unique_ptr<CPDF_JavaScript>(
68 CPDFJavaScriptActionFromFPDFJavaScriptAction(javascript));
74 unsigned long buflen) {
81 return Utf16EncodeMaybeCopyAndReturnLength(
88 unsigned long buflen) {
95 return Utf16EncodeMaybeCopyAndReturnLength(
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
#define UNSAFE_BUFFERS(...)
CPDF_JavaScript * CPDFJavaScriptActionFromFPDFJavaScriptAction(FPDF_JAVASCRIPT_ACTION javascript)
CPDF_Document * CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFJavaScriptAction_GetName(FPDF_JAVASCRIPT_ACTION javascript, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT int FPDF_CALLCONV FPDFDoc_GetJavaScriptActionCount(FPDF_DOCUMENT document)
FPDF_EXPORT void FPDF_CALLCONV FPDFDoc_CloseJavaScriptAction(FPDF_JAVASCRIPT_ACTION javascript)
FPDF_EXPORT FPDF_JAVASCRIPT_ACTION FPDF_CALLCONV FPDFDoc_GetJavaScriptAction(FPDF_DOCUMENT document, int index)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFJavaScriptAction_GetScript(FPDF_JAVASCRIPT_ACTION javascript, FPDF_WCHAR *buffer, unsigned long buflen)
fxcrt::WideString WideString