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

Side by Side Diff: core/fpdfapi/edit/fpdf_edit_create.cpp

Issue 2517513003: Add unit test for CXFA_FileRead. (Closed)
Patch Set: Created 4 years, 1 month 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 | « BUILD.gn ('k') | core/fpdfapi/parser/cpdf_stream.h » ('j') | 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/edit/editint.h" 7 #include "core/fpdfapi/edit/editint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 410 }
411 } 411 }
412 412
413 CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, bool bFlateEncode) 413 CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, bool bFlateEncode)
414 : m_pData(nullptr), 414 : m_pData(nullptr),
415 m_dwSize(0), 415 m_dwSize(0),
416 m_pDict(nullptr), 416 m_pDict(nullptr),
417 m_bCloned(false), 417 m_bCloned(false),
418 m_bNewData(false) { 418 m_bNewData(false) {
419 m_Acc.LoadAllData(pStream, true); 419 m_Acc.LoadAllData(pStream, true);
420 if ((pStream && pStream->GetDict() && 420 bool bHasFilter = pStream && pStream->HasFilter();
421 pStream->GetDict()->KeyExist("Filter")) || 421 if (bHasFilter && !bFlateEncode) {
422 !bFlateEncode) { 422 CPDF_StreamAcc destAcc;
423 if (pStream->GetDict()->KeyExist("Filter") && !bFlateEncode) { 423 destAcc.LoadAllData(pStream);
424 CPDF_StreamAcc destAcc; 424 m_dwSize = destAcc.GetSize();
425 destAcc.LoadAllData(pStream); 425 m_pData = (uint8_t*)destAcc.DetachData();
426 m_dwSize = destAcc.GetSize(); 426 m_pDict = ToDictionary(pStream->GetDict()->Clone().release());
427 m_pData = (uint8_t*)destAcc.DetachData(); 427 m_pDict->RemoveFor("Filter");
428 m_pDict = ToDictionary(pStream->GetDict()->Clone().release()); 428 m_bNewData = true;
429 m_pDict->RemoveFor("Filter"); 429 m_bCloned = true;
430 m_bNewData = true;
431 m_bCloned = true;
432 } else {
433 m_pData = (uint8_t*)m_Acc.GetData();
434 m_dwSize = m_Acc.GetSize();
435 m_pDict = pStream->GetDict();
436 }
437 return; 430 return;
438 } 431 }
439 432 if (bHasFilter || !bFlateEncode) {
433 m_pData = (uint8_t*)m_Acc.GetData();
434 m_dwSize = m_Acc.GetSize();
435 m_pDict = pStream->GetDict();
436 return;
437 }
440 m_bNewData = true; 438 m_bNewData = true;
441 m_bCloned = true; 439 m_bCloned = true;
442 // TODO(thestig): Move to Init() and check return value. 440 // TODO(thestig): Move to Init() and check return value.
443 ::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), &m_pData, &m_dwSize); 441 ::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), &m_pData, &m_dwSize);
444 m_pDict = ToDictionary(pStream->GetDict()->Clone().release()); 442 m_pDict = ToDictionary(pStream->GetDict()->Clone().release());
445 m_pDict->SetIntegerFor("Length", m_dwSize); 443 m_pDict->SetIntegerFor("Length", m_dwSize);
446 m_pDict->SetNameFor("Filter", "FlateDecode"); 444 m_pDict->SetNameFor("Filter", "FlateDecode");
447 m_pDict->RemoveFor("DecodeParms"); 445 m_pDict->RemoveFor("DecodeParms");
448 } 446 }
449 447
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 m_pCryptoHandler = nullptr; 2009 m_pCryptoHandler = nullptr;
2012 } 2010 }
2013 void CPDF_Creator::ResetStandardSecurity() { 2011 void CPDF_Creator::ResetStandardSecurity() {
2014 if (!m_bLocalCryptoHandler) 2012 if (!m_bLocalCryptoHandler)
2015 return; 2013 return;
2016 2014
2017 delete m_pCryptoHandler; 2015 delete m_pCryptoHandler;
2018 m_pCryptoHandler = nullptr; 2016 m_pCryptoHandler = nullptr;
2019 m_bLocalCryptoHandler = false; 2017 m_bLocalCryptoHandler = false;
2020 } 2018 }
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | core/fpdfapi/parser/cpdf_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698