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

Side by Side Diff: core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp

Issue 1540693002: Get rid of a few CPDF_Object Create() methods and just use new instead. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 5 years 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
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 "editint.h" 7 #include "editint.h"
8 8
9 #include "core/include/fxcrt/fx_ext.h" 9 #include "core/include/fxcrt/fx_ext.h"
10 #include "core/include/fpdfapi/fpdf_serial.h" 10 #include "core/include/fpdfapi/fpdf_serial.h"
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 if (flags & FPDFCREATE_PROGRESSIVE) { 2003 if (flags & FPDFCREATE_PROGRESSIVE) {
2004 return TRUE; 2004 return TRUE;
2005 } 2005 }
2006 return Continue(NULL) > -1; 2006 return Continue(NULL) > -1;
2007 } 2007 }
2008 void CPDF_Creator::InitID(FX_BOOL bDefault) { 2008 void CPDF_Creator::InitID(FX_BOOL bDefault) {
2009 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL; 2009 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL;
2010 FX_BOOL bNewId = !m_pIDArray; 2010 FX_BOOL bNewId = !m_pIDArray;
2011 if (!m_pIDArray) { 2011 if (!m_pIDArray) {
2012 FX_DWORD* pBuffer = NULL; 2012 FX_DWORD* pBuffer = NULL;
2013 m_pIDArray = CPDF_Array::Create(); 2013 m_pIDArray = new CPDF_Array;
2014 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetElement(0) : NULL; 2014 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetElement(0) : NULL;
2015 if (pID1) { 2015 if (pID1) {
2016 m_pIDArray->Add(pID1->Clone()); 2016 m_pIDArray->Add(pID1->Clone());
2017 } else { 2017 } else {
2018 pBuffer = FX_Alloc(FX_DWORD, 4); 2018 pBuffer = FX_Alloc(FX_DWORD, 4);
2019 PDF_GenerateFileID((FX_DWORD)(uintptr_t) this, m_dwLastObjNum, pBuffer); 2019 PDF_GenerateFileID((FX_DWORD)(uintptr_t) this, m_dwLastObjNum, pBuffer);
2020 CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD)); 2020 CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD));
2021 m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument); 2021 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument);
2022 } 2022 }
2023 FX_Free(pBuffer); 2023 FX_Free(pBuffer);
2024 } 2024 }
2025 if (!bDefault) { 2025 if (!bDefault) {
2026 return; 2026 return;
2027 } 2027 }
2028 if (pOldIDArray) { 2028 if (pOldIDArray) {
2029 CPDF_Object* pID2 = pOldIDArray->GetElement(1); 2029 CPDF_Object* pID2 = pOldIDArray->GetElement(1);
2030 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) { 2030 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) {
2031 m_pIDArray->Add(pID2->Clone()); 2031 m_pIDArray->Add(pID2->Clone());
2032 return; 2032 return;
2033 } 2033 }
2034 FX_DWORD* pBuffer = FX_Alloc(FX_DWORD, 4); 2034 FX_DWORD* pBuffer = FX_Alloc(FX_DWORD, 4);
2035 PDF_GenerateFileID((FX_DWORD)(uintptr_t) this, m_dwLastObjNum, pBuffer); 2035 PDF_GenerateFileID((FX_DWORD)(uintptr_t) this, m_dwLastObjNum, pBuffer);
2036 CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD)); 2036 CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD));
2037 m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument); 2037 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument);
2038 FX_Free(pBuffer); 2038 FX_Free(pBuffer);
2039 return; 2039 return;
2040 } 2040 }
2041 m_pIDArray->Add(m_pIDArray->GetElement(0)->Clone()); 2041 m_pIDArray->Add(m_pIDArray->GetElement(0)->Clone());
2042 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { 2042 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) {
2043 if (m_pEncryptDict->GetString("Filter") == "Standard") { 2043 if (m_pEncryptDict->GetString("Filter") == "Standard") {
2044 CPDF_StandardSecurityHandler handler; 2044 CPDF_StandardSecurityHandler handler;
2045 CFX_ByteString user_pass = m_pParser->GetPassword(); 2045 CFX_ByteString user_pass = m_pParser->GetPassword();
2046 FX_DWORD flag = PDF_ENCRYPT_CONTENT; 2046 FX_DWORD flag = PDF_ENCRYPT_CONTENT;
2047 handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass, 2047 handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 m_bNewCrypto = FALSE; 2103 m_bNewCrypto = FALSE;
2104 if (!m_bStandardSecurity) { 2104 if (!m_bStandardSecurity) {
2105 return; 2105 return;
2106 } 2106 }
2107 if (m_pEncryptDict) { 2107 if (m_pEncryptDict) {
2108 m_pEncryptDict->Release(); 2108 m_pEncryptDict->Release();
2109 m_pEncryptDict = NULL; 2109 m_pEncryptDict = NULL;
2110 } 2110 }
2111 m_bStandardSecurity = FALSE; 2111 m_bStandardSecurity = FALSE;
2112 } 2112 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp ('k') | core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698