Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1312 m_Offset += size; | 1312 m_Offset += size; |
| 1313 if (AppendObjectNumberToXRef(objnum) < 0) { | 1313 if (AppendObjectNumberToXRef(objnum) < 0) { |
| 1314 return -1; | 1314 return -1; |
| 1315 } | 1315 } |
| 1316 } | 1316 } |
| 1317 FX_Free(pBuffer); | 1317 FX_Free(pBuffer); |
| 1318 } | 1318 } |
| 1319 return 1; | 1319 return 1; |
| 1320 } | 1320 } |
| 1321 int32_t CPDF_Creator::WriteOldObjs(IFX_Pause* pPause) { | 1321 int32_t CPDF_Creator::WriteOldObjs(IFX_Pause* pPause) { |
| 1322 FX_DWORD nOldSize = m_pParser->m_CrossRef.GetSize(); | 1322 FX_DWORD nOldSize = m_pParser->GetSize(); |
| 1323 FX_DWORD objnum = (FX_DWORD)(uintptr_t)m_Pos; | 1323 FX_DWORD objnum = (FX_DWORD)(uintptr_t)m_Pos; |
| 1324 for (; objnum < nOldSize; objnum++) { | 1324 for (; objnum < nOldSize; objnum++) { |
|
Wei Li
2015/12/18 19:20:34
Not matter much. This sequential search could also
Lei Zhang
2015/12/19 02:09:52
Previously, if we only had 1 element in |m_CrossRe
| |
| 1325 int32_t iRet = WriteOldIndirectObject(objnum); | 1325 int32_t iRet = WriteOldIndirectObject(objnum); |
| 1326 if (!iRet) { | 1326 if (!iRet) { |
| 1327 continue; | 1327 continue; |
| 1328 } | 1328 } |
| 1329 if (iRet < 0) { | 1329 if (iRet < 0) { |
| 1330 return iRet; | 1330 return iRet; |
| 1331 } | 1331 } |
| 1332 m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]); | 1332 m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]); |
| 1333 if (pPause && pPause->NeedToPauseNow()) { | 1333 if (pPause && pPause->NeedToPauseNow()) { |
| 1334 m_Pos = (void*)(uintptr_t)(objnum + 1); | 1334 m_Pos = (void*)(uintptr_t)(objnum + 1); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1382 j++; | 1382 j++; |
| 1383 } | 1383 } |
| 1384 m_ObjectOffset.Add(dwStart, j - dwStart); | 1384 m_ObjectOffset.Add(dwStart, j - dwStart); |
| 1385 m_ObjectSize.Add(dwStart, j - dwStart); | 1385 m_ObjectSize.Add(dwStart, j - dwStart); |
| 1386 dwStart = j; | 1386 dwStart = j; |
| 1387 } | 1387 } |
| 1388 } | 1388 } |
| 1389 void CPDF_Creator::InitNewObjNumOffsets() { | 1389 void CPDF_Creator::InitNewObjNumOffsets() { |
| 1390 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; | 1390 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; |
| 1391 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; | 1391 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; |
| 1392 FX_DWORD nOldSize = m_pParser ? m_pParser->m_CrossRef.GetSize() : 0; | 1392 FX_DWORD nOldSize = m_pParser ? m_pParser->GetSize() : 0; |
| 1393 FX_POSITION pos = m_pDocument->m_IndirectObjs.GetStartPosition(); | 1393 FX_POSITION pos = m_pDocument->m_IndirectObjs.GetStartPosition(); |
| 1394 while (pos) { | 1394 while (pos) { |
| 1395 size_t key = 0; | 1395 size_t key = 0; |
| 1396 CPDF_Object* pObj; | 1396 CPDF_Object* pObj; |
| 1397 m_pDocument->m_IndirectObjs.GetNextAssoc(pos, (void*&)key, (void*&)pObj); | 1397 m_pDocument->m_IndirectObjs.GetNextAssoc(pos, (void*&)key, (void*&)pObj); |
| 1398 FX_DWORD objnum = (FX_DWORD)key; | 1398 FX_DWORD objnum = (FX_DWORD)key; |
| 1399 if (pObj->GetObjNum() == -1) { | 1399 if (pObj->GetObjNum() == -1) { |
| 1400 continue; | 1400 continue; |
| 1401 } | 1401 } |
| 1402 if (bIncremental) { | 1402 if (bIncremental) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1548 if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && | 1548 if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && |
| 1549 m_pParser->GetLastXRefOffset() == 0) { | 1549 m_pParser->GetLastXRefOffset() == 0) { |
| 1550 InitOldObjNumOffsets(); | 1550 InitOldObjNumOffsets(); |
| 1551 FX_DWORD dwEnd = m_pParser->GetLastObjNum(); | 1551 FX_DWORD dwEnd = m_pParser->GetLastObjNum(); |
| 1552 FX_BOOL bObjStm = (m_dwFlags & FPDFCREATE_OBJECTSTREAM) != 0; | 1552 FX_BOOL bObjStm = (m_dwFlags & FPDFCREATE_OBJECTSTREAM) != 0; |
| 1553 for (FX_DWORD objnum = 0; objnum <= dwEnd; objnum++) { | 1553 for (FX_DWORD objnum = 0; objnum <= dwEnd; objnum++) { |
| 1554 if (m_pParser->m_V5Type[objnum] == 0 || | 1554 if (m_pParser->m_V5Type[objnum] == 0 || |
| 1555 m_pParser->m_V5Type[objnum] == 255) { | 1555 m_pParser->m_V5Type[objnum] == 255) { |
| 1556 continue; | 1556 continue; |
| 1557 } | 1557 } |
| 1558 m_ObjectOffset[objnum] = m_pParser->m_CrossRef[objnum]; | 1558 m_ObjectOffset[objnum] = m_pParser->m_ObjectInfo[objnum].pos; |
| 1559 if (bObjStm) { | 1559 if (bObjStm) { |
| 1560 m_pXRefStream->AddObjectNumberToIndexArray(objnum); | 1560 m_pXRefStream->AddObjectNumberToIndexArray(objnum); |
| 1561 } | 1561 } |
| 1562 } | 1562 } |
| 1563 if (bObjStm) { | 1563 if (bObjStm) { |
| 1564 m_pXRefStream->EndXRefStream(this); | 1564 m_pXRefStream->EndXRefStream(this); |
| 1565 m_pXRefStream->Start(); | 1565 m_pXRefStream->Start(); |
| 1566 } | 1566 } |
| 1567 } | 1567 } |
| 1568 m_iStage = 20; | 1568 m_iStage = 20; |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2103 m_bNewCrypto = FALSE; | 2103 m_bNewCrypto = FALSE; |
| 2104 if (!m_bStandardSecurity) { | 2104 if (!m_bStandardSecurity) { |
| 2105 return; | 2105 return; |
| 2106 } | 2106 } |
| 2107 if (m_pEncryptDict) { | 2107 if (m_pEncryptDict) { |
| 2108 m_pEncryptDict->Release(); | 2108 m_pEncryptDict->Release(); |
| 2109 m_pEncryptDict = NULL; | 2109 m_pEncryptDict = NULL; |
| 2110 } | 2110 } |
| 2111 m_bStandardSecurity = FALSE; | 2111 m_bStandardSecurity = FALSE; |
| 2112 } | 2112 } |
| OLD | NEW |