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

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

Issue 1841173002: Rename GetElementValue() to GetDirectObject{By,At}(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix test name 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
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_edit/editint.h" 7 #include "core/fpdfapi/fpdf_edit/editint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 offset += len + 6; 89 offset += len + 6;
90 break; 90 break;
91 } 91 }
92 case CPDF_Object::ARRAY: { 92 case CPDF_Object::ARRAY: {
93 if (pFile->AppendString("[") < 0) { 93 if (pFile->AppendString("[") < 0) {
94 return -1; 94 return -1;
95 } 95 }
96 offset += 1; 96 offset += 1;
97 const CPDF_Array* p = pObj->AsArray(); 97 const CPDF_Array* p = pObj->AsArray();
98 for (uint32_t i = 0; i < p->GetCount(); i++) { 98 for (uint32_t i = 0; i < p->GetCount(); i++) {
99 CPDF_Object* pElement = p->GetElement(i); 99 CPDF_Object* pElement = p->GetObjectAt(i);
100 if (pElement->GetObjNum()) { 100 if (pElement->GetObjNum()) {
101 if (pFile->AppendString(" ") < 0) { 101 if (pFile->AppendString(" ") < 0) {
102 return -1; 102 return -1;
103 } 103 }
104 if ((len = pFile->AppendDWord(pElement->GetObjNum())) < 0) { 104 if ((len = pFile->AppendDWord(pElement->GetObjNum())) < 0) {
105 return -1; 105 return -1;
106 } 106 }
107 if (pFile->AppendString(" 0 R") < 0) { 107 if (pFile->AppendString(" 0 R") < 0) {
108 return -1; 108 return -1;
109 } 109 }
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 m_Offset += len + 5; 1192 m_Offset += len + 5;
1193 break; 1193 break;
1194 } 1194 }
1195 case CPDF_Object::ARRAY: { 1195 case CPDF_Object::ARRAY: {
1196 if (m_File.AppendString("[") < 0) { 1196 if (m_File.AppendString("[") < 0) {
1197 return -1; 1197 return -1;
1198 } 1198 }
1199 m_Offset += 1; 1199 m_Offset += 1;
1200 const CPDF_Array* p = pObj->AsArray(); 1200 const CPDF_Array* p = pObj->AsArray();
1201 for (uint32_t i = 0; i < p->GetCount(); i++) { 1201 for (uint32_t i = 0; i < p->GetCount(); i++) {
1202 CPDF_Object* pElement = p->GetElement(i); 1202 CPDF_Object* pElement = p->GetObjectAt(i);
1203 if (pElement->GetObjNum()) { 1203 if (pElement->GetObjNum()) {
1204 if (m_File.AppendString(" ") < 0) { 1204 if (m_File.AppendString(" ") < 0) {
1205 return -1; 1205 return -1;
1206 } 1206 }
1207 if ((len = m_File.AppendDWord(pElement->GetObjNum())) < 0) { 1207 if ((len = m_File.AppendDWord(pElement->GetObjNum())) < 0) {
1208 return -1; 1208 return -1;
1209 } 1209 }
1210 if (m_File.AppendString(" 0 R") < 0) { 1210 if (m_File.AppendString(" 0 R") < 0) {
1211 return -1; 1211 return -1;
1212 } 1212 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) { 1486 int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
1487 FXSYS_assert(m_iStage > -1 || m_iStage < 20); 1487 FXSYS_assert(m_iStage > -1 || m_iStage < 20);
1488 if (m_iStage == 0) { 1488 if (m_iStage == 0) {
1489 if (!m_pParser) { 1489 if (!m_pParser) {
1490 m_dwFlags &= ~FPDFCREATE_INCREMENTAL; 1490 m_dwFlags &= ~FPDFCREATE_INCREMENTAL;
1491 } 1491 }
1492 if (m_bSecurityChanged && (m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0) { 1492 if (m_bSecurityChanged && (m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0) {
1493 m_dwFlags &= ~FPDFCREATE_INCREMENTAL; 1493 m_dwFlags &= ~FPDFCREATE_INCREMENTAL;
1494 } 1494 }
1495 CPDF_Dictionary* pDict = m_pDocument->GetRoot(); 1495 CPDF_Dictionary* pDict = m_pDocument->GetRoot();
1496 m_pMetadata = pDict ? pDict->GetElementValue("Metadata") : NULL; 1496 m_pMetadata = pDict ? pDict->GetDirectObjectBy("Metadata") : NULL;
1497 if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) { 1497 if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) {
1498 m_pXRefStream = new CPDF_XRefStream; 1498 m_pXRefStream = new CPDF_XRefStream;
1499 m_pXRefStream->Start(); 1499 m_pXRefStream->Start();
1500 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser) { 1500 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser) {
1501 FX_FILESIZE prev = m_pParser->GetLastXRefOffset(); 1501 FX_FILESIZE prev = m_pParser->GetLastXRefOffset();
1502 m_pXRefStream->m_PrevOffset = prev; 1502 m_pXRefStream->m_PrevOffset = prev;
1503 } 1503 }
1504 } 1504 }
1505 m_iStage = 10; 1505 m_iStage = 10;
1506 } 1506 }
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 if (flags & FPDFCREATE_PROGRESSIVE) { 1972 if (flags & FPDFCREATE_PROGRESSIVE) {
1973 return true; 1973 return true;
1974 } 1974 }
1975 return Continue(NULL) > -1; 1975 return Continue(NULL) > -1;
1976 } 1976 }
1977 void CPDF_Creator::InitID(FX_BOOL bDefault) { 1977 void CPDF_Creator::InitID(FX_BOOL bDefault) {
1978 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL; 1978 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL;
1979 FX_BOOL bNewId = !m_pIDArray; 1979 FX_BOOL bNewId = !m_pIDArray;
1980 if (!m_pIDArray) { 1980 if (!m_pIDArray) {
1981 m_pIDArray = new CPDF_Array; 1981 m_pIDArray = new CPDF_Array;
1982 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetElement(0) : NULL; 1982 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : NULL;
1983 if (pID1) { 1983 if (pID1) {
1984 m_pIDArray->Add(pID1->Clone()); 1984 m_pIDArray->Add(pID1->Clone());
1985 } else { 1985 } else {
1986 std::vector<uint8_t> buffer = 1986 std::vector<uint8_t> buffer =
1987 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum); 1987 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum);
1988 CFX_ByteStringC bsBuffer(buffer.data(), buffer.size()); 1988 CFX_ByteStringC bsBuffer(buffer.data(), buffer.size());
1989 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument); 1989 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument);
1990 } 1990 }
1991 } 1991 }
1992 if (!bDefault) { 1992 if (!bDefault) {
1993 return; 1993 return;
1994 } 1994 }
1995 if (pOldIDArray) { 1995 if (pOldIDArray) {
1996 CPDF_Object* pID2 = pOldIDArray->GetElement(1); 1996 CPDF_Object* pID2 = pOldIDArray->GetObjectAt(1);
1997 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) { 1997 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) {
1998 m_pIDArray->Add(pID2->Clone()); 1998 m_pIDArray->Add(pID2->Clone());
1999 return; 1999 return;
2000 } 2000 }
2001 std::vector<uint8_t> buffer = 2001 std::vector<uint8_t> buffer =
2002 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum); 2002 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum);
2003 CFX_ByteStringC bsBuffer(buffer.data(), buffer.size()); 2003 CFX_ByteStringC bsBuffer(buffer.data(), buffer.size());
2004 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument); 2004 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument);
2005 return; 2005 return;
2006 } 2006 }
2007 m_pIDArray->Add(m_pIDArray->GetElement(0)->Clone()); 2007 m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone());
2008 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { 2008 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) {
2009 if (m_pEncryptDict->GetStringBy("Filter") == "Standard") { 2009 if (m_pEncryptDict->GetStringBy("Filter") == "Standard") {
2010 CPDF_StandardSecurityHandler handler; 2010 CPDF_StandardSecurityHandler handler;
2011 CFX_ByteString user_pass = m_pParser->GetPassword(); 2011 CFX_ByteString user_pass = m_pParser->GetPassword();
2012 uint32_t flag = PDF_ENCRYPT_CONTENT; 2012 uint32_t flag = PDF_ENCRYPT_CONTENT;
2013 handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass, 2013 handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass,
2014 user_pass.GetLength(), flag); 2014 user_pass.GetLength(), flag);
2015 if (m_bNewCrypto) { 2015 if (m_bNewCrypto) {
2016 delete m_pCryptoHandler; 2016 delete m_pCryptoHandler;
2017 } 2017 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 m_bNewCrypto = FALSE; 2069 m_bNewCrypto = FALSE;
2070 if (!m_bStandardSecurity) { 2070 if (!m_bStandardSecurity) {
2071 return; 2071 return;
2072 } 2072 }
2073 if (m_pEncryptDict) { 2073 if (m_pEncryptDict) {
2074 m_pEncryptDict->Release(); 2074 m_pEncryptDict->Release();
2075 m_pEncryptDict = NULL; 2075 m_pEncryptDict = NULL;
2076 } 2076 }
2077 m_bStandardSecurity = FALSE; 2077 m_bStandardSecurity = FALSE;
2078 } 2078 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp ('k') | core/fpdfapi/fpdf_font/cpdf_cidfont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698