summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfdoc.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-20 16:24:45 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-20 16:24:45 -0400
commitf1251c1ff2b3452854681d0648b4c1ca4180ff0d (patch)
treedbcff41b8f8a5ea3d1d5280ff0c946b9647c301a /fpdfsdk/src/fpdfdoc.cpp
parent49f88b708d905b052bc00769ac7cb48202cac019 (diff)
downloadpdfium-f1251c1ff2b3452854681d0648b4c1ca4180ff0d.tar.xz
[Merge to XFA] Revert "Revert "Add type cast definitions for CPDF_Dictionary.""
This reverts commit 937840e1722d1f2b77d80575d6e710d760662c9c. Add type cast definitions for CPDF_Dictionary. This CL adds ToCPDFDictionary type definitions and updates one file to use instead of straight casts. I had to fix two places where we'd casted off the constness of the original pointer. BUG=pdfium:201 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1420583003 . (cherry picked from commit 39869b641511c882d78e17548293cdb458c36f38) Review URL: https://codereview.chromium.org/1410343003 .
Diffstat (limited to 'fpdfsdk/src/fpdfdoc.cpp')
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index b770295604..ad8ef8bea3 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -56,7 +56,8 @@ FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
if (!pDoc)
return nullptr;
CPDF_BookmarkTree tree(pDoc);
- CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict);
+ CPDF_Bookmark bookmark =
+ CPDF_Bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
return tree.GetFirstChild(bookmark).GetDict();
}
@@ -68,7 +69,8 @@ FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
if (!pDoc)
return nullptr;
CPDF_BookmarkTree tree(pDoc);
- CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict);
+ CPDF_Bookmark bookmark =
+ CPDF_Bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
return tree.GetNextSibling(bookmark).GetDict();
}
@@ -77,7 +79,7 @@ DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict,
unsigned long buflen) {
if (!pDict)
return 0;
- CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
+ CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
CFX_WideString title = bookmark.GetTitle();
CFX_ByteString encodedTitle = title.UTF16LE_Encode();
unsigned long len = encodedTitle.GetLength();
@@ -107,7 +109,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
- CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
+ CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
CPDF_Dest dest = bookmark.GetDest(pDoc);
if (dest)
return dest.GetObject();
@@ -122,7 +124,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) {
if (!pDict)
return NULL;
- CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
+ CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
return bookmark.GetAction().GetDict();
}
@@ -130,7 +132,7 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) {
if (!pDict)
return PDFACTION_UNSUPPORTED;
- CPDF_Action action((CPDF_Dictionary*)pDict);
+ CPDF_Action action(ToDictionary(static_cast<CPDF_Object*>(pDict)));
CPDF_Action::ActionType type = action.GetType();
switch (type) {
case CPDF_Action::GoTo:
@@ -153,7 +155,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
- CPDF_Action action((CPDF_Dictionary*)pDict);
+ CPDF_Action action(ToDictionary(static_cast<CPDF_Object*>(pDict)));
return action.GetDest(pDoc).GetObject();
}
@@ -163,7 +165,7 @@ FPDFAction_GetFilePath(FPDF_ACTION pDict, void* buffer, unsigned long buflen) {
if (type != PDFACTION_REMOTEGOTO && type != PDFACTION_LAUNCH)
return 0;
- CPDF_Action action((CPDF_Dictionary*)pDict);
+ CPDF_Action action(ToDictionary(static_cast<CPDF_Object*>(pDict)));
CFX_ByteString path = action.GetFilePath().UTF8Encode();
unsigned long len = path.GetLength() + 1;
if (buffer && buflen >= len)
@@ -180,7 +182,7 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return 0;
- CPDF_Action action((CPDF_Dictionary*)pDict);
+ CPDF_Action action(ToDictionary(static_cast<CPDF_Object*>(pDict)));
CFX_ByteString path = action.GetURI(pDoc);
unsigned long len = path.GetLength() + 1;
if (buffer && buflen >= len)
@@ -235,7 +237,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
- CPDF_Link link((CPDF_Dictionary*)pDict);
+ CPDF_Link link(ToDictionary(static_cast<CPDF_Object*>(pDict)));
FPDF_DEST dest = link.GetDest(pDoc).GetObject();
if (dest)
return dest;
@@ -250,7 +252,7 @@ DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) {
if (!pDict)
return nullptr;
- CPDF_Link link((CPDF_Dictionary*)pDict);
+ CPDF_Link link(ToDictionary(static_cast<CPDF_Object*>(pDict)));
return link.GetAction().GetDict();
}
@@ -266,8 +268,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page,
if (!pAnnots)
return FALSE;
for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) {
- CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i);
- if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY)
+ CPDF_Dictionary* pDict =
+ ToDictionary(static_cast<CPDF_Object*>(pAnnots->GetElementValue(i)));
+ if (!pDict)
continue;
if (pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) {
*startPos = i + 1;
@@ -282,7 +285,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot,
FS_RECTF* rect) {
if (!linkAnnot || !rect)
return FALSE;
- CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
+ CPDF_Dictionary* pAnnotDict =
+ ToDictionary(static_cast<CPDF_Object*>(linkAnnot));
CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect"));
rect->left = rt.left;
rect->bottom = rt.bottom;
@@ -294,7 +298,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot,
DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) {
if (!linkAnnot)
return 0;
- CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
+ CPDF_Dictionary* pAnnotDict =
+ ToDictionary(static_cast<CPDF_Object*>(linkAnnot));
CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
if (!pArray)
return 0;
@@ -306,7 +311,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot,
FS_QUADPOINTSF* quadPoints) {
if (!linkAnnot || !quadPoints)
return FALSE;
- CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
+ CPDF_Dictionary* pAnnotDict =
+ ToDictionary(static_cast<CPDF_Object*>(linkAnnot));
CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
if (pArray) {
if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount() / 8 ||