OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../../include/fxcrt/fx_ext.h" | 7 #include "../../../include/fxcrt/fx_ext.h" |
8 #include "../../../include/fpdfapi/fpdf_serial.h" | 8 #include "../../../include/fpdfapi/fpdf_serial.h" |
9 #include "editint.h" | 9 #include "editint.h" |
10 | 10 |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 744 } |
745 if (pFile->AppendString(FX_BSTRC("]/Size ")) < 0) { | 745 if (pFile->AppendString(FX_BSTRC("]/Size ")) < 0) { |
746 return FALSE; | 746 return FALSE; |
747 } | 747 } |
748 if ((len = pFile->AppendDWord(objnum + 1)) < 0) { | 748 if ((len = pFile->AppendDWord(objnum + 1)) < 0) { |
749 return FALSE; | 749 return FALSE; |
750 } | 750 } |
751 offset += len + 7; | 751 offset += len + 7; |
752 if (m_PrevOffset > 0) { | 752 if (m_PrevOffset > 0) { |
753 if (pFile->AppendString(FX_BSTRC("/Prev ")) < 0) { | 753 if (pFile->AppendString(FX_BSTRC("/Prev ")) < 0) { |
754 return -1; | 754 return FALSE; |
755 } | 755 } |
756 FX_CHAR offset_buf[20]; | 756 FX_CHAR offset_buf[20]; |
757 FXSYS_memset(offset_buf, 0, sizeof(offset_buf)); | 757 FXSYS_memset(offset_buf, 0, sizeof(offset_buf)); |
758 FXSYS_i64toa(m_PrevOffset, offset_buf, 10); | 758 FXSYS_i64toa(m_PrevOffset, offset_buf, 10); |
759 int32_t len = (int32_t)FXSYS_strlen(offset_buf); | 759 int32_t len = (int32_t)FXSYS_strlen(offset_buf); |
760 if (pFile->AppendBlock(offset_buf, len) < 0) { | 760 if (pFile->AppendBlock(offset_buf, len) < 0) { |
761 return -1; | 761 return FALSE; |
762 } | 762 } |
763 offset += len + 6; | 763 offset += len + 6; |
764 } | 764 } |
765 FX_BOOL bPredictor = TRUE; | 765 FX_BOOL bPredictor = TRUE; |
766 CPDF_FlateEncoder encoder; | 766 CPDF_FlateEncoder encoder; |
767 encoder.Initialize(m_Buffer.GetBuffer(), m_Buffer.GetLength(), pCreator->m_b
Compress, bPredictor); | 767 encoder.Initialize(m_Buffer.GetBuffer(), m_Buffer.GetLength(), pCreator->m_b
Compress, bPredictor); |
768 if (pCreator->m_bCompress) { | 768 if (pCreator->m_bCompress) { |
769 if (pFile->AppendString(FX_BSTRC("/Filter /FlateDecode")) < 0) { | 769 if (pFile->AppendString(FX_BSTRC("/Filter /FlateDecode")) < 0) { |
770 return FALSE; | 770 return FALSE; |
771 } | 771 } |
772 offset += 20; | 772 offset += 20; |
773 if (bPredictor) { | 773 if (bPredictor) { |
774 if ((len = pFile->AppendString(FX_BSTRC("/DecodeParms<</Columns 7/Pr
edictor 12>>"))) < 0) { | 774 if ((len = pFile->AppendString(FX_BSTRC("/DecodeParms<</Columns 7/Pr
edictor 12>>"))) < 0) { |
775 return FALSE; | 775 return FALSE; |
776 } | 776 } |
777 offset += len; | 777 offset += len; |
778 } | 778 } |
779 } | 779 } |
780 if (pFile->AppendString(FX_BSTRC("/Length ")) < 0) { | 780 if (pFile->AppendString(FX_BSTRC("/Length ")) < 0) { |
781 return FALSE; | 781 return FALSE; |
782 } | 782 } |
783 if ((len = pFile->AppendDWord(encoder.m_dwSize)) < 0) { | 783 if ((len = pFile->AppendDWord(encoder.m_dwSize)) < 0) { |
784 return FALSE; | 784 return FALSE; |
785 } | 785 } |
786 offset += len + 8; | 786 offset += len + 8; |
787 if (bEOF) { | 787 if (bEOF) { |
788 if ((len = PDF_CreatorWriteTrailer(pCreator->m_pDocument, pFile, pCreato
r->m_pIDArray, pCreator->m_bCompress)) < 0) { | 788 if ((len = PDF_CreatorWriteTrailer(pCreator->m_pDocument, pFile, pCreato
r->m_pIDArray, pCreator->m_bCompress)) < 0) { |
789 return -1; | 789 return FALSE; |
790 } | 790 } |
791 offset += len; | 791 offset += len; |
792 if (pCreator->m_pEncryptDict) { | 792 if (pCreator->m_pEncryptDict) { |
793 FX_DWORD dwEncryptObjNum = pCreator->m_pEncryptDict->GetObjNum(); | 793 FX_DWORD dwEncryptObjNum = pCreator->m_pEncryptDict->GetObjNum(); |
794 if (dwEncryptObjNum == 0) { | 794 if (dwEncryptObjNum == 0) { |
795 dwEncryptObjNum = pCreator->m_dwEnryptObjNum; | 795 dwEncryptObjNum = pCreator->m_dwEnryptObjNum; |
796 } | 796 } |
797 if ((len = PDF_CreatorWriteEncrypt(pCreator->m_pEncryptDict, dwEncry
ptObjNum, pFile)) < 0) { | 797 if ((len = PDF_CreatorWriteEncrypt(pCreator->m_pEncryptDict, dwEncry
ptObjNum, pFile)) < 0) { |
798 return -1; | 798 return FALSE; |
799 } | 799 } |
800 offset += len; | 800 offset += len; |
801 } | 801 } |
802 } | 802 } |
803 if ((len = pFile->AppendString(FX_BSTRC(">>stream\r\n"))) < 0) { | 803 if ((len = pFile->AppendString(FX_BSTRC(">>stream\r\n"))) < 0) { |
804 return FALSE; | 804 return FALSE; |
805 } | 805 } |
806 offset += len; | 806 offset += len; |
807 if (pFile->AppendBlock(encoder.m_pData, encoder.m_dwSize) < 0) { | 807 if (pFile->AppendBlock(encoder.m_pData, encoder.m_dwSize) < 0) { |
808 return FALSE; | 808 return FALSE; |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |