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

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

Issue 2266033002: Revert of Move parser pointer to CPDF_Document (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 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 | core/fpdfapi/fpdf_parser/cfdf_document.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/fpdf_edit/editint.h" 7 #include "core/fpdfapi/fpdf_edit/editint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 break; 1226 break;
1227 } 1227 }
1228 } 1228 }
1229 return 1; 1229 return 1;
1230 } 1230 }
1231 int32_t CPDF_Creator::WriteOldIndirectObject(uint32_t objnum) { 1231 int32_t CPDF_Creator::WriteOldIndirectObject(uint32_t objnum) {
1232 if (m_pParser->IsObjectFreeOrNull(objnum)) 1232 if (m_pParser->IsObjectFreeOrNull(objnum))
1233 return 0; 1233 return 0;
1234 1234
1235 m_ObjectOffset[objnum] = m_Offset; 1235 m_ObjectOffset[objnum] = m_Offset;
1236 FX_BOOL bExistInMap = !!m_pDocument->GetIndirectObject(objnum); 1236 FX_BOOL bExistInMap =
1237 pdfium::ContainsKey(m_pDocument->m_IndirectObjs, objnum);
1237 const uint8_t object_type = m_pParser->GetObjectType(objnum); 1238 const uint8_t object_type = m_pParser->GetObjectType(objnum);
1238 bool bObjStm = (object_type == 2) && m_pEncryptDict && !m_pXRefStream; 1239 bool bObjStm = (object_type == 2) && m_pEncryptDict && !m_pXRefStream;
1239 if (m_pParser->IsVersionUpdated() || m_bSecurityChanged || bExistInMap || 1240 if (m_pParser->IsVersionUpdated() || m_bSecurityChanged || bExistInMap ||
1240 bObjStm) { 1241 bObjStm) {
1241 CPDF_Object* pObj = m_pDocument->GetOrParseIndirectObject(objnum); 1242 CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum);
1242 if (!pObj) { 1243 if (!pObj) {
1243 m_ObjectOffset[objnum] = 0; 1244 m_ObjectOffset[objnum] = 0;
1244 return 0; 1245 return 0;
1245 } 1246 }
1246 if (WriteIndirectObj(pObj)) { 1247 if (WriteIndirectObj(pObj)) {
1247 return -1; 1248 return -1;
1248 } 1249 }
1249 if (!bExistInMap) { 1250 if (!bExistInMap) {
1250 m_pDocument->ReleaseIndirectObject(objnum); 1251 m_pDocument->ReleaseIndirectObject(objnum);
1251 } 1252 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 return 1; 1313 return 1;
1313 } 1314 }
1314 } 1315 }
1315 return 0; 1316 return 0;
1316 } 1317 }
1317 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause) { 1318 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause) {
1318 int32_t iCount = m_NewObjNumArray.GetSize(); 1319 int32_t iCount = m_NewObjNumArray.GetSize();
1319 int32_t index = (int32_t)(uintptr_t)m_Pos; 1320 int32_t index = (int32_t)(uintptr_t)m_Pos;
1320 while (index < iCount) { 1321 while (index < iCount) {
1321 uint32_t objnum = m_NewObjNumArray.ElementAt(index); 1322 uint32_t objnum = m_NewObjNumArray.ElementAt(index);
1322 CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum); 1323 auto it = m_pDocument->m_IndirectObjs.find(objnum);
1323 if (!pObj) { 1324 if (it == m_pDocument->m_IndirectObjs.end()) {
1324 ++index; 1325 ++index;
1325 continue; 1326 continue;
1326 } 1327 }
1327 m_ObjectOffset[objnum] = m_Offset; 1328 m_ObjectOffset[objnum] = m_Offset;
1328 if (WriteIndirectObj(pObj)) { 1329 if (WriteIndirectObj(it->second)) {
1329 return -1; 1330 return -1;
1330 } 1331 }
1331 index++; 1332 index++;
1332 if (pPause && pPause->NeedToPauseNow()) { 1333 if (pPause && pPause->NeedToPauseNow()) {
1333 m_Pos = (FX_POSITION)(uintptr_t)index; 1334 m_Pos = (FX_POSITION)(uintptr_t)index;
1334 return 1; 1335 return 1;
1335 } 1336 }
1336 } 1337 }
1337 return 0; 1338 return 0;
1338 } 1339 }
(...skipping 16 matching lines...) Expand all
1355 j++; 1356 j++;
1356 1357
1357 m_ObjectOffset.Add(dwStart, j - dwStart); 1358 m_ObjectOffset.Add(dwStart, j - dwStart);
1358 dwStart = j; 1359 dwStart = j;
1359 } 1360 }
1360 } 1361 }
1361 1362
1362 void CPDF_Creator::InitNewObjNumOffsets() { 1363 void CPDF_Creator::InitNewObjNumOffsets() {
1363 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; 1364 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0;
1364 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; 1365 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0;
1365 for (const auto& pair : *m_pDocument) { 1366 for (const auto& pair : m_pDocument->m_IndirectObjs) {
1366 const uint32_t objnum = pair.first; 1367 const uint32_t objnum = pair.first;
1367 const CPDF_Object* pObj = pair.second; 1368 const CPDF_Object* pObj = pair.second;
1368 if (bIncremental || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) 1369 if (bIncremental || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum)
1369 continue; 1370 continue;
1370 if (m_pParser && m_pParser->IsValidObjectNumber(objnum) && 1371 if (m_pParser && m_pParser->IsValidObjectNumber(objnum) &&
1371 m_pParser->GetObjectType(objnum)) { 1372 m_pParser->GetObjectType(objnum)) {
1372 continue; 1373 continue;
1373 } 1374 }
1374 AppendNewObjNum(objnum); 1375 AppendNewObjNum(objnum);
1375 } 1376 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) { 1696 int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
1696 ASSERT(m_iStage >= 90); 1697 ASSERT(m_iStage >= 90);
1697 if ((m_dwFlags & FPDFCREATE_OBJECTSTREAM) == 0) { 1698 if ((m_dwFlags & FPDFCREATE_OBJECTSTREAM) == 0) {
1698 FX_BOOL bXRefStream = 1699 FX_BOOL bXRefStream =
1699 (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser->IsXRefStream(); 1700 (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser->IsXRefStream();
1700 if (!bXRefStream) { 1701 if (!bXRefStream) {
1701 if (m_File.AppendString("trailer\r\n<<") < 0) { 1702 if (m_File.AppendString("trailer\r\n<<") < 0) {
1702 return -1; 1703 return -1;
1703 } 1704 }
1704 } else { 1705 } else {
1705 if (m_File.AppendDWord(m_pDocument->GetLastObjNum() + 1) < 0) { 1706 if (m_File.AppendDWord(m_pDocument->m_LastObjNum + 1) < 0) {
1706 return -1; 1707 return -1;
1707 } 1708 }
1708 if (m_File.AppendString(" 0 obj <<") < 0) { 1709 if (m_File.AppendString(" 0 obj <<") < 0) {
1709 return -1; 1710 return -1;
1710 } 1711 }
1711 } 1712 }
1712 if (m_pParser) { 1713 if (m_pParser) {
1713 CPDF_Dictionary* p = m_pParser->GetTrailer(); 1714 CPDF_Dictionary* p = m_pParser->GetTrailer();
1714 for (const auto& it : *p) { 1715 for (const auto& it : *p) {
1715 const CFX_ByteString& key = it.first; 1716 const CFX_ByteString& key = it.first;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 m_pCryptoHandler = nullptr; 2016 m_pCryptoHandler = nullptr;
2016 } 2017 }
2017 void CPDF_Creator::ResetStandardSecurity() { 2018 void CPDF_Creator::ResetStandardSecurity() {
2018 if (!m_bLocalCryptoHandler) 2019 if (!m_bLocalCryptoHandler)
2019 return; 2020 return;
2020 2021
2021 delete m_pCryptoHandler; 2022 delete m_pCryptoHandler;
2022 m_pCryptoHandler = nullptr; 2023 m_pCryptoHandler = nullptr;
2023 m_bLocalCryptoHandler = FALSE; 2024 m_bLocalCryptoHandler = FALSE;
2024 } 2025 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/cfdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698