diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-10-15 16:17:18 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-10-15 16:17:18 -0700 |
commit | 471a1034e70ddcfc93ce2a93b28a8385109e83de (patch) | |
tree | c845fb1b73b936023be1fc2e7699ff4768aec652 /fpdfsdk/src/fpdfdoc.cpp | |
parent | dfbf8e7ba55695c4e6cb30eadbe9c6a2955815ba (diff) | |
download | pdfium-471a1034e70ddcfc93ce2a93b28a8385109e83de.tar.xz |
Merge to XFA: Introduce CPDF_DocumentFromFPDFDocument().
Manual merges everywhere.
Original Review URL: https://codereview.chromium.org/1395493007 .
(cherry picked from commit bb51c4fb6bc6095984c303c95e5336f83e66bc67)
Original Review URL: https://codereview.chromium.org/1396283006 .
(cherry picked from commit 86adb658843658969041a13bf6cf0cc950ffe8ed)
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1395353004 .
Diffstat (limited to 'fpdfsdk/src/fpdfdoc.cpp')
-rw-r--r-- | fpdfsdk/src/fpdfdoc.cpp | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp index 568622b842..d4b6b08ff3 100644 --- a/fpdfsdk/src/fpdfdoc.cpp +++ b/fpdfsdk/src/fpdfdoc.cpp @@ -54,9 +54,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 = ((CPDFXFA_Document*)document)->GetPDFDoc(); + CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) + return nullptr; CPDF_BookmarkTree tree(pDoc); CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict); return tree.GetFirstChild(bookmark).GetDict(); @@ -64,9 +64,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 = ((CPDFXFA_Document*)document)->GetPDFDoc(); + if (!pDict) + return nullptr; + CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) + return nullptr; CPDF_BookmarkTree tree(pDoc); CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict); return tree.GetNextSibling(bookmark).GetDict(); @@ -89,11 +91,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 = ((CPDFXFA_Document*)document)->GetPDFDoc(); + return nullptr; + CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) + return nullptr; CPDF_BookmarkTree tree(pDoc); FX_STRSIZE len = CFX_WideString::WStringLength(title); CFX_WideString encodedTitle = CFX_WideString::FromUTF16LE(title, len); @@ -102,12 +104,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 = CPDFDocumentFromFPDFDocument(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(); @@ -115,7 +117,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(); } @@ -148,10 +150,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 = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) return nullptr; - - CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); CPDF_Action action((CPDF_Dictionary*)pDict); return action.GetDest(pDoc).GetObject(); } @@ -174,10 +177,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 = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) return 0; - - CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); CPDF_Action action((CPDF_Dictionary*)pDict); CFX_ByteString path = action.GetURI(pDoc); unsigned long len = path.GetLength() + 1; @@ -188,10 +192,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 = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) return 0; - - CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); CPDF_Dest dest((CPDF_Array*)pDict); return dest.GetPageIndex(pDoc); } @@ -229,10 +234,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 = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) return nullptr; - - CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); CPDF_Link link((CPDF_Dictionary*)pDict); FPDF_DEST dest = link.GetDest(pDoc).GetObject(); if (dest) @@ -327,10 +333,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 = CPDFDocumentFromFPDFDocument(doc); + if (!pDoc) return 0; - CPDF_Document* pDoc = ((CPDFXFA_Document*)doc)->GetPDFDoc(); - // Get info dictionary CPDF_Dictionary* pInfo = pDoc->GetInfo(); if (!pInfo) return 0; |