Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp

Issue 1911673002: Remove CFX_ArrayTemplate from fpdf_parser_decode.cpp (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: IWYU for std::pair. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" 7 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" 13 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
15 #include "core/fpdfapi/include/cpdf_modulemgr.h" 16 #include "core/fpdfapi/include/cpdf_modulemgr.h"
16 #include "core/fxcodec/include/fx_codec.h" 17 #include "core/fxcodec/include/fx_codec.h"
17 #include "core/fxcrt/include/fx_ext.h" 18 #include "core/fxcrt/include/fx_ext.h"
18 #include "third_party/base/stl_util.h" 19 #include "third_party/base/stl_util.h"
19 20
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 CFX_ByteString& ImageEncoding, 336 CFX_ByteString& ImageEncoding,
336 CPDF_Dictionary*& pImageParms, 337 CPDF_Dictionary*& pImageParms,
337 uint32_t last_estimated_size, 338 uint32_t last_estimated_size,
338 FX_BOOL bImageAcc) { 339 FX_BOOL bImageAcc) {
339 CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectBy("Filter") : nullptr; 340 CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectBy("Filter") : nullptr;
340 if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName())) 341 if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName()))
341 return FALSE; 342 return FALSE;
342 343
343 CPDF_Object* pParams = 344 CPDF_Object* pParams =
344 pDict ? pDict->GetDirectObjectBy("DecodeParms") : nullptr; 345 pDict ? pDict->GetDirectObjectBy("DecodeParms") : nullptr;
345 std::vector<CFX_ByteString> DecoderList; 346
346 CFX_ArrayTemplate<CPDF_Object*> ParamList; 347 std::vector<std::pair<CFX_ByteString, CPDF_Object*>> DecoderArray;
347 if (CPDF_Array* pDecoders = pDecoder->AsArray()) { 348 if (CPDF_Array* pDecoders = pDecoder->AsArray()) {
348 CPDF_Array* pParamsArray = ToArray(pParams); 349 CPDF_Array* pParamsArray = ToArray(pParams);
349 if (!pParamsArray) 350 if (!pParamsArray)
350 pParams = nullptr; 351 pParams = nullptr;
351 352
352 for (size_t i = 0; i < pDecoders->GetCount(); i++) { 353 for (size_t i = 0; i < pDecoders->GetCount(); i++) {
353 DecoderList.push_back(pDecoders->GetStringAt(i)); 354 DecoderArray.push_back({pDecoders->GetStringAt(i),
354 ParamList.Add(pParams ? pParamsArray->GetDictAt(i) : nullptr); 355 pParams ? pParamsArray->GetDictAt(i) : nullptr});
Lei Zhang 2016/04/21 00:51:58 Use |pParamsArray| instead of |pParams| and don't
Tom Sepez 2016/04/21 17:48:07 Done.
355 } 356 }
356 } else { 357 } else {
357 DecoderList.push_back(pDecoder->GetString()); 358 DecoderArray.push_back(
358 ParamList.Add(pParams ? pParams->GetDict() : nullptr); 359 {pDecoder->GetString(), pParams ? pParams->GetDict() : nullptr});
359 } 360 }
360 uint8_t* last_buf = (uint8_t*)src_buf; 361 uint8_t* last_buf = const_cast<uint8_t*>(src_buf);
361 uint32_t last_size = src_size; 362 uint32_t last_size = src_size;
362 int nSize = pdfium::CollectionSize<int>(DecoderList); 363 int nSize = pdfium::CollectionSize<int>(DecoderArray);
363 for (int i = 0; i < nSize; i++) { 364 for (int i = 0; i < nSize; i++) {
364 int estimated_size = i == nSize - 1 ? last_estimated_size : 0; 365 int estimated_size = i == nSize - 1 ? last_estimated_size : 0;
365 CFX_ByteString decoder = DecoderList[i]; 366 CFX_ByteString decoder = DecoderArray[i].first;
366 // Use ToDictionary here because we can push nullptr into the ParamList. 367 CPDF_Dictionary* pParam = ToDictionary(DecoderArray[i].second);
367 CPDF_Dictionary* pParam = ToDictionary(ParamList[i]);
368 uint8_t* new_buf = nullptr; 368 uint8_t* new_buf = nullptr;
369 uint32_t new_size = (uint32_t)-1; 369 uint32_t new_size = (uint32_t)-1;
370 int offset = -1; 370 int offset = -1;
371 if (decoder == "FlateDecode" || decoder == "Fl") { 371 if (decoder == "FlateDecode" || decoder == "Fl") {
372 if (bImageAcc && i == nSize - 1) { 372 if (bImageAcc && i == nSize - 1) {
373 ImageEncoding = "FlateDecode"; 373 ImageEncoding = "FlateDecode";
374 dest_buf = (uint8_t*)last_buf; 374 dest_buf = (uint8_t*)last_buf;
375 dest_size = last_size; 375 dest_size = last_size;
376 pImageParms = pParam; 376 pImageParms = pParam;
377 return TRUE; 377 return TRUE;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 uint32_t src_size, 580 uint32_t src_size,
581 uint8_t*& dest_buf, 581 uint8_t*& dest_buf,
582 uint32_t& dest_size) { 582 uint32_t& dest_size) {
583 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 583 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
584 if (pEncoders) { 584 if (pEncoders) {
585 return pEncoders->GetFlateModule()->FlateOrLZWDecode( 585 return pEncoders->GetFlateModule()->FlateOrLZWDecode(
586 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); 586 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size);
587 } 587 }
588 return 0; 588 return 0;
589 } 589 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698