summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfdoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/fpdfdoc.cpp')
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp67
1 files changed, 37 insertions, 30 deletions
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index 4e2e7f3d0b..ffdad281c6 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -52,9 +52,9 @@ CPDF_LinkList* GetLinkList(CPDF_Page* page) {
DLLEXPORT FPDF_BOOKMARK STDCALL
FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
- if (!document)
- return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+ if (!pDoc)
+ return nullptr;
CPDF_BookmarkTree tree(pDoc);
CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict);
return tree.GetFirstChild(bookmark).GetDict();
@@ -62,9 +62,11 @@ FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
DLLEXPORT FPDF_BOOKMARK STDCALL
FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
- if (!document || !pDict)
- return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ if (!pDict)
+ return nullptr;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+ if (!pDoc)
+ return nullptr;
CPDF_BookmarkTree tree(pDoc);
CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict);
return tree.GetNextSibling(bookmark).GetDict();
@@ -87,11 +89,11 @@ DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict,
DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document,
FPDF_WIDESTRING title) {
- if (!document)
- return NULL;
if (!title || title[0] == 0)
- return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ return nullptr;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+ if (!pDoc)
+ return nullptr;
CPDF_BookmarkTree tree(pDoc);
FX_STRSIZE len = CFX_WideString::WStringLength(title);
CFX_WideString encodedTitle = CFX_WideString::FromUTF16LE(title, len);
@@ -100,12 +102,12 @@ DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document,
DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
FPDF_BOOKMARK pDict) {
- if (!document)
- return NULL;
if (!pDict)
- return NULL;
+ return nullptr;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+ if (!pDoc)
+ return nullptr;
CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
- CPDF_Document* pDoc = (CPDF_Document*)document;
CPDF_Dest dest = bookmark.GetDest(pDoc);
if (dest)
return dest.GetObject();
@@ -113,7 +115,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
// action
CPDF_Action action = bookmark.GetAction();
if (!action)
- return NULL;
+ return nullptr;
return action.GetDest(pDoc).GetObject();
}
@@ -146,10 +148,11 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) {
DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document,
FPDF_ACTION pDict) {
- if (!document || !pDict)
+ if (!pDict)
+ return nullptr;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+ if (!pDoc)
return nullptr;
-
- CPDF_Document* pDoc = (CPDF_Document*)document;
CPDF_Action action((CPDF_Dictionary*)pDict);
return action.GetDest(pDoc).GetObject();
}
@@ -172,10 +175,11 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document,
FPDF_ACTION pDict,
void* buffer,
unsigned long buflen) {
- if (!document || !pDict)
+ if (!pDict)
+ return 0;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+ if (!pDoc)
return 0;
-
- CPDF_Document* pDoc = (CPDF_Document*)document;
CPDF_Action action((CPDF_Dictionary*)pDict);
CFX_ByteString path = action.GetURI(pDoc);
unsigned long len = path.GetLength() + 1;
@@ -186,10 +190,11 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document,
DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document,
FPDF_DEST pDict) {
- if (!document || !pDict)
+ if (!pDict)
+ return 0;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+ if (!pDoc)
return 0;
-
- CPDF_Document* pDoc = (CPDF_Document*)document;
CPDF_Dest dest((CPDF_Array*)pDict);
return dest.GetPageIndex(pDoc);
}
@@ -219,10 +224,11 @@ FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y) {
DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
FPDF_LINK pDict) {
- if (!document || !pDict)
+ if (!pDict)
+ return nullptr;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+ if (!pDoc)
return nullptr;
-
- CPDF_Document* pDoc = (CPDF_Document*)document;
CPDF_Link link((CPDF_Dictionary*)pDict);
FPDF_DEST dest = link.GetDest(pDoc).GetObject();
if (dest)
@@ -317,10 +323,11 @@ DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc,
FPDF_BYTESTRING tag,
void* buffer,
unsigned long buflen) {
- if (!doc || !tag)
+ if (!tag)
+ return 0;
+ CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(doc);
+ if (!pDoc)
return 0;
- CPDF_Document* pDoc = (CPDF_Document*)doc;
- // Get info dictionary
CPDF_Dictionary* pInfo = pDoc->GetInfo();
if (!pInfo)
return 0;