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

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

Issue 2001933002: Delete CPDF_Object::IsModified(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 7 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/include/cpdf_object.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/fpdf_edit/editint.h" 7 #include "core/fpdfapi/fpdf_edit/editint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 break; 1346 break;
1347 1347
1348 j = dwStart; 1348 j = dwStart;
1349 while (j <= dwEnd && !m_pParser->IsObjectFreeOrNull(j)) 1349 while (j <= dwEnd && !m_pParser->IsObjectFreeOrNull(j))
1350 j++; 1350 j++;
1351 1351
1352 m_ObjectOffset.Add(dwStart, j - dwStart); 1352 m_ObjectOffset.Add(dwStart, j - dwStart);
1353 dwStart = j; 1353 dwStart = j;
1354 } 1354 }
1355 } 1355 }
1356
1356 void CPDF_Creator::InitNewObjNumOffsets() { 1357 void CPDF_Creator::InitNewObjNumOffsets() {
1357 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; 1358 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0;
1358 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; 1359 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0;
1359 for (const auto& pair : m_pDocument->m_IndirectObjs) { 1360 for (const auto& pair : m_pDocument->m_IndirectObjs) {
1360 const uint32_t objnum = pair.first; 1361 const uint32_t objnum = pair.first;
1361 const CPDF_Object* pObj = pair.second; 1362 const CPDF_Object* pObj = pair.second;
1362 if (pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) 1363 if (bIncremental || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum)
1363 continue; 1364 continue;
1364 if (bIncremental) { 1365 if (m_pParser && m_pParser->IsValidObjectNumber(objnum) &&
1365 if (!pObj->IsModified()) 1366 m_pParser->GetObjectType(objnum)) {
1366 continue;
1367 } else if (m_pParser && m_pParser->IsValidObjectNumber(objnum) &&
1368 m_pParser->GetObjectType(objnum)) {
1369 continue; 1367 continue;
1370 } 1368 }
1371 AppendNewObjNum(objnum); 1369 AppendNewObjNum(objnum);
1372 } 1370 }
1373 1371
1374 int32_t iCount = m_NewObjNumArray.GetSize(); 1372 int32_t iCount = m_NewObjNumArray.GetSize();
1375 if (iCount == 0) { 1373 if (iCount == 0)
1376 return; 1374 return;
1377 } 1375
1378 int32_t i = 0; 1376 int32_t i = 0;
1379 uint32_t dwStartObjNum = 0; 1377 uint32_t dwStartObjNum = 0;
1380 FX_BOOL bCrossRefValid = m_pParser && m_pParser->GetLastXRefOffset() > 0; 1378 FX_BOOL bCrossRefValid = m_pParser && m_pParser->GetLastXRefOffset() > 0;
1381 while (i < iCount) { 1379 while (i < iCount) {
1382 dwStartObjNum = m_NewObjNumArray.ElementAt(i); 1380 dwStartObjNum = m_NewObjNumArray.ElementAt(i);
1383 if ((bIncremental && (bNoOriginal || bCrossRefValid)) || 1381 if ((bIncremental && (bNoOriginal || bCrossRefValid)) ||
1384 !m_ObjectOffset.GetPtrAt(dwStartObjNum)) { 1382 !m_ObjectOffset.GetPtrAt(dwStartObjNum)) {
1385 break; 1383 break;
1386 } 1384 }
1387 i++; 1385 i++;
1388 } 1386 }
1389 if (i >= iCount) { 1387 if (i >= iCount)
1390 return; 1388 return;
1391 } 1389
1392 uint32_t dwLastObjNum = dwStartObjNum; 1390 uint32_t dwLastObjNum = dwStartObjNum;
1393 i++; 1391 i++;
1394 FX_BOOL bNewStart = FALSE; 1392 bool bNewStart = false;
1395 for (; i < iCount; i++) { 1393 for (; i < iCount; i++) {
1396 uint32_t dwCurObjNum = m_NewObjNumArray.ElementAt(i); 1394 uint32_t dwCurObjNum = m_NewObjNumArray.ElementAt(i);
1397 bool bExist = m_pParser && m_pParser->IsValidObjectNumber(dwCurObjNum) && 1395 bool bExist = m_pParser && m_pParser->IsValidObjectNumber(dwCurObjNum) &&
1398 m_ObjectOffset.GetPtrAt(dwCurObjNum); 1396 m_ObjectOffset.GetPtrAt(dwCurObjNum);
1399 if (bExist || dwCurObjNum - dwLastObjNum > 1) { 1397 if (bExist || dwCurObjNum - dwLastObjNum > 1) {
1400 if (!bNewStart) 1398 if (!bNewStart)
1401 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); 1399 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1402 dwStartObjNum = dwCurObjNum; 1400 dwStartObjNum = dwCurObjNum;
1403 } 1401 }
1404 if (bNewStart) { 1402 if (bNewStart)
1405 dwStartObjNum = dwCurObjNum; 1403 dwStartObjNum = dwCurObjNum;
1406 } 1404
1407 bNewStart = bExist; 1405 bNewStart = bExist;
1408 dwLastObjNum = dwCurObjNum; 1406 dwLastObjNum = dwCurObjNum;
1409 } 1407 }
1410 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); 1408 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1411 } 1409 }
1410
1412 void CPDF_Creator::AppendNewObjNum(uint32_t objbum) { 1411 void CPDF_Creator::AppendNewObjNum(uint32_t objbum) {
1413 int32_t iStart = 0, iFind = 0; 1412 int32_t iStart = 0, iFind = 0;
1414 int32_t iEnd = m_NewObjNumArray.GetUpperBound(); 1413 int32_t iEnd = m_NewObjNumArray.GetUpperBound();
1415 while (iStart <= iEnd) { 1414 while (iStart <= iEnd) {
1416 int32_t iMid = (iStart + iEnd) / 2; 1415 int32_t iMid = (iStart + iEnd) / 2;
1417 uint32_t dwMid = m_NewObjNumArray.ElementAt(iMid); 1416 uint32_t dwMid = m_NewObjNumArray.ElementAt(iMid);
1418 if (objbum < dwMid) { 1417 if (objbum < dwMid) {
1419 iEnd = iMid - 1; 1418 iEnd = iMid - 1;
1420 } else { 1419 } else {
1421 if (iMid == iEnd) { 1420 if (iMid == iEnd) {
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 m_pCryptoHandler = nullptr; 2009 m_pCryptoHandler = nullptr;
2011 } 2010 }
2012 void CPDF_Creator::ResetStandardSecurity() { 2011 void CPDF_Creator::ResetStandardSecurity() {
2013 if (!m_bLocalCryptoHandler) 2012 if (!m_bLocalCryptoHandler)
2014 return; 2013 return;
2015 2014
2016 delete m_pCryptoHandler; 2015 delete m_pCryptoHandler;
2017 m_pCryptoHandler = nullptr; 2016 m_pCryptoHandler = nullptr;
2018 m_bLocalCryptoHandler = FALSE; 2017 m_bLocalCryptoHandler = FALSE;
2019 } 2018 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/include/cpdf_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698