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 "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 Loading... |
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 = | 1236 FX_BOOL bExistInMap = !!m_pDocument->GetIndirectObject(objnum); |
1237 pdfium::ContainsKey(m_pDocument->m_IndirectObjs, objnum); | |
1238 const uint8_t object_type = m_pParser->GetObjectType(objnum); | 1237 const uint8_t object_type = m_pParser->GetObjectType(objnum); |
1239 bool bObjStm = (object_type == 2) && m_pEncryptDict && !m_pXRefStream; | 1238 bool bObjStm = (object_type == 2) && m_pEncryptDict && !m_pXRefStream; |
1240 if (m_pParser->IsVersionUpdated() || m_bSecurityChanged || bExistInMap || | 1239 if (m_pParser->IsVersionUpdated() || m_bSecurityChanged || bExistInMap || |
1241 bObjStm) { | 1240 bObjStm) { |
1242 CPDF_Object* pObj = m_pDocument->GetOrParseIndirectObject(objnum); | 1241 CPDF_Object* pObj = m_pDocument->GetOrParseIndirectObject(objnum); |
1243 if (!pObj) { | 1242 if (!pObj) { |
1244 m_ObjectOffset[objnum] = 0; | 1243 m_ObjectOffset[objnum] = 0; |
1245 return 0; | 1244 return 0; |
1246 } | 1245 } |
1247 if (WriteIndirectObj(pObj)) { | 1246 if (WriteIndirectObj(pObj)) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 return 1; | 1312 return 1; |
1314 } | 1313 } |
1315 } | 1314 } |
1316 return 0; | 1315 return 0; |
1317 } | 1316 } |
1318 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause) { | 1317 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause) { |
1319 int32_t iCount = m_NewObjNumArray.GetSize(); | 1318 int32_t iCount = m_NewObjNumArray.GetSize(); |
1320 int32_t index = (int32_t)(uintptr_t)m_Pos; | 1319 int32_t index = (int32_t)(uintptr_t)m_Pos; |
1321 while (index < iCount) { | 1320 while (index < iCount) { |
1322 uint32_t objnum = m_NewObjNumArray.ElementAt(index); | 1321 uint32_t objnum = m_NewObjNumArray.ElementAt(index); |
1323 auto it = m_pDocument->m_IndirectObjs.find(objnum); | 1322 CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum); |
1324 if (it == m_pDocument->m_IndirectObjs.end()) { | 1323 if (!pObj) { |
1325 ++index; | 1324 ++index; |
1326 continue; | 1325 continue; |
1327 } | 1326 } |
1328 m_ObjectOffset[objnum] = m_Offset; | 1327 m_ObjectOffset[objnum] = m_Offset; |
1329 if (WriteIndirectObj(it->second)) { | 1328 if (WriteIndirectObj(pObj)) |
1330 return -1; | 1329 return -1; |
1331 } | 1330 |
1332 index++; | 1331 index++; |
1333 if (pPause && pPause->NeedToPauseNow()) { | 1332 if (pPause && pPause->NeedToPauseNow()) { |
1334 m_Pos = (FX_POSITION)(uintptr_t)index; | 1333 m_Pos = (FX_POSITION)(uintptr_t)index; |
1335 return 1; | 1334 return 1; |
1336 } | 1335 } |
1337 } | 1336 } |
1338 return 0; | 1337 return 0; |
1339 } | 1338 } |
1340 void CPDF_Creator::InitOldObjNumOffsets() { | 1339 void CPDF_Creator::InitOldObjNumOffsets() { |
1341 if (!m_pParser) { | 1340 if (!m_pParser) { |
(...skipping 14 matching lines...) Expand all Loading... |
1356 j++; | 1355 j++; |
1357 | 1356 |
1358 m_ObjectOffset.Add(dwStart, j - dwStart); | 1357 m_ObjectOffset.Add(dwStart, j - dwStart); |
1359 dwStart = j; | 1358 dwStart = j; |
1360 } | 1359 } |
1361 } | 1360 } |
1362 | 1361 |
1363 void CPDF_Creator::InitNewObjNumOffsets() { | 1362 void CPDF_Creator::InitNewObjNumOffsets() { |
1364 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; | 1363 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; |
1365 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; | 1364 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; |
1366 for (const auto& pair : m_pDocument->m_IndirectObjs) { | 1365 for (const auto& pair : *m_pDocument) { |
1367 const uint32_t objnum = pair.first; | 1366 const uint32_t objnum = pair.first; |
1368 const CPDF_Object* pObj = pair.second; | 1367 const CPDF_Object* pObj = pair.second; |
1369 if (bIncremental || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) | 1368 if (bIncremental || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) |
1370 continue; | 1369 continue; |
1371 if (m_pParser && m_pParser->IsValidObjectNumber(objnum) && | 1370 if (m_pParser && m_pParser->IsValidObjectNumber(objnum) && |
1372 m_pParser->GetObjectType(objnum)) { | 1371 m_pParser->GetObjectType(objnum)) { |
1373 continue; | 1372 continue; |
1374 } | 1373 } |
1375 AppendNewObjNum(objnum); | 1374 AppendNewObjNum(objnum); |
1376 } | 1375 } |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 m_pCryptoHandler = nullptr; | 2015 m_pCryptoHandler = nullptr; |
2017 } | 2016 } |
2018 void CPDF_Creator::ResetStandardSecurity() { | 2017 void CPDF_Creator::ResetStandardSecurity() { |
2019 if (!m_bLocalCryptoHandler) | 2018 if (!m_bLocalCryptoHandler) |
2020 return; | 2019 return; |
2021 | 2020 |
2022 delete m_pCryptoHandler; | 2021 delete m_pCryptoHandler; |
2023 m_pCryptoHandler = nullptr; | 2022 m_pCryptoHandler = nullptr; |
2024 m_bLocalCryptoHandler = FALSE; | 2023 m_bLocalCryptoHandler = FALSE; |
2025 } | 2024 } |
OLD | NEW |