diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-22 15:02:06 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-22 15:02:06 -0400 |
commit | 2b11dc1220746d2f6f97a940fc9e4235c8ed4975 (patch) | |
tree | e25b2ba13112f4ead789260ee57fe5b40c13b83e /core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | |
parent | bc6c6723c37772b02de9e6e43fa0fd9439874905 (diff) | |
download | pdfium-2b11dc1220746d2f6f97a940fc9e4235c8ed4975.tar.xz |
Merge to XFA: Add type cast definitions for CPDF_Array.
This Cl adds ToArray, CPDF_Object::AsArray and CPDF_Object::IsArray and
updates the src to use them as needed.
BUG=pdfium:201
R=thestig@chromium.org, tsepez@chromium.org
Review URL: https://codereview.chromium.org/1417893003 .
(cherry picked from commit c2bfc000e502c42c9a3017038fd9104c7997d126)
Review URL: https://codereview.chromium.org/1419643005 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp')
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index cbbfbd7197..1815d40194 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -331,31 +331,27 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, { CPDF_Object* pDecoder = - pDict ? pDict->GetElementValue(FX_BSTRC("Filter")) : NULL; - if (!pDecoder || (pDecoder->GetType() != PDFOBJ_ARRAY && !pDecoder->IsName())) + pDict ? pDict->GetElementValue(FX_BSTRC("Filter")) : nullptr; + if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName())) return FALSE; CPDF_Object* pParams = - pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : NULL; + pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : nullptr; CFX_ByteStringArray DecoderList; CFX_PtrArray ParamList; - if (pDecoder->GetType() == PDFOBJ_ARRAY) { - if (pParams && pParams->GetType() != PDFOBJ_ARRAY) { - pParams = NULL; - } - CPDF_Array* pDecoders = (CPDF_Array*)pDecoder; + if (CPDF_Array* pDecoders = pDecoder->AsArray()) { + CPDF_Array* pParamsArray = ToArray(pParams); + if (!pParamsArray) + pParams = nullptr; + for (FX_DWORD i = 0; i < pDecoders->GetCount(); i++) { CFX_ByteStringC str = pDecoders->GetConstString(i); DecoderList.Add(str); - if (pParams) { - ParamList.Add(((CPDF_Array*)pParams)->GetDict(i)); - } else { - ParamList.Add(NULL); - } + ParamList.Add(pParams ? pParamsArray->GetDict(i) : nullptr); } } else { DecoderList.Add(pDecoder->GetConstString()); - ParamList.Add(pParams ? pParams->GetDict() : NULL); + ParamList.Add(pParams ? pParams->GetDict() : nullptr); } uint8_t* last_buf = (uint8_t*)src_buf; FX_DWORD last_size = src_size; |