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

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

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: 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 FX_BYTE* 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, FX_LPBYTE& de st_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(FX_LPCBYTE src_buf, FX_DWORD src_size, int predictor, in t Colors, int BitsPerComponent, int Columns,
13 FX_LPBYTE& dest_buf, FX_DWORD& dest_size); 13 FX_LPBYTE& 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 FX_INT32 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 FX_INT32 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;
24 } 24 }
25 switch (pObj->GetType()) { 25 switch (pObj->GetType()) {
26 case PDFOBJ_NULL: 26 case PDFOBJ_NULL:
27 if (pFile->AppendString(FX_BSTRC(" null")) < 0) { 27 if (pFile->AppendString(FX_BSTRC(" null")) < 0) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 164 }
165 offset += len; 165 offset += len;
166 break; 166 break;
167 } 167 }
168 default: 168 default:
169 ASSERT(FALSE); 169 ASSERT(FALSE);
170 break; 170 break;
171 } 171 }
172 return 1; 172 return 1;
173 } 173 }
174 FX_INT32 PDF_CreatorWriteTrailer(CPDF_Document* pDocument, CFX_FileBufferArchive * pFile, CPDF_Array* pIDArray, FX_BOOL bCompress) 174 int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument, CFX_FileBufferArchive* pFile, CPDF_Array* pIDArray, FX_BOOL bCompress)
175 { 175 {
176 FX_FILESIZE offset = 0; 176 FX_FILESIZE offset = 0;
177 FX_INT32 len = 0; 177 int32_t len = 0;
178 FXSYS_assert(pDocument && pFile); 178 FXSYS_assert(pDocument && pFile);
179 CPDF_Parser *pParser = (CPDF_Parser*)pDocument->GetParser(); 179 CPDF_Parser *pParser = (CPDF_Parser*)pDocument->GetParser();
180 if (pParser) { 180 if (pParser) {
181 CPDF_Dictionary* p = pParser->GetTrailer(); 181 CPDF_Dictionary* p = pParser->GetTrailer();
182 FX_POSITION pos = p->GetStartPos(); 182 FX_POSITION pos = p->GetStartPos();
183 while (pos) { 183 while (pos) {
184 CFX_ByteString key; 184 CFX_ByteString key;
185 CPDF_Object* pValue = p->GetNextElement(pos, key); 185 CPDF_Object* pValue = p->GetNextElement(pos, key);
186 if (key == FX_BSTRC("Encrypt") || key == FX_BSTRC("Size") || key == FX_BSTRC("Filter") || 186 if (key == FX_BSTRC("Encrypt") || key == FX_BSTRC("Size") || key == FX_BSTRC("Filter") ||
187 key == FX_BSTRC("Index") || key == FX_BSTRC("Length") || key == FX_BSTRC("Prev") || 187 key == FX_BSTRC("Index") || key == FX_BSTRC("Length") || key == FX_BSTRC("Prev") ||
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (pFile->AppendString((FX_BSTRC("/ID"))) < 0) { 252 if (pFile->AppendString((FX_BSTRC("/ID"))) < 0) {
253 return -1; 253 return -1;
254 } 254 }
255 offset += 3; 255 offset += 3;
256 if (PDF_CreatorAppendObject(pIDArray, pFile, offset) < 0) { 256 if (PDF_CreatorAppendObject(pIDArray, pFile, offset) < 0) {
257 return -1; 257 return -1;
258 } 258 }
259 } 259 }
260 return offset; 260 return offset;
261 } 261 }
262 FX_INT32 PDF_CreatorWriteEncrypt(const CPDF_Dictionary* pEncryptDict, FX_DWORD d wObjNum, CFX_FileBufferArchive *pFile) 262 int32_t PDF_CreatorWriteEncrypt(const CPDF_Dictionary* pEncryptDict, FX_DWORD dw ObjNum, CFX_FileBufferArchive *pFile)
263 { 263 {
264 if (!pEncryptDict) { 264 if (!pEncryptDict) {
265 return 0; 265 return 0;
266 } 266 }
267 FXSYS_assert(pFile); 267 FXSYS_assert(pFile);
268 FX_FILESIZE offset = 0; 268 FX_FILESIZE offset = 0;
269 FX_INT32 len = 0; 269 int32_t len = 0;
270 if (pFile->AppendString(FX_BSTRC("/Encrypt")) < 0) { 270 if (pFile->AppendString(FX_BSTRC("/Encrypt")) < 0) {
271 return -1; 271 return -1;
272 } 272 }
273 offset += 8; 273 offset += 8;
274 if (pFile->AppendString(FX_BSTRC(" ")) < 0) { 274 if (pFile->AppendString(FX_BSTRC(" ")) < 0) {
275 return -1; 275 return -1;
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_LPDWORD pBuffe r)
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 FX_LPVOID pContext = FX_Random_MT_Start(dwSeed1);
292 FX_INT32 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;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = (FX_LPBYTE)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(FX_BYTE, 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 }
422 CPDF_Encryptor::~CPDF_Encryptor() 422 CPDF_Encryptor::~CPDF_Encryptor()
423 { 423 {
424 if (m_bNewBuf) { 424 if (m_bNewBuf) {
425 FX_Free(m_pData); 425 FX_Free(m_pData);
426 } 426 }
427 } 427 }
428 CPDF_ObjectStream::CPDF_ObjectStream() 428 CPDF_ObjectStream::CPDF_ObjectStream()
429 : m_dwObjNum(0) 429 : m_dwObjNum(0)
430 , m_index(0) 430 , m_index(0)
431 { 431 {
432 } 432 }
433 FX_BOOL CPDF_ObjectStream::Start() 433 FX_BOOL CPDF_ObjectStream::Start()
434 { 434 {
435 m_ObjNumArray.RemoveAll(); 435 m_ObjNumArray.RemoveAll();
436 m_OffsetArray.RemoveAll(); 436 m_OffsetArray.RemoveAll();
437 m_Buffer.Clear(); 437 m_Buffer.Clear();
438 m_dwObjNum = 0; 438 m_dwObjNum = 0;
439 m_index = 0; 439 m_index = 0;
440 return TRUE; 440 return TRUE;
441 } 441 }
442 FX_INT32 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 FX_INT32 CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE pBuffer, FX_DWORD dwSize) 449 int32_t CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE 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) {
460 return 0; 460 return 0;
461 } 461 }
462 CFX_FileBufferArchive *pFile = &pCreator->m_File; 462 CFX_FileBufferArchive *pFile = &pCreator->m_File;
463 CPDF_CryptoHandler *pHandler = pCreator->m_pCryptoHandler; 463 CPDF_CryptoHandler *pHandler = pCreator->m_pCryptoHandler;
464 FX_FILESIZE ObjOffset = pCreator->m_Offset; 464 FX_FILESIZE ObjOffset = pCreator->m_Offset;
465 if (!m_dwObjNum) { 465 if (!m_dwObjNum) {
466 m_dwObjNum = ++pCreator->m_dwLastObjNum; 466 m_dwObjNum = ++pCreator->m_dwLastObjNum;
467 } 467 }
468 CFX_ByteTextBuf tempBuffer; 468 CFX_ByteTextBuf tempBuffer;
469 FX_INT32 iCount = m_ObjNumArray.GetSize(); 469 int32_t iCount = m_ObjNumArray.GetSize();
470 for (FX_INT32 i = 0; i < iCount; i++) { 470 for (int32_t i = 0; i < iCount; i++) {
471 tempBuffer << m_ObjNumArray.ElementAt(i) << FX_BSTRC(" ") << m_OffsetArr ay.ElementAt(i) << FX_BSTRC(" "); 471 tempBuffer << m_ObjNumArray.ElementAt(i) << FX_BSTRC(" ") << m_OffsetArr ay.ElementAt(i) << FX_BSTRC(" ");
472 } 472 }
473 FX_FILESIZE &offset = pCreator->m_Offset; 473 FX_FILESIZE &offset = pCreator->m_Offset;
474 FX_INT32 len = pFile->AppendDWord(m_dwObjNum); 474 int32_t len = pFile->AppendDWord(m_dwObjNum);
475 if (len < 0) { 475 if (len < 0) {
476 return -1; 476 return -1;
477 } 477 }
478 offset += len; 478 offset += len;
479 if ((len = pFile->AppendString(FX_BSTRC(" 0 obj\r\n<</Type /ObjStm /N "))) < 0) { 479 if ((len = pFile->AppendString(FX_BSTRC(" 0 obj\r\n<</Type /ObjStm /N "))) < 0) {
480 return -1; 480 return -1;
481 } 481 }
482 offset += len; 482 offset += len;
483 if ((len = pFile->AppendDWord((FX_DWORD)iCount)) < 0) { 483 if ((len = pFile->AppendDWord((FX_DWORD)iCount)) < 0) {
484 return -1; 484 return -1;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 , m_iSeg(0) 545 , m_iSeg(0)
546 { 546 {
547 } 547 }
548 FX_BOOL CPDF_XRefStream::Start() 548 FX_BOOL CPDF_XRefStream::Start()
549 { 549 {
550 m_IndexArray.RemoveAll(); 550 m_IndexArray.RemoveAll();
551 m_Buffer.Clear(); 551 m_Buffer.Clear();
552 m_iSeg = 0; 552 m_iSeg = 0;
553 return TRUE; 553 return TRUE;
554 } 554 }
555 FX_INT32 CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, const CPDF_O bject *pObj, CPDF_Creator *pCreator) 555 int32_t CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, const CPDF_Ob ject *pObj, CPDF_Creator *pCreator)
556 { 556 {
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 FX_INT32 CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE p Buffer, FX_DWORD dwSize, CPDF_Creator *pCreator) 567 int32_t CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE pB uffer, 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 16 matching lines...) Expand all
594 static void _AppendIndex1(CFX_ByteTextBuf& buffer, FX_FILESIZE offset) 594 static void _AppendIndex1(CFX_ByteTextBuf& buffer, FX_FILESIZE offset)
595 { 595 {
596 buffer.AppendByte(1); 596 buffer.AppendByte(1);
597 buffer.AppendByte(FX_GETBYTEOFFSET24(offset)); 597 buffer.AppendByte(FX_GETBYTEOFFSET24(offset));
598 buffer.AppendByte(FX_GETBYTEOFFSET16(offset)); 598 buffer.AppendByte(FX_GETBYTEOFFSET16(offset));
599 buffer.AppendByte(FX_GETBYTEOFFSET8(offset)); 599 buffer.AppendByte(FX_GETBYTEOFFSET8(offset));
600 buffer.AppendByte(FX_GETBYTEOFFSET0(offset)); 600 buffer.AppendByte(FX_GETBYTEOFFSET0(offset));
601 buffer.AppendByte(0); 601 buffer.AppendByte(0);
602 buffer.AppendByte(0); 602 buffer.AppendByte(0);
603 } 603 }
604 static void _AppendIndex2(CFX_ByteTextBuf& buffer, FX_DWORD objnum, FX_INT32 ind ex) 604 static void _AppendIndex2(CFX_ByteTextBuf& buffer, FX_DWORD objnum, int32_t inde x)
605 { 605 {
606 buffer.AppendByte(2); 606 buffer.AppendByte(2);
607 buffer.AppendByte(FX_GETBYTEOFFSET24(objnum)); 607 buffer.AppendByte(FX_GETBYTEOFFSET24(objnum));
608 buffer.AppendByte(FX_GETBYTEOFFSET16(objnum)); 608 buffer.AppendByte(FX_GETBYTEOFFSET16(objnum));
609 buffer.AppendByte(FX_GETBYTEOFFSET8(objnum)); 609 buffer.AppendByte(FX_GETBYTEOFFSET8(objnum));
610 buffer.AppendByte(FX_GETBYTEOFFSET0(objnum)); 610 buffer.AppendByte(FX_GETBYTEOFFSET0(objnum));
611 buffer.AppendByte(FX_GETBYTEOFFSET8(index)); 611 buffer.AppendByte(FX_GETBYTEOFFSET8(index));
612 buffer.AppendByte(FX_GETBYTEOFFSET0(index)); 612 buffer.AppendByte(FX_GETBYTEOFFSET0(index));
613 } 613 }
614 FX_INT32 CPDF_XRefStream::EndObjectStream(CPDF_Creator *pCreator, FX_BOOL bEOF) 614 int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator *pCreator, FX_BOOL bEOF)
615 { 615 {
616 FX_FILESIZE objOffset = 0; 616 FX_FILESIZE objOffset = 0;
617 if (bEOF) { 617 if (bEOF) {
618 objOffset = m_ObjStream.End(pCreator); 618 objOffset = m_ObjStream.End(pCreator);
619 if (objOffset < 0) { 619 if (objOffset < 0) {
620 return -1; 620 return -1;
621 } 621 }
622 } 622 }
623 FX_DWORD &dwObjStmNum = m_ObjStream.m_dwObjNum; 623 FX_DWORD &dwObjStmNum = m_ObjStream.m_dwObjNum;
624 if (!dwObjStmNum) { 624 if (!dwObjStmNum) {
625 dwObjStmNum = ++pCreator->m_dwLastObjNum; 625 dwObjStmNum = ++pCreator->m_dwLastObjNum;
626 } 626 }
627 FX_INT32 iSize = m_ObjStream.m_ObjNumArray.GetSize(); 627 int32_t iSize = m_ObjStream.m_ObjNumArray.GetSize();
628 FX_INT32 iSeg = m_IndexArray.GetSize() / 2; 628 int32_t iSeg = m_IndexArray.GetSize() / 2;
629 if (!(pCreator->m_dwFlags & FPDFCREATE_INCREMENTAL)) { 629 if (!(pCreator->m_dwFlags & FPDFCREATE_INCREMENTAL)) {
630 if (m_dwTempObjNum == 0) { 630 if (m_dwTempObjNum == 0) {
631 _AppendIndex0(m_Buffer); 631 _AppendIndex0(m_Buffer);
632 m_dwTempObjNum++; 632 m_dwTempObjNum++;
633 } 633 }
634 FX_DWORD end_num = m_IndexArray.GetAt((iSeg - 1) * 2) + m_IndexArray.Get At((iSeg - 1) * 2 + 1); 634 FX_DWORD end_num = m_IndexArray.GetAt((iSeg - 1) * 2) + m_IndexArray.Get At((iSeg - 1) * 2 + 1);
635 int index = 0; 635 int index = 0;
636 for (; m_dwTempObjNum < end_num; m_dwTempObjNum++) { 636 for (; m_dwTempObjNum < end_num; m_dwTempObjNum++) {
637 FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(m_dwTempObjN um); 637 FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(m_dwTempObjN um);
638 if (offset) { 638 if (offset) {
(...skipping 10 matching lines...) Expand all
649 pCreator->m_ObjectOffset.Add(dwObjStmNum, 1); 649 pCreator->m_ObjectOffset.Add(dwObjStmNum, 1);
650 pCreator->m_ObjectSize.Add(dwObjStmNum, 1); 650 pCreator->m_ObjectSize.Add(dwObjStmNum, 1);
651 pCreator->m_ObjectOffset[dwObjStmNum] = objOffset; 651 pCreator->m_ObjectOffset[dwObjStmNum] = objOffset;
652 } 652 }
653 m_iSeg = iSeg; 653 m_iSeg = iSeg;
654 if (bEOF) { 654 if (bEOF) {
655 m_ObjStream.Start(); 655 m_ObjStream.Start();
656 } 656 }
657 return 1; 657 return 1;
658 } 658 }
659 FX_INT32 &j = m_ObjStream.m_index; 659 int32_t &j = m_ObjStream.m_index;
660 for (int i = m_iSeg; i < iSeg; i++) { 660 for (int i = m_iSeg; i < iSeg; i++) {
661 FX_DWORD start = m_IndexArray.ElementAt(i * 2); 661 FX_DWORD start = m_IndexArray.ElementAt(i * 2);
662 FX_DWORD end = m_IndexArray.ElementAt(i * 2 + 1) + start; 662 FX_DWORD end = m_IndexArray.ElementAt(i * 2 + 1) + start;
663 for (FX_DWORD m = start; m < end; m++) { 663 for (FX_DWORD m = start; m < end; m++) {
664 if (j >= iSize || m != m_ObjStream.m_ObjNumArray.ElementAt(j)) { 664 if (j >= iSize || m != m_ObjStream.m_ObjNumArray.ElementAt(j)) {
665 _AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[m]); 665 _AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[m]);
666 } else { 666 } else {
667 _AppendIndex2(m_Buffer, dwObjStmNum, j++); 667 _AppendIndex2(m_Buffer, dwObjStmNum, j++);
668 } 668 }
669 } 669 }
(...skipping 23 matching lines...) Expand all
693 FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(m_dwTempObjN um); 693 FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(m_dwTempObjN um);
694 if (offset) { 694 if (offset) {
695 _AppendIndex1(m_Buffer, *offset); 695 _AppendIndex1(m_Buffer, *offset);
696 } else { 696 } else {
697 _AppendIndex0(m_Buffer, FALSE); 697 _AppendIndex0(m_Buffer, FALSE);
698 } 698 }
699 } 699 }
700 } 700 }
701 _AppendIndex1(m_Buffer, offset_tmp); 701 _AppendIndex1(m_Buffer, offset_tmp);
702 FX_FILESIZE &offset = pCreator->m_Offset; 702 FX_FILESIZE &offset = pCreator->m_Offset;
703 FX_INT32 len = pFile->AppendDWord(objnum); 703 int32_t len = pFile->AppendDWord(objnum);
704 if (len < 0) { 704 if (len < 0) {
705 return FALSE; 705 return FALSE;
706 } 706 }
707 offset += len; 707 offset += len;
708 if ((len = pFile->AppendString(FX_BSTRC(" 0 obj\r\n<</Type /XRef/W[1 4 2]/In dex["))) < 0) { 708 if ((len = pFile->AppendString(FX_BSTRC(" 0 obj\r\n<</Type /XRef/W[1 4 2]/In dex["))) < 0) {
709 return FALSE; 709 return FALSE;
710 } 710 }
711 offset += len; 711 offset += len;
712 if (!bIncremental) { 712 if (!bIncremental) {
713 if ((len = pFile->AppendDWord(0)) < 0) { 713 if ((len = pFile->AppendDWord(0)) < 0) {
714 return FALSE; 714 return FALSE;
715 } 715 }
716 if ((len = pFile->AppendString(FX_BSTRC(" "))) < 0) { 716 if ((len = pFile->AppendString(FX_BSTRC(" "))) < 0) {
717 return FALSE; 717 return FALSE;
718 } 718 }
719 offset += len + 1; 719 offset += len + 1;
720 if ((len = pFile->AppendDWord(objnum + 1)) < 0) { 720 if ((len = pFile->AppendDWord(objnum + 1)) < 0) {
721 return FALSE; 721 return FALSE;
722 } 722 }
723 offset += len; 723 offset += len;
724 } else { 724 } else {
725 FX_INT32 iSeg = m_IndexArray.GetSize() / 2; 725 int32_t iSeg = m_IndexArray.GetSize() / 2;
726 for (FX_INT32 i = 0; i < iSeg; i++) { 726 for (int32_t i = 0; i < iSeg; i++) {
727 if ((len = pFile->AppendDWord(m_IndexArray.ElementAt(i * 2))) < 0) { 727 if ((len = pFile->AppendDWord(m_IndexArray.ElementAt(i * 2))) < 0) {
728 return FALSE; 728 return FALSE;
729 } 729 }
730 if (pFile->AppendString(FX_BSTRC(" ")) < 0) { 730 if (pFile->AppendString(FX_BSTRC(" ")) < 0) {
731 return FALSE; 731 return FALSE;
732 } 732 }
733 offset += len + 1; 733 offset += len + 1;
734 if ((len = pFile->AppendDWord(m_IndexArray.ElementAt(i * 2 + 1))) < 0) { 734 if ((len = pFile->AppendDWord(m_IndexArray.ElementAt(i * 2 + 1))) < 0) {
735 return FALSE; 735 return FALSE;
736 } 736 }
(...skipping 10 matching lines...) Expand all
747 return FALSE; 747 return FALSE;
748 } 748 }
749 offset += len + 7; 749 offset += len + 7;
750 if (m_PrevOffset > 0) { 750 if (m_PrevOffset > 0) {
751 if (pFile->AppendString(FX_BSTRC("/Prev ")) < 0) { 751 if (pFile->AppendString(FX_BSTRC("/Prev ")) < 0) {
752 return -1; 752 return -1;
753 } 753 }
754 FX_CHAR offset_buf[20]; 754 FX_CHAR offset_buf[20];
755 FXSYS_memset32(offset_buf, 0, sizeof(offset_buf)); 755 FXSYS_memset32(offset_buf, 0, sizeof(offset_buf));
756 FXSYS_i64toa(m_PrevOffset, offset_buf, 10); 756 FXSYS_i64toa(m_PrevOffset, offset_buf, 10);
757 FX_INT32 len = (FX_INT32)FXSYS_strlen(offset_buf); 757 int32_t len = (int32_t)FXSYS_strlen(offset_buf);
758 if (pFile->AppendBlock(offset_buf, len) < 0) { 758 if (pFile->AppendBlock(offset_buf, len) < 0) {
759 return -1; 759 return -1;
760 } 760 }
761 offset += len + 6; 761 offset += len + 6;
762 } 762 }
763 FX_BOOL bPredictor = TRUE; 763 FX_BOOL bPredictor = TRUE;
764 CPDF_FlateEncoder encoder; 764 CPDF_FlateEncoder encoder;
765 encoder.Initialize(m_Buffer.GetBuffer(), m_Buffer.GetLength(), pCreator->m_b Compress, bPredictor); 765 encoder.Initialize(m_Buffer.GetBuffer(), m_Buffer.GetLength(), pCreator->m_b Compress, bPredictor);
766 if (pCreator->m_bCompress) { 766 if (pCreator->m_bCompress) {
767 if (pFile->AppendString(FX_BSTRC("/Filter /FlateDecode")) < 0) { 767 if (pFile->AppendString(FX_BSTRC("/Filter /FlateDecode")) < 0) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 _AppendIndex0(m_Buffer); 825 _AppendIndex0(m_Buffer);
826 for (FX_DWORD i = 1; i < pCreator->m_dwLastObjNum + 1; i++) { 826 for (FX_DWORD i = 1; i < pCreator->m_dwLastObjNum + 1; i++) {
827 FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(i); 827 FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(i);
828 if (offset) { 828 if (offset) {
829 _AppendIndex1(m_Buffer, *offset); 829 _AppendIndex1(m_Buffer, *offset);
830 } else { 830 } else {
831 _AppendIndex0(m_Buffer, FALSE); 831 _AppendIndex0(m_Buffer, FALSE);
832 } 832 }
833 } 833 }
834 } else { 834 } else {
835 FX_INT32 iSeg = m_IndexArray.GetSize() / 2; 835 int32_t iSeg = m_IndexArray.GetSize() / 2;
836 for (int i = 0; i < iSeg; i++) { 836 for (int i = 0; i < iSeg; i++) {
837 FX_DWORD start = m_IndexArray.ElementAt(i * 2); 837 FX_DWORD start = m_IndexArray.ElementAt(i * 2);
838 FX_DWORD end = m_IndexArray.ElementAt(i * 2 + 1) + start; 838 FX_DWORD end = m_IndexArray.ElementAt(i * 2 + 1) + start;
839 for (FX_DWORD j = start; j < end; j++) { 839 for (FX_DWORD j = start; j < end; j++) {
840 _AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[j]); 840 _AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[j]);
841 } 841 }
842 } 842 }
843 } 843 }
844 return GenerateXRefStream(pCreator, FALSE); 844 return GenerateXRefStream(pCreator, FALSE);
845 } 845 }
846 FX_BOOL CPDF_XRefStream::AddObjectNumberToIndexArray(FX_DWORD objnum) 846 FX_BOOL CPDF_XRefStream::AddObjectNumberToIndexArray(FX_DWORD objnum)
847 { 847 {
848 FX_INT32 iSize = m_IndexArray.GetSize(); 848 int32_t iSize = m_IndexArray.GetSize();
849 if (iSize == 0) { 849 if (iSize == 0) {
850 m_IndexArray.Add(objnum); 850 m_IndexArray.Add(objnum);
851 m_IndexArray.Add(1); 851 m_IndexArray.Add(1);
852 } else { 852 } else {
853 FXSYS_assert(iSize > 1); 853 FXSYS_assert(iSize > 1);
854 FX_DWORD startobjnum = m_IndexArray.ElementAt(iSize - 2); 854 FX_DWORD startobjnum = m_IndexArray.ElementAt(iSize - 2);
855 FX_INT32 iCount = m_IndexArray.ElementAt(iSize - 1); 855 int32_t iCount = m_IndexArray.ElementAt(iSize - 1);
856 if (objnum == startobjnum + iCount) { 856 if (objnum == startobjnum + iCount) {
857 m_IndexArray[iSize - 1] = iCount + 1; 857 m_IndexArray[iSize - 1] = iCount + 1;
858 } else { 858 } else {
859 m_IndexArray.Add(objnum); 859 m_IndexArray.Add(objnum);
860 m_IndexArray.Add(1); 860 m_IndexArray.Add(1);
861 } 861 }
862 } 862 }
863 return TRUE; 863 return TRUE;
864 } 864 }
865 CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc) 865 CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 m_pEncryptDict->Release(); 899 m_pEncryptDict->Release();
900 m_pEncryptDict = NULL; 900 m_pEncryptDict = NULL;
901 } 901 }
902 Clear(); 902 Clear();
903 } 903 }
904 static FX_BOOL _IsXRefNeedEnd(CPDF_XRefStream* pXRef, FX_DWORD flag) 904 static FX_BOOL _IsXRefNeedEnd(CPDF_XRefStream* pXRef, FX_DWORD flag)
905 { 905 {
906 if (!(flag & FPDFCREATE_INCREMENTAL)) { 906 if (!(flag & FPDFCREATE_INCREMENTAL)) {
907 return FALSE; 907 return FALSE;
908 } 908 }
909 FX_INT32 iSize = pXRef->m_IndexArray.GetSize() / 2; 909 int32_t iSize = pXRef->m_IndexArray.GetSize() / 2;
910 FX_INT32 iCount = 0; 910 int32_t iCount = 0;
911 for (FX_INT32 i = 0; i < iSize; i++) { 911 for (int32_t i = 0; i < iSize; i++) {
912 iCount += pXRef->m_IndexArray.ElementAt(i * 2 + 1); 912 iCount += pXRef->m_IndexArray.ElementAt(i * 2 + 1);
913 } 913 }
914 return (iCount >= PDF_XREFSTREAM_MAXSIZE); 914 return (iCount >= PDF_XREFSTREAM_MAXSIZE);
915 } 915 }
916 FX_INT32 CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) 916 int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj)
917 { 917 {
918 if (!m_pXRefStream) { 918 if (!m_pXRefStream) {
919 return 1; 919 return 1;
920 } 920 }
921 FX_DWORD objnum = pObj->GetObjNum(); 921 FX_DWORD objnum = pObj->GetObjNum();
922 if (m_pParser && m_pParser->m_ObjVersion.GetSize() > (FX_INT32)objnum && m_p Parser->m_ObjVersion[objnum] > 0) { 922 if (m_pParser && m_pParser->m_ObjVersion.GetSize() > (int32_t)objnum && m_pP arser->m_ObjVersion[objnum] > 0) {
923 return 1; 923 return 1;
924 } 924 }
925 if (pObj->GetType() == PDFOBJ_NUMBER) { 925 if (pObj->GetType() == PDFOBJ_NUMBER) {
926 return 1; 926 return 1;
927 } 927 }
928 CPDF_Dictionary *pDict = pObj->GetDict(); 928 CPDF_Dictionary *pDict = pObj->GetDict();
929 if (pObj->GetType() == PDFOBJ_STREAM) { 929 if (pObj->GetType() == PDFOBJ_STREAM) {
930 if (pDict && pDict->GetString(FX_BSTRC("Type")) == FX_BSTRC("XRef")) { 930 if (pDict && pDict->GetString(FX_BSTRC("Type")) == FX_BSTRC("XRef")) {
931 return 0; 931 return 0;
932 } 932 }
(...skipping 18 matching lines...) Expand all
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 FX_INT32 CPDF_Creator::WriteIndirectObjectToStream(FX_DWORD objnum, FX_LPCBYTE p Buffer, FX_DWORD dwSize) 961 int32_t CPDF_Creator::WriteIndirectObjectToStream(FX_DWORD objnum, FX_LPCBYTE pB uffer, 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 FX_INT32 iRet = m_pXRefStream->CompressIndirectObject(objnum, pBuffer, dwSiz e, 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)) {
972 return 0; 972 return 0;
973 } 973 }
974 if (!m_pXRefStream->End(this)) { 974 if (!m_pXRefStream->End(this)) {
975 return -1; 975 return -1;
976 } 976 }
977 if (!m_pXRefStream->Start()) { 977 if (!m_pXRefStream->Start()) {
978 return -1; 978 return -1;
979 } 979 }
980 return 0; 980 return 0;
981 } 981 }
982 FX_INT32 CPDF_Creator::AppendObjectNumberToXRef(FX_DWORD objnum) 982 int32_t CPDF_Creator::AppendObjectNumberToXRef(FX_DWORD objnum)
983 { 983 {
984 if (!m_pXRefStream) { 984 if (!m_pXRefStream) {
985 return 1; 985 return 1;
986 } 986 }
987 m_pXRefStream->AddObjectNumberToIndexArray(objnum); 987 m_pXRefStream->AddObjectNumberToIndexArray(objnum);
988 if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) { 988 if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) {
989 return 0; 989 return 0;
990 } 990 }
991 if (!m_pXRefStream->End(this)) { 991 if (!m_pXRefStream->End(this)) {
992 return -1; 992 return -1;
993 } 993 }
994 if (!m_pXRefStream->Start()) { 994 if (!m_pXRefStream->Start()) {
995 return -1; 995 return -1;
996 } 996 }
997 return 0; 997 return 0;
998 } 998 }
999 FX_INT32 CPDF_Creator::WriteStream(const CPDF_Object* pStream, FX_DWORD objnum, CPDF_CryptoHandler* pCrypto) 999 int32_t CPDF_Creator::WriteStream(const CPDF_Object* pStream, FX_DWORD objnum, C PDF_CryptoHandler* pCrypto)
1000 { 1000 {
1001 CPDF_FlateEncoder encoder; 1001 CPDF_FlateEncoder encoder;
1002 encoder.Initialize((CPDF_Stream*)pStream, pStream == m_pMetadata ? FALSE : m _bCompress); 1002 encoder.Initialize((CPDF_Stream*)pStream, pStream == m_pMetadata ? FALSE : m _bCompress);
1003 CPDF_Encryptor encryptor; 1003 CPDF_Encryptor encryptor;
1004 if(!encryptor.Initialize(pCrypto, objnum, encoder.m_pData, encoder.m_dwSize) ) { 1004 if(!encryptor.Initialize(pCrypto, objnum, encoder.m_pData, encoder.m_dwSize) ) {
1005 return -1; 1005 return -1;
1006 } 1006 }
1007 if ((FX_DWORD)encoder.m_pDict->GetInteger(FX_BSTRC("Length")) != encryptor.m _dwSize) { 1007 if ((FX_DWORD)encoder.m_pDict->GetInteger(FX_BSTRC("Length")) != encryptor.m _dwSize) {
1008 encoder.CloneDict(); 1008 encoder.CloneDict();
1009 encoder.m_pDict->SetAtInteger(FX_BSTRC("Length"), encryptor.m_dwSize); 1009 encoder.m_pDict->SetAtInteger(FX_BSTRC("Length"), encryptor.m_dwSize);
1010 } 1010 }
1011 if (WriteDirectObj(objnum, encoder.m_pDict) < 0) { 1011 if (WriteDirectObj(objnum, encoder.m_pDict) < 0) {
1012 return -1; 1012 return -1;
1013 } 1013 }
1014 int len = m_File.AppendString(FX_BSTRC("stream\r\n")); 1014 int len = m_File.AppendString(FX_BSTRC("stream\r\n"));
1015 if (len < 0) { 1015 if (len < 0) {
1016 return -1; 1016 return -1;
1017 } 1017 }
1018 m_Offset += len; 1018 m_Offset += len;
1019 if (m_File.AppendBlock(encryptor.m_pData, encryptor.m_dwSize) < 0) { 1019 if (m_File.AppendBlock(encryptor.m_pData, encryptor.m_dwSize) < 0) {
1020 return -1; 1020 return -1;
1021 } 1021 }
1022 m_Offset += encryptor.m_dwSize; 1022 m_Offset += encryptor.m_dwSize;
1023 if ((len = m_File.AppendString(FX_BSTRC("\r\nendstream"))) < 0) { 1023 if ((len = m_File.AppendString(FX_BSTRC("\r\nendstream"))) < 0) {
1024 return -1; 1024 return -1;
1025 } 1025 }
1026 m_Offset += len; 1026 m_Offset += len;
1027 return 1; 1027 return 1;
1028 } 1028 }
1029 FX_INT32 CPDF_Creator::WriteIndirectObj(FX_DWORD objnum, const CPDF_Object* pObj ) 1029 int32_t CPDF_Creator::WriteIndirectObj(FX_DWORD objnum, const CPDF_Object* pObj)
1030 { 1030 {
1031 FX_INT32 len = m_File.AppendDWord(objnum); 1031 int32_t len = m_File.AppendDWord(objnum);
1032 if (len < 0) { 1032 if (len < 0) {
1033 return -1; 1033 return -1;
1034 } 1034 }
1035 m_Offset += len; 1035 m_Offset += len;
1036 if ((len = m_File.AppendString(FX_BSTRC(" 0 obj\r\n"))) < 0) { 1036 if ((len = m_File.AppendString(FX_BSTRC(" 0 obj\r\n"))) < 0) {
1037 return -1; 1037 return -1;
1038 } 1038 }
1039 m_Offset += len; 1039 m_Offset += len;
1040 if (pObj->GetType() == PDFOBJ_STREAM) { 1040 if (pObj->GetType() == PDFOBJ_STREAM) {
1041 CPDF_CryptoHandler *pHandler = NULL; 1041 CPDF_CryptoHandler *pHandler = NULL;
1042 pHandler = (pObj == m_pMetadata && !m_bEncryptMetadata) ? NULL : m_pCryp toHandler; 1042 pHandler = (pObj == m_pMetadata && !m_bEncryptMetadata) ? NULL : m_pCryp toHandler;
1043 if (WriteStream(pObj, objnum, pHandler) < 0) { 1043 if (WriteStream(pObj, objnum, pHandler) < 0) {
1044 return -1; 1044 return -1;
1045 } 1045 }
1046 } else { 1046 } else {
1047 if (WriteDirectObj(objnum, pObj) < 0) { 1047 if (WriteDirectObj(objnum, pObj) < 0) {
1048 return -1; 1048 return -1;
1049 } 1049 }
1050 } 1050 }
1051 if ((len = m_File.AppendString(FX_BSTRC("\r\nendobj\r\n"))) < 0) { 1051 if ((len = m_File.AppendString(FX_BSTRC("\r\nendobj\r\n"))) < 0) {
1052 return -1; 1052 return -1;
1053 } 1053 }
1054 m_Offset += len; 1054 m_Offset += len;
1055 if (AppendObjectNumberToXRef(objnum) < 0) { 1055 if (AppendObjectNumberToXRef(objnum) < 0) {
1056 return -1; 1056 return -1;
1057 } 1057 }
1058 return 0; 1058 return 0;
1059 } 1059 }
1060 FX_INT32 CPDF_Creator::WriteIndirectObj(const CPDF_Object* pObj) 1060 int32_t CPDF_Creator::WriteIndirectObj(const CPDF_Object* pObj)
1061 { 1061 {
1062 FX_INT32 iRet = WriteIndirectObjectToStream(pObj); 1062 int32_t iRet = WriteIndirectObjectToStream(pObj);
1063 if (iRet < 1) { 1063 if (iRet < 1) {
1064 return iRet; 1064 return iRet;
1065 } 1065 }
1066 return WriteIndirectObj(pObj->GetObjNum(), pObj); 1066 return WriteIndirectObj(pObj->GetObjNum(), pObj);
1067 } 1067 }
1068 FX_INT32 CPDF_Creator::WriteDirectObj(FX_DWORD objnum, const CPDF_Object* pObj, FX_BOOL bEncrypt) 1068 int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum, const CPDF_Object* pObj, F X_BOOL bEncrypt)
1069 { 1069 {
1070 FX_INT32 len = 0; 1070 int32_t len = 0;
1071 if (pObj == NULL) { 1071 if (pObj == NULL) {
1072 if (m_File.AppendString(FX_BSTRC(" null")) < 0) { 1072 if (m_File.AppendString(FX_BSTRC(" null")) < 0) {
1073 return -1; 1073 return -1;
1074 } 1074 }
1075 m_Offset += 5; 1075 m_Offset += 5;
1076 return 1; 1076 return 1;
1077 } 1077 }
1078 switch (pObj->GetType()) { 1078 switch (pObj->GetType()) {
1079 case PDFOBJ_NULL: 1079 case PDFOBJ_NULL:
1080 if (m_File.AppendString(FX_BSTRC(" null")) < 0) { 1080 if (m_File.AppendString(FX_BSTRC(" null")) < 0) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 } 1239 }
1240 if (m_File.AppendString(FX_BSTRC(">>")) < 0) { 1240 if (m_File.AppendString(FX_BSTRC(">>")) < 0) {
1241 return -1; 1241 return -1;
1242 } 1242 }
1243 m_Offset += 2; 1243 m_Offset += 2;
1244 break; 1244 break;
1245 } 1245 }
1246 } 1246 }
1247 return 1; 1247 return 1;
1248 } 1248 }
1249 FX_INT32 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 FX_LPVOID valuetemp = NULL;
1256 FX_BOOL bExistInMap = m_pDocument->m_IndirectObjs.Lookup((FX_LPVOID)(FX_UINT PTR)objnum, valuetemp); 1256 FX_BOOL bExistInMap = m_pDocument->m_IndirectObjs.Lookup((FX_LPVOID)(uintptr _t)objnum, 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;
1267 } 1267 }
1268 if (!bExistInMap) { 1268 if (!bExistInMap) {
1269 m_pDocument->ReleaseIndirectObject(objnum); 1269 m_pDocument->ReleaseIndirectObject(objnum);
1270 } 1270 }
1271 } else { 1271 } else {
1272 FX_BYTE* pBuffer; 1272 uint8_t* pBuffer;
1273 FX_DWORD size; 1273 FX_DWORD size;
1274 m_pParser->GetIndirectBinary(objnum, pBuffer, size); 1274 m_pParser->GetIndirectBinary(objnum, pBuffer, size);
1275 if (pBuffer == NULL) { 1275 if (pBuffer == NULL) {
1276 return 0; 1276 return 0;
1277 } 1277 }
1278 if (m_pParser->m_V5Type[objnum] == 2) { 1278 if (m_pParser->m_V5Type[objnum] == 2) {
1279 if (m_pXRefStream) { 1279 if (m_pXRefStream) {
1280 if (WriteIndirectObjectToStream(objnum, pBuffer, size) < 0) { 1280 if (WriteIndirectObjectToStream(objnum, pBuffer, size) < 0) {
1281 FX_Free(pBuffer); 1281 FX_Free(pBuffer);
1282 return -1; 1282 return -1;
1283 } 1283 }
1284 } else { 1284 } else {
1285 FX_INT32 len = m_File.AppendDWord(objnum); 1285 int32_t len = m_File.AppendDWord(objnum);
1286 if (len < 0) { 1286 if (len < 0) {
1287 return -1; 1287 return -1;
1288 } 1288 }
1289 if (m_File.AppendString(FX_BSTRC(" 0 obj ")) < 0) { 1289 if (m_File.AppendString(FX_BSTRC(" 0 obj ")) < 0) {
1290 return -1; 1290 return -1;
1291 } 1291 }
1292 m_Offset += len + 7; 1292 m_Offset += len + 7;
1293 if (m_File.AppendBlock(pBuffer, size) < 0) { 1293 if (m_File.AppendBlock(pBuffer, size) < 0) {
1294 return -1; 1294 return -1;
1295 } 1295 }
1296 m_Offset += size; 1296 m_Offset += size;
1297 if (m_File.AppendString(FX_BSTRC("\r\nendobj\r\n")) < 0) { 1297 if (m_File.AppendString(FX_BSTRC("\r\nendobj\r\n")) < 0) {
1298 return -1; 1298 return -1;
1299 } 1299 }
1300 m_Offset += 10; 1300 m_Offset += 10;
1301 } 1301 }
1302 } else { 1302 } else {
1303 if (m_File.AppendBlock(pBuffer, size) < 0) { 1303 if (m_File.AppendBlock(pBuffer, size) < 0) {
1304 return -1; 1304 return -1;
1305 } 1305 }
1306 m_Offset += size; 1306 m_Offset += size;
1307 if(AppendObjectNumberToXRef(objnum) < 0) { 1307 if(AppendObjectNumberToXRef(objnum) < 0) {
1308 return -1; 1308 return -1;
1309 } 1309 }
1310 } 1310 }
1311 FX_Free(pBuffer); 1311 FX_Free(pBuffer);
1312 } 1312 }
1313 return 1; 1313 return 1;
1314 } 1314 }
1315 FX_INT32 CPDF_Creator::WriteOldObjs(IFX_Pause *pPause) 1315 int32_t CPDF_Creator::WriteOldObjs(IFX_Pause *pPause)
1316 { 1316 {
1317 FX_DWORD nOldSize = m_pParser->m_CrossRef.GetSize(); 1317 FX_DWORD nOldSize = m_pParser->m_CrossRef.GetSize();
1318 FX_DWORD objnum = (FX_DWORD)(FX_UINTPTR)m_Pos; 1318 FX_DWORD objnum = (FX_DWORD)(uintptr_t)m_Pos;
1319 for(; objnum < nOldSize; objnum ++) { 1319 for(; objnum < nOldSize; objnum ++) {
1320 FX_INT32 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)(FX_UINTPTR)(objnum + 1); 1329 m_Pos = (FX_LPVOID)(uintptr_t)(objnum + 1);
1330 return 1; 1330 return 1;
1331 } 1331 }
1332 } 1332 }
1333 return 0; 1333 return 0;
1334 } 1334 }
1335 FX_INT32 CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause *pPause) 1335 int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause *pPause)
1336 { 1336 {
1337 FX_INT32 iCount = m_NewObjNumArray.GetSize(); 1337 int32_t iCount = m_NewObjNumArray.GetSize();
1338 FX_INT32 index = (FX_INT32)(FX_UINTPTR)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)(FX_UINTPTR)objnum, (FX_LP VOID&)pObj); 1342 m_pDocument->m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, (FX_LPV OID&)pObj);
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++;
1353 if (pPause && pPause->NeedToPauseNow()) { 1353 if (pPause && pPause->NeedToPauseNow()) {
1354 m_Pos = (FX_POSITION)(FX_UINTPTR)index; 1354 m_Pos = (FX_POSITION)(uintptr_t)index;
1355 return 1; 1355 return 1;
1356 } 1356 }
1357 } 1357 }
1358 return 0; 1358 return 0;
1359 } 1359 }
1360 void CPDF_Creator::InitOldObjNumOffsets() 1360 void CPDF_Creator::InitOldObjNumOffsets()
1361 { 1361 {
1362 if (!m_pParser) { 1362 if (!m_pParser) {
1363 return; 1363 return;
1364 } 1364 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
1404 continue; 1404 continue;
1405 } 1405 }
1406 } 1406 }
1407 AppendNewObjNum(objnum); 1407 AppendNewObjNum(objnum);
1408 } 1408 }
1409 FX_INT32 iCount = m_NewObjNumArray.GetSize(); 1409 int32_t iCount = m_NewObjNumArray.GetSize();
1410 if (iCount == 0) { 1410 if (iCount == 0) {
1411 return; 1411 return;
1412 } 1412 }
1413 FX_INT32 i = 0; 1413 int32_t i = 0;
1414 FX_DWORD dwStartObjNum = 0; 1414 FX_DWORD dwStartObjNum = 0;
1415 FX_BOOL bCrossRefValid = m_pParser && m_pParser->GetLastXRefOffset() > 0; 1415 FX_BOOL bCrossRefValid = m_pParser && m_pParser->GetLastXRefOffset() > 0;
1416 while (i < iCount) { 1416 while (i < iCount) {
1417 dwStartObjNum = m_NewObjNumArray.ElementAt(i); 1417 dwStartObjNum = m_NewObjNumArray.ElementAt(i);
1418 if ((bIncremental && (bNoOriginal || bCrossRefValid)) || !m_ObjectOffset .GetPtrAt(dwStartObjNum)) { 1418 if ((bIncremental && (bNoOriginal || bCrossRefValid)) || !m_ObjectOffset .GetPtrAt(dwStartObjNum)) {
1419 break; 1419 break;
1420 } 1420 }
1421 i++; 1421 i++;
1422 } 1422 }
1423 if (i >= iCount) { 1423 if (i >= iCount) {
(...skipping 16 matching lines...) Expand all
1440 dwStartObjNum = dwCurObjNum; 1440 dwStartObjNum = dwCurObjNum;
1441 } 1441 }
1442 bNewStart = bExist; 1442 bNewStart = bExist;
1443 dwLastObjNum = dwCurObjNum; 1443 dwLastObjNum = dwCurObjNum;
1444 } 1444 }
1445 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); 1445 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1446 m_ObjectSize.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); 1446 m_ObjectSize.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1447 } 1447 }
1448 void CPDF_Creator::AppendNewObjNum(FX_DWORD objbum) 1448 void CPDF_Creator::AppendNewObjNum(FX_DWORD objbum)
1449 { 1449 {
1450 FX_INT32 iStart = 0, iFind = 0; 1450 int32_t iStart = 0, iFind = 0;
1451 FX_INT32 iEnd = m_NewObjNumArray.GetUpperBound(); 1451 int32_t iEnd = m_NewObjNumArray.GetUpperBound();
1452 while (iStart <= iEnd) { 1452 while (iStart <= iEnd) {
1453 FX_INT32 iMid = (iStart + iEnd) / 2; 1453 int32_t iMid = (iStart + iEnd) / 2;
1454 FX_DWORD dwMid = m_NewObjNumArray.ElementAt(iMid); 1454 FX_DWORD dwMid = m_NewObjNumArray.ElementAt(iMid);
1455 if (objbum < dwMid) { 1455 if (objbum < dwMid) {
1456 iEnd = iMid - 1; 1456 iEnd = iMid - 1;
1457 } else { 1457 } else {
1458 if (iMid == iEnd) { 1458 if (iMid == iEnd) {
1459 iFind = iMid + 1; 1459 iFind = iMid + 1;
1460 break; 1460 break;
1461 } 1461 }
1462 FX_DWORD dwNext = m_NewObjNumArray.ElementAt(iMid + 1); 1462 FX_DWORD dwNext = m_NewObjNumArray.ElementAt(iMid + 1);
1463 if (objbum < dwNext) { 1463 if (objbum < dwNext) {
1464 iFind = iMid + 1; 1464 iFind = iMid + 1;
1465 break; 1465 break;
1466 } 1466 }
1467 iStart = iMid + 1; 1467 iStart = iMid + 1;
1468 } 1468 }
1469 } 1469 }
1470 m_NewObjNumArray.InsertAt(iFind, objbum); 1470 m_NewObjNumArray.InsertAt(iFind, objbum);
1471 } 1471 }
1472 FX_INT32 CPDF_Creator::WriteDoc_Stage1(IFX_Pause *pPause) 1472 int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause *pPause)
1473 { 1473 {
1474 FXSYS_assert(m_iStage > -1 || m_iStage < 20); 1474 FXSYS_assert(m_iStage > -1 || m_iStage < 20);
1475 if (m_iStage == 0) { 1475 if (m_iStage == 0) {
1476 if (m_pParser == NULL) { 1476 if (m_pParser == NULL) {
1477 m_dwFlags &= ~FPDFCREATE_INCREMENTAL; 1477 m_dwFlags &= ~FPDFCREATE_INCREMENTAL;
1478 } 1478 }
1479 if (m_bSecurityChanged && (m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0) { 1479 if (m_bSecurityChanged && (m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0) {
1480 m_dwFlags &= ~FPDFCREATE_INCREMENTAL; 1480 m_dwFlags &= ~FPDFCREATE_INCREMENTAL;
1481 } 1481 }
1482 CPDF_Dictionary* pDict = m_pDocument->GetRoot(); 1482 CPDF_Dictionary* pDict = m_pDocument->GetRoot();
1483 m_pMetadata = pDict ? pDict->GetElementValue(FX_BSTRC("Metadata")) : NUL L; 1483 m_pMetadata = pDict ? pDict->GetElementValue(FX_BSTRC("Metadata")) : NUL L;
1484 if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) { 1484 if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) {
1485 m_pXRefStream = new CPDF_XRefStream; 1485 m_pXRefStream = new CPDF_XRefStream;
1486 m_pXRefStream->Start(); 1486 m_pXRefStream->Start();
1487 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser) { 1487 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser) {
1488 FX_FILESIZE prev = m_pParser->GetLastXRefOffset(); 1488 FX_FILESIZE prev = m_pParser->GetLastXRefOffset();
1489 m_pXRefStream->m_PrevOffset = prev; 1489 m_pXRefStream->m_PrevOffset = prev;
1490 } 1490 }
1491 } 1491 }
1492 m_iStage = 10; 1492 m_iStage = 10;
1493 } 1493 }
1494 if (m_iStage == 10) { 1494 if (m_iStage == 10) {
1495 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0) { 1495 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0) {
1496 if (m_File.AppendString(FX_BSTRC("%PDF-1.")) < 0) { 1496 if (m_File.AppendString(FX_BSTRC("%PDF-1.")) < 0) {
1497 return -1; 1497 return -1;
1498 } 1498 }
1499 m_Offset += 7; 1499 m_Offset += 7;
1500 FX_INT32 version = 7; 1500 int32_t version = 7;
1501 if (m_FileVersion) { 1501 if (m_FileVersion) {
1502 version = m_FileVersion; 1502 version = m_FileVersion;
1503 } else if (m_pParser) { 1503 } else if (m_pParser) {
1504 version = m_pParser->GetFileVersion(); 1504 version = m_pParser->GetFileVersion();
1505 } 1505 }
1506 FX_INT32 len = m_File.AppendDWord(version % 10); 1506 int32_t len = m_File.AppendDWord(version % 10);
1507 if (len < 0) { 1507 if (len < 0) {
1508 return -1; 1508 return -1;
1509 } 1509 }
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)(FX_UINTPTR)m_Offset; 1520 m_Pos = (FX_LPVOID)(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 FX_BYTE buffer[4096]; 1527 uint8_t buffer[4096];
1528 FX_DWORD src_size = (FX_DWORD)(FX_UINTPTR)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)(FX_UINTPTR)src_size; 1539 m_Pos = (FX_LPVOID)(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) {
1550 continue; 1550 continue;
1551 } 1551 }
1552 m_ObjectOffset[objnum] = m_pParser->m_CrossRef[objnum]; 1552 m_ObjectOffset[objnum] = m_pParser->m_CrossRef[objnum];
1553 if (bObjStm) { 1553 if (bObjStm) {
1554 m_pXRefStream->AddObjectNumberToIndexArray(objnum); 1554 m_pXRefStream->AddObjectNumberToIndexArray(objnum);
1555 } 1555 }
1556 } 1556 }
1557 if (bObjStm) { 1557 if (bObjStm) {
1558 m_pXRefStream->EndXRefStream(this); 1558 m_pXRefStream->EndXRefStream(this);
1559 m_pXRefStream->Start(); 1559 m_pXRefStream->Start();
1560 } 1560 }
1561 } 1561 }
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 FX_INT32 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)(FX_UINTPTR)0; 1572 m_Pos = (FX_LPVOID)(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 FX_INT32 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)(FX_UINTPTR)0; 1586 m_Pos = (FX_LPVOID)(uintptr_t)0;
1587 m_iStage = 26; 1587 m_iStage = 26;
1588 } 1588 }
1589 if (m_iStage == 26) { 1589 if (m_iStage == 26) {
1590 FX_INT32 iRet = WriteNewObjs((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0, pPause); 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) {
1597 if (NULL != m_pEncryptDict && 0 == m_pEncryptDict->GetObjNum()) { 1597 if (NULL != m_pEncryptDict && 0 == m_pEncryptDict->GetObjNum()) {
1598 m_dwLastObjNum += 1; 1598 m_dwLastObjNum += 1;
1599 FX_FILESIZE saveOffset = m_Offset; 1599 FX_FILESIZE saveOffset = m_Offset;
1600 if (WriteIndirectObj(m_dwLastObjNum, m_pEncryptDict) < 0) { 1600 if (WriteIndirectObj(m_dwLastObjNum, m_pEncryptDict) < 0) {
1601 return -1; 1601 return -1;
1602 } 1602 }
1603 m_ObjectOffset.Add(m_dwLastObjNum, 1); 1603 m_ObjectOffset.Add(m_dwLastObjNum, 1);
1604 m_ObjectOffset[m_dwLastObjNum] = saveOffset; 1604 m_ObjectOffset[m_dwLastObjNum] = saveOffset;
1605 m_ObjectSize.Add(m_dwLastObjNum, 1); 1605 m_ObjectSize.Add(m_dwLastObjNum, 1);
1606 m_ObjectSize[m_dwLastObjNum] = m_Offset - saveOffset; 1606 m_ObjectSize[m_dwLastObjNum] = m_Offset - saveOffset;
1607 m_dwEnryptObjNum = m_dwLastObjNum; 1607 m_dwEnryptObjNum = m_dwLastObjNum;
1608 if (m_dwFlags & FPDFCREATE_INCREMENTAL) { 1608 if (m_dwFlags & FPDFCREATE_INCREMENTAL) {
1609 m_NewObjNumArray.Add(m_dwLastObjNum); 1609 m_NewObjNumArray.Add(m_dwLastObjNum);
1610 } 1610 }
1611 } 1611 }
1612 m_iStage = 80; 1612 m_iStage = 80;
1613 } 1613 }
1614 return m_iStage; 1614 return m_iStage;
1615 } 1615 }
1616 FX_INT32 CPDF_Creator::WriteDoc_Stage3(IFX_Pause *pPause) 1616 int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause *pPause)
1617 { 1617 {
1618 FXSYS_assert(m_iStage >= 80 || m_iStage < 90); 1618 FXSYS_assert(m_iStage >= 80 || m_iStage < 90);
1619 FX_DWORD dwLastObjNum = m_dwLastObjNum; 1619 FX_DWORD dwLastObjNum = m_dwLastObjNum;
1620 if (m_iStage == 80) { 1620 if (m_iStage == 80) {
1621 m_XrefStart = m_Offset; 1621 m_XrefStart = m_Offset;
1622 if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) { 1622 if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) {
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)(FX_UINTPTR)1; 1633 m_Pos = (FX_LPVOID)(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)(FX_UINTPTR)0; 1639 m_Pos = (FX_LPVOID)(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)(FX_UINTPTR)m_Pos, j; 1648 FX_DWORD i = (FX_DWORD)(uintptr_t)m_Pos, j;
1649 while (i <= dwLastObjNum) { 1649 while (i <= dwLastObjNum) {
1650 while (i <= dwLastObjNum && !m_ObjectOffset.GetPtrAt(i)) { 1650 while (i <= dwLastObjNum && !m_ObjectOffset.GetPtrAt(i)) {
1651 i++; 1651 i++;
1652 } 1652 }
1653 if (i > dwLastObjNum) { 1653 if (i > dwLastObjNum) {
1654 break; 1654 break;
1655 } 1655 }
1656 j = i; 1656 j = i;
1657 while (j <= dwLastObjNum && m_ObjectOffset.GetPtrAt(j)) { 1657 while (j <= dwLastObjNum && m_ObjectOffset.GetPtrAt(j)) {
1658 j++; 1658 j++;
1659 } 1659 }
1660 if (i == 1) { 1660 if (i == 1) {
1661 str.Format("0 %d\r\n0000000000 65536 f\r\n", j); 1661 str.Format("0 %d\r\n0000000000 65536 f\r\n", j);
1662 } else { 1662 } else {
1663 str.Format("%d %d\r\n", i, j - i); 1663 str.Format("%d %d\r\n", i, j - i);
1664 } 1664 }
1665 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) { 1665 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) {
1666 return -1; 1666 return -1;
1667 } 1667 }
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)(FX_UINTPTR)i; 1678 m_Pos = (FX_LPVOID)(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 FX_INT32 iCount = m_NewObjNumArray.GetSize(); 1686 int32_t iCount = m_NewObjNumArray.GetSize();
1687 FX_INT32 i = (FX_INT32)(FX_UINTPTR)m_Pos; 1687 int32_t i = (int32_t)(uintptr_t)m_Pos;
1688 while (i < iCount) { 1688 while (i < iCount) {
1689 FX_INT32 j = i; 1689 int32_t j = i;
1690 FX_DWORD objnum = m_NewObjNumArray.ElementAt(i); 1690 FX_DWORD objnum = m_NewObjNumArray.ElementAt(i);
1691 while (j < iCount) { 1691 while (j < iCount) {
1692 if (++j == iCount) { 1692 if (++j == iCount) {
1693 break; 1693 break;
1694 } 1694 }
1695 FX_DWORD dwCurrent = m_NewObjNumArray.ElementAt(j); 1695 FX_DWORD dwCurrent = m_NewObjNumArray.ElementAt(j);
1696 if (dwCurrent - objnum > 1) { 1696 if (dwCurrent - objnum > 1) {
1697 break; 1697 break;
1698 } 1698 }
1699 objnum = dwCurrent; 1699 objnum = dwCurrent;
1700 } 1700 }
1701 objnum = m_NewObjNumArray.ElementAt(i); 1701 objnum = m_NewObjNumArray.ElementAt(i);
1702 if (objnum == 1) { 1702 if (objnum == 1) {
1703 str.Format("0 %d\r\n0000000000 65536 f\r\n", j - i + 1); 1703 str.Format("0 %d\r\n0000000000 65536 f\r\n", j - i + 1);
1704 } else { 1704 } else {
1705 str.Format("%d %d\r\n", objnum, j - i); 1705 str.Format("%d %d\r\n", objnum, j - i);
1706 } 1706 }
1707 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) { 1707 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) {
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)(FX_UINTPTR)i; 1718 m_Pos = (FX_LPVOID)(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 FX_INT32 _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);
1729 if (sizeof(offset) > 4) { 1729 if (sizeof(offset) > 4) {
1730 if (FX_GETBYTEOFFSET32(offset)) { 1730 if (FX_GETBYTEOFFSET32(offset)) {
1731 if (pFile->AppendByte(FX_GETBYTEOFFSET56(offset)) < 0) { 1731 if (pFile->AppendByte(FX_GETBYTEOFFSET56(offset)) < 0) {
1732 return -1; 1732 return -1;
1733 } 1733 }
1734 if (pFile->AppendByte(FX_GETBYTEOFFSET48(offset)) < 0) { 1734 if (pFile->AppendByte(FX_GETBYTEOFFSET48(offset)) < 0) {
1735 return -1; 1735 return -1;
1736 } 1736 }
(...skipping 15 matching lines...) Expand all
1752 return -1; 1752 return -1;
1753 } 1753 }
1754 if (pFile->AppendByte(FX_GETBYTEOFFSET0(offset)) < 0) { 1754 if (pFile->AppendByte(FX_GETBYTEOFFSET0(offset)) < 0) {
1755 return -1; 1755 return -1;
1756 } 1756 }
1757 if (pFile->AppendByte(0) < 0) { 1757 if (pFile->AppendByte(0) < 0) {
1758 return -1; 1758 return -1;
1759 } 1759 }
1760 return 0; 1760 return 0;
1761 } 1761 }
1762 FX_INT32 CPDF_Creator::WriteDoc_Stage4(IFX_Pause *pPause) 1762 int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause *pPause)
1763 { 1763 {
1764 FXSYS_assert(m_iStage >= 90); 1764 FXSYS_assert(m_iStage >= 90);
1765 if ((m_dwFlags & FPDFCREATE_OBJECTSTREAM) == 0) { 1765 if ((m_dwFlags & FPDFCREATE_OBJECTSTREAM) == 0) {
1766 FX_BOOL bXRefStream = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pPa rser->IsXRefStream(); 1766 FX_BOOL bXRefStream = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pPa rser->IsXRefStream();
1767 if (!bXRefStream) { 1767 if (!bXRefStream) {
1768 if (m_File.AppendString(FX_BSTRC("trailer\r\n<<")) < 0) { 1768 if (m_File.AppendString(FX_BSTRC("trailer\r\n<<")) < 0) {
1769 return -1; 1769 return -1;
1770 } 1770 }
1771 } else { 1771 } else {
1772 if (m_File.AppendDWord(m_pDocument->m_LastObjNum + 1) < 0) { 1772 if (m_File.AppendDWord(m_pDocument->m_LastObjNum + 1) < 0) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 } 1911 }
1912 for (i = 0; i < m_dwLastObjNum; i++) { 1912 for (i = 0; i < m_dwLastObjNum; i++) {
1913 FX_FILESIZE* offset = m_ObjectOffset.GetPtrAt(i); 1913 FX_FILESIZE* offset = m_ObjectOffset.GetPtrAt(i);
1914 if (!offset) { 1914 if (!offset) {
1915 continue; 1915 continue;
1916 } 1916 }
1917 _OutPutIndex(&m_File, *offset); 1917 _OutPutIndex(&m_File, *offset);
1918 } 1918 }
1919 } else { 1919 } else {
1920 int count = m_NewObjNumArray.GetSize(); 1920 int count = m_NewObjNumArray.GetSize();
1921 FX_INT32 i = 0; 1921 int32_t i = 0;
1922 for (i = 0; i < count; i++) { 1922 for (i = 0; i < count; i++) {
1923 FX_DWORD objnum = m_NewObjNumArray.ElementAt(i); 1923 FX_DWORD objnum = m_NewObjNumArray.ElementAt(i);
1924 if (m_File.AppendDWord(objnum) < 0) { 1924 if (m_File.AppendDWord(objnum) < 0) {
1925 return -1; 1925 return -1;
1926 } 1926 }
1927 if (m_File.AppendString(FX_BSTRC(" 1 ")) < 0) { 1927 if (m_File.AppendString(FX_BSTRC(" 1 ")) < 0) {
1928 return -1; 1928 return -1;
1929 } 1929 }
1930 } 1930 }
1931 if (m_File.AppendString(FX_BSTRC("]/Length ")) < 0) { 1931 if (m_File.AppendString(FX_BSTRC("]/Length ")) < 0) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_LPDWORD 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)(FX_UINTPTR)this, m_dwLastObjNum, pBuff er); 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((FX_LPCBYTE)pBuffer, 4 * sizeof(FX_DWORD));
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_LPDWORD pBuffer = FX_Alloc(FX_DWORD, 4);
2056 PDF_GenerateFileID((FX_DWORD)(FX_UINTPTR)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((FX_LPCBYTE)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, (FX_LPCBYTE)user_pass, 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 }
2079 FX_INT32 CPDF_Creator::Continue(IFX_Pause *pPause) 2079 int32_t CPDF_Creator::Continue(IFX_Pause *pPause)
2080 { 2080 {
2081 if (m_iStage < 0) { 2081 if (m_iStage < 0) {
2082 return m_iStage; 2082 return m_iStage;
2083 } 2083 }
2084 FX_INT32 iRet = 0; 2084 int32_t iRet = 0;
2085 while (m_iStage < 100) { 2085 while (m_iStage < 100) {
2086 if (m_iStage < 20) { 2086 if (m_iStage < 20) {
2087 iRet = WriteDoc_Stage1(pPause); 2087 iRet = WriteDoc_Stage1(pPause);
2088 } else if (m_iStage < 30) { 2088 } else if (m_iStage < 30) {
2089 iRet = WriteDoc_Stage2(pPause); 2089 iRet = WriteDoc_Stage2(pPause);
2090 } else if (m_iStage < 90) { 2090 } else if (m_iStage < 90) {
2091 iRet = WriteDoc_Stage3(pPause); 2091 iRet = WriteDoc_Stage3(pPause);
2092 } else { 2092 } else {
2093 iRet = WriteDoc_Stage4(pPause); 2093 iRet = WriteDoc_Stage4(pPause);
2094 } 2094 }
2095 if (iRet < m_iStage) { 2095 if (iRet < m_iStage) {
2096 break; 2096 break;
2097 } 2097 }
2098 } 2098 }
2099 if (iRet < 1 || m_iStage == 100) { 2099 if (iRet < 1 || m_iStage == 100) {
2100 m_iStage = -1; 2100 m_iStage = -1;
2101 Clear(); 2101 Clear();
2102 return iRet > 99 ? 0 : (iRet < 1 ? -1 : iRet); 2102 return iRet > 99 ? 0 : (iRet < 1 ? -1 : iRet);
2103 } 2103 }
2104 return m_iStage; 2104 return m_iStage;
2105 } 2105 }
2106 FX_BOOL CPDF_Creator::SetFileVersion(FX_INT32 fileVersion ) 2106 FX_BOOL CPDF_Creator::SetFileVersion(int32_t fileVersion )
2107 { 2107 {
2108 if (fileVersion < 10 || fileVersion > 17) { 2108 if (fileVersion < 10 || fileVersion > 17) {
2109 return FALSE; 2109 return FALSE;
2110 } 2110 }
2111 m_FileVersion = fileVersion; 2111 m_FileVersion = fileVersion;
2112 return TRUE; 2112 return TRUE;
2113 } 2113 }
2114 void CPDF_Creator::RemoveSecurity() 2114 void CPDF_Creator::RemoveSecurity()
2115 { 2115 {
2116 ResetStandardSecurity(); 2116 ResetStandardSecurity();
(...skipping 10 matching lines...) Expand all
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