OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/src/fpdfapi/fpdf_edit/editint.h" | 7 #include "core/src/fpdfapi/fpdf_edit/editint.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "core/include/fpdfapi/cpdf_document.h" | 11 #include "core/include/fpdfapi/cpdf_document.h" |
12 #include "core/include/fpdfapi/cpdf_parser.h" | 12 #include "core/include/fpdfapi/cpdf_parser.h" |
13 #include "core/include/fpdfapi/fpdf_parser.h" | 13 #include "core/include/fpdfapi/fpdf_parser_decode.h" |
14 #include "core/include/fpdfapi/fpdf_serial.h" | 14 #include "core/include/fpdfapi/fpdf_serial.h" |
15 #include "core/include/fpdfapi/ipdf_crypto_handler.h" | 15 #include "core/include/fpdfapi/ipdf_crypto_handler.h" |
16 #include "core/include/fxcrt/fx_ext.h" | 16 #include "core/include/fxcrt/fx_ext.h" |
17 #include "core/src/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h" | 17 #include "core/src/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h" |
18 #include "core/src/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h" | 18 #include "core/src/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h" |
19 #include "third_party/base/stl_util.h" | 19 #include "third_party/base/stl_util.h" |
20 | 20 |
21 #define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024) | 21 #define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024) |
22 #define PDF_XREFSTREAM_MAXSIZE 10000 | 22 #define PDF_XREFSTREAM_MAXSIZE 10000 |
23 | 23 |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 CPDF_Dictionary* pDict = pObj->GetDict(); | 953 CPDF_Dictionary* pDict = pObj->GetDict(); |
954 if (pObj->IsStream()) { | 954 if (pObj->IsStream()) { |
955 if (pDict && pDict->GetStringBy("Type") == "XRef") | 955 if (pDict && pDict->GetStringBy("Type") == "XRef") |
956 return 0; | 956 return 0; |
957 return 1; | 957 return 1; |
958 } | 958 } |
959 | 959 |
960 if (pDict) { | 960 if (pDict) { |
961 if (pDict == m_pDocument->m_pRootDict || pDict == m_pEncryptDict) | 961 if (pDict == m_pDocument->m_pRootDict || pDict == m_pEncryptDict) |
962 return 1; | 962 return 1; |
963 if (IsSignatureDict(pDict)) | 963 if (pDict->IsSignatureDict()) |
964 return 1; | 964 return 1; |
965 if (pDict->GetStringBy("Type") == "Page") | 965 if (pDict->GetStringBy("Type") == "Page") |
966 return 1; | 966 return 1; |
967 } | 967 } |
968 | 968 |
969 m_pXRefStream->AddObjectNumberToIndexArray(objnum); | 969 m_pXRefStream->AddObjectNumberToIndexArray(objnum); |
970 if (m_pXRefStream->CompressIndirectObject(objnum, pObj, this) < 0) | 970 if (m_pXRefStream->CompressIndirectObject(objnum, pObj, this) < 0) |
971 return -1; | 971 return -1; |
972 if (!IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) | 972 if (!IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) |
973 return 0; | 973 return 0; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 } | 1219 } |
1220 case CPDF_Object::DICTIONARY: { | 1220 case CPDF_Object::DICTIONARY: { |
1221 if (!m_pCryptoHandler || pObj == m_pEncryptDict) { | 1221 if (!m_pCryptoHandler || pObj == m_pEncryptDict) { |
1222 return PDF_CreatorAppendObject(pObj, &m_File, m_Offset); | 1222 return PDF_CreatorAppendObject(pObj, &m_File, m_Offset); |
1223 } | 1223 } |
1224 if (m_File.AppendString("<<") < 0) { | 1224 if (m_File.AppendString("<<") < 0) { |
1225 return -1; | 1225 return -1; |
1226 } | 1226 } |
1227 m_Offset += 2; | 1227 m_Offset += 2; |
1228 const CPDF_Dictionary* p = pObj->AsDictionary(); | 1228 const CPDF_Dictionary* p = pObj->AsDictionary(); |
1229 bool bSignDict = IsSignatureDict(p); | 1229 bool bSignDict = p->IsSignatureDict(); |
1230 for (const auto& it : *p) { | 1230 for (const auto& it : *p) { |
1231 FX_BOOL bSignValue = FALSE; | 1231 FX_BOOL bSignValue = FALSE; |
1232 const CFX_ByteString& key = it.first; | 1232 const CFX_ByteString& key = it.first; |
1233 CPDF_Object* pValue = it.second; | 1233 CPDF_Object* pValue = it.second; |
1234 if (m_File.AppendString("/") < 0) { | 1234 if (m_File.AppendString("/") < 0) { |
1235 return -1; | 1235 return -1; |
1236 } | 1236 } |
1237 if ((len = m_File.AppendString(PDF_NameEncode(key))) < 0) { | 1237 if ((len = m_File.AppendString(PDF_NameEncode(key))) < 0) { |
1238 return -1; | 1238 return -1; |
1239 } | 1239 } |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 m_bNewCrypto = FALSE; | 2061 m_bNewCrypto = FALSE; |
2062 if (!m_bStandardSecurity) { | 2062 if (!m_bStandardSecurity) { |
2063 return; | 2063 return; |
2064 } | 2064 } |
2065 if (m_pEncryptDict) { | 2065 if (m_pEncryptDict) { |
2066 m_pEncryptDict->Release(); | 2066 m_pEncryptDict->Release(); |
2067 m_pEncryptDict = NULL; | 2067 m_pEncryptDict = NULL; |
2068 } | 2068 } |
2069 m_bStandardSecurity = FALSE; | 2069 m_bStandardSecurity = FALSE; |
2070 } | 2070 } |
OLD | NEW |