| 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/edit/editint.h" | 7 #include "core/fpdfapi/edit/editint.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 return -1; | 1475 return -1; |
| 1476 } | 1476 } |
| 1477 m_Offset += len; | 1477 m_Offset += len; |
| 1478 if ((len = m_File.AppendString("\r\n%\xA1\xB3\xC5\xD7\r\n")) < 0) { | 1478 if ((len = m_File.AppendString("\r\n%\xA1\xB3\xC5\xD7\r\n")) < 0) { |
| 1479 return -1; | 1479 return -1; |
| 1480 } | 1480 } |
| 1481 m_Offset += len; | 1481 m_Offset += len; |
| 1482 InitOldObjNumOffsets(); | 1482 InitOldObjNumOffsets(); |
| 1483 m_iStage = 20; | 1483 m_iStage = 20; |
| 1484 } else { | 1484 } else { |
| 1485 IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); | 1485 IFX_SeekableReadStream* pSrcFile = m_pParser->GetFileAccess(); |
| 1486 m_Offset = pSrcFile->GetSize(); | 1486 m_Offset = pSrcFile->GetSize(); |
| 1487 m_Pos = (void*)(uintptr_t)m_Offset; | 1487 m_Pos = (void*)(uintptr_t)m_Offset; |
| 1488 m_iStage = 15; | 1488 m_iStage = 15; |
| 1489 } | 1489 } |
| 1490 } | 1490 } |
| 1491 if (m_iStage == 15) { | 1491 if (m_iStage == 15) { |
| 1492 if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && m_Pos) { | 1492 if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && m_Pos) { |
| 1493 IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); | 1493 IFX_SeekableReadStream* pSrcFile = m_pParser->GetFileAccess(); |
| 1494 uint8_t buffer[4096]; | 1494 uint8_t buffer[4096]; |
| 1495 uint32_t src_size = (uint32_t)(uintptr_t)m_Pos; | 1495 uint32_t src_size = (uint32_t)(uintptr_t)m_Pos; |
| 1496 while (src_size) { | 1496 while (src_size) { |
| 1497 uint32_t block_size = src_size > 4096 ? 4096 : src_size; | 1497 uint32_t block_size = src_size > 4096 ? 4096 : src_size; |
| 1498 if (!pSrcFile->ReadBlock(buffer, m_Offset - src_size, block_size)) { | 1498 if (!pSrcFile->ReadBlock(buffer, m_Offset - src_size, block_size)) { |
| 1499 return -1; | 1499 return -1; |
| 1500 } | 1500 } |
| 1501 if (m_File.AppendBlock(buffer, block_size) < 0) { | 1501 if (m_File.AppendBlock(buffer, block_size) < 0) { |
| 1502 return -1; | 1502 return -1; |
| 1503 } | 1503 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 return m_iStage = 100; | 1900 return m_iStage = 100; |
| 1901 } | 1901 } |
| 1902 | 1902 |
| 1903 void CPDF_Creator::Clear() { | 1903 void CPDF_Creator::Clear() { |
| 1904 m_pXRefStream.reset(); | 1904 m_pXRefStream.reset(); |
| 1905 m_File.Clear(); | 1905 m_File.Clear(); |
| 1906 m_NewObjNumArray.RemoveAll(); | 1906 m_NewObjNumArray.RemoveAll(); |
| 1907 m_pIDArray.reset(); | 1907 m_pIDArray.reset(); |
| 1908 } | 1908 } |
| 1909 | 1909 |
| 1910 bool CPDF_Creator::Create(IFX_StreamWrite* pFile, uint32_t flags) { | 1910 bool CPDF_Creator::Create(IFX_WriteStream* pFile, uint32_t flags) { |
| 1911 m_File.AttachFile(pFile); | 1911 m_File.AttachFile(pFile); |
| 1912 return Create(flags); | 1912 return Create(flags); |
| 1913 } | 1913 } |
| 1914 | 1914 |
| 1915 bool CPDF_Creator::Create(uint32_t flags) { | 1915 bool CPDF_Creator::Create(uint32_t flags) { |
| 1916 m_dwFlags = flags; | 1916 m_dwFlags = flags; |
| 1917 m_iStage = 0; | 1917 m_iStage = 0; |
| 1918 m_Offset = 0; | 1918 m_Offset = 0; |
| 1919 m_dwLastObjNum = m_pDocument->GetLastObjNum(); | 1919 m_dwLastObjNum = m_pDocument->GetLastObjNum(); |
| 1920 m_ObjectOffset.Clear(); | 1920 m_ObjectOffset.Clear(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 m_pCryptoHandler = nullptr; | 2013 m_pCryptoHandler = nullptr; |
| 2014 } | 2014 } |
| 2015 void CPDF_Creator::ResetStandardSecurity() { | 2015 void CPDF_Creator::ResetStandardSecurity() { |
| 2016 if (!m_bLocalCryptoHandler) | 2016 if (!m_bLocalCryptoHandler) |
| 2017 return; | 2017 return; |
| 2018 | 2018 |
| 2019 delete m_pCryptoHandler; | 2019 delete m_pCryptoHandler; |
| 2020 m_pCryptoHandler = nullptr; | 2020 m_pCryptoHandler = nullptr; |
| 2021 m_bLocalCryptoHandler = FALSE; | 2021 m_bLocalCryptoHandler = FALSE; |
| 2022 } | 2022 } |
| OLD | NEW |