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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 } | 922 } |
923 FX_DWORD objnum = pObj->GetObjNum(); | 923 FX_DWORD objnum = pObj->GetObjNum(); |
924 if (m_pParser && m_pParser->m_ObjVersion.GetSize() > (int32_t)objnum && m_pP
arser->m_ObjVersion[objnum] > 0) { | 924 if (m_pParser && m_pParser->m_ObjVersion.GetSize() > (int32_t)objnum && m_pP
arser->m_ObjVersion[objnum] > 0) { |
925 return 1; | 925 return 1; |
926 } | 926 } |
927 if (pObj->GetType() == PDFOBJ_NUMBER) { | 927 if (pObj->GetType() == PDFOBJ_NUMBER) { |
928 return 1; | 928 return 1; |
929 } | 929 } |
930 CPDF_Dictionary *pDict = pObj->GetDict(); | 930 CPDF_Dictionary *pDict = pObj->GetDict(); |
931 if (pObj->GetType() == PDFOBJ_STREAM) { | 931 if (pObj->GetType() == PDFOBJ_STREAM) { |
932 if (pDict && pDict->GetString(FX_BSTRC("Type")) == FX_BSTRC("XRef")) { | 932 if (pDict && pDict->GetStringAt("Type") == "XRef") { |
933 return 0; | 933 return 0; |
934 } | 934 } |
935 return 1; | 935 return 1; |
936 } | 936 } |
937 if (pDict) { | 937 if (pDict) { |
938 if (pDict == m_pDocument->m_pRootDict || pDict == m_pEncryptDict) { | 938 if (pDict == m_pDocument->m_pRootDict || pDict == m_pEncryptDict) { |
939 return 1; | 939 return 1; |
940 } | 940 } |
941 if (IsSignatureDict(pDict)) { | 941 if (IsSignatureDict(pDict)) { |
942 return 1; | 942 return 1; |
943 } | 943 } |
944 if (pDict->GetString(FX_BSTRC("Type")) == FX_BSTRC("Page")) { | 944 if (pDict->GetStringAt("Type") == "Page") { |
945 return 1; | 945 return 1; |
946 } | 946 } |
947 } | 947 } |
948 m_pXRefStream->AddObjectNumberToIndexArray(objnum); | 948 m_pXRefStream->AddObjectNumberToIndexArray(objnum); |
949 if (m_pXRefStream->CompressIndirectObject(objnum, pObj, this) < 0) { | 949 if (m_pXRefStream->CompressIndirectObject(objnum, pObj, this) < 0) { |
950 return -1; | 950 return -1; |
951 } | 951 } |
952 if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) { | 952 if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) { |
953 return 0; | 953 return 0; |
954 } | 954 } |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 } | 2054 } |
2055 FX_DWORD* 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((const uint8_t*)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->GetStringAt("Filter") == "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, (const uint8_t*)user_pa
ss, user_pass.GetLength(), flag); | 2068 handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pa
ss, user_pass.GetLength(), flag); |
2069 if (m_bNewCrypto) { | 2069 if (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; |
(...skipping 52 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 |