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/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 |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 FX_BOOL bHex = ((CPDF_String*)pObj)->IsHex(); | 1100 FX_BOOL bHex = ((CPDF_String*)pObj)->IsHex(); |
1101 if (m_pCryptoHandler == NULL || !bEncrypt) { | 1101 if (m_pCryptoHandler == NULL || !bEncrypt) { |
1102 CFX_ByteString content = PDF_EncodeString(str, bHex); | 1102 CFX_ByteString content = PDF_EncodeString(str, bHex); |
1103 if ((len = m_File.AppendString(content)) < 0) { | 1103 if ((len = m_File.AppendString(content)) < 0) { |
1104 return -1; | 1104 return -1; |
1105 } | 1105 } |
1106 m_Offset += len; | 1106 m_Offset += len; |
1107 break; | 1107 break; |
1108 } | 1108 } |
1109 CPDF_Encryptor encryptor; | 1109 CPDF_Encryptor encryptor; |
1110 encryptor.Initialize(m_pCryptoHandler, objnum, (FX_LPBYTE)(FX_LP
CSTR)str, str.GetLength()); | 1110 encryptor.Initialize(m_pCryptoHandler, objnum, (FX_LPBYTE)str.c_
str(), str.GetLength()); |
1111 CFX_ByteString content = PDF_EncodeString(CFX_ByteString((FX_LPC
STR)encryptor.m_pData, encryptor.m_dwSize), bHex); | 1111 CFX_ByteString content = PDF_EncodeString(CFX_ByteString((FX_LPC
STR)encryptor.m_pData, encryptor.m_dwSize), bHex); |
1112 if ((len = m_File.AppendString(content)) < 0) { | 1112 if ((len = m_File.AppendString(content)) < 0) { |
1113 return -1; | 1113 return -1; |
1114 } | 1114 } |
1115 m_Offset += len; | 1115 m_Offset += len; |
1116 break; | 1116 break; |
1117 } | 1117 } |
1118 case PDFOBJ_STREAM: { | 1118 case PDFOBJ_STREAM: { |
1119 CPDF_FlateEncoder encoder; | 1119 CPDF_FlateEncoder encoder; |
1120 encoder.Initialize((CPDF_Stream*)pObj, m_bCompress); | 1120 encoder.Initialize((CPDF_Stream*)pObj, m_bCompress); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 } | 1658 } |
1659 j = i; | 1659 j = i; |
1660 while (j <= dwLastObjNum && m_ObjectOffset.GetPtrAt(j)) { | 1660 while (j <= dwLastObjNum && m_ObjectOffset.GetPtrAt(j)) { |
1661 j++; | 1661 j++; |
1662 } | 1662 } |
1663 if (i == 1) { | 1663 if (i == 1) { |
1664 str.Format("0 %d\r\n0000000000 65536 f\r\n", j); | 1664 str.Format("0 %d\r\n0000000000 65536 f\r\n", j); |
1665 } else { | 1665 } else { |
1666 str.Format("%d %d\r\n", i, j - i); | 1666 str.Format("%d %d\r\n", i, j - i); |
1667 } | 1667 } |
1668 if (m_File.AppendBlock((FX_LPCSTR)str, str.GetLength()) < 0) { | 1668 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) { |
1669 return -1; | 1669 return -1; |
1670 } | 1670 } |
1671 while (i < j) { | 1671 while (i < j) { |
1672 str.Format("%010d 00000 n\r\n", m_ObjectOffset[i ++]); | 1672 str.Format("%010d 00000 n\r\n", m_ObjectOffset[i ++]); |
1673 if (m_File.AppendBlock((FX_LPCSTR)str, str.GetLength()) < 0) { | 1673 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) { |
1674 return -1; | 1674 return -1; |
1675 } | 1675 } |
1676 } | 1676 } |
1677 if (i > dwLastObjNum) { | 1677 if (i > dwLastObjNum) { |
1678 break; | 1678 break; |
1679 } | 1679 } |
1680 if (pPause && pPause->NeedToPauseNow()) { | 1680 if (pPause && pPause->NeedToPauseNow()) { |
1681 m_Pos = (FX_LPVOID)(FX_UINTPTR)i; | 1681 m_Pos = (FX_LPVOID)(FX_UINTPTR)i; |
1682 return 1; | 1682 return 1; |
1683 } | 1683 } |
(...skipping 16 matching lines...) Expand all Loading... |
1700 break; | 1700 break; |
1701 } | 1701 } |
1702 objnum = dwCurrent; | 1702 objnum = dwCurrent; |
1703 } | 1703 } |
1704 objnum = m_NewObjNumArray.ElementAt(i); | 1704 objnum = m_NewObjNumArray.ElementAt(i); |
1705 if (objnum == 1) { | 1705 if (objnum == 1) { |
1706 str.Format("0 %d\r\n0000000000 65536 f\r\n", j - i + 1); | 1706 str.Format("0 %d\r\n0000000000 65536 f\r\n", j - i + 1); |
1707 } else { | 1707 } else { |
1708 str.Format("%d %d\r\n", objnum, j - i); | 1708 str.Format("%d %d\r\n", objnum, j - i); |
1709 } | 1709 } |
1710 if (m_File.AppendBlock((FX_LPCSTR)str, str.GetLength()) < 0) { | 1710 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) { |
1711 return -1; | 1711 return -1; |
1712 } | 1712 } |
1713 while (i < j) { | 1713 while (i < j) { |
1714 objnum = m_NewObjNumArray.ElementAt(i++); | 1714 objnum = m_NewObjNumArray.ElementAt(i++); |
1715 str.Format("%010d 00000 n\r\n", m_ObjectOffset[objnum]); | 1715 str.Format("%010d 00000 n\r\n", m_ObjectOffset[objnum]); |
1716 if (m_File.AppendBlock((FX_LPCSTR)str, str.GetLength()) < 0) { | 1716 if (m_File.AppendBlock(str.c_str(), str.GetLength()) < 0) { |
1717 return -1; | 1717 return -1; |
1718 } | 1718 } |
1719 } | 1719 } |
1720 if (pPause && (i % 100) == 0 && pPause->NeedToPauseNow()) { | 1720 if (pPause && (i % 100) == 0 && pPause->NeedToPauseNow()) { |
1721 m_Pos = (FX_LPVOID)(FX_UINTPTR)i; | 1721 m_Pos = (FX_LPVOID)(FX_UINTPTR)i; |
1722 return 1; | 1722 return 1; |
1723 } | 1723 } |
1724 } | 1724 } |
1725 m_iStage = 90; | 1725 m_iStage = 90; |
1726 } | 1726 } |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2130 m_bNewCrypto = FALSE; | 2130 m_bNewCrypto = FALSE; |
2131 if (!m_bStandardSecurity) { | 2131 if (!m_bStandardSecurity) { |
2132 return; | 2132 return; |
2133 } | 2133 } |
2134 if (m_pEncryptDict) { | 2134 if (m_pEncryptDict) { |
2135 m_pEncryptDict->Release(); | 2135 m_pEncryptDict->Release(); |
2136 m_pEncryptDict = NULL; | 2136 m_pEncryptDict = NULL; |
2137 } | 2137 } |
2138 m_bStandardSecurity = FALSE; | 2138 m_bStandardSecurity = FALSE; |
2139 } | 2139 } |
OLD | NEW |