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/fpdfapi/fpdf_edit/editint.h" | 7 #include "core/fpdfapi/fpdf_edit/editint.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 FX_BOOL bNewId = !m_pIDArray; | 1933 FX_BOOL bNewId = !m_pIDArray; |
1934 if (!m_pIDArray) { | 1934 if (!m_pIDArray) { |
1935 m_pIDArray = new CPDF_Array; | 1935 m_pIDArray = new CPDF_Array; |
1936 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr; | 1936 CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr; |
1937 if (pID1) { | 1937 if (pID1) { |
1938 m_pIDArray->Add(pID1->Clone()); | 1938 m_pIDArray->Add(pID1->Clone()); |
1939 } else { | 1939 } else { |
1940 std::vector<uint8_t> buffer = | 1940 std::vector<uint8_t> buffer = |
1941 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum); | 1941 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum); |
1942 CFX_ByteString bsBuffer(buffer.data(), buffer.size()); | 1942 CFX_ByteString bsBuffer(buffer.data(), buffer.size()); |
1943 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument); | 1943 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE)); |
1944 } | 1944 } |
1945 } | 1945 } |
1946 if (!bDefault) { | 1946 if (!bDefault) { |
1947 return; | 1947 return; |
1948 } | 1948 } |
1949 if (pOldIDArray) { | 1949 if (pOldIDArray) { |
1950 CPDF_Object* pID2 = pOldIDArray->GetObjectAt(1); | 1950 CPDF_Object* pID2 = pOldIDArray->GetObjectAt(1); |
1951 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) { | 1951 if ((m_dwFlags & FPDFCREATE_INCREMENTAL) && m_pEncryptDict && pID2) { |
1952 m_pIDArray->Add(pID2->Clone()); | 1952 m_pIDArray->Add(pID2->Clone()); |
1953 return; | 1953 return; |
1954 } | 1954 } |
1955 std::vector<uint8_t> buffer = | 1955 std::vector<uint8_t> buffer = |
1956 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum); | 1956 PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum); |
1957 CFX_ByteString bsBuffer(buffer.data(), buffer.size()); | 1957 CFX_ByteString bsBuffer(buffer.data(), buffer.size()); |
1958 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument); | 1958 m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE)); |
1959 return; | 1959 return; |
1960 } | 1960 } |
1961 m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone()); | 1961 m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone()); |
1962 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { | 1962 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { |
1963 if (m_pEncryptDict->GetStringFor("Filter") == "Standard") { | 1963 if (m_pEncryptDict->GetStringFor("Filter") == "Standard") { |
1964 CFX_ByteString user_pass = m_pParser->GetPassword(); | 1964 CFX_ByteString user_pass = m_pParser->GetPassword(); |
1965 uint32_t flag = PDF_ENCRYPT_CONTENT; | 1965 uint32_t flag = PDF_ENCRYPT_CONTENT; |
1966 | 1966 |
1967 CPDF_SecurityHandler handler; | 1967 CPDF_SecurityHandler handler; |
1968 handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(), | 1968 handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 m_pCryptoHandler = nullptr; | 2016 m_pCryptoHandler = nullptr; |
2017 } | 2017 } |
2018 void CPDF_Creator::ResetStandardSecurity() { | 2018 void CPDF_Creator::ResetStandardSecurity() { |
2019 if (!m_bLocalCryptoHandler) | 2019 if (!m_bLocalCryptoHandler) |
2020 return; | 2020 return; |
2021 | 2021 |
2022 delete m_pCryptoHandler; | 2022 delete m_pCryptoHandler; |
2023 m_pCryptoHandler = nullptr; | 2023 m_pCryptoHandler = nullptr; |
2024 m_bLocalCryptoHandler = FALSE; | 2024 m_bLocalCryptoHandler = FALSE; |
2025 } | 2025 } |
OLD | NEW |