| 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 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1960         return -1; | 1960         return -1; | 
| 1961     } | 1961     } | 
| 1962     if (m_File.AppendString(FX_BSTRC("\r\n%%EOF\r\n")) < 0) { | 1962     if (m_File.AppendString(FX_BSTRC("\r\n%%EOF\r\n")) < 0) { | 
| 1963         return -1; | 1963         return -1; | 
| 1964     } | 1964     } | 
| 1965     m_File.Flush(); | 1965     m_File.Flush(); | 
| 1966     return m_iStage = 100; | 1966     return m_iStage = 100; | 
| 1967 } | 1967 } | 
| 1968 void CPDF_Creator::Clear() | 1968 void CPDF_Creator::Clear() | 
| 1969 { | 1969 { | 
| 1970     if (m_pXRefStream) { | 1970     delete m_pXRefStream; | 
| 1971         delete m_pXRefStream; | 1971     m_pXRefStream = NULL; | 
| 1972         m_pXRefStream = NULL; |  | 
| 1973     } |  | 
| 1974     m_File.Clear(); | 1972     m_File.Clear(); | 
| 1975     m_NewObjNumArray.RemoveAll(); | 1973     m_NewObjNumArray.RemoveAll(); | 
| 1976     if (m_pIDArray) { | 1974     if (m_pIDArray) { | 
| 1977         m_pIDArray->Release(); | 1975         m_pIDArray->Release(); | 
| 1978         m_pIDArray = NULL; | 1976         m_pIDArray = NULL; | 
| 1979     } | 1977     } | 
| 1980 } | 1978 } | 
| 1981 FX_BOOL CPDF_Creator::Create(const FX_CHAR* filename, FX_DWORD flags) | 1979 FX_BOOL CPDF_Creator::Create(const FX_CHAR* filename, FX_DWORD flags) | 
| 1982 { | 1980 { | 
| 1983     if (!m_File.AttachFile(filename)) { | 1981     if (!m_File.AttachFile(filename)) { | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2061         FX_Free(pBuffer); | 2059         FX_Free(pBuffer); | 
| 2062         return; | 2060         return; | 
| 2063     } | 2061     } | 
| 2064     m_pIDArray->Add(m_pIDArray->GetElement(0)->Clone()); | 2062     m_pIDArray->Add(m_pIDArray->GetElement(0)->Clone()); | 
| 2065     if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { | 2063     if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { | 
| 2066         if (m_pEncryptDict->GetString(FX_BSTRC("Filter")) == FX_BSTRC("Standard"
      )) { | 2064         if (m_pEncryptDict->GetString(FX_BSTRC("Filter")) == FX_BSTRC("Standard"
      )) { | 
| 2067             CPDF_StandardSecurityHandler handler; | 2065             CPDF_StandardSecurityHandler handler; | 
| 2068             CFX_ByteString user_pass = m_pParser->GetPassword(); | 2066             CFX_ByteString user_pass = m_pParser->GetPassword(); | 
| 2069             FX_DWORD flag = PDF_ENCRYPT_CONTENT; | 2067             FX_DWORD flag = PDF_ENCRYPT_CONTENT; | 
| 2070             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); | 
| 2071             if (m_pCryptoHandler && m_bNewCrypto) { | 2069             if (m_bNewCrypto) { | 
| 2072                 delete m_pCryptoHandler; | 2070                 delete m_pCryptoHandler; | 
| 2073             } | 2071             } | 
| 2074             m_pCryptoHandler = new CPDF_StandardCryptoHandler; | 2072             m_pCryptoHandler = new CPDF_StandardCryptoHandler; | 
| 2075             m_pCryptoHandler->Init(m_pEncryptDict, &handler); | 2073             m_pCryptoHandler->Init(m_pEncryptDict, &handler); | 
| 2076             m_bNewCrypto = TRUE; | 2074             m_bNewCrypto = TRUE; | 
| 2077             m_bSecurityChanged = TRUE; | 2075             m_bSecurityChanged = TRUE; | 
| 2078         } | 2076         } | 
| 2079     } | 2077     } | 
| 2080 } | 2078 } | 
| 2081 int32_t CPDF_Creator::Continue(IFX_Pause *pPause) | 2079 int32_t CPDF_Creator::Continue(IFX_Pause *pPause) | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2115 } | 2113 } | 
| 2116 void CPDF_Creator::RemoveSecurity() | 2114 void CPDF_Creator::RemoveSecurity() | 
| 2117 { | 2115 { | 
| 2118     ResetStandardSecurity(); | 2116     ResetStandardSecurity(); | 
| 2119     m_bSecurityChanged = TRUE; | 2117     m_bSecurityChanged = TRUE; | 
| 2120     m_pEncryptDict = NULL; | 2118     m_pEncryptDict = NULL; | 
| 2121     m_pCryptoHandler = NULL; | 2119     m_pCryptoHandler = NULL; | 
| 2122 } | 2120 } | 
| 2123 void CPDF_Creator::ResetStandardSecurity() | 2121 void CPDF_Creator::ResetStandardSecurity() | 
| 2124 { | 2122 { | 
| 2125     if ((m_bStandardSecurity || m_bNewCrypto) && m_pCryptoHandler) { | 2123     if (m_bStandardSecurity || m_bNewCrypto) { | 
| 2126         delete m_pCryptoHandler; | 2124         delete m_pCryptoHandler; | 
| 2127         m_pCryptoHandler = NULL; | 2125         m_pCryptoHandler = NULL; | 
| 2128     } | 2126     } | 
| 2129     m_bNewCrypto = FALSE; | 2127     m_bNewCrypto = FALSE; | 
| 2130     if (!m_bStandardSecurity) { | 2128     if (!m_bStandardSecurity) { | 
| 2131         return; | 2129         return; | 
| 2132     } | 2130     } | 
| 2133     if (m_pEncryptDict) { | 2131     if (m_pEncryptDict) { | 
| 2134         m_pEncryptDict->Release(); | 2132         m_pEncryptDict->Release(); | 
| 2135         m_pEncryptDict = NULL; | 2133         m_pEncryptDict = NULL; | 
| 2136     } | 2134     } | 
| 2137     m_bStandardSecurity = FALSE; | 2135     m_bStandardSecurity = FALSE; | 
| 2138 } | 2136 } | 
| OLD | NEW | 
|---|