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 "fpdfsdk/cpdfsdk_helpers.h"
29#include "public/fpdf_formfill.h"
30#include "third_party/base/check.h"
31#include "third_party/base/containers/contains.h"
32#include "third_party/base/numerics/safe_conversions.h"
38 const WideString& title,
39 std::set<
const CPDF_Dictionary*>* visited) {
41 if (pdfium::Contains(*visited, bookmark
.GetDict()))
55 CPDF_Bookmark found = FindBookmark(tree, child, title, visited);
63CPDF_LinkList* GetLinkList(CPDF_Page* page) {
69 auto pNewList =
std::make_unique<CPDF_LinkList>();
70 pList = pNewList.get();
71 pDoc->SetLinksContext(
std::move(pNewList));
108 unsigned long buflen) {
136 std::set<
const CPDF_Dictionary*> visited;
137 return FPDFBookmarkFromCPDFDictionary(
138 FindBookmark(tree, CPDF_Bookmark(), encodedTitle, &visited).GetDict());
195 FPDF_ACTION action) {
226 unsigned long buflen) {
238 const unsigned long len =
239 pdfium::base::checked_cast<
unsigned long>(path.GetLength() + 1);
240 if (buffer && len <= buflen)
266 const unsigned long nParams =
267 pdfium::base::checked_cast<
unsigned long>(destination.GetNumParams());
268 DCHECK(nParams <= 4);
269 *pNumParams = nParams;
270 for (
unsigned long i = 0; i < nParams; ++i)
271 pParams[i] = destination.GetParam(i);
279 FPDF_BOOL* hasZoomVal,
297 *hasZoomVal = bHasZoom;
308 CPDF_LinkList* pLinkList = GetLinkList(pPage);
313 pPage
, CFX_PointF(
static_cast<
float>(x),
static_cast<
float>(y))
, nullptr);
316 return FPDFLinkFromCPDFDictionary(link.GetMutableDict());
326 CPDF_LinkList* pLinkList = GetLinkList(pPage);
332 pPage
, CFX_PointF(
static_cast<
float>(x),
static_cast<
float>(y))
,
365 FPDF_LINK* link_annot) {
366 if (!start_pos || !link_annot)
371 RetainPtr<CPDF_Array> pAnnots = pPage->GetMutableAnnotsArray();
374 for (size_t i = *start_pos; i < pAnnots->size(); i++) {
376 ToDictionary(pAnnots->GetMutableDirectObjectAt(i));
379 if (pDict->GetByteStringFor(
"Subtype") ==
"Link") {
380 *start_pos =
static_cast<
int>(i + 1);
381 *link_annot = FPDFLinkFromCPDFDictionary(pDict.Get());
391 RetainPtr<CPDF_Dictionary> pAnnotDict(CPDFDictionaryFromFPDFLink(link_annot));
392 if (!pPage || !pAnnotDict)
399 return FPDFAnnotationFromCPDFAnnotContext(pAnnotContext.release());
404 if (!link_annot || !rect)
414 GetQuadPointsArrayFromDictionary(CPDFDictionaryFromFPDFLink(link_annot));
415 return pArray ?
static_cast<
int>(pArray->size() / 8) : 0;
421 FS_QUADPOINTSF* quad_points) {
422 if (!quad_points || quad_index < 0)
430 GetQuadPointsArrayFromDictionary(pLinkDict);
434 return GetQuadPointsAtIndex(std::move(pArray),
435 static_cast<size_t>(quad_index), quad_points);
462 FPDF_FILEIDTYPE id_type,
464 unsigned long buflen) {
470 if (id_type != FILEIDTYPE_PERMANENT && id_type != FILEIDTYPE_CHANGING)
473 RetainPtr<
const CPDF_Array> pFileId = pDoc->GetFileIdentifier();
477 size_t nIndex = id_type == FILEIDTYPE_PERMANENT ? 0 : 1;
479 ToString(pFileId->GetDirectObjectAt(nIndex));
483 return NulTerminateMaybeCopyAndReturnLength(pValue->GetString(), buffer,
490 unsigned long buflen) {
497 RetainPtr<
const CPDF_Dictionary> pInfo = pDoc->GetInfo();
501 WideString text = pInfo->GetUnicodeTextFor(tag);
509 unsigned long buflen) {
515 absl::optional<WideString> str = label.GetLabel(page_index);
516 return str.has_value()
517 ? Utf16EncodeMaybeCopyAndReturnLength(str.value(), buffer, buflen)
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
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
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 *pDocument)
CPDF_Document * GetDocument() const override
const char * c_str() const
ByteString ToUTF8() const
const wchar_t * c_str() const
int CompareNoCase(const wchar_t *str) const
WideString WideStringFromFPDFWideString(FPDF_WIDESTRING wide_string)
unsigned long NulTerminateMaybeCopyAndReturnLength(const ByteString &text, void *buffer, unsigned long buflen)
FPDF_DEST FPDFDestFromCPDFArray(const CPDF_Array *dest)
IPDF_Page * IPDFPageFromFPDFPage(FPDF_PAGE page)
CPDF_Array * CPDFArrayFromFPDFDest(FPDF_DEST dest)
unsigned long Utf16EncodeMaybeCopyAndReturnLength(const WideString &text, void *buffer, unsigned long buflen)
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