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

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

Issue 1171733003: Remove typdefs for pointer types in fx_system.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual fixes. Created 5 years, 6 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
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 "../../../include/fpdfapi/fpdf_serial.h" 7 #include "../../../include/fpdfapi/fpdf_serial.h"
8 #include "editint.h" 8 #include "editint.h"
9 #define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024) 9 #define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024)
10 #define PDF_XREFSTREAM_MAXSIZE 10000 10 #define PDF_XREFSTREAM_MAXSIZE 10000
11 extern void FlateEncode(const uint8_t* src_buf, FX_DWORD src_data, FX_LPBYTE& de st_buf, FX_DWORD& dest_size); 11 extern void FlateEncode(const uint8_t* src_buf, FX_DWORD src_data, uint8_t*& des t_buf, FX_DWORD& dest_size);
12 extern void FlateEncode(FX_LPCBYTE src_buf, FX_DWORD src_size, int predictor, in t Colors, int BitsPerComponent, int Columns, 12 extern void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, int predictor , int Colors, int BitsPerComponent, int Columns,
13 FX_LPBYTE& dest_buf, FX_DWORD& dest_size); 13 uint8_t*& dest_buf, FX_DWORD& dest_size);
14 extern FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict); 14 extern FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict);
15 int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, CFX_FileBufferArchive * pFile, FX_FILESIZE& offset) 15 int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, CFX_FileBufferArchive * pFile, FX_FILESIZE& offset)
16 { 16 {
17 int32_t len = 0; 17 int32_t len = 0;
18 if (pObj == NULL) { 18 if (pObj == NULL) {
19 if (pFile->AppendString(FX_BSTRC(" null")) < 0) { 19 if (pFile->AppendString(FX_BSTRC(" null")) < 0) {
20 return -1; 20 return -1;
21 } 21 }
22 offset += 5; 22 offset += 5;
23 return 1; 23 return 1;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 276 }
277 if ((len = pFile->AppendDWord(dwObjNum)) < 0) { 277 if ((len = pFile->AppendDWord(dwObjNum)) < 0) {
278 return -1; 278 return -1;
279 } 279 }
280 if (pFile->AppendString(FX_BSTRC(" 0 R ")) < 0) { 280 if (pFile->AppendString(FX_BSTRC(" 0 R ")) < 0) {
281 return -1; 281 return -1;
282 } 282 }
283 offset += len + 6; 283 offset += len + 6;
284 return offset; 284 return offset;
285 } 285 }
286 FX_BOOL PDF_GenerateFileID(FX_DWORD dwSeed1, FX_DWORD dwSeed2, FX_LPDWORD pBuffe r) 286 FX_BOOL PDF_GenerateFileID(FX_DWORD dwSeed1, FX_DWORD dwSeed2, FX_DWORD* pBuffer )
287 { 287 {
288 if (!pBuffer) { 288 if (!pBuffer) {
289 return FALSE; 289 return FALSE;
290 } 290 }
291 FX_LPVOID pContext = FX_Random_MT_Start(dwSeed1); 291 void* pContext = FX_Random_MT_Start(dwSeed1);
292 int32_t i = 0; 292 int32_t i = 0;
293 for (i = 0; i < 2; i++) { 293 for (i = 0; i < 2; i++) {
294 *pBuffer++ = FX_Random_MT_Generate(pContext); 294 *pBuffer++ = FX_Random_MT_Generate(pContext);
295 } 295 }
296 FX_Random_MT_Close(pContext); 296 FX_Random_MT_Close(pContext);
297 pContext = FX_Random_MT_Start(dwSeed2); 297 pContext = FX_Random_MT_Start(dwSeed2);
298 for (i = 0; i < 2; i++) { 298 for (i = 0; i < 2; i++) {
299 *pBuffer++ = FX_Random_MT_Generate(pContext); 299 *pBuffer++ = FX_Random_MT_Generate(pContext);
300 } 300 }
301 FX_Random_MT_Close(pContext); 301 FX_Random_MT_Close(pContext);
302 return TRUE; 302 return TRUE;
303 } 303 }
304 class CPDF_FlateEncoder 304 class CPDF_FlateEncoder
305 { 305 {
306 public: 306 public:
307 CPDF_FlateEncoder(); 307 CPDF_FlateEncoder();
308 ~CPDF_FlateEncoder(); 308 ~CPDF_FlateEncoder();
309 FX_BOOL Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode); 309 FX_BOOL Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode);
310 FX_BOOL» » Initialize(FX_LPCBYTE pBuffer, FX_DWORD size, FX_BOOL bF lateEncode, FX_BOOL bXRefStream = FALSE); 310 FX_BOOL» » Initialize(const uint8_t* pBuffer, FX_DWORD size, FX_BOO L bFlateEncode, FX_BOOL bXRefStream = FALSE);
311 void CloneDict(); 311 void CloneDict();
312 FX_LPBYTE» » » m_pData; 312 uint8_t*» » » m_pData;
313 FX_DWORD m_dwSize; 313 FX_DWORD m_dwSize;
314 CPDF_Dictionary* m_pDict; 314 CPDF_Dictionary* m_pDict;
315 FX_BOOL m_bCloned; 315 FX_BOOL m_bCloned;
316 FX_BOOL m_bNewData; 316 FX_BOOL m_bNewData;
317 CPDF_StreamAcc m_Acc; 317 CPDF_StreamAcc m_Acc;
318 }; 318 };
319 CPDF_FlateEncoder::CPDF_FlateEncoder() 319 CPDF_FlateEncoder::CPDF_FlateEncoder()
320 { 320 {
321 m_pData = NULL; 321 m_pData = NULL;
322 m_dwSize = 0; 322 m_dwSize = 0;
323 m_pDict = NULL; 323 m_pDict = NULL;
324 m_bCloned = FALSE; 324 m_bCloned = FALSE;
325 m_bNewData = FALSE; 325 m_bNewData = FALSE;
326 } 326 }
327 void CPDF_FlateEncoder::CloneDict() 327 void CPDF_FlateEncoder::CloneDict()
328 { 328 {
329 if (!m_bCloned) { 329 if (!m_bCloned) {
330 m_pDict = (CPDF_Dictionary*)m_pDict->Clone(); 330 m_pDict = (CPDF_Dictionary*)m_pDict->Clone();
331 m_bCloned = TRUE; 331 m_bCloned = TRUE;
332 } 332 }
333 } 333 }
334 FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode ) 334 FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode )
335 { 335 {
336 m_Acc.LoadAllData(pStream, TRUE); 336 m_Acc.LoadAllData(pStream, TRUE);
337 if ((pStream && pStream->GetDict() && pStream->GetDict()->KeyExist("Filter") ) || !bFlateEncode) { 337 if ((pStream && pStream->GetDict() && pStream->GetDict()->KeyExist("Filter") ) || !bFlateEncode) {
338 if (pStream->GetDict()->KeyExist("Filter") && !bFlateEncode) { 338 if (pStream->GetDict()->KeyExist("Filter") && !bFlateEncode) {
339 CPDF_StreamAcc destAcc; 339 CPDF_StreamAcc destAcc;
340 destAcc.LoadAllData(pStream); 340 destAcc.LoadAllData(pStream);
341 m_dwSize = destAcc.GetSize(); 341 m_dwSize = destAcc.GetSize();
342 m_pData = (FX_LPBYTE)destAcc.DetachData(); 342 m_pData = (uint8_t*)destAcc.DetachData();
343 m_pDict = (CPDF_Dictionary*)pStream->GetDict()->Clone(); 343 m_pDict = (CPDF_Dictionary*)pStream->GetDict()->Clone();
344 m_pDict->RemoveAt(FX_BSTRC("Filter")); 344 m_pDict->RemoveAt(FX_BSTRC("Filter"));
345 m_bNewData = TRUE; 345 m_bNewData = TRUE;
346 m_bCloned = TRUE; 346 m_bCloned = TRUE;
347 } else { 347 } else {
348 m_pData = (FX_LPBYTE)m_Acc.GetData(); 348 m_pData = (uint8_t*)m_Acc.GetData();
349 m_dwSize = m_Acc.GetSize(); 349 m_dwSize = m_Acc.GetSize();
350 m_pDict = pStream->GetDict(); 350 m_pDict = pStream->GetDict();
351 } 351 }
352 return TRUE; 352 return TRUE;
353 } 353 }
354 m_pData = NULL; 354 m_pData = NULL;
355 m_dwSize = 0; 355 m_dwSize = 0;
356 m_bNewData = TRUE; 356 m_bNewData = TRUE;
357 m_bCloned = TRUE; 357 m_bCloned = TRUE;
358 ::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), m_pData, m_dwSize); 358 ::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), m_pData, m_dwSize);
359 m_pDict = (CPDF_Dictionary*)pStream->GetDict()->Clone(); 359 m_pDict = (CPDF_Dictionary*)pStream->GetDict()->Clone();
360 m_pDict->SetAtInteger("Length", m_dwSize); 360 m_pDict->SetAtInteger("Length", m_dwSize);
361 m_pDict->SetAtName("Filter", "FlateDecode"); 361 m_pDict->SetAtName("Filter", "FlateDecode");
362 m_pDict->RemoveAt("DecodeParms"); 362 m_pDict->RemoveAt("DecodeParms");
363 return TRUE; 363 return TRUE;
364 } 364 }
365 FX_BOOL CPDF_FlateEncoder::Initialize(FX_LPCBYTE pBuffer, FX_DWORD size, FX_BOOL bFlateEncode, FX_BOOL bXRefStream) 365 FX_BOOL CPDF_FlateEncoder::Initialize(const uint8_t* pBuffer, FX_DWORD size, FX_ BOOL bFlateEncode, FX_BOOL bXRefStream)
366 { 366 {
367 if (!bFlateEncode) { 367 if (!bFlateEncode) {
368 m_pData = (FX_LPBYTE)pBuffer; 368 m_pData = (uint8_t*)pBuffer;
369 m_dwSize = size; 369 m_dwSize = size;
370 return TRUE; 370 return TRUE;
371 } 371 }
372 m_bNewData = TRUE; 372 m_bNewData = TRUE;
373 if (bXRefStream) { 373 if (bXRefStream) {
374 ::FlateEncode(pBuffer, size, 12, 1, 8, 7, m_pData, m_dwSize); 374 ::FlateEncode(pBuffer, size, 12, 1, 8, 7, m_pData, m_dwSize);
375 } else { 375 } else {
376 ::FlateEncode(pBuffer, size, m_pData, m_dwSize); 376 ::FlateEncode(pBuffer, size, m_pData, m_dwSize);
377 } 377 }
378 return TRUE; 378 return TRUE;
379 } 379 }
380 CPDF_FlateEncoder::~CPDF_FlateEncoder() 380 CPDF_FlateEncoder::~CPDF_FlateEncoder()
381 { 381 {
382 if (m_bCloned && m_pDict) { 382 if (m_bCloned && m_pDict) {
383 m_pDict->Release(); 383 m_pDict->Release();
384 } 384 }
385 if (m_bNewData && m_pData) { 385 if (m_bNewData && m_pData) {
386 FX_Free(m_pData); 386 FX_Free(m_pData);
387 } 387 }
388 } 388 }
389 class CPDF_Encryptor 389 class CPDF_Encryptor
390 { 390 {
391 public: 391 public:
392 CPDF_Encryptor(); 392 CPDF_Encryptor();
393 ~CPDF_Encryptor(); 393 ~CPDF_Encryptor();
394 FX_BOOL» » Initialize(CPDF_CryptoHandler* pHandler, int objnum, FX_ LPBYTE src_data, FX_DWORD src_size); 394 FX_BOOL» » Initialize(CPDF_CryptoHandler* pHandler, int objnum, uin t8_t* src_data, FX_DWORD src_size);
395 FX_LPBYTE» » » m_pData; 395 uint8_t*» » » m_pData;
396 FX_DWORD m_dwSize; 396 FX_DWORD m_dwSize;
397 FX_BOOL m_bNewBuf; 397 FX_BOOL m_bNewBuf;
398 }; 398 };
399 CPDF_Encryptor::CPDF_Encryptor() 399 CPDF_Encryptor::CPDF_Encryptor()
400 { 400 {
401 m_pData = NULL; 401 m_pData = NULL;
402 m_dwSize = 0; 402 m_dwSize = 0;
403 m_bNewBuf = FALSE; 403 m_bNewBuf = FALSE;
404 } 404 }
405 FX_BOOL CPDF_Encryptor::Initialize(CPDF_CryptoHandler* pHandler, int objnum, FX_ LPBYTE src_data, FX_DWORD src_size) 405 FX_BOOL CPDF_Encryptor::Initialize(CPDF_CryptoHandler* pHandler, int objnum, uin t8_t* src_data, FX_DWORD src_size)
406 { 406 {
407 if (src_size == 0) { 407 if (src_size == 0) {
408 return TRUE; 408 return TRUE;
409 } 409 }
410 if (pHandler == NULL) { 410 if (pHandler == NULL) {
411 m_pData = (FX_LPBYTE)src_data; 411 m_pData = (uint8_t*)src_data;
412 m_dwSize = src_size; 412 m_dwSize = src_size;
413 m_bNewBuf = FALSE; 413 m_bNewBuf = FALSE;
414 return TRUE; 414 return TRUE;
415 } 415 }
416 m_dwSize = pHandler->EncryptGetSize(objnum, 0, src_data, src_size); 416 m_dwSize = pHandler->EncryptGetSize(objnum, 0, src_data, src_size);
417 m_pData = FX_Alloc(uint8_t, m_dwSize); 417 m_pData = FX_Alloc(uint8_t, m_dwSize);
418 pHandler->EncryptContent(objnum, 0, src_data, src_size, m_pData, m_dwSize); 418 pHandler->EncryptContent(objnum, 0, src_data, src_size, m_pData, m_dwSize);
419 m_bNewBuf = TRUE; 419 m_bNewBuf = TRUE;
420 return TRUE; 420 return TRUE;
421 } 421 }
(...skipping 17 matching lines...) Expand all
439 m_index = 0; 439 m_index = 0;
440 return TRUE; 440 return TRUE;
441 } 441 }
442 int32_t CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, const CPDF_ Object *pObj) 442 int32_t CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, const CPDF_ Object *pObj)
443 { 443 {
444 m_ObjNumArray.Add(dwObjNum); 444 m_ObjNumArray.Add(dwObjNum);
445 m_OffsetArray.Add(m_Buffer.GetLength()); 445 m_OffsetArray.Add(m_Buffer.GetLength());
446 m_Buffer << pObj; 446 m_Buffer << pObj;
447 return 1; 447 return 1;
448 } 448 }
449 int32_t CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE pBuffer, FX_DWORD dwSize) 449 int32_t CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, const uint8 _t* pBuffer, FX_DWORD dwSize)
450 { 450 {
451 m_ObjNumArray.Add(dwObjNum); 451 m_ObjNumArray.Add(dwObjNum);
452 m_OffsetArray.Add(m_Buffer.GetLength()); 452 m_OffsetArray.Add(m_Buffer.GetLength());
453 m_Buffer.AppendBlock(pBuffer, dwSize); 453 m_Buffer.AppendBlock(pBuffer, dwSize);
454 return 1; 454 return 1;
455 } 455 }
456 FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) 456 FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator)
457 { 457 {
458 FXSYS_assert(pCreator); 458 FXSYS_assert(pCreator);
459 if (m_ObjNumArray.GetSize() == 0) { 459 if (m_ObjNumArray.GetSize() == 0) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 if (!pCreator) { 557 if (!pCreator) {
558 return 0; 558 return 0;
559 } 559 }
560 m_ObjStream.CompressIndirectObject(dwObjNum, pObj); 560 m_ObjStream.CompressIndirectObject(dwObjNum, pObj);
561 if (m_ObjStream.m_ObjNumArray.GetSize() < pCreator->m_ObjectStreamSize && 561 if (m_ObjStream.m_ObjNumArray.GetSize() < pCreator->m_ObjectStreamSize &&
562 m_ObjStream.m_Buffer.GetLength() < PDF_OBJECTSTREAM_MAXLENGTH) { 562 m_ObjStream.m_Buffer.GetLength() < PDF_OBJECTSTREAM_MAXLENGTH) {
563 return 1; 563 return 1;
564 } 564 }
565 return EndObjectStream(pCreator); 565 return EndObjectStream(pCreator);
566 } 566 }
567 int32_t CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE pB uffer, FX_DWORD dwSize, CPDF_Creator *pCreator) 567 int32_t CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, const uint8_t * pBuffer, FX_DWORD dwSize, CPDF_Creator *pCreator)
568 { 568 {
569 if (!pCreator) { 569 if (!pCreator) {
570 return 0; 570 return 0;
571 } 571 }
572 m_ObjStream.CompressIndirectObject(dwObjNum, pBuffer, dwSize); 572 m_ObjStream.CompressIndirectObject(dwObjNum, pBuffer, dwSize);
573 if (m_ObjStream.m_ObjNumArray.GetSize() < pCreator->m_ObjectStreamSize && 573 if (m_ObjStream.m_ObjNumArray.GetSize() < pCreator->m_ObjectStreamSize &&
574 m_ObjStream.m_Buffer.GetLength() < PDF_OBJECTSTREAM_MAXLENGTH) { 574 m_ObjStream.m_Buffer.GetLength() < PDF_OBJECTSTREAM_MAXLENGTH) {
575 return 1; 575 return 1;
576 } 576 }
577 return EndObjectStream(pCreator); 577 return EndObjectStream(pCreator);
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 return 0; 951 return 0;
952 } 952 }
953 if (!m_pXRefStream->End(this)) { 953 if (!m_pXRefStream->End(this)) {
954 return -1; 954 return -1;
955 } 955 }
956 if (!m_pXRefStream->Start()) { 956 if (!m_pXRefStream->Start()) {
957 return -1; 957 return -1;
958 } 958 }
959 return 0; 959 return 0;
960 } 960 }
961 int32_t CPDF_Creator::WriteIndirectObjectToStream(FX_DWORD objnum, FX_LPCBYTE pB uffer, FX_DWORD dwSize) 961 int32_t CPDF_Creator::WriteIndirectObjectToStream(FX_DWORD objnum, const uint8_t * pBuffer, FX_DWORD dwSize)
962 { 962 {
963 if (!m_pXRefStream) { 963 if (!m_pXRefStream) {
964 return 1; 964 return 1;
965 } 965 }
966 m_pXRefStream->AddObjectNumberToIndexArray(objnum); 966 m_pXRefStream->AddObjectNumberToIndexArray(objnum);
967 int32_t iRet = m_pXRefStream->CompressIndirectObject(objnum, pBuffer, dwSize , this); 967 int32_t iRet = m_pXRefStream->CompressIndirectObject(objnum, pBuffer, dwSize , this);
968 if (iRet < 1) { 968 if (iRet < 1) {
969 return iRet; 969 return iRet;
970 } 970 }
971 if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) { 971 if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 FX_BOOL bHex = ((CPDF_String*)pObj)->IsHex(); 1097 FX_BOOL bHex = ((CPDF_String*)pObj)->IsHex();
1098 if (m_pCryptoHandler == NULL || !bEncrypt) { 1098 if (m_pCryptoHandler == NULL || !bEncrypt) {
1099 CFX_ByteString content = PDF_EncodeString(str, bHex); 1099 CFX_ByteString content = PDF_EncodeString(str, bHex);
1100 if ((len = m_File.AppendString(content)) < 0) { 1100 if ((len = m_File.AppendString(content)) < 0) {
1101 return -1; 1101 return -1;
1102 } 1102 }
1103 m_Offset += len; 1103 m_Offset += len;
1104 break; 1104 break;
1105 } 1105 }
1106 CPDF_Encryptor encryptor; 1106 CPDF_Encryptor encryptor;
1107 encryptor.Initialize(m_pCryptoHandler, objnum, (FX_LPBYTE)str.c_ str(), str.GetLength()); 1107 encryptor.Initialize(m_pCryptoHandler, objnum, (uint8_t*)str.c_s tr(), str.GetLength());
1108 CFX_ByteString content = PDF_EncodeString(CFX_ByteString((FX_LPC STR)encryptor.m_pData, encryptor.m_dwSize), bHex); 1108 CFX_ByteString content = PDF_EncodeString(CFX_ByteString((const FX_CHAR*)encryptor.m_pData, encryptor.m_dwSize), bHex);
1109 if ((len = m_File.AppendString(content)) < 0) { 1109 if ((len = m_File.AppendString(content)) < 0) {
1110 return -1; 1110 return -1;
1111 } 1111 }
1112 m_Offset += len; 1112 m_Offset += len;
1113 break; 1113 break;
1114 } 1114 }
1115 case PDFOBJ_STREAM: { 1115 case PDFOBJ_STREAM: {
1116 CPDF_FlateEncoder encoder; 1116 CPDF_FlateEncoder encoder;
1117 encoder.Initialize((CPDF_Stream*)pObj, m_bCompress); 1117 encoder.Initialize((CPDF_Stream*)pObj, m_bCompress);
1118 CPDF_Encryptor encryptor; 1118 CPDF_Encryptor encryptor;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 } 1245 }
1246 } 1246 }
1247 return 1; 1247 return 1;
1248 } 1248 }
1249 int32_t CPDF_Creator::WriteOldIndirectObject(FX_DWORD objnum) 1249 int32_t CPDF_Creator::WriteOldIndirectObject(FX_DWORD objnum)
1250 { 1250 {
1251 if(m_pParser->m_V5Type[objnum] == 0 || m_pParser->m_V5Type[objnum] == 255) { 1251 if(m_pParser->m_V5Type[objnum] == 0 || m_pParser->m_V5Type[objnum] == 255) {
1252 return 0; 1252 return 0;
1253 } 1253 }
1254 m_ObjectOffset[objnum] = m_Offset; 1254 m_ObjectOffset[objnum] = m_Offset;
1255 FX_LPVOID valuetemp = NULL; 1255 void* valuetemp = NULL;
1256 FX_BOOL bExistInMap = m_pDocument->m_IndirectObjs.Lookup((FX_LPVOID)(uintptr _t)objnum, valuetemp); 1256 FX_BOOL bExistInMap = m_pDocument->m_IndirectObjs.Lookup((void*)(uintptr_t)o bjnum, valuetemp);
1257 FX_BOOL bObjStm = (m_pParser->m_V5Type[objnum] == 2) && m_pEncryptDict && !m _pXRefStream; 1257 FX_BOOL bObjStm = (m_pParser->m_V5Type[objnum] == 2) && m_pEncryptDict && !m _pXRefStream;
1258 if(m_pParser->m_bVersionUpdated || m_bSecurityChanged || bExistInMap || bObj Stm) { 1258 if(m_pParser->m_bVersionUpdated || m_bSecurityChanged || bExistInMap || bObj Stm) {
1259 CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum); 1259 CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum);
1260 if (pObj == NULL) { 1260 if (pObj == NULL) {
1261 m_ObjectOffset[objnum] = 0; 1261 m_ObjectOffset[objnum] = 0;
1262 m_ObjectSize[objnum] = 0; 1262 m_ObjectSize[objnum] = 0;
1263 return 0; 1263 return 0;
1264 } 1264 }
1265 if (WriteIndirectObj(pObj)) { 1265 if (WriteIndirectObj(pObj)) {
1266 return -1; 1266 return -1;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 for(; objnum < nOldSize; objnum ++) { 1319 for(; objnum < nOldSize; objnum ++) {
1320 int32_t iRet = WriteOldIndirectObject(objnum); 1320 int32_t iRet = WriteOldIndirectObject(objnum);
1321 if (!iRet) { 1321 if (!iRet) {
1322 continue; 1322 continue;
1323 } 1323 }
1324 if (iRet < 0) { 1324 if (iRet < 0) {
1325 return iRet; 1325 return iRet;
1326 } 1326 }
1327 m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]); 1327 m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]);
1328 if (pPause && pPause->NeedToPauseNow()) { 1328 if (pPause && pPause->NeedToPauseNow()) {
1329 m_Pos = (FX_LPVOID)(uintptr_t)(objnum + 1); 1329 m_Pos = (void*)(uintptr_t)(objnum + 1);
1330 return 1; 1330 return 1;
1331 } 1331 }
1332 } 1332 }
1333 return 0; 1333 return 0;
1334 } 1334 }
1335 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause *pPause) 1335 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause *pPause)
1336 { 1336 {
1337 int32_t iCount = m_NewObjNumArray.GetSize(); 1337 int32_t iCount = m_NewObjNumArray.GetSize();
1338 int32_t index = (int32_t)(uintptr_t)m_Pos; 1338 int32_t index = (int32_t)(uintptr_t)m_Pos;
1339 while (index < iCount) { 1339 while (index < iCount) {
1340 FX_DWORD objnum = m_NewObjNumArray.ElementAt(index); 1340 FX_DWORD objnum = m_NewObjNumArray.ElementAt(index);
1341 CPDF_Object *pObj = NULL; 1341 CPDF_Object *pObj = NULL;
1342 m_pDocument->m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, (FX_LPV OID&)pObj); 1342 m_pDocument->m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, (void*&)pOb j);
1343 if (NULL == pObj) { 1343 if (NULL == pObj) {
1344 ++index; 1344 ++index;
1345 continue; 1345 continue;
1346 } 1346 }
1347 m_ObjectOffset[objnum] = m_Offset; 1347 m_ObjectOffset[objnum] = m_Offset;
1348 if (WriteIndirectObj(pObj)) { 1348 if (WriteIndirectObj(pObj)) {
1349 return -1; 1349 return -1;
1350 } 1350 }
1351 m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]); 1351 m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]);
1352 index++; 1352 index++;
(...skipping 30 matching lines...) Expand all
1383 } 1383 }
1384 void CPDF_Creator::InitNewObjNumOffsets() 1384 void CPDF_Creator::InitNewObjNumOffsets()
1385 { 1385 {
1386 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; 1386 FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0;
1387 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; 1387 FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0;
1388 FX_DWORD nOldSize = m_pParser ? m_pParser->m_CrossRef.GetSize() : 0; 1388 FX_DWORD nOldSize = m_pParser ? m_pParser->m_CrossRef.GetSize() : 0;
1389 FX_POSITION pos = m_pDocument->m_IndirectObjs.GetStartPosition(); 1389 FX_POSITION pos = m_pDocument->m_IndirectObjs.GetStartPosition();
1390 while (pos) { 1390 while (pos) {
1391 size_t key = 0; 1391 size_t key = 0;
1392 CPDF_Object* pObj; 1392 CPDF_Object* pObj;
1393 m_pDocument->m_IndirectObjs.GetNextAssoc(pos, (FX_LPVOID&)key, (FX_LPVOI D&)pObj); 1393 m_pDocument->m_IndirectObjs.GetNextAssoc(pos, (void*&)key, (void*&)pObj) ;
1394 FX_DWORD objnum = (FX_DWORD)key; 1394 FX_DWORD objnum = (FX_DWORD)key;
1395 if (pObj->GetObjNum() == -1) { 1395 if (pObj->GetObjNum() == -1) {
1396 continue; 1396 continue;
1397 } 1397 }
1398 if (bIncremental) { 1398 if (bIncremental) {
1399 if (!pObj->IsModified()) { 1399 if (!pObj->IsModified()) {
1400 continue; 1400 continue;
1401 } 1401 }
1402 } else { 1402 } else {
1403 if (objnum < nOldSize && m_pParser->m_V5Type[objnum] != 0) { 1403 if (objnum < nOldSize && m_pParser->m_V5Type[objnum] != 0) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 m_Offset += len; 1510 m_Offset += len;
1511 if ((len = m_File.AppendString(FX_BSTRC("\r\n%\xA1\xB3\xC5\xD7\r\n") )) < 0) { 1511 if ((len = m_File.AppendString(FX_BSTRC("\r\n%\xA1\xB3\xC5\xD7\r\n") )) < 0) {
1512 return -1; 1512 return -1;
1513 } 1513 }
1514 m_Offset += len; 1514 m_Offset += len;
1515 InitOldObjNumOffsets(); 1515 InitOldObjNumOffsets();
1516 m_iStage = 20; 1516 m_iStage = 20;
1517 } else { 1517 } else {
1518 IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); 1518 IFX_FileRead* pSrcFile = m_pParser->GetFileAccess();
1519 m_Offset = pSrcFile->GetSize(); 1519 m_Offset = pSrcFile->GetSize();
1520 m_Pos = (FX_LPVOID)(uintptr_t)m_Offset; 1520 m_Pos = (void*)(uintptr_t)m_Offset;
1521 m_iStage = 15; 1521 m_iStage = 15;
1522 } 1522 }
1523 } 1523 }
1524 if (m_iStage == 15) { 1524 if (m_iStage == 15) {
1525 if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && m_Pos) { 1525 if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && m_Pos) {
1526 IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); 1526 IFX_FileRead* pSrcFile = m_pParser->GetFileAccess();
1527 uint8_t buffer[4096]; 1527 uint8_t buffer[4096];
1528 FX_DWORD src_size = (FX_DWORD)(uintptr_t)m_Pos; 1528 FX_DWORD src_size = (FX_DWORD)(uintptr_t)m_Pos;
1529 while (src_size) { 1529 while (src_size) {
1530 FX_DWORD block_size = src_size > 4096 ? 4096 : src_size; 1530 FX_DWORD block_size = src_size > 4096 ? 4096 : src_size;
1531 if (!pSrcFile->ReadBlock(buffer, m_Offset - src_size, block_size )) { 1531 if (!pSrcFile->ReadBlock(buffer, m_Offset - src_size, block_size )) {
1532 return -1; 1532 return -1;
1533 } 1533 }
1534 if (m_File.AppendBlock(buffer, block_size) < 0) { 1534 if (m_File.AppendBlock(buffer, block_size) < 0) {
1535 return -1; 1535 return -1;
1536 } 1536 }
1537 src_size -= block_size; 1537 src_size -= block_size;
1538 if (pPause && pPause->NeedToPauseNow()) { 1538 if (pPause && pPause->NeedToPauseNow()) {
1539 m_Pos = (FX_LPVOID)(uintptr_t)src_size; 1539 m_Pos = (void*)(uintptr_t)src_size;
1540 return 1; 1540 return 1;
1541 } 1541 }
1542 } 1542 }
1543 } 1543 }
1544 if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && m_pParser->GetLastXRefO ffset() == 0) { 1544 if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && m_pParser->GetLastXRefO ffset() == 0) {
1545 InitOldObjNumOffsets(); 1545 InitOldObjNumOffsets();
1546 FX_DWORD dwEnd = m_pParser->GetLastObjNum(); 1546 FX_DWORD dwEnd = m_pParser->GetLastObjNum();
1547 FX_BOOL bObjStm = (m_dwFlags & FPDFCREATE_OBJECTSTREAM) != 0; 1547 FX_BOOL bObjStm = (m_dwFlags & FPDFCREATE_OBJECTSTREAM) != 0;
1548 for (FX_DWORD objnum = 0; objnum <= dwEnd; objnum++) { 1548 for (FX_DWORD objnum = 0; objnum <= dwEnd; objnum++) {
1549 if (m_pParser->m_V5Type[objnum] == 0 || m_pParser->m_V5Type[objn um] == 255) { 1549 if (m_pParser->m_V5Type[objnum] == 0 || m_pParser->m_V5Type[objn um] == 255) {
(...skipping 12 matching lines...) Expand all
1562 m_iStage = 20; 1562 m_iStage = 20;
1563 } 1563 }
1564 InitNewObjNumOffsets(); 1564 InitNewObjNumOffsets();
1565 return m_iStage; 1565 return m_iStage;
1566 } 1566 }
1567 int32_t CPDF_Creator::WriteDoc_Stage2(IFX_Pause *pPause) 1567 int32_t CPDF_Creator::WriteDoc_Stage2(IFX_Pause *pPause)
1568 { 1568 {
1569 FXSYS_assert(m_iStage >= 20 || m_iStage < 30); 1569 FXSYS_assert(m_iStage >= 20 || m_iStage < 30);
1570 if (m_iStage == 20) { 1570 if (m_iStage == 20) {
1571 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 && m_pParser) { 1571 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 && m_pParser) {
1572 m_Pos = (FX_LPVOID)(uintptr_t)0; 1572 m_Pos = (void*)(uintptr_t)0;
1573 m_iStage = 21; 1573 m_iStage = 21;
1574 } else { 1574 } else {
1575 m_iStage = 25; 1575 m_iStage = 25;
1576 } 1576 }
1577 } 1577 }
1578 if (m_iStage == 21) { 1578 if (m_iStage == 21) {
1579 int32_t iRet = WriteOldObjs(pPause); 1579 int32_t iRet = WriteOldObjs(pPause);
1580 if (iRet) { 1580 if (iRet) {
1581 return iRet; 1581 return iRet;
1582 } 1582 }
1583 m_iStage = 25; 1583 m_iStage = 25;
1584 } 1584 }
1585 if (m_iStage == 25) { 1585 if (m_iStage == 25) {
1586 m_Pos = (FX_LPVOID)(uintptr_t)0; 1586 m_Pos = (void*)(uintptr_t)0;
1587 m_iStage = 26; 1587 m_iStage = 26;
1588 } 1588 }
1589 if (m_iStage == 26) { 1589 if (m_iStage == 26) {
1590 int32_t iRet = WriteNewObjs((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0, p Pause); 1590 int32_t iRet = WriteNewObjs((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0, p Pause);
1591 if (iRet) { 1591 if (iRet) {
1592 return iRet; 1592 return iRet;
1593 } 1593 }
1594 m_iStage = 27; 1594 m_iStage = 27;
1595 } 1595 }
1596 if (m_iStage == 27) { 1596 if (m_iStage == 27) {
(...skipping 26 matching lines...) Expand all
1623 m_pXRefStream->End(this, TRUE); 1623 m_pXRefStream->End(this, TRUE);
1624 m_XrefStart = m_pXRefStream->m_PrevOffset; 1624 m_XrefStart = m_pXRefStream->m_PrevOffset;
1625 m_iStage = 90; 1625 m_iStage = 90;
1626 } else if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 || !m_pParser->IsXR efStream()) { 1626 } else if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 || !m_pParser->IsXR efStream()) {
1627 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 || m_pParser->GetLastX RefOffset() == 0) { 1627 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 || m_pParser->GetLastX RefOffset() == 0) {
1628 CFX_ByteString str; 1628 CFX_ByteString str;
1629 str = m_ObjectOffset.GetPtrAt(1) ? FX_BSTRC("xref\r\n") : FX_BST RC("xref\r\n0 1\r\n0000000000 65536 f\r\n"); 1629 str = m_ObjectOffset.GetPtrAt(1) ? FX_BSTRC("xref\r\n") : FX_BST RC("xref\r\n0 1\r\n0000000000 65536 f\r\n");
1630 if (m_File.AppendString(str) < 0) { 1630 if (m_File.AppendString(str) < 0) {
1631 return -1; 1631 return -1;
1632 } 1632 }
1633 m_Pos = (FX_LPVOID)(uintptr_t)1; 1633 m_Pos = (void*)(uintptr_t)1;
1634 m_iStage = 81; 1634 m_iStage = 81;
1635 } else { 1635 } else {
1636 if (m_File.AppendString(FX_BSTRC("xref\r\n")) < 0) { 1636 if (m_File.AppendString(FX_BSTRC("xref\r\n")) < 0) {
1637 return -1; 1637 return -1;
1638 } 1638 }
1639 m_Pos = (FX_LPVOID)(uintptr_t)0; 1639 m_Pos = (void*)(uintptr_t)0;
1640 m_iStage = 82; 1640 m_iStage = 82;
1641 } 1641 }
1642 } else { 1642 } else {
1643 m_iStage = 90; 1643 m_iStage = 90;
1644 } 1644 }
1645 } 1645 }
1646 if (m_iStage == 81) { 1646 if (m_iStage == 81) {
1647 CFX_ByteString str; 1647 CFX_ByteString str;
1648 FX_DWORD i = (FX_DWORD)(uintptr_t)m_Pos, j; 1648 FX_DWORD i = (FX_DWORD)(uintptr_t)m_Pos, j;
1649 while (i <= dwLastObjNum) { 1649 while (i <= dwLastObjNum) {
(...skipping 18 matching lines...) Expand all
1668 while (i < j) { 1668 while (i < j) {
1669 str.Format("%010d 00000 n\r\n", m_ObjectOffset[i ++]); 1669 str.Format("%010d 00000 n\r\n", m_ObjectOffset[i ++]);
1670 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) { 1670 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) {
1671 return -1; 1671 return -1;
1672 } 1672 }
1673 } 1673 }
1674 if (i > dwLastObjNum) { 1674 if (i > dwLastObjNum) {
1675 break; 1675 break;
1676 } 1676 }
1677 if (pPause && pPause->NeedToPauseNow()) { 1677 if (pPause && pPause->NeedToPauseNow()) {
1678 m_Pos = (FX_LPVOID)(uintptr_t)i; 1678 m_Pos = (void*)(uintptr_t)i;
1679 return 1; 1679 return 1;
1680 } 1680 }
1681 } 1681 }
1682 m_iStage = 90; 1682 m_iStage = 90;
1683 } 1683 }
1684 if (m_iStage == 82) { 1684 if (m_iStage == 82) {
1685 CFX_ByteString str; 1685 CFX_ByteString str;
1686 int32_t iCount = m_NewObjNumArray.GetSize(); 1686 int32_t iCount = m_NewObjNumArray.GetSize();
1687 int32_t i = (int32_t)(uintptr_t)m_Pos; 1687 int32_t i = (int32_t)(uintptr_t)m_Pos;
1688 while (i < iCount) { 1688 while (i < iCount) {
(...skipping 19 matching lines...) Expand all
1708 return -1; 1708 return -1;
1709 } 1709 }
1710 while (i < j) { 1710 while (i < j) {
1711 objnum = m_NewObjNumArray.ElementAt(i++); 1711 objnum = m_NewObjNumArray.ElementAt(i++);
1712 str.Format("%010d 00000 n\r\n", m_ObjectOffset[objnum]); 1712 str.Format("%010d 00000 n\r\n", m_ObjectOffset[objnum]);
1713 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) { 1713 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) {
1714 return -1; 1714 return -1;
1715 } 1715 }
1716 } 1716 }
1717 if (pPause && (i % 100) == 0 && pPause->NeedToPauseNow()) { 1717 if (pPause && (i % 100) == 0 && pPause->NeedToPauseNow()) {
1718 m_Pos = (FX_LPVOID)(uintptr_t)i; 1718 m_Pos = (void*)(uintptr_t)i;
1719 return 1; 1719 return 1;
1720 } 1720 }
1721 } 1721 }
1722 m_iStage = 90; 1722 m_iStage = 90;
1723 } 1723 }
1724 return m_iStage; 1724 return m_iStage;
1725 } 1725 }
1726 static int32_t _OutPutIndex(CFX_FileBufferArchive* pFile, FX_FILESIZE offset) 1726 static int32_t _OutPutIndex(CFX_FileBufferArchive* pFile, FX_FILESIZE offset)
1727 { 1727 {
1728 FXSYS_assert(pFile); 1728 FXSYS_assert(pFile);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 delete m_pXRefStream; 1969 delete m_pXRefStream;
1970 m_pXRefStream = NULL; 1970 m_pXRefStream = NULL;
1971 } 1971 }
1972 m_File.Clear(); 1972 m_File.Clear();
1973 m_NewObjNumArray.RemoveAll(); 1973 m_NewObjNumArray.RemoveAll();
1974 if (m_pIDArray) { 1974 if (m_pIDArray) {
1975 m_pIDArray->Release(); 1975 m_pIDArray->Release();
1976 m_pIDArray = NULL; 1976 m_pIDArray = NULL;
1977 } 1977 }
1978 } 1978 }
1979 FX_BOOL CPDF_Creator::Create(FX_LPCSTR filename, FX_DWORD flags) 1979 FX_BOOL CPDF_Creator::Create(const FX_CHAR* filename, FX_DWORD flags)
1980 { 1980 {
1981 if (!m_File.AttachFile(filename)) { 1981 if (!m_File.AttachFile(filename)) {
1982 return FALSE; 1982 return FALSE;
1983 } 1983 }
1984 FX_BOOL bRet = Create(flags); 1984 FX_BOOL bRet = Create(flags);
1985 if (!bRet || !(flags & FPDFCREATE_PROGRESSIVE)) { 1985 if (!bRet || !(flags & FPDFCREATE_PROGRESSIVE)) {
1986 Clear(); 1986 Clear();
1987 } 1987 }
1988 return bRet; 1988 return bRet;
1989 } 1989 }
1990 FX_BOOL CPDF_Creator::Create(FX_LPCWSTR filename, FX_DWORD flags) 1990 FX_BOOL CPDF_Creator::Create(const FX_WCHAR* filename, FX_DWORD flags)
1991 { 1991 {
1992 if (!m_File.AttachFile(filename)) { 1992 if (!m_File.AttachFile(filename)) {
1993 return FALSE; 1993 return FALSE;
1994 } 1994 }
1995 FX_BOOL bRet = Create(flags); 1995 FX_BOOL bRet = Create(flags);
1996 if (!bRet || !(flags & FPDFCREATE_PROGRESSIVE)) { 1996 if (!bRet || !(flags & FPDFCREATE_PROGRESSIVE)) {
1997 Clear(); 1997 Clear();
1998 } 1998 }
1999 return bRet; 1999 return bRet;
2000 } 2000 }
(...skipping 20 matching lines...) Expand all
2021 if (flags & FPDFCREATE_PROGRESSIVE) { 2021 if (flags & FPDFCREATE_PROGRESSIVE) {
2022 return TRUE; 2022 return TRUE;
2023 } 2023 }
2024 return Continue(NULL) > -1; 2024 return Continue(NULL) > -1;
2025 } 2025 }
2026 void CPDF_Creator::InitID(FX_BOOL bDefault ) 2026 void CPDF_Creator::InitID(FX_BOOL bDefault )
2027 { 2027 {
2028 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL; 2028 CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL;
2029 FX_BOOL bNewId = !m_pIDArray; 2029 FX_BOOL bNewId = !m_pIDArray;
2030 if (!m_pIDArray) { 2030 if (!m_pIDArray) {
2031 FX_LPDWORD pBuffer = NULL; 2031 FX_DWORD* pBuffer = NULL;
2032 m_pIDArray = CPDF_Array::Create(); 2032 m_pIDArray = CPDF_Array::Create();
2033 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetElement(0) : NULL; 2033 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetElement(0) : NULL;
2034 if (pID1) { 2034 if (pID1) {
2035 m_pIDArray->Add(pID1->Clone()); 2035 m_pIDArray->Add(pID1->Clone());
2036 } else { 2036 } else {
2037 pBuffer = FX_Alloc(FX_DWORD, 4); 2037 pBuffer = FX_Alloc(FX_DWORD, 4);
2038 PDF_GenerateFileID((FX_DWORD)(uintptr_t)this, m_dwLastObjNum, pBuffe r); 2038 PDF_GenerateFileID((FX_DWORD)(uintptr_t)this, m_dwLastObjNum, pBuffe r);
2039 CFX_ByteStringC bsBuffer((FX_LPCBYTE)pBuffer, 4 * sizeof(FX_DWORD)); 2039 CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWOR D));
2040 m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument); 2040 m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument);
2041 } 2041 }
2042 if (pBuffer) { 2042 if (pBuffer) {
2043 FX_Free(pBuffer); 2043 FX_Free(pBuffer);
2044 } 2044 }
2045 } 2045 }
2046 if (!bDefault) { 2046 if (!bDefault) {
2047 return; 2047 return;
2048 } 2048 }
2049 if (pOldIDArray) { 2049 if (pOldIDArray) {
2050 CPDF_Object* pID2 = pOldIDArray->GetElement(1); 2050 CPDF_Object* pID2 = pOldIDArray->GetElement(1);
2051 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) { 2051 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) {
2052 m_pIDArray->Add(pID2->Clone()); 2052 m_pIDArray->Add(pID2->Clone());
2053 return; 2053 return;
2054 } 2054 }
2055 FX_LPDWORD pBuffer = FX_Alloc(FX_DWORD, 4); 2055 FX_DWORD* pBuffer = FX_Alloc(FX_DWORD, 4);
2056 PDF_GenerateFileID((FX_DWORD)(uintptr_t)this, m_dwLastObjNum, pBuffer); 2056 PDF_GenerateFileID((FX_DWORD)(uintptr_t)this, m_dwLastObjNum, pBuffer);
2057 CFX_ByteStringC bsBuffer((FX_LPCBYTE)pBuffer, 4 * sizeof(FX_DWORD)); 2057 CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD));
2058 m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument); 2058 m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument);
2059 FX_Free(pBuffer); 2059 FX_Free(pBuffer);
2060 return; 2060 return;
2061 } 2061 }
2062 m_pIDArray->Add(m_pIDArray->GetElement(0)->Clone()); 2062 m_pIDArray->Add(m_pIDArray->GetElement(0)->Clone());
2063 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { 2063 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) {
2064 if (m_pEncryptDict->GetString(FX_BSTRC("Filter")) == FX_BSTRC("Standard" )) { 2064 if (m_pEncryptDict->GetString(FX_BSTRC("Filter")) == FX_BSTRC("Standard" )) {
2065 CPDF_StandardSecurityHandler handler; 2065 CPDF_StandardSecurityHandler handler;
2066 CFX_ByteString user_pass = m_pParser->GetPassword(); 2066 CFX_ByteString user_pass = m_pParser->GetPassword();
2067 FX_DWORD flag = PDF_ENCRYPT_CONTENT; 2067 FX_DWORD flag = PDF_ENCRYPT_CONTENT;
2068 handler.OnCreate(m_pEncryptDict, m_pIDArray, (FX_LPCBYTE)user_pass, user_pass.GetLength(), flag); 2068 handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pa ss, user_pass.GetLength(), flag);
2069 if (m_pCryptoHandler && m_bNewCrypto) { 2069 if (m_pCryptoHandler && m_bNewCrypto) {
2070 delete m_pCryptoHandler; 2070 delete m_pCryptoHandler;
2071 } 2071 }
2072 m_pCryptoHandler = new CPDF_StandardCryptoHandler; 2072 m_pCryptoHandler = new CPDF_StandardCryptoHandler;
2073 m_pCryptoHandler->Init(m_pEncryptDict, &handler); 2073 m_pCryptoHandler->Init(m_pEncryptDict, &handler);
2074 m_bNewCrypto = TRUE; 2074 m_bNewCrypto = TRUE;
2075 m_bSecurityChanged = TRUE; 2075 m_bSecurityChanged = TRUE;
2076 } 2076 }
2077 } 2077 }
2078 } 2078 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 m_bNewCrypto = FALSE; 2127 m_bNewCrypto = FALSE;
2128 if (!m_bStandardSecurity) { 2128 if (!m_bStandardSecurity) {
2129 return; 2129 return;
2130 } 2130 }
2131 if (m_pEncryptDict) { 2131 if (m_pEncryptDict) {
2132 m_pEncryptDict->Release(); 2132 m_pEncryptDict->Release();
2133 m_pEncryptDict = NULL; 2133 m_pEncryptDict = NULL;
2134 } 2134 }
2135 m_bStandardSecurity = FALSE; 2135 m_bStandardSecurity = FALSE;
2136 } 2136 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp ('k') | core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698