7#include "public/fpdf_doc.h"
13#include "constants/form_fields.h"
14#include "core/fpdfapi/page/cpdf_annotcontext.h"
15#include "core/fpdfapi/page/cpdf_page.h"
16#include "core/fpdfapi/parser/cpdf_array.h"
17#include "core/fpdfapi/parser/cpdf_dictionary.h"
18#include "core/fpdfapi/parser/cpdf_document.h"
19#include "core/fpdfapi/parser/cpdf_number.h"
20#include "core/fpdfapi/parser/cpdf_string.h"
21#include "core/fpdfapi/parser/fpdf_parser_decode.h"
22#include "core/fpdfdoc/cpdf_aaction.h"
23#include "core/fpdfdoc/cpdf_bookmark.h"
24#include "core/fpdfdoc/cpdf_bookmarktree.h"
25#include "core/fpdfdoc/cpdf_dest.h"
26#include "core/fpdfdoc/cpdf_linklist.h"
27#include "core/fpdfdoc/cpdf_pagelabel.h"
28#include "core/fxcrt/check.h"
29#include "core/fxcrt/compiler_specific.h"
30#include "core/fxcrt/containers/contains.h"
31#include "core/fxcrt/fx_memcpy_wrappers.h"
32#include "core/fxcrt/numerics/safe_conversions.h"
33#include "core/fxcrt/span.h"
34#include "core/fxcrt/span_util.h"
35#include "fpdfsdk/cpdfsdk_helpers.h"
36#include "public/fpdf_formfill.h"
43 std::set<
const CPDF_Dictionary*>* visited) {
59 CPDF_Bookmark found = FindBookmark(tree, child, title, visited);
67CPDF_LinkList* GetLinkList(CPDF_Page* page) {
73 auto pNewList =
std::make_unique<CPDF_LinkList>();
74 pList = pNewList.get();
75 pDoc->SetLinksContext(
std::move(pNewList));
112 unsigned long buflen) {
119 return Utf16EncodeMaybeCopyAndReturnLength(
139 if (encodedTitle.IsEmpty())
143 std::set<
const CPDF_Dictionary*> visited;
144 return FPDFBookmarkFromCPDFDictionary(
145 FindBookmark(tree, CPDF_Bookmark(), encodedTitle, &visited).GetDict());
202 FPDF_ACTION action) {
226 return NulTerminateMaybeCopyAndReturnLength(
234 unsigned long buflen) {
244 auto result_span =
UNSAFE_BUFFERS(SpanFromFPDFApiArgs(buffer, buflen));
247 fxcrt::try_spancpy(result_span, path.span_with_terminator());
248 return static_cast<
unsigned long>(path.span_with_terminator().size());
271 const unsigned long nParams =
272 pdfium::checked_cast<
unsigned long>(destination.GetNumParams());
274 *pNumParams = nParams;
275 for (
unsigned long i = 0; i < nParams; ++i) {
285 FPDF_BOOL* hasZoomVal,
303 *hasZoomVal = bHasZoom;
314 CPDF_LinkList* pLinkList = GetLinkList(pPage);
319 pPage
, CFX_PointF(
static_cast<
float>(x),
static_cast<
float>(y))
, nullptr);
322 return FPDFLinkFromCPDFDictionary(link.GetMutableDict());
332 CPDF_LinkList* pLinkList = GetLinkList(pPage);
338 pPage
, CFX_PointF(
static_cast<
float>(x),
static_cast<
float>(y))
,
371 FPDF_LINK* link_annot) {
372 if (!start_pos || !link_annot)
380 for (size_t i = *start_pos; i < pAnnots->size(); i++) {
382 ToDictionary(pAnnots->GetMutableDirectObjectAt(i));
385 if (pDict->GetByteStringFor(
"Subtype") ==
"Link") {
386 *start_pos =
static_cast<
int>(i + 1);
387 *link_annot = FPDFLinkFromCPDFDictionary(pDict.Get());
398 if (!pPage || !pAnnotDict)
405 return FPDFAnnotationFromCPDFAnnotContext(pAnnotContext.release());
410 if (!link_annot || !rect)
420 GetQuadPointsArrayFromDictionary(CPDFDictionaryFromFPDFLink(link_annot));
421 return pArray ?
static_cast<
int>(pArray->size() / 8) : 0;
427 FS_QUADPOINTSF* quad_points) {
428 if (!quad_points || quad_index < 0)
436 GetQuadPointsArrayFromDictionary(pLinkDict);
440 return GetQuadPointsAtIndex(std::move(pArray),
441 static_cast<size_t>(quad_index), quad_points);
468 FPDF_FILEIDTYPE id_type,
470 unsigned long buflen) {
476 if (id_type != FILEIDTYPE_PERMANENT && id_type != FILEIDTYPE_CHANGING)
483 size_t nIndex = id_type == FILEIDTYPE_PERMANENT ? 0 : 1;
485 ToString(pFileId->GetDirectObjectAt(nIndex));
490 return NulTerminateMaybeCopyAndReturnLength(
491 pValue->GetString(),
UNSAFE_BUFFERS(SpanFromFPDFApiArgs(buffer, buflen)));
497 unsigned long buflen) {
509 return Utf16EncodeMaybeCopyAndReturnLength(
510 pInfo->GetUnicodeTextFor(tag),
518 unsigned long buflen) {
525 if (!str.has_value()) {
529 return Utf16EncodeMaybeCopyAndReturnLength(
530 str.value(),
UNSAFE_BUFFERS(SpanFromFPDFApiArgs(buffer, buflen)));
fxcrt::ByteString ByteString
bool ActionExist(AActionType eType) const
CPDF_Action GetAction(AActionType eType) const
CPDF_Dest GetDest(CPDF_Document *pDoc) const
WideString GetFilePath() const
ByteString GetURI(const CPDF_Document *pDoc) const
const CPDF_Dictionary * GetDict() const
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
CPDF_Bookmark GetFirstChild(const CPDF_Bookmark &parent) const
CPDF_BookmarkTree(const CPDF_Document *doc)
CPDF_Bookmark GetNextSibling(const CPDF_Bookmark &bookmark) const
WideString GetTitle() const
CPDF_Action GetAction() const
const CPDF_Dictionary * GetDict() const
CPDF_Dest GetDest(CPDF_Document *pDocument) const
bool GetXYZ(bool *pHasX, bool *pHasY, bool *pHasZoom, float *pX, float *pY, float *pZoom) const
int GetDestPageIndex(CPDF_Document *pDoc) const
const CPDF_Array * GetArray() const
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
CFX_FloatRect GetRectFor(const ByteString &key) const
LinkListIface * GetLinksContext() const
CPDF_Link GetLinkAtPoint(CPDF_Page *pPage, const CFX_PointF &point, int *z_order)
CPDF_Dest GetDest(CPDF_Document *pDoc)
CPDF_PageLabel(CPDF_Document *doc)
CPDF_Document * GetDocument() const override
ByteString ToUTF8() const
int CompareNoCase(const wchar_t *str) const
#define UNSAFE_BUFFERS(...)
UNSAFE_BUFFER_USAGE WideString WideStringFromFPDFWideString(FPDF_WIDESTRING wide_string)
FPDF_DEST FPDFDestFromCPDFArray(const CPDF_Array *dest)
IPDF_Page * IPDFPageFromFPDFPage(FPDF_PAGE page)
CPDF_Array * CPDFArrayFromFPDFDest(FPDF_DEST dest)
FPDF_ACTION FPDFActionFromCPDFDictionary(const CPDF_Dictionary *action)
CPDF_Dictionary * CPDFDictionaryFromFPDFBookmark(FPDF_BOOKMARK bookmark)
FS_RECTF FSRectFFromCFXFloatRect(const CFX_FloatRect &rect)
CPDF_Dictionary * CPDFDictionaryFromFPDFLink(FPDF_LINK link)
CPDF_Page * CPDFPageFromFPDFPage(FPDF_PAGE page)
CPDF_Document * CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc)
FPDF_BOOKMARK FPDFBookmarkFromCPDFDictionary(const CPDF_Dictionary *bookmark)
CPDF_Dictionary * CPDFDictionaryFromFPDFAction(FPDF_ACTION action)
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFLink_GetAction(FPDF_LINK link)
FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFLink_GetDest(FPDF_DOCUMENT document, FPDF_LINK link)
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark)
FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTION action)
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFDest_GetView(FPDF_DEST dest, unsigned long *pNumParams, FS_FLOAT *pParams)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, void *buffer, unsigned long buflen)
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDF_GetPageAAction(FPDF_PAGE page, int aa_type)
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)
FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetAnnotRect(FPDF_LINK link_annot, FS_RECTF *rect)
FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetFilePath(FPDF_ACTION action, void *buffer, unsigned long buflen)
FPDF_EXPORT int FPDF_CALLCONV FPDFBookmark_GetCount(FPDF_BOOKMARK bookmark)
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFLink_GetAnnot(FPDF_PAGE page, FPDF_LINK link_annot)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetFileIdentifier(FPDF_DOCUMENT document, FPDF_FILEIDTYPE id_type, void *buffer, unsigned long buflen)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetType(FPDF_ACTION action)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFDest_GetLocationInPage(FPDF_DEST dest, FPDF_BOOL *hasXVal, FPDF_BOOL *hasYVal, FPDF_BOOL *hasZoomVal, FS_FLOAT *x, FS_FLOAT *y, FS_FLOAT *zoom)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION action, void *buffer, unsigned long buflen)
FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountQuadPoints(FPDF_LINK link_annot)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetQuadPoints(FPDF_LINK link_annot, int quad_index, FS_QUADPOINTSF *quad_points)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetMetaText(FPDF_DOCUMENT document, FPDF_BYTESTRING tag, void *buffer, unsigned long buflen)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetPageLabel(FPDF_DOCUMENT document, int page_index, void *buffer, unsigned long buflen)
FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y)
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)
FPDF_EXPORT int FPDF_CALLCONV FPDFDest_GetDestPageIndex(FPDF_DOCUMENT document, FPDF_DEST dest)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_Enumerate(FPDF_PAGE page, int *start_pos, FPDF_LINK *link_annot)
#define PDFACTION_REMOTEGOTO
#define PDFACTION_EMBEDDEDGOTO
#define PDFACTION_UNSUPPORTED
fxcrt::WideString WideString