diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-20 16:24:45 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-20 16:24:45 -0400 |
commit | f1251c1ff2b3452854681d0648b4c1ca4180ff0d (patch) | |
tree | dbcff41b8f8a5ea3d1d5280ff0c946b9647c301a /core/src/fpdfapi/fpdf_page | |
parent | 49f88b708d905b052bc00769ac7cb48202cac019 (diff) | |
download | pdfium-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 'core/src/fpdfapi/fpdf_page')
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp | 6 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp | 14 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp | 5 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 23 |
4 files changed, 24 insertions, 24 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp index 224c99bb69..d66a9efdaa 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp @@ -818,8 +818,8 @@ CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) { type = ((CPDF_Stream*)pFuncObj) ->GetDict() ->GetInteger(FX_BSTRC("FunctionType")); - } else if (pFuncObj->GetType() == PDFOBJ_DICTIONARY) { - type = ((CPDF_Dictionary*)pFuncObj)->GetInteger(FX_BSTRC("FunctionType")); + } else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) { + type = pDict->GetInteger(FX_BSTRC("FunctionType")); } else { return NULL; } @@ -853,7 +853,7 @@ FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { if (pObj->GetType() == PDFOBJ_STREAM) { pDict = ((CPDF_Stream*)pObj)->GetDict(); } else { - pDict = (CPDF_Dictionary*)pObj; + pDict = pObj->AsDictionary(); } CPDF_Array* pDomains = pDict->GetArray(FX_BSTRC("Domain")); if (pDomains == NULL) { diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp index f11a2bb8d1..6d071f3ae0 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp @@ -530,7 +530,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, break; } case FXBSTR_ID('S', 'M', 'a', 's'): - if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY) { + if (ToDictionary(pObject)) { pGeneralState->m_pSoftMask = pObject; FXSYS_memcpy(pGeneralState->m_SMaskMatrix, &pParser->GetCurStates()->m_CTM, sizeof(CPDF_Matrix)); @@ -599,20 +599,21 @@ CPDF_ContentMarkItem::CPDF_ContentMarkItem(const CPDF_ContentMarkItem& src) { m_MarkName = src.m_MarkName; m_ParamType = src.m_ParamType; if (m_ParamType == DirectDict) { - m_pParam = ((CPDF_Dictionary*)src.m_pParam)->Clone(); + m_pParam = ToDictionary(static_cast<CPDF_Object*>(src.m_pParam))->Clone(); } else { m_pParam = src.m_pParam; } } CPDF_ContentMarkItem::~CPDF_ContentMarkItem() { if (m_ParamType == DirectDict && m_pParam) { - ((CPDF_Dictionary*)m_pParam)->Release(); + ToDictionary(static_cast<CPDF_Object*>(m_pParam))->Release(); } } FX_BOOL CPDF_ContentMarkItem::HasMCID() const { if (m_pParam && (m_ParamType == DirectDict || m_ParamType == PropertiesDict)) { - return ((CPDF_Dictionary*)m_pParam)->KeyExist(FX_BSTRC("MCID")); + return ToDictionary(static_cast<CPDF_Object*>(m_pParam)) + ->KeyExist(FX_BSTRC("MCID")); } return FALSE; } @@ -627,7 +628,8 @@ int CPDF_ContentMarkData::GetMCID() const { type = m_Marks[i].GetParamType(); if (type == CPDF_ContentMarkItem::PropertiesDict || type == CPDF_ContentMarkItem::DirectDict) { - CPDF_Dictionary* pDict = (CPDF_Dictionary*)m_Marks[i].GetParam(); + CPDF_Dictionary* pDict = + ToDictionary(static_cast<CPDF_Object*>(m_Marks[i].GetParam())); if (pDict->KeyExist(FX_BSTRC("MCID"))) { return pDict->GetInteger(FX_BSTRC("MCID")); } @@ -677,7 +679,7 @@ FX_BOOL CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark, pDict = NULL; if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { - pDict = (CPDF_Dictionary*)item.GetParam(); + pDict = ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); } return TRUE; } diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp index e9f70c14db..9cdf00e717 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp @@ -52,8 +52,7 @@ CPDF_Image* CPDF_Image::Clone() { pImage->LoadImageF((CPDF_Stream*)((CPDF_Object*)m_pStream)->Clone(), m_bInline); if (m_bInline) { - CPDF_Dictionary* pInlineDict = (CPDF_Dictionary*)m_pInlineDict->Clone(TRUE); - pImage->SetInlineDict(pInlineDict); + pImage->SetInlineDict(ToDictionary(m_pInlineDict->Clone(TRUE))); } return pImage; } @@ -86,7 +85,7 @@ FX_BOOL CPDF_Image::LoadImageF(CPDF_Stream* pStream, FX_BOOL bInline) { m_bInline = bInline; CPDF_Dictionary* pDict = pStream->GetDict(); if (m_bInline) { - m_pInlineDict = (CPDF_Dictionary*)pDict->Clone(); + m_pInlineDict = ToDictionary(pDict->Clone()); } m_pOC = pDict->GetDict(FX_BSTRC("OC")); m_bIsMask = !pDict->KeyExist(FX_BSTRC("ColorSpace")) || diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 127fb93250..ffa5e62a07 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -418,11 +418,9 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { } bDirect = FALSE; } - if (pProperty->GetType() != PDFOBJ_DICTIONARY) { - return; + if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { + m_CurContentMark.GetModify()->AddMark(tag, pDict, bDirect); } - m_CurContentMark.GetModify()->AddMark(tag, (CPDF_Dictionary*)pProperty, - bDirect); } void CPDF_StreamContentParser::Handle_BeginMarkedContent() { if (!m_Options.m_bMarkedContent) { @@ -487,7 +485,7 @@ static CFX_ByteStringC _PDF_FindFullName(const _FX_BSTR* table, void _PDF_ReplaceAbbr(CPDF_Object* pObj) { switch (pObj->GetType()) { case PDFOBJ_DICTIONARY: { - CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj; + CPDF_Dictionary* pDict = pObj->AsDictionary(); FX_POSITION pos = pDict->GetStartPos(); while (pos) { CFX_ByteString key; @@ -550,7 +548,7 @@ static CFX_ByteStringC _PDF_FindAbbrName(const _FX_BSTR* table, void _PDF_ReplaceFull(CPDF_Object* pObj) { switch (pObj->GetType()) { case PDFOBJ_DICTIONARY: { - CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj; + CPDF_Dictionary* pDict = pObj->AsDictionary(); FX_POSITION pos = pDict->GetStartPos(); while (pos) { CFX_ByteString key; @@ -886,8 +884,8 @@ void CPDF_StreamContentParser::Handle_SetGray_Stroke() { void CPDF_StreamContentParser::Handle_SetExtendGraphState() { CFX_ByteString name = GetString(0); CPDF_Dictionary* pGS = - (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("ExtGState"), name); - if (pGS == NULL || pGS->GetType() != PDFOBJ_DICTIONARY) { + ToDictionary(FindResourceObj(FX_BSTRC("ExtGState"), name)); + if (!pGS) { m_bResourceMissing = TRUE; return; } @@ -1217,11 +1215,12 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj( } CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { CPDF_Dictionary* pFontDict = - (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("Font"), name); - if (pFontDict == NULL || pFontDict->GetType() != PDFOBJ_DICTIONARY) { + ToDictionary(FindResourceObj(FX_BSTRC("Font"), name)); + if (!pFontDict) { m_bResourceMissing = TRUE; return CPDF_Font::GetStockFont(m_pDocument, FX_BSTRC("Helvetica")); } + CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); if (pFont && pFont->GetType3Font()) { pFont->GetType3Font()->SetPageResources(m_pResources); @@ -1261,8 +1260,8 @@ CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name, FX_BOOL bShading) { CPDF_Object* pPattern = FindResourceObj( bShading ? FX_BSTRC("Shading") : FX_BSTRC("Pattern"), name); - if (pPattern == NULL || (pPattern->GetType() != PDFOBJ_DICTIONARY && - pPattern->GetType() != PDFOBJ_STREAM)) { + if (pPattern == NULL || + (!pPattern->IsDictionary() && pPattern->GetType() != PDFOBJ_STREAM)) { m_bResourceMissing = TRUE; return NULL; } |