summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-20 13:30:34 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-20 13:30:34 -0400
commit937840e1722d1f2b77d80575d6e710d760662c9c (patch)
treeff065615d6d91abe8e5c788da3a08386fc2d25d6 /fpdfsdk/src
parentc29bee029cd5fe3f8a4ceb580235ac2d0e5ce8fd (diff)
downloadpdfium-937840e1722d1f2b77d80575d6e710d760662c9c.tar.xz
Revert "Add type cast definitions for CPDF_Dictionary."
This reverts commit 4816432671eef6467354aa252f22bb80acc315b7. Reason, broke the javascript_test Rendering PDF file /mnt/data/b/build/slave/linux/build/pdfium/out/Debug/gen/pdfium/testing/javascript/document_methods.pdf. Non-linearized path... FAILURE: document_methods.in; Command '['/mnt/data/b/build/slave/linux/build/pdfium/out/Debug/pdfium_test', '/mnt/data/b/build/slave/linux/build/pdfium/out/Debug/gen/pdfium/testing/javascript/document_methods.pdf']' returned non-zero exit status -11 BUG=pdfium:201 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1412413002 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp8
-rw-r--r--fpdfsdk/src/formfiller/FFL_Utils.cpp2
-rw-r--r--fpdfsdk/src/fpdf_flatten.cpp5
-rw-r--r--fpdfsdk/src/fpdf_transformpage.cpp4
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp38
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp7
-rw-r--r--fpdfsdk/src/fpdfppo.cpp18
-rw-r--r--fpdfsdk/src/fpdfview.cpp4
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp3
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp3
10 files changed, 49 insertions, 43 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
index 147a0588cc..3a8853cb24 100644
--- a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
+++ b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
@@ -137,9 +137,11 @@ CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict,
if (pObj == NULL)
continue;
- CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
- if (!pElement)
+ CPDF_Object* pDirect = pObj->GetDirect();
+ if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY)
continue;
+
+ CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
if (pElement->GetString("Type") != "Font")
continue;
@@ -179,7 +181,7 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
// to avoid checkbox and radiobutton
CPDF_Object* pObject = pAPDict->GetElement(m_sAPType);
- if (ToDictionary(pObject))
+ if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY)
return;
CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType);
diff --git a/fpdfsdk/src/formfiller/FFL_Utils.cpp b/fpdfsdk/src/formfiller/FFL_Utils.cpp
index a4463b7242..d2ce56ac52 100644
--- a/fpdfsdk/src/formfiller/FFL_Utils.cpp
+++ b/fpdfsdk/src/formfiller/FFL_Utils.cpp
@@ -51,7 +51,7 @@ FX_BOOL CFFL_Utils::TraceObject(CPDF_Object* pObj) {
} break;
case PDFOBJ_DICTIONARY: {
- CPDF_Dictionary* pDict = pObj->AsDictionary();
+ CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
FX_POSITION fPos = pDict->GetStartPos();
CFX_ByteString csKey;
diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp
index fee93f2663..b2303f36aa 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -94,10 +94,11 @@ int ParserAnnots(CPDF_Document* pSourceDoc,
FX_DWORD dwSize = pAnnots->GetCount();
for (int i = 0; i < (int)dwSize; i++) {
- CPDF_Dictionary* pAnnotDic = ToDictionary(pAnnots->GetElementValue(i));
- if (!pAnnotDic)
+ CPDF_Object* pObj = pAnnots->GetElementValue(i);
+ if (!pObj || pObj->GetType() != PDFOBJ_DICTIONARY)
continue;
+ CPDF_Dictionary* pAnnotDic = (CPDF_Dictionary*)pObj;
CFX_ByteString sSubtype = pAnnotDic->GetString("Subtype");
if (sSubtype == "Popup")
continue;
diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp
index 1e24b68f08..cdc646ae7e 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -166,8 +166,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key);
if (pObj->GetType() == PDFOBJ_REFERENCE)
pObj = pObj->GetDirect();
- if (pObj->IsDictionary()) {
- pDict = pObj->AsDictionary();
+ if (pObj->GetType() == PDFOBJ_DICTIONARY) {
+ pDict = (CPDF_Dictionary*)pObj;
} else if (pObj->GetType() == PDFOBJ_STREAM) {
pDict = ((CPDF_Stream*)pObj)->GetDict();
} else
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index ad8ef8bea3..b770295604 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -56,8 +56,7 @@ FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
if (!pDoc)
return nullptr;
CPDF_BookmarkTree tree(pDoc);
- CPDF_Bookmark bookmark =
- CPDF_Bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict);
return tree.GetFirstChild(bookmark).GetDict();
}
@@ -69,8 +68,7 @@ FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
if (!pDoc)
return nullptr;
CPDF_BookmarkTree tree(pDoc);
- CPDF_Bookmark bookmark =
- CPDF_Bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict);
return tree.GetNextSibling(bookmark).GetDict();
}
@@ -79,7 +77,7 @@ DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict,
unsigned long buflen) {
if (!pDict)
return 0;
- CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
CFX_WideString title = bookmark.GetTitle();
CFX_ByteString encodedTitle = title.UTF16LE_Encode();
unsigned long len = encodedTitle.GetLength();
@@ -109,7 +107,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
- CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
CPDF_Dest dest = bookmark.GetDest(pDoc);
if (dest)
return dest.GetObject();
@@ -124,7 +122,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(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
return bookmark.GetAction().GetDict();
}
@@ -132,7 +130,7 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) {
if (!pDict)
return PDFACTION_UNSUPPORTED;
- CPDF_Action action(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Action action((CPDF_Dictionary*)pDict);
CPDF_Action::ActionType type = action.GetType();
switch (type) {
case CPDF_Action::GoTo:
@@ -155,7 +153,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
- CPDF_Action action(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Action action((CPDF_Dictionary*)pDict);
return action.GetDest(pDoc).GetObject();
}
@@ -165,7 +163,7 @@ FPDFAction_GetFilePath(FPDF_ACTION pDict, void* buffer, unsigned long buflen) {
if (type != PDFACTION_REMOTEGOTO && type != PDFACTION_LAUNCH)
return 0;
- CPDF_Action action(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Action action((CPDF_Dictionary*)pDict);
CFX_ByteString path = action.GetFilePath().UTF8Encode();
unsigned long len = path.GetLength() + 1;
if (buffer && buflen >= len)
@@ -182,7 +180,7 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return 0;
- CPDF_Action action(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Action action((CPDF_Dictionary*)pDict);
CFX_ByteString path = action.GetURI(pDoc);
unsigned long len = path.GetLength() + 1;
if (buffer && buflen >= len)
@@ -237,7 +235,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
- CPDF_Link link(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Link link((CPDF_Dictionary*)pDict);
FPDF_DEST dest = link.GetDest(pDoc).GetObject();
if (dest)
return dest;
@@ -252,7 +250,7 @@ DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) {
if (!pDict)
return nullptr;
- CPDF_Link link(ToDictionary(static_cast<CPDF_Object*>(pDict)));
+ CPDF_Link link((CPDF_Dictionary*)pDict);
return link.GetAction().GetDict();
}
@@ -268,9 +266,8 @@ 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 =
- ToDictionary(static_cast<CPDF_Object*>(pAnnots->GetElementValue(i)));
- if (!pDict)
+ CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i);
+ if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY)
continue;
if (pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) {
*startPos = i + 1;
@@ -285,8 +282,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot,
FS_RECTF* rect) {
if (!linkAnnot || !rect)
return FALSE;
- CPDF_Dictionary* pAnnotDict =
- ToDictionary(static_cast<CPDF_Object*>(linkAnnot));
+ CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect"));
rect->left = rt.left;
rect->bottom = rt.bottom;
@@ -298,8 +294,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot,
DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) {
if (!linkAnnot)
return 0;
- CPDF_Dictionary* pAnnotDict =
- ToDictionary(static_cast<CPDF_Object*>(linkAnnot));
+ CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
if (!pArray)
return 0;
@@ -311,8 +306,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot,
FS_QUADPOINTSF* quadPoints) {
if (!linkAnnot || !quadPoints)
return FALSE;
- CPDF_Dictionary* pAnnotDict =
- ToDictionary(static_cast<CPDF_Object*>(linkAnnot));
+ CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
if (pArray) {
if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount() / 8 ||
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index 7b70526b0c..f2d13d6ba1 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -103,7 +103,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
else {
if (pDict->KeyExist("Parent")) {
CPDF_Dictionary* pPages =
- ToDictionary(pDict->GetElement("Parent")->GetDirect());
+ (CPDF_Dictionary*)pDict->GetElement("Parent")->GetDirect();
while (pPages) {
if (pPages->KeyExist("Rotate")) {
rotate =
@@ -113,7 +113,8 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
: 0;
break;
} else if (pPages->KeyExist("Parent"))
- pPages = ToDictionary(pPages->GetElement("Parent")->GetDirect());
+ pPages =
+ (CPDF_Dictionary*)pPages->GetElement("Parent")->GetDirect();
else
break;
}
@@ -212,7 +213,7 @@ FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
return TRUE;
CPDF_Dictionary* pSMaskDict =
- pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : NULL;
+ pGeneralState ? (CPDF_Dictionary*)pGeneralState->m_pSoftMask : NULL;
if (pSMaskDict)
return TRUE;
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index ab25b76934..2508adca7b 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -60,7 +60,7 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc,
CPDF_Object* pElement = pNewRoot->GetElement("Pages");
CPDF_Dictionary* pNewPages =
- pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
+ pElement ? (CPDF_Dictionary*)pElement->GetDirect() : nullptr;
if (!pNewPages) {
pNewPages = new CPDF_Dictionary;
FX_DWORD NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages);
@@ -183,13 +183,14 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
if (pType->GetString().Compare("Page"))
return nullptr;
- CPDF_Dictionary* pp = ToDictionary(pDict->GetElement("Parent")->GetDirect());
- if (!pp)
+ CPDF_Object* pParent = pDict->GetElement("Parent")->GetDirect();
+ if (!pParent || pParent->GetType() != PDFOBJ_DICTIONARY)
return nullptr;
if (pDict->KeyExist((const char*)nSrctag))
return pDict->GetElement((const char*)nSrctag);
+ CPDF_Dictionary* pp = (CPDF_Dictionary*)pParent;
while (pp) {
if (pp->KeyExist((const char*)nSrctag)) {
return pp->GetElement((const char*)nSrctag);
@@ -197,8 +198,12 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
if (!pp->KeyExist("Parent")) {
break;
}
- pp = ToDictionary(pp->GetElement("Parent")->GetDirect());
+ pp = (CPDF_Dictionary*)pp->GetElement("Parent")->GetDirect();
+ if (pp->GetType() == PDFOBJ_NULL) {
+ break;
+ }
}
+
return nullptr;
}
@@ -215,7 +220,7 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
break;
}
case PDFOBJ_DICTIONARY: {
- CPDF_Dictionary* pDict = pObj->AsDictionary();
+ CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
FX_POSITION pos = pDict->GetStartPos();
while (pos) {
@@ -286,7 +291,8 @@ FX_DWORD CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
if (!pClone)
return 0;
- if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) {
+ if (pClone->GetType() == PDFOBJ_DICTIONARY) {
+ CPDF_Dictionary* pDictClone = (CPDF_Dictionary*)pClone;
if (pDictClone->KeyExist("Type")) {
CFX_ByteString strType = pDictClone->GetString("Type");
if (!FXSYS_stricmp(strType, "Pages")) {
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 0d6dcf29f1..19faea5cc9 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -882,8 +882,8 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
}
if (!pDestObj)
return NULL;
- if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) {
- pDestObj = pDict->GetArray(FX_BSTRC("D"));
+ if (pDestObj->GetType() == PDFOBJ_DICTIONARY) {
+ pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D"));
if (!pDestObj)
return NULL;
}
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index b4aa822bb6..7d0346c797 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -65,7 +65,8 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
return psub->GetType() == PDFOBJ_STREAM;
case FIELDTYPE_CHECKBOX:
case FIELDTYPE_RADIOBUTTON:
- if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) {
+ if (psub->GetType() == PDFOBJ_DICTIONARY) {
+ CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)psub;
return pSubDict->GetStream(GetAppState()) != NULL;
}
return FALSE;
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index fccfbe9aa2..5d765a495d 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -482,7 +482,8 @@ FX_BOOL CPDFSDK_Document::ProcOpenAction() {
if (pOpenAction->GetType() == PDFOBJ_ARRAY)
return TRUE;
- if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) {
+ if (pOpenAction->GetType() == PDFOBJ_DICTIONARY) {
+ CPDF_Dictionary* pDict = (CPDF_Dictionary*)pOpenAction;
CPDF_Action action(pDict);
if (m_pEnv->GetActionHander())
m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);