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

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

Issue 1543413002: Remove CPDF_Creator::m_ObjectSize, it's never read from. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 11 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 | « core/include/fxcrt/fx_basic.h ('k') | no next file » | 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 "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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 _AppendIndex1(m_Buffer, *offset); 647 _AppendIndex1(m_Buffer, *offset);
648 } else { 648 } else {
649 _AppendIndex2(m_Buffer, dwObjStmNum, index++); 649 _AppendIndex2(m_Buffer, dwObjStmNum, index++);
650 } 650 }
651 } else { 651 } else {
652 _AppendIndex0(m_Buffer, FALSE); 652 _AppendIndex0(m_Buffer, FALSE);
653 } 653 }
654 } 654 }
655 if (iSize > 0 && bEOF) { 655 if (iSize > 0 && bEOF) {
656 pCreator->m_ObjectOffset.Add(dwObjStmNum, 1); 656 pCreator->m_ObjectOffset.Add(dwObjStmNum, 1);
657 pCreator->m_ObjectSize.Add(dwObjStmNum, 1);
658 pCreator->m_ObjectOffset[dwObjStmNum] = objOffset; 657 pCreator->m_ObjectOffset[dwObjStmNum] = objOffset;
659 } 658 }
660 m_iSeg = iSeg; 659 m_iSeg = iSeg;
661 if (bEOF) { 660 if (bEOF) {
662 m_ObjStream.Start(); 661 m_ObjStream.Start();
663 } 662 }
664 return 1; 663 return 1;
665 } 664 }
666 int32_t& j = m_ObjStream.m_index; 665 int32_t& j = m_ObjStream.m_index;
667 for (int i = m_iSeg; i < iSeg; i++) { 666 for (int i = m_iSeg; i < iSeg; i++) {
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 void* valuetemp = NULL; 1257 void* valuetemp = NULL;
1259 FX_BOOL bExistInMap = 1258 FX_BOOL bExistInMap =
1260 m_pDocument->m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, valuetemp); 1259 m_pDocument->m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, valuetemp);
1261 FX_BOOL bObjStm = 1260 FX_BOOL bObjStm =
1262 (m_pParser->m_V5Type[objnum] == 2) && m_pEncryptDict && !m_pXRefStream; 1261 (m_pParser->m_V5Type[objnum] == 2) && m_pEncryptDict && !m_pXRefStream;
1263 if (m_pParser->m_bVersionUpdated || m_bSecurityChanged || bExistInMap || 1262 if (m_pParser->m_bVersionUpdated || m_bSecurityChanged || bExistInMap ||
1264 bObjStm) { 1263 bObjStm) {
1265 CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum); 1264 CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum);
1266 if (!pObj) { 1265 if (!pObj) {
1267 m_ObjectOffset[objnum] = 0; 1266 m_ObjectOffset[objnum] = 0;
1268 m_ObjectSize[objnum] = 0;
1269 return 0; 1267 return 0;
1270 } 1268 }
1271 if (WriteIndirectObj(pObj)) { 1269 if (WriteIndirectObj(pObj)) {
1272 return -1; 1270 return -1;
1273 } 1271 }
1274 if (!bExistInMap) { 1272 if (!bExistInMap) {
1275 m_pDocument->ReleaseIndirectObject(objnum); 1273 m_pDocument->ReleaseIndirectObject(objnum);
1276 } 1274 }
1277 } else { 1275 } else {
1278 uint8_t* pBuffer; 1276 uint8_t* pBuffer;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 1323
1326 FX_DWORD objnum = (FX_DWORD)(uintptr_t)m_Pos; 1324 FX_DWORD objnum = (FX_DWORD)(uintptr_t)m_Pos;
1327 for (; objnum <= nLastObjNum; ++objnum) { 1325 for (; objnum <= nLastObjNum; ++objnum) {
1328 int32_t iRet = WriteOldIndirectObject(objnum); 1326 int32_t iRet = WriteOldIndirectObject(objnum);
1329 if (iRet < 0) 1327 if (iRet < 0)
1330 return iRet; 1328 return iRet;
1331 1329
1332 if (!iRet) 1330 if (!iRet)
1333 continue; 1331 continue;
1334 1332
1335 m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]);
1336 if (pPause && pPause->NeedToPauseNow()) { 1333 if (pPause && pPause->NeedToPauseNow()) {
1337 m_Pos = (void*)(uintptr_t)(objnum + 1); 1334 m_Pos = (void*)(uintptr_t)(objnum + 1);
1338 return 1; 1335 return 1;
1339 } 1336 }
1340 } 1337 }
1341 return 0; 1338 return 0;
1342 } 1339 }
1343 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause) { 1340 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause) {
1344 int32_t iCount = m_NewObjNumArray.GetSize(); 1341 int32_t iCount = m_NewObjNumArray.GetSize();
1345 int32_t index = (int32_t)(uintptr_t)m_Pos; 1342 int32_t index = (int32_t)(uintptr_t)m_Pos;
1346 while (index < iCount) { 1343 while (index < iCount) {
1347 FX_DWORD objnum = m_NewObjNumArray.ElementAt(index); 1344 FX_DWORD objnum = m_NewObjNumArray.ElementAt(index);
1348 CPDF_Object* pObj = NULL; 1345 CPDF_Object* pObj = NULL;
1349 m_pDocument->m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, (void*&)pObj); 1346 m_pDocument->m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, (void*&)pObj);
1350 if (NULL == pObj) { 1347 if (NULL == pObj) {
1351 ++index; 1348 ++index;
1352 continue; 1349 continue;
1353 } 1350 }
1354 m_ObjectOffset[objnum] = m_Offset; 1351 m_ObjectOffset[objnum] = m_Offset;
1355 if (WriteIndirectObj(pObj)) { 1352 if (WriteIndirectObj(pObj)) {
1356 return -1; 1353 return -1;
1357 } 1354 }
1358 m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]);
1359 index++; 1355 index++;
1360 if (pPause && pPause->NeedToPauseNow()) { 1356 if (pPause && pPause->NeedToPauseNow()) {
1361 m_Pos = (FX_POSITION)(uintptr_t)index; 1357 m_Pos = (FX_POSITION)(uintptr_t)index;
1362 return 1; 1358 return 1;
1363 } 1359 }
1364 } 1360 }
1365 return 0; 1361 return 0;
1366 } 1362 }
1367 void CPDF_Creator::InitOldObjNumOffsets() { 1363 void CPDF_Creator::InitOldObjNumOffsets() {
1368 if (!m_pParser) { 1364 if (!m_pParser) {
1369 return; 1365 return;
1370 } 1366 }
1371 FX_DWORD j = 0; 1367 FX_DWORD j = 0;
1372 FX_DWORD dwStart = 0; 1368 FX_DWORD dwStart = 0;
1373 FX_DWORD dwEnd = m_pParser->GetLastObjNum(); 1369 FX_DWORD dwEnd = m_pParser->GetLastObjNum();
1374 while (dwStart <= dwEnd) { 1370 while (dwStart <= dwEnd) {
1375 while (dwStart <= dwEnd && (m_pParser->m_V5Type[dwStart] == 0 || 1371 while (dwStart <= dwEnd && (m_pParser->m_V5Type[dwStart] == 0 ||
1376 m_pParser->m_V5Type[dwStart] == 255)) { 1372 m_pParser->m_V5Type[dwStart] == 255)) {
1377 dwStart++; 1373 dwStart++;
1378 } 1374 }
1379 if (dwStart > dwEnd) { 1375 if (dwStart > dwEnd) {
1380 break; 1376 break;
1381 } 1377 }
1382 j = dwStart; 1378 j = dwStart;
1383 while (j <= dwEnd && m_pParser->m_V5Type[j] != 0 && 1379 while (j <= dwEnd && m_pParser->m_V5Type[j] != 0 &&
1384 m_pParser->m_V5Type[j] != 255) { 1380 m_pParser->m_V5Type[j] != 255) {
1385 j++; 1381 j++;
1386 } 1382 }
1387 m_ObjectOffset.Add(dwStart, j - dwStart); 1383 m_ObjectOffset.Add(dwStart, j - dwStart);
1388 m_ObjectSize.Add(dwStart, j - dwStart);
1389 dwStart = j; 1384 dwStart = j;
1390 } 1385 }
1391 } 1386 }
1392 void CPDF_Creator::InitNewObjNumOffsets() { 1387 void CPDF_Creator::InitNewObjNumOffsets() {
1393 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; 1388 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0;
1394 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; 1389 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0;
1395 FX_POSITION pos = m_pDocument->m_IndirectObjs.GetStartPosition(); 1390 FX_POSITION pos = m_pDocument->m_IndirectObjs.GetStartPosition();
1396 while (pos) { 1391 while (pos) {
1397 size_t key = 0; 1392 size_t key = 0;
1398 CPDF_Object* pObj; 1393 CPDF_Object* pObj;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 return; 1425 return;
1431 } 1426 }
1432 FX_DWORD dwLastObjNum = dwStartObjNum; 1427 FX_DWORD dwLastObjNum = dwStartObjNum;
1433 i++; 1428 i++;
1434 FX_BOOL bNewStart = FALSE; 1429 FX_BOOL bNewStart = FALSE;
1435 for (; i < iCount; i++) { 1430 for (; i < iCount; i++) {
1436 FX_DWORD dwCurObjNum = m_NewObjNumArray.ElementAt(i); 1431 FX_DWORD dwCurObjNum = m_NewObjNumArray.ElementAt(i);
1437 bool bExist = m_pParser && m_pParser->IsValidObjectNumber(dwCurObjNum) && 1432 bool bExist = m_pParser && m_pParser->IsValidObjectNumber(dwCurObjNum) &&
1438 m_ObjectOffset.GetPtrAt(dwCurObjNum); 1433 m_ObjectOffset.GetPtrAt(dwCurObjNum);
1439 if (bExist || dwCurObjNum - dwLastObjNum > 1) { 1434 if (bExist || dwCurObjNum - dwLastObjNum > 1) {
1440 if (!bNewStart) { 1435 if (!bNewStart)
1441 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); 1436 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1442 m_ObjectSize.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1443 }
1444 dwStartObjNum = dwCurObjNum; 1437 dwStartObjNum = dwCurObjNum;
1445 } 1438 }
1446 if (bNewStart) { 1439 if (bNewStart) {
1447 dwStartObjNum = dwCurObjNum; 1440 dwStartObjNum = dwCurObjNum;
1448 } 1441 }
1449 bNewStart = bExist; 1442 bNewStart = bExist;
1450 dwLastObjNum = dwCurObjNum; 1443 dwLastObjNum = dwCurObjNum;
1451 } 1444 }
1452 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); 1445 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1453 m_ObjectSize.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1454 } 1446 }
1455 void CPDF_Creator::AppendNewObjNum(FX_DWORD objbum) { 1447 void CPDF_Creator::AppendNewObjNum(FX_DWORD objbum) {
1456 int32_t iStart = 0, iFind = 0; 1448 int32_t iStart = 0, iFind = 0;
1457 int32_t iEnd = m_NewObjNumArray.GetUpperBound(); 1449 int32_t iEnd = m_NewObjNumArray.GetUpperBound();
1458 while (iStart <= iEnd) { 1450 while (iStart <= iEnd) {
1459 int32_t iMid = (iStart + iEnd) / 2; 1451 int32_t iMid = (iStart + iEnd) / 2;
1460 FX_DWORD dwMid = m_NewObjNumArray.ElementAt(iMid); 1452 FX_DWORD dwMid = m_NewObjNumArray.ElementAt(iMid);
1461 if (objbum < dwMid) { 1453 if (objbum < dwMid) {
1462 iEnd = iMid - 1; 1454 iEnd = iMid - 1;
1463 } else { 1455 } else {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 } 1594 }
1603 if (m_iStage == 27) { 1595 if (m_iStage == 27) {
1604 if (NULL != m_pEncryptDict && 0 == m_pEncryptDict->GetObjNum()) { 1596 if (NULL != m_pEncryptDict && 0 == m_pEncryptDict->GetObjNum()) {
1605 m_dwLastObjNum += 1; 1597 m_dwLastObjNum += 1;
1606 FX_FILESIZE saveOffset = m_Offset; 1598 FX_FILESIZE saveOffset = m_Offset;
1607 if (WriteIndirectObj(m_dwLastObjNum, m_pEncryptDict) < 0) { 1599 if (WriteIndirectObj(m_dwLastObjNum, m_pEncryptDict) < 0) {
1608 return -1; 1600 return -1;
1609 } 1601 }
1610 m_ObjectOffset.Add(m_dwLastObjNum, 1); 1602 m_ObjectOffset.Add(m_dwLastObjNum, 1);
1611 m_ObjectOffset[m_dwLastObjNum] = saveOffset; 1603 m_ObjectOffset[m_dwLastObjNum] = saveOffset;
1612 m_ObjectSize.Add(m_dwLastObjNum, 1);
1613 m_ObjectSize[m_dwLastObjNum] = m_Offset - saveOffset;
1614 m_dwEnryptObjNum = m_dwLastObjNum; 1604 m_dwEnryptObjNum = m_dwLastObjNum;
1615 if (m_dwFlags & FPDFCREATE_INCREMENTAL) { 1605 if (m_dwFlags & FPDFCREATE_INCREMENTAL) {
1616 m_NewObjNumArray.Add(m_dwLastObjNum); 1606 m_NewObjNumArray.Add(m_dwLastObjNum);
1617 } 1607 }
1618 } 1608 }
1619 m_iStage = 80; 1609 m_iStage = 80;
1620 } 1610 }
1621 return m_iStage; 1611 return m_iStage;
1622 } 1612 }
1623 int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause* pPause) { 1613 int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause* pPause) {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 return FALSE; 1981 return FALSE;
1992 } 1982 }
1993 return Create(flags); 1983 return Create(flags);
1994 } 1984 }
1995 FX_BOOL CPDF_Creator::Create(FX_DWORD flags) { 1985 FX_BOOL CPDF_Creator::Create(FX_DWORD flags) {
1996 m_dwFlags = flags; 1986 m_dwFlags = flags;
1997 m_iStage = 0; 1987 m_iStage = 0;
1998 m_Offset = 0; 1988 m_Offset = 0;
1999 m_dwLastObjNum = m_pDocument->GetLastObjNum(); 1989 m_dwLastObjNum = m_pDocument->GetLastObjNum();
2000 m_ObjectOffset.Clear(); 1990 m_ObjectOffset.Clear();
2001 m_ObjectSize.Clear();
2002 m_NewObjNumArray.RemoveAll(); 1991 m_NewObjNumArray.RemoveAll();
2003 InitID(); 1992 InitID();
2004 if (flags & FPDFCREATE_PROGRESSIVE) { 1993 if (flags & FPDFCREATE_PROGRESSIVE) {
2005 return TRUE; 1994 return TRUE;
2006 } 1995 }
2007 return Continue(NULL) > -1; 1996 return Continue(NULL) > -1;
2008 } 1997 }
2009 void CPDF_Creator::InitID(FX_BOOL bDefault) { 1998 void CPDF_Creator::InitID(FX_BOOL bDefault) {
2010 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL; 1999 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL;
2011 FX_BOOL bNewId = !m_pIDArray; 2000 FX_BOOL bNewId = !m_pIDArray;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 m_bNewCrypto = FALSE; 2093 m_bNewCrypto = FALSE;
2105 if (!m_bStandardSecurity) { 2094 if (!m_bStandardSecurity) {
2106 return; 2095 return;
2107 } 2096 }
2108 if (m_pEncryptDict) { 2097 if (m_pEncryptDict) {
2109 m_pEncryptDict->Release(); 2098 m_pEncryptDict->Release();
2110 m_pEncryptDict = NULL; 2099 m_pEncryptDict = NULL;
2111 } 2100 }
2112 m_bStandardSecurity = FALSE; 2101 m_bStandardSecurity = FALSE;
2113 } 2102 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_basic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698