diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-20 13:30:34 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-20 13:30:34 -0400 |
commit | 937840e1722d1f2b77d80575d6e710d760662c9c (patch) | |
tree | ff065615d6d91abe8e5c788da3a08386fc2d25d6 /core/src/fpdfdoc | |
parent | c29bee029cd5fe3f8a4ceb580235ac2d0e5ce8fd (diff) | |
download | pdfium-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 'core/src/fpdfdoc')
-rw-r--r-- | core/src/fpdfdoc/doc_action.cpp | 20 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_annot.cpp | 10 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_basic.cpp | 49 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_form.cpp | 26 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formcontrol.cpp | 14 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_ocg.cpp | 15 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_tagged.cpp | 18 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_utils.cpp | 49 |
8 files changed, 116 insertions, 85 deletions
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp index 409d050484..759a06c656 100644 --- a/core/src/fpdfdoc/doc_action.cpp +++ b/core/src/fpdfdoc/doc_action.cpp @@ -251,10 +251,13 @@ CPDF_Action CPDF_Action::GetSubAction(FX_DWORD iIndex) const { return CPDF_Action(); } CPDF_Object* pNext = m_pDict->GetElementValue("Next"); - if (CPDF_Dictionary* pDict = ToDictionary(pNext)) { - if (iIndex == 0) + int iObjType = pNext->GetType(); + if (iObjType == PDFOBJ_DICTIONARY) { + CPDF_Dictionary* pDict = static_cast<CPDF_Dictionary*>(pNext); + if (iIndex == 0) { return CPDF_Action(pDict); - } else if (pNext->GetType() == PDFOBJ_ARRAY) { + } + } else if (iObjType == PDFOBJ_ARRAY) { CPDF_Array* pArray = static_cast<CPDF_Array*>(pNext); return CPDF_Action(pArray->GetDict(iIndex)); } @@ -292,10 +295,9 @@ CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos, return CPDF_Action(); } CPDF_Object* pDirect = pObj->GetDirect(); - CPDF_Dictionary* pDict = ToDictionary(pDirect); - if (!pDict) + if (!pDirect || pDirect->GetType() != PDFOBJ_DICTIONARY) { return CPDF_Action(); - + } int i = 0; while (g_sAATypes[i][0] != '\0') { if (csKey == g_sAATypes[i]) { @@ -304,7 +306,7 @@ CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos, i++; } eType = (AActionType)i; - return CPDF_Action(pDict); + return CPDF_Action(static_cast<CPDF_Dictionary*>(pDirect)); } CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) { m_pDocument = pDoc; @@ -319,7 +321,7 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(int index, ASSERT(m_pDocument != NULL); CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript")); CPDF_Object* pAction = name_tree.LookupValue(index, csName); - if (!ToDictionary(pAction)) { + if (pAction == NULL || pAction->GetType() != PDFOBJ_DICTIONARY) { return CPDF_Action(); } return CPDF_Action(pAction->GetDict()); @@ -328,7 +330,7 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { ASSERT(m_pDocument != NULL); CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript")); CPDF_Object* pAction = name_tree.LookupValue(csName); - if (!ToDictionary(pAction)) { + if (pAction == NULL || pAction->GetType() != PDFOBJ_DICTIONARY) { return CPDF_Action(); } return CPDF_Action(pAction->GetDict()); diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp index 4d0b703036..6f5ff797f2 100644 --- a/core/src/fpdfdoc/doc_annot.cpp +++ b/core/src/fpdfdoc/doc_annot.cpp @@ -23,8 +23,8 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) { CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); FX_BOOL bRegenerateAP = pAcroForm && pAcroForm->GetBoolean("NeedAppearances"); for (FX_DWORD i = 0; i < pAnnots->GetCount(); ++i) { - CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetElementValue(i)); - if (!pDict) { + CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); + if (pDict == NULL || pDict->GetType() != PDFOBJ_DICTIONARY) { continue; } FX_DWORD dwObjNum = pDict->GetObjNum(); @@ -202,7 +202,7 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Stream* pStream = NULL; if (psub->GetType() == PDFOBJ_STREAM) { pStream = (CPDF_Stream*)psub; - } else if (CPDF_Dictionary* pDict = psub->AsDictionary()) { + } else if (psub->GetType() == PDFOBJ_DICTIONARY) { CFX_ByteString as = pAnnotDict->GetString("AS"); if (as.IsEmpty()) { CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V")); @@ -210,13 +210,13 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent")); value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString(); } - if (value.IsEmpty() || !pDict->KeyExist(value)) { + if (value.IsEmpty() || !((CPDF_Dictionary*)psub)->KeyExist(value)) { as = FX_BSTRC("Off"); } else { as = value; } } - pStream = pDict->GetStream(as); + pStream = ((CPDF_Dictionary*)psub)->GetStream(as); } return pStream; } diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp index e3b630862c..39b5788c86 100644 --- a/core/src/fpdfdoc/doc_basic.cpp +++ b/core/src/fpdfdoc/doc_basic.cpp @@ -17,7 +17,7 @@ int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) { if (pPage->GetType() == PDFOBJ_NUMBER) { return pPage->GetInteger(); } - if (!pPage->IsDictionary()) { + if (pPage->GetType() != PDFOBJ_DICTIONARY) { return 0; } return pDoc->GetPageIndex(pPage->GetObjNum()); @@ -33,7 +33,7 @@ FX_DWORD CPDF_Dest::GetPageObjNum() { if (pPage->GetType() == PDFOBJ_NUMBER) { return pPage->GetInteger(); } - if (pPage->IsDictionary()) { + if (pPage->GetType() == PDFOBJ_DICTIONARY) { return pPage->GetObjNum(); } return 0; @@ -243,8 +243,8 @@ CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc, if (pValue->GetType() == PDFOBJ_ARRAY) { return (CPDF_Array*)pValue; } - if (CPDF_Dictionary* pDict = pValue->AsDictionary()) { - return pDict->GetArray(FX_BSTRC("D")); + if (pValue->GetType() == PDFOBJ_DICTIONARY) { + return ((CPDF_Dictionary*)pValue)->GetArray(FX_BSTRC("D")); } return NULL; } @@ -311,10 +311,11 @@ static CFX_WideString FILESPEC_DecodeFileName(const CFX_WideStringC& filepath) { #endif } FX_BOOL CPDF_FileSpec::GetFileName(CFX_WideString& csFileName) const { - if (!m_pObj) { + if (m_pObj == NULL) { return FALSE; } - if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { + if (m_pObj->GetType() == PDFOBJ_DICTIONARY) { + CPDF_Dictionary* pDict = (CPDF_Dictionary*)m_pObj; csFileName = pDict->GetUnicodeText(FX_BSTRC("UF")); if (csFileName.IsEmpty()) { csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F"))); @@ -344,15 +345,20 @@ FX_BOOL CPDF_FileSpec::GetFileName(CFX_WideString& csFileName) const { } CPDF_FileSpec::CPDF_FileSpec() { m_pObj = CPDF_Dictionary::Create(); - if (CPDF_Dictionary* pDict = ToDictionary(m_pObj)) { - pDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Filespec")); + if (m_pObj != NULL) { + ((CPDF_Dictionary*)m_pObj) + ->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Filespec")); } } FX_BOOL CPDF_FileSpec::IsURL() const { - if (CPDF_Dictionary* pDict = ToDictionary(m_pObj)) { - return pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL"); + if (m_pObj == NULL) { + return FALSE; + } + if (m_pObj->GetType() != PDFOBJ_DICTIONARY) { + return FALSE; } - return FALSE; + return ((CPDF_Dictionary*)m_pObj)->GetString(FX_BSTRC("FS")) == + FX_BSTRC("URL"); } CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath) { if (filepath.GetLength() <= 1) { @@ -396,10 +402,15 @@ CPDF_Stream* CPDF_FileSpec::GetFileStream() const { return NULL; } int32_t iType = m_pObj->GetType(); - if (iType == PDFOBJ_STREAM) + if (iType == PDFOBJ_STREAM) { return (CPDF_Stream*)m_pObj; - if (CPDF_Dictionary* pEF = m_pObj->AsDictionary()->GetDict(FX_BSTRC("EF"))) + } else if (iType == PDFOBJ_DICTIONARY) { + CPDF_Dictionary* pEF = ((CPDF_Dictionary*)m_pObj)->GetDict(FX_BSTRC("EF")); + if (pEF == NULL) { + return NULL; + } return pEF->GetStream(FX_BSTRC("F")); + } return NULL; } static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object* pObj, @@ -415,7 +426,8 @@ static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object* pObj, int32_t iType = pObj->GetType(); if (iType == PDFOBJ_STRING) { pObj->SetString(CFX_ByteString::FromUnicode(wsStr)); - } else if (CPDF_Dictionary* pDict = pObj->AsDictionary()) { + } else if (iType == PDFOBJ_DICTIONARY) { + CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj; pDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(wsStr)); pDict->SetAtString(FX_BSTRC("UF"), PDF_EncodeText(wsStr)); } @@ -423,10 +435,8 @@ static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object* pObj, void CPDF_FileSpec::SetFileName(const CFX_WideStringC& wsFileName, FX_BOOL bURL) { ASSERT(m_pObj != NULL); - if (bURL) { - if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { - pDict->SetAtName(FX_BSTRC("FS"), "URL"); - } + if (m_pObj->GetType() == PDFOBJ_DICTIONARY && bURL) { + ((CPDF_Dictionary*)m_pObj)->SetAtName(FX_BSTRC("FS"), "URL"); } FPDFDOC_FILESPEC_SetFileName(m_pObj, wsFileName, bURL); } @@ -507,7 +517,8 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { } if (pValue != NULL) { pValue = pValue->GetDirect(); - if (CPDF_Dictionary* pLabel = pValue->AsDictionary()) { + if (pValue->GetType() == PDFOBJ_DICTIONARY) { + CPDF_Dictionary* pLabel = (CPDF_Dictionary*)pValue; if (pLabel->KeyExist(FX_BSTRC("P"))) { wsLabel += pLabel->GetUnicodeText(FX_BSTRC("P")); } diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 8078608883..17f1808444 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -854,9 +854,9 @@ CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { if (pArray == NULL) { return NULL; } - if (CPDF_Dictionary* pElement = - ToDictionary(pArray->GetElementValue(index))) { - return GetFieldByDict(pElement); + CPDF_Object* pElement = pArray->GetElementValue(index); + if (pElement != NULL && pElement->GetType() == PDFOBJ_DICTIONARY) { + return GetFieldByDict((CPDF_Dictionary*)pElement); } return NULL; } @@ -1049,24 +1049,25 @@ void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) { } } } -CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { +CPDF_FormField* CPDF_InterForm::AddTerminalField( + const CPDF_Dictionary* pFieldDict) { if (!pFieldDict->KeyExist(FX_BSTRC("T"))) { return NULL; } - CPDF_Dictionary* pDict = pFieldDict; - CFX_WideString csWName = GetFullName(pFieldDict); + CPDF_Dictionary* pDict = (CPDF_Dictionary*)pFieldDict; + CFX_WideString csWName = GetFullName(pDict); if (csWName.IsEmpty()) { return NULL; } CPDF_FormField* pField = NULL; pField = m_pFieldTree->GetField(csWName); if (pField == NULL) { - CPDF_Dictionary* pParent = pFieldDict; + CPDF_Dictionary* pParent = (CPDF_Dictionary*)pFieldDict; if (!pFieldDict->KeyExist(FX_BSTRC("T")) && pFieldDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget")) { pParent = pFieldDict->GetDict(FX_BSTRC("Parent")); if (!pParent) { - pParent = pFieldDict; + pParent = (CPDF_Dictionary*)pFieldDict; } } if (pParent && pParent != pFieldDict && @@ -1115,14 +1116,15 @@ CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { } return pField; } -CPDF_FormControl* CPDF_InterForm::AddControl(const CPDF_FormField* pField, - CPDF_Dictionary* pWidgetDict) { +CPDF_FormControl* CPDF_InterForm::AddControl( + const CPDF_FormField* pField, + const CPDF_Dictionary* pWidgetDict) { const auto it = m_ControlMap.find(pWidgetDict); if (it != m_ControlMap.end()) return it->second; - CPDF_FormControl* pControl = - new CPDF_FormControl((CPDF_FormField*)pField, pWidgetDict); + CPDF_FormControl* pControl = new CPDF_FormControl( + (CPDF_FormField*)pField, (CPDF_Dictionary*)pWidgetDict); m_ControlMap[pWidgetDict] = pControl; ((CPDF_FormField*)pField)->m_ControlList.Add(pControl); return pControl; diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp index c5f47d20cb..410f9a1f21 100644 --- a/core/src/fpdfdoc/doc_formcontrol.cpp +++ b/core/src/fpdfdoc/doc_formcontrol.cpp @@ -61,10 +61,10 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) { continue; } CPDF_Object* pObjDirect1 = pObj1->GetDirect(); - CPDF_Dictionary* pSubDict = pObjDirect1->AsDictionary(); - if (!pSubDict) + if (pObjDirect1->GetType() != PDFOBJ_DICTIONARY) { continue; - + } + CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)pObjDirect1; FX_POSITION pos2 = pSubDict->GetStartPos(); while (pos2) { CFX_ByteString csKey2; @@ -287,8 +287,8 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { return nullptr; CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); - if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { - CPDF_Dictionary* pFonts = pDict->GetDict("Font"); + if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) { + CPDF_Dictionary* pFonts = ((CPDF_Dictionary*)pObj)->GetDict("Font"); if (pFonts) { CPDF_Dictionary* pElement = pFonts->GetDict(csFontNameTag); if (pElement) { @@ -304,8 +304,8 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDict("P"); pObj = FPDF_GetFieldAttr(pPageDict, "Resources"); - if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { - CPDF_Dictionary* pFonts = pDict->GetDict("Font"); + if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) { + CPDF_Dictionary* pFonts = ((CPDF_Dictionary*)pObj)->GetDict("Font"); if (pFonts) { CPDF_Dictionary* pElement = pFonts->GetDict(csFontNameTag); if (pElement) { diff --git a/core/src/fpdfdoc/doc_ocg.cpp b/core/src/fpdfdoc/doc_ocg.cpp index e66b04489f..70ad9c710d 100644 --- a/core/src/fpdfdoc/doc_ocg.cpp +++ b/core/src/fpdfdoc/doc_ocg.cpp @@ -209,8 +209,9 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, if (pOCGObj == NULL) { return FALSE; } - if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) { - return !(bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict)); + if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) { + return !(bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) + : GetOCGVisible((CPDF_Dictionary*)pOCGObj)); } if (pOCGObj->GetType() == PDFOBJ_ARRAY) { return !GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1); @@ -225,8 +226,9 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, continue; } FX_BOOL bItem = FALSE; - if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) { - bItem = bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict); + if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) { + bItem = bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) + : GetOCGVisible((CPDF_Dictionary*)pOCGObj); } else if (pOCGObj->GetType() == PDFOBJ_ARRAY) { bItem = GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1); } @@ -256,8 +258,9 @@ FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, if (pOCGObj == NULL) { return TRUE; } - if (const CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) { - return bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict); + if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) { + return bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) + : GetOCGVisible((CPDF_Dictionary*)pOCGObj); } if (pOCGObj->GetType() != PDFOBJ_ARRAY) { return TRUE; diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp index fb3a05d59f..facad46886 100644 --- a/core/src/fpdfdoc/doc_tagged.cpp +++ b/core/src/fpdfdoc/doc_tagged.cpp @@ -54,9 +54,9 @@ void CPDF_StructTreeImpl::LoadDocTree() { if (pKids == NULL) { return; } - if (CPDF_Dictionary* pDict = pKids->AsDictionary()) { + if (pKids->GetType() == PDFOBJ_DICTIONARY) { CPDF_StructElementImpl* pStructElementImpl = - new CPDF_StructElementImpl(this, NULL, pDict); + new CPDF_StructElementImpl(this, NULL, (CPDF_Dictionary*)pKids); m_Kids.Add(pStructElementImpl); return; } @@ -81,7 +81,7 @@ void CPDF_StructTreeImpl::LoadPageTree(const CPDF_Dictionary* pPageDict) { return; } FX_DWORD dwKids = 0; - if (pKids->IsDictionary()) { + if (pKids->GetType() == PDFOBJ_DICTIONARY) { dwKids = 1; } else if (pKids->GetType() == PDFOBJ_ARRAY) { dwKids = ((CPDF_Array*)pKids)->GetCount(); @@ -161,7 +161,7 @@ FX_BOOL CPDF_StructTreeImpl::AddTopLevelNode(CPDF_Dictionary* pDict, if (!pObj) { return FALSE; } - if (pObj->IsDictionary()) { + if (pObj->GetType() == PDFOBJ_DICTIONARY) { if (pObj->GetObjNum() == pDict->GetObjNum()) { if (m_Kids[0]) { m_Kids[0]->Release(); @@ -266,10 +266,10 @@ void CPDF_StructElementImpl::LoadKid(FX_DWORD PageObjNum, pKid->m_PageContent.m_PageObjNum = PageObjNum; return; } - CPDF_Dictionary* pKidDict = pKidObj->AsDictionary(); - if (!pKidDict) + if (pKidObj->GetType() != PDFOBJ_DICTIONARY) { return; - + } + CPDF_Dictionary* pKidDict = (CPDF_Dictionary*)pKidObj; CPDF_Object* pPageObj = pKidDict->GetElement(FX_BSTRC("Pg")); if (pPageObj && pPageObj->GetType() == PDFOBJ_REFERENCE) { PageObjNum = ((CPDF_Reference*)pPageObj)->GetRefObjNum(); @@ -322,8 +322,8 @@ static CPDF_Dictionary* FindAttrDict(CPDF_Object* pAttrs, return NULL; } CPDF_Dictionary* pDict = NULL; - if (pAttrs->IsDictionary()) { - pDict = pAttrs->AsDictionary(); + if (pAttrs->GetType() == PDFOBJ_DICTIONARY) { + pDict = (CPDF_Dictionary*)pAttrs; } else if (pAttrs->GetType() == PDFOBJ_STREAM) { pDict = ((CPDF_Stream*)pAttrs)->GetDict(); } else if (pAttrs->GetType() == PDFOBJ_ARRAY) { diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp index 7d3fdf2f23..1ed0017078 100644 --- a/core/src/fpdfdoc/doc_utils.cpp +++ b/core/src/fpdfdoc/doc_utils.cpp @@ -290,8 +290,9 @@ FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) { if (pObj == NULL) { continue; } - if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) { - if (pDirect->GetString("Type") == "Font") { + CPDF_Object* pDirect = pObj->GetDirect(); + if (pDirect != NULL && pDirect->GetType() == PDFOBJ_DICTIONARY) { + if (((CPDF_Dictionary*)pDirect)->GetString("Type") == "Font") { dwCount++; } } @@ -322,11 +323,14 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, 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; - if (pElement->GetString("Type") != "Font") + } + CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; + if (pElement->GetString("Type") != "Font") { continue; + } if (dwCount == index) { csNameTag = csKey; return pDocument->LoadFont(pElement); @@ -382,16 +386,18 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, 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; - if (pElement->GetString("Type") != "Font") + } + CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; + if (pElement->GetString("Type") != "Font") { continue; - + } CPDF_Font* pFind = pDocument->LoadFont(pElement); - if (!pFind) + if (pFind == NULL) { continue; - + } CFX_ByteString csBaseFont; csBaseFont = pFind->GetBaseFont(); csBaseFont.Remove(' '); @@ -425,11 +431,14 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, 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; - if (pElement->GetString("Type") != "Font") + } + CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; + if (pElement->GetString("Type") != "Font") { continue; + } CPDF_Font* pFind = pDocument->LoadFont(pElement); if (pFind == NULL) { continue; @@ -483,9 +492,11 @@ FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict, 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; } @@ -523,9 +534,11 @@ FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict, 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; } |