Add an experimental API to surface a page's additional action.
Add an API to surface a page's additional action (/AA) to the embedder.
FORM_GetPageAAction() returns either a page open action or a page close action, depending on the input type.
Change-Id: I435d04ddd6bd0755d651a3cbb6e1abd93b81d356
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/72590
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_doc.cpp b/fpdfsdk/fpdf_doc.cpp
index b6a5ed4..94a1d04 100644
--- a/fpdfsdk/fpdf_doc.cpp
+++ b/fpdfsdk/fpdf_doc.cpp
@@ -10,6 +10,7 @@
#include <set>
#include <utility>
+#include "constants/form_fields.h"
#include "core/fpdfapi/page/cpdf_annotcontext.h"
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_array.h"
@@ -18,12 +19,14 @@
#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
+#include "core/fpdfdoc/cpdf_aaction.h"
#include "core/fpdfdoc/cpdf_bookmark.h"
#include "core/fpdfdoc/cpdf_bookmarktree.h"
#include "core/fpdfdoc/cpdf_dest.h"
#include "core/fpdfdoc/cpdf_linklist.h"
#include "core/fpdfdoc/cpdf_pagelabel.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
+#include "public/fpdf_formfill.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -412,6 +415,30 @@
quad_points);
}
+FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDF_GetPageAAction(FPDF_PAGE page,
+ int aa_type) {
+ CPDF_Page* pdf_page = CPDFPageFromFPDFPage(page);
+ if (!pdf_page)
+ return nullptr;
+
+ CPDF_Dictionary* page_dict = pdf_page->GetDict();
+ CPDF_AAction aa(page_dict->GetDictFor(pdfium::form_fields::kAA));
+
+ CPDF_AAction::AActionType type;
+ if (aa_type == FPDFPAGE_AACTION_OPEN)
+ type = CPDF_AAction::kOpenPage;
+ else if (aa_type == FPDFPAGE_AACTION_CLOSE)
+ type = CPDF_AAction::kClosePage;
+ else
+ return nullptr;
+
+ if (!aa.ActionExist(type))
+ return nullptr;
+
+ CPDF_Action action = aa.GetAction(type);
+ return FPDFActionFromCPDFDictionary(action.GetDict());
+}
+
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_GetFileIdentifier(FPDF_DOCUMENT document,
FPDF_FILEIDTYPE id_type,