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/doc_basic.cpp | |
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/doc_basic.cpp')
-rw-r--r-- | core/src/fpdfdoc/doc_basic.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
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")); } |