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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 else | 874 else |
875 m_IndexArray.push_back({objnum, 1}); | 875 m_IndexArray.push_back({objnum, 1}); |
876 } | 876 } |
877 | 877 |
878 CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc) | 878 CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc) |
879 : m_pDocument(pDoc), | 879 : m_pDocument(pDoc), |
880 m_pParser(pDoc->GetParser()), | 880 m_pParser(pDoc->GetParser()), |
881 m_bSecurityChanged(FALSE), | 881 m_bSecurityChanged(FALSE), |
882 m_pEncryptDict(m_pParser ? m_pParser->GetEncryptDict() : nullptr), | 882 m_pEncryptDict(m_pParser ? m_pParser->GetEncryptDict() : nullptr), |
883 m_dwEncryptObjNum(0), | 883 m_dwEncryptObjNum(0), |
| 884 m_bEncryptCloned(FALSE), |
884 m_pCryptoHandler(m_pParser ? m_pParser->GetCryptoHandler() : nullptr), | 885 m_pCryptoHandler(m_pParser ? m_pParser->GetCryptoHandler() : nullptr), |
885 m_pMetadata(nullptr), | 886 m_pMetadata(nullptr), |
| 887 m_pXRefStream(nullptr), |
886 m_ObjectStreamSize(200), | 888 m_ObjectStreamSize(200), |
887 m_dwLastObjNum(m_pDocument->GetLastObjNum()), | 889 m_dwLastObjNum(m_pDocument->GetLastObjNum()), |
888 m_Offset(0), | 890 m_Offset(0), |
889 m_iStage(-1), | 891 m_iStage(-1), |
890 m_dwFlags(0), | 892 m_dwFlags(0), |
891 m_Pos(nullptr), | 893 m_Pos(nullptr), |
892 m_XrefStart(0), | 894 m_XrefStart(0), |
893 m_pIDArray(nullptr), | 895 m_pIDArray(nullptr), |
894 m_FileVersion(0) {} | 896 m_FileVersion(0) {} |
895 | 897 |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 } | 1954 } |
1953 m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone()); | 1955 m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone()); |
1954 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { | 1956 if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { |
1955 if (m_pEncryptDict->GetStringBy("Filter") == "Standard") { | 1957 if (m_pEncryptDict->GetStringBy("Filter") == "Standard") { |
1956 CFX_ByteString user_pass = m_pParser->GetPassword(); | 1958 CFX_ByteString user_pass = m_pParser->GetPassword(); |
1957 uint32_t flag = PDF_ENCRYPT_CONTENT; | 1959 uint32_t flag = PDF_ENCRYPT_CONTENT; |
1958 | 1960 |
1959 CPDF_SecurityHandler handler; | 1961 CPDF_SecurityHandler handler; |
1960 handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(), | 1962 handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(), |
1961 user_pass.GetLength(), flag); | 1963 user_pass.GetLength(), flag); |
1962 if (m_bLocalCryptoHandler) | 1964 delete m_pCryptoHandler; |
1963 delete m_pCryptoHandler; | |
1964 m_pCryptoHandler = new CPDF_CryptoHandler; | 1965 m_pCryptoHandler = new CPDF_CryptoHandler; |
1965 m_pCryptoHandler->Init(m_pEncryptDict, &handler); | 1966 m_pCryptoHandler->Init(m_pEncryptDict, &handler); |
1966 m_bLocalCryptoHandler = TRUE; | |
1967 m_bSecurityChanged = TRUE; | 1967 m_bSecurityChanged = TRUE; |
1968 } | 1968 } |
1969 } | 1969 } |
1970 } | 1970 } |
1971 int32_t CPDF_Creator::Continue(IFX_Pause* pPause) { | 1971 int32_t CPDF_Creator::Continue(IFX_Pause* pPause) { |
1972 if (m_iStage < 0) { | 1972 if (m_iStage < 0) { |
1973 return m_iStage; | 1973 return m_iStage; |
1974 } | 1974 } |
1975 int32_t iRet = 0; | 1975 int32_t iRet = 0; |
1976 while (m_iStage < 100) { | 1976 while (m_iStage < 100) { |
(...skipping 24 matching lines...) Expand all Loading... |
2001 m_FileVersion = fileVersion; | 2001 m_FileVersion = fileVersion; |
2002 return TRUE; | 2002 return TRUE; |
2003 } | 2003 } |
2004 void CPDF_Creator::RemoveSecurity() { | 2004 void CPDF_Creator::RemoveSecurity() { |
2005 ResetStandardSecurity(); | 2005 ResetStandardSecurity(); |
2006 m_bSecurityChanged = TRUE; | 2006 m_bSecurityChanged = TRUE; |
2007 m_pEncryptDict = nullptr; | 2007 m_pEncryptDict = nullptr; |
2008 m_pCryptoHandler = nullptr; | 2008 m_pCryptoHandler = nullptr; |
2009 } | 2009 } |
2010 void CPDF_Creator::ResetStandardSecurity() { | 2010 void CPDF_Creator::ResetStandardSecurity() { |
2011 if (!m_bLocalCryptoHandler) | |
2012 return; | |
2013 | |
2014 delete m_pCryptoHandler; | 2011 delete m_pCryptoHandler; |
2015 m_pCryptoHandler = nullptr; | 2012 m_pCryptoHandler = nullptr; |
2016 m_bLocalCryptoHandler = FALSE; | |
2017 } | 2013 } |
OLD | NEW |