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

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

Issue 2498223005: Make CPDF_Array take unique_ptrs (Closed)
Patch Set: nits 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 | « no previous file | core/fpdfapi/font/cpdf_fontencoding.cpp » ('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 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 return Continue(nullptr) > -1; 1924 return Continue(nullptr) > -1;
1925 } 1925 }
1926 1926
1927 void CPDF_Creator::InitID(bool bDefault) { 1927 void CPDF_Creator::InitID(bool bDefault) {
1928 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr; 1928 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr;
1929 bool bNewId = !m_pIDArray; 1929 bool bNewId = !m_pIDArray;
1930 if (bNewId) { 1930 if (bNewId) {
1931 m_pIDArray.reset(new CPDF_Array); 1931 m_pIDArray.reset(new CPDF_Array);
1932 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr; 1932 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr;
1933 if (pID1) { 1933 if (pID1) {
1934 m_pIDArray->Add(pID1->Clone().release()); 1934 m_pIDArray->Add(pID1->Clone());
1935 } else { 1935 } else {
1936 std::vector<uint8_t> buffer = 1936 std::vector<uint8_t> buffer =
1937 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum); 1937 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum);
1938 CFX_ByteString bsBuffer(buffer.data(), buffer.size()); 1938 CFX_ByteString bsBuffer(buffer.data(), buffer.size());
1939 m_pIDArray->Add(new CPDF_String(bsBuffer, true)); 1939 m_pIDArray->AddNew<CPDF_String>(bsBuffer, true);
1940 } 1940 }
1941 } 1941 }
1942 if (!bDefault) { 1942 if (!bDefault) {
1943 return; 1943 return;
1944 } 1944 }
1945 if (pOldIDArray) { 1945 if (pOldIDArray) {
1946 CPDF_Object* pID2 = pOldIDArray->GetObjectAt(1); 1946 CPDF_Object* pID2 = pOldIDArray->GetObjectAt(1);
1947 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) { 1947 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) {
1948 m_pIDArray->Add(pID2->Clone().release()); 1948 m_pIDArray->Add(pID2->Clone());
1949 return; 1949 return;
1950 } 1950 }
1951 std::vector<uint8_t> buffer = 1951 std::vector<uint8_t> buffer =
1952 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum); 1952 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum);
1953 CFX_ByteString bsBuffer(buffer.data(), buffer.size()); 1953 CFX_ByteString bsBuffer(buffer.data(), buffer.size());
1954 m_pIDArray->Add(new CPDF_String(bsBuffer, true)); 1954 m_pIDArray->AddNew<CPDF_String>(bsBuffer, true);
1955 return; 1955 return;
1956 } 1956 }
1957 m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone().release()); 1957 m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone());
1958 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { 1958 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) {
1959 if (m_pEncryptDict->GetStringFor("Filter") == "Standard") { 1959 if (m_pEncryptDict->GetStringFor("Filter") == "Standard") {
1960 CFX_ByteString user_pass = m_pParser->GetPassword(); 1960 CFX_ByteString user_pass = m_pParser->GetPassword();
1961 uint32_t flag = PDF_ENCRYPT_CONTENT; 1961 uint32_t flag = PDF_ENCRYPT_CONTENT;
1962
1963 CPDF_SecurityHandler handler; 1962 CPDF_SecurityHandler handler;
1964 handler.OnCreate(m_pEncryptDict, m_pIDArray.get(), user_pass.raw_str(), 1963 handler.OnCreate(m_pEncryptDict, m_pIDArray.get(), user_pass.raw_str(),
1965 user_pass.GetLength(), flag); 1964 user_pass.GetLength(), flag);
1966 if (m_bLocalCryptoHandler) 1965 if (m_bLocalCryptoHandler)
1967 delete m_pCryptoHandler; 1966 delete m_pCryptoHandler;
1968 m_pCryptoHandler = new CPDF_CryptoHandler; 1967 m_pCryptoHandler = new CPDF_CryptoHandler;
1969 m_pCryptoHandler->Init(m_pEncryptDict, &handler); 1968 m_pCryptoHandler->Init(m_pEncryptDict, &handler);
1970 m_bLocalCryptoHandler = true; 1969 m_bLocalCryptoHandler = true;
1971 m_bSecurityChanged = true; 1970 m_bSecurityChanged = true;
1972 } 1971 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 m_pCryptoHandler = nullptr; 2011 m_pCryptoHandler = nullptr;
2013 } 2012 }
2014 void CPDF_Creator::ResetStandardSecurity() { 2013 void CPDF_Creator::ResetStandardSecurity() {
2015 if (!m_bLocalCryptoHandler) 2014 if (!m_bLocalCryptoHandler)
2016 return; 2015 return;
2017 2016
2018 delete m_pCryptoHandler; 2017 delete m_pCryptoHandler;
2019 m_pCryptoHandler = nullptr; 2018 m_pCryptoHandler = nullptr;
2020 m_bLocalCryptoHandler = false; 2019 m_bLocalCryptoHandler = false;
2021 } 2020 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/font/cpdf_fontencoding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698