diff options
Diffstat (limited to 'core')
35 files changed, 131 insertions, 117 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h index 5de3793eb5..8b0efdd309 100644 --- a/core/fpdfapi/edit/cpdf_creator.h +++ b/core/fpdfapi/edit/cpdf_creator.h @@ -32,7 +32,7 @@ class CPDF_Creator { ~CPDF_Creator(); void RemoveSecurity(); - bool Create(IFX_StreamWrite* pFile, uint32_t flags = 0); + bool Create(IFX_WriteStream* pFile, uint32_t flags = 0); int32_t Continue(IFX_Pause* pPause = nullptr); FX_BOOL SetFileVersion(int32_t fileVersion = 17); diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp index e5b1fe1bb0..b4e1157d9e 100644 --- a/core/fpdfapi/edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/edit/fpdf_edit_create.cpp @@ -1482,7 +1482,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) { InitOldObjNumOffsets(); m_iStage = 20; } else { - IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); + IFX_SeekableReadStream* pSrcFile = m_pParser->GetFileAccess(); m_Offset = pSrcFile->GetSize(); m_Pos = (void*)(uintptr_t)m_Offset; m_iStage = 15; @@ -1490,7 +1490,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) { } if (m_iStage == 15) { if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && m_Pos) { - IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); + IFX_SeekableReadStream* pSrcFile = m_pParser->GetFileAccess(); uint8_t buffer[4096]; uint32_t src_size = (uint32_t)(uintptr_t)m_Pos; while (src_size) { @@ -1907,7 +1907,7 @@ void CPDF_Creator::Clear() { m_pIDArray.reset(); } -bool CPDF_Creator::Create(IFX_StreamWrite* pFile, uint32_t flags) { +bool CPDF_Creator::Create(IFX_WriteStream* pFile, uint32_t flags) { m_File.AttachFile(pFile); return Create(flags); } diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index 50768c5058..b40bc3ca8e 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -123,7 +123,7 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) { return pDict; } -void CPDF_Image::SetJpegImage(IFX_FileRead* pFile) { +void CPDF_Image::SetJpegImage(IFX_SeekableReadStream* pFile) { uint32_t size = (uint32_t)pFile->GetSize(); if (!size) return; diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h index 72de0d8cef..1e6f70fa33 100644 --- a/core/fpdfapi/page/cpdf_image.h +++ b/core/fpdfapi/page/cpdf_image.h @@ -16,14 +16,14 @@ #define PDF_IMAGE_MASK_LOSSY_COMPRESS 0x0004 #define PDF_IMAGE_MASK_LOSSLESS_COMPRESS 0x0008 -class CFX_DIBitmap; class CFX_DIBSource; +class CFX_DIBitmap; class CPDF_Dictionay; class CPDF_Document; class CPDF_Page; -class IFX_FileRead; -class IFX_FileWrite; class IFX_Pause; +class IFX_SeekableReadStream; +class IFX_SeekableWriteStream; class CPDF_Image { public: @@ -56,7 +56,7 @@ class CPDF_Image { FX_BOOL bLoadMask = FALSE) const; void SetImage(const CFX_DIBitmap* pDIBitmap, int32_t iCompress); - void SetJpegImage(IFX_FileRead* pFile); + void SetJpegImage(IFX_SeekableReadStream* pFile); void ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pDIBitmap); diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp index a1518dfed0..3bafdda9f2 100644 --- a/core/fpdfapi/parser/cfdf_document.cpp +++ b/core/fpdfapi/parser/cfdf_document.cpp @@ -33,7 +33,8 @@ CFDF_Document* CFDF_Document::CreateNewDoc() { return pDoc; } -CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead* pFile, FX_BOOL bOwnFile) { +CFDF_Document* CFDF_Document::ParseFile(IFX_SeekableReadStream* pFile, + FX_BOOL bOwnFile) { if (!pFile) return nullptr; @@ -47,7 +48,8 @@ CFDF_Document* CFDF_Document::ParseMemory(const uint8_t* pData, uint32_t size) { TRUE); } -void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) { +void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, + FX_BOOL bOwnFile) { m_pFile = pFile; m_bOwnFile = bOwnFile; CPDF_SyntaxParser parser; diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h index 21ac62d11c..32d0aab422 100644 --- a/core/fpdfapi/parser/cfdf_document.h +++ b/core/fpdfapi/parser/cfdf_document.h @@ -18,7 +18,7 @@ class CPDF_Dictionary; class CFDF_Document : public CPDF_IndirectObjectHolder { public: static CFDF_Document* CreateNewDoc(); - static CFDF_Document* ParseFile(IFX_FileRead* pFile, + static CFDF_Document* ParseFile(IFX_SeekableReadStream* pFile, FX_BOOL bOwnFile = FALSE); static CFDF_Document* ParseMemory(const uint8_t* pData, uint32_t size); ~CFDF_Document() override; @@ -31,10 +31,10 @@ class CFDF_Document : public CPDF_IndirectObjectHolder { protected: CFDF_Document(); - void ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile); + void ParseStream(IFX_SeekableReadStream* pFile, FX_BOOL bOwnFile); CPDF_Dictionary* m_pRootDict; - IFX_FileRead* m_pFile; + IFX_SeekableReadStream* m_pFile; FX_BOOL m_bOwnFile; CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool; }; diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index e23aa8ecfb..c6a434be5d 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -32,7 +32,7 @@ CPDF_DataAvail::DownloadHints::~DownloadHints() {} int CPDF_DataAvail::s_CurrentDataAvailRecursionDepth = 0; CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail, - IFX_FileRead* pFileRead, + IFX_SeekableReadStream* pFileRead, FX_BOOL bSupportHintTable) : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) { m_Pos = 0; diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index fe5c481af2..138fe1e3d8 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -93,7 +93,7 @@ class CPDF_DataAvail final { }; CPDF_DataAvail(FileAvail* pFileAvail, - IFX_FileRead* pFileRead, + IFX_SeekableReadStream* pFileRead, FX_BOOL bSupportHintTable); ~CPDF_DataAvail(); @@ -104,7 +104,7 @@ class CPDF_DataAvail final { DocLinearizationStatus IsLinearizedPDF(); FX_BOOL IsLinearized(); void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, uint32_t* pSize); - IFX_FileRead* GetFileRead() const { return m_pFileRead; } + IFX_SeekableReadStream* GetFileRead() const { return m_pFileRead; } int GetPageCount() const; CPDF_Dictionary* GetPage(int index); @@ -193,7 +193,7 @@ class CPDF_DataAvail final { FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size, DownloadHints* pHints); FileAvail* const m_pFileAvail; - IFX_FileRead* const m_pFileRead; + IFX_SeekableReadStream* const m_pFileRead; CPDF_Parser m_parser; CPDF_SyntaxParser m_syntaxParser; CPDF_Object* m_pRoot; diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index c29ae18da2..c2748882cf 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -119,7 +119,7 @@ CPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() { return m_pSyntax->m_pCryptoHandler.get(); } -IFX_FileRead* CPDF_Parser::GetFileAccess() const { +IFX_SeekableReadStream* CPDF_Parser::GetFileAccess() const { return m_pSyntax->m_pFileAccess; } @@ -139,7 +139,7 @@ void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) { m_ObjectInfo[objnum - 1].pos = 0; } -CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, +CPDF_Parser::Error CPDF_Parser::StartParse(IFX_SeekableReadStream* pFileAccess, CPDF_Document* pDocument) { ASSERT(!m_bHasParsed); m_bHasParsed = true; @@ -1438,7 +1438,7 @@ uint32_t CPDF_Parser::GetPermissions() const { return dwPermission; } -FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, +FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess, uint32_t offset) { m_pSyntax->InitParser(pFileAccess, offset); m_pSyntax->RestorePos(m_pSyntax->m_HeaderOffset + 9); @@ -1491,8 +1491,9 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, return FALSE; } -CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(IFX_FileRead* pFileAccess, - CPDF_Document* pDocument) { +CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( + IFX_SeekableReadStream* pFileAccess, + CPDF_Document* pDocument) { ASSERT(!m_bHasParsed); m_bXRefStream = FALSE; diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h index 83b591f3b2..887857628a 100644 --- a/core/fpdfapi/parser/cpdf_parser.h +++ b/core/fpdfapi/parser/cpdf_parser.h @@ -23,7 +23,7 @@ class CPDF_Object; class CPDF_SecurityHandler; class CPDF_StreamAcc; class CPDF_SyntaxParser; -class IFX_FileRead; +class IFX_SeekableReadStream; class CPDF_Parser { public: @@ -42,8 +42,9 @@ class CPDF_Parser { CPDF_Parser(); ~CPDF_Parser(); - Error StartParse(IFX_FileRead* pFile, CPDF_Document* pDocument); - Error StartLinearizedParse(IFX_FileRead* pFile, CPDF_Document* pDocument); + Error StartParse(IFX_SeekableReadStream* pFile, CPDF_Document* pDocument); + Error StartLinearizedParse(IFX_SeekableReadStream* pFile, + CPDF_Document* pDocument); void SetPassword(const FX_CHAR* password) { m_Password = password; } CFX_ByteString GetPassword() { return m_Password; } @@ -68,7 +69,7 @@ class CPDF_Parser { bool IsVersionUpdated() const { return m_bVersionUpdated; } bool IsObjectFreeOrNull(uint32_t objnum) const; CPDF_CryptoHandler* GetCryptoHandler(); - IFX_FileRead* GetFileAccess() const; + IFX_SeekableReadStream* GetFileAccess() const; FX_FILESIZE GetObjectOffset(uint32_t objnum) const; FX_FILESIZE GetObjectSize(uint32_t objnum) const; @@ -136,7 +137,8 @@ class CPDF_Parser { FX_BOOL LoadLinearizedAllCrossRefV5(FX_FILESIZE pos); Error LoadLinearizedMainXRefTable(); CPDF_StreamAcc* GetObjectStream(uint32_t number); - FX_BOOL IsLinearizedFile(IFX_FileRead* pFileAccess, uint32_t offset); + FX_BOOL IsLinearizedFile(IFX_SeekableReadStream* pFileAccess, + uint32_t offset); void SetEncryptDictionary(CPDF_Dictionary* pDict); void ShrinkObjectMap(uint32_t size); // A simple check whether the cross reference table matches with diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp index c97b88e6d1..6c6fb213f4 100644 --- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp @@ -13,7 +13,7 @@ #include "testing/utils/path_service.h" // Provide a way to read test data from a buffer instead of a file. -class CFX_TestBufferRead : public IFX_FileRead { +class CFX_TestBufferRead : public IFX_SeekableReadStream { public: CFX_TestBufferRead(const unsigned char* buffer_in, size_t buf_size) : buffer_(buffer_in), total_size_(buf_size) {} @@ -21,7 +21,7 @@ class CFX_TestBufferRead : public IFX_FileRead { // IFX_Stream void Release() override { delete this; } - // IFX_FileRead + // IFX_SeekableReadStream FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { if (offset < 0 || offset + size > total_size_) { return FALSE; @@ -45,7 +45,7 @@ class CPDF_TestParser : public CPDF_Parser { // Setup reading from a file and initial states. bool InitTestFromFile(const FX_CHAR* path) { - IFX_FileRead* pFileAccess = FX_CreateFileRead(path); + IFX_SeekableReadStream* pFileAccess = FX_CreateFileRead(path); if (!pFileAccess) return false; diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp index 935c80c5c8..93899db24e 100644 --- a/core/fpdfapi/parser/cpdf_stream.cpp +++ b/core/fpdfapi/parser/cpdf_stream.cpp @@ -57,7 +57,7 @@ void CPDF_Stream::InitStream(const uint8_t* pData, m_pDict->SetIntegerFor("Length", m_dwSize); } -void CPDF_Stream::InitStreamFromFile(IFX_FileRead* pFile, +void CPDF_Stream::InitStreamFromFile(IFX_SeekableReadStream* pFile, CPDF_Dictionary* pDict) { m_pDict.reset(pDict); m_bMemoryBased = false; diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h index 756eccfba1..588714eadc 100644 --- a/core/fpdfapi/parser/cpdf_stream.h +++ b/core/fpdfapi/parser/cpdf_stream.h @@ -37,7 +37,8 @@ class CPDF_Stream : public CPDF_Object { void SetData(const uint8_t* pData, uint32_t size); void InitStream(const uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict); - void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict); + void InitStreamFromFile(IFX_SeekableReadStream* pFile, + CPDF_Dictionary* pDict); FX_BOOL ReadRawData(FX_FILESIZE start_pos, uint8_t* pBuf, @@ -55,7 +56,7 @@ class CPDF_Stream : public CPDF_Object { bool m_bMemoryBased = true; uint32_t m_dwSize = 0; std::unique_ptr<uint8_t, FxFreeDeleter> m_pDataBuf; - IFX_FileRead* m_pFile = nullptr; + IFX_SeekableReadStream* m_pFile = nullptr; }; using UniqueStream = std::unique_ptr<CPDF_Stream, ReleaseDeleter<CPDF_Object>>; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index e7f25d15c2..3b1df94503 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -782,7 +782,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, return pStream; } -void CPDF_SyntaxParser::InitParser(IFX_FileRead* pFileAccess, +void CPDF_SyntaxParser::InitParser(IFX_SeekableReadStream* pFileAccess, uint32_t HeaderOffset) { FX_Free(m_pFileBuf); diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h index 444a94bde1..5694d233e1 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/parser/cpdf_syntax_parser.h @@ -18,7 +18,7 @@ class CPDF_Dictionary; class CPDF_IndirectObjectHolder; class CPDF_Object; class CPDF_Stream; -class IFX_FileRead; +class IFX_SeekableReadStream; class CPDF_SyntaxParser { public: @@ -26,7 +26,7 @@ class CPDF_SyntaxParser { explicit CPDF_SyntaxParser(const CFX_WeakPtr<CFX_ByteStringPool>& pPool); ~CPDF_SyntaxParser(); - void InitParser(IFX_FileRead* pFileAccess, uint32_t HeaderOffset); + void InitParser(IFX_SeekableReadStream* pFileAccess, uint32_t HeaderOffset); FX_FILESIZE SavePos() const { return m_Pos; } void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } @@ -86,7 +86,7 @@ class CPDF_SyntaxParser { FX_FILESIZE m_Pos; int m_MetadataObjnum; - IFX_FileRead* m_pFileAccess; + IFX_SeekableReadStream* m_pFileAccess; FX_FILESIZE m_HeaderOffset; FX_FILESIZE m_FileLen; uint8_t* m_pFileBuf; diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp index 7b9ead4005..8fdef1eb11 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp @@ -68,7 +68,7 @@ const char PDF_CharType[256] = { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W'}; -int32_t GetHeaderOffset(IFX_FileRead* pFile) { +int32_t GetHeaderOffset(IFX_SeekableReadStream* pFile) { const size_t kBufSize = 4; uint8_t buf[kBufSize]; for (int32_t offset = 0; offset <= 1024; ++offset) { diff --git a/core/fpdfapi/parser/fpdf_parser_utility.h b/core/fpdfapi/parser/fpdf_parser_utility.h index 4c0187ed4a..589171f1a4 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.h +++ b/core/fpdfapi/parser/fpdf_parser_utility.h @@ -10,7 +10,7 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" -class IFX_FileRead; +class IFX_SeekableReadStream; class CPDF_Dictionary; // Use the accessors below instead of directly accessing PDF_CharType. @@ -33,7 +33,7 @@ inline bool PDFCharIsLineEnding(uint8_t c) { return c == '\r' || c == '\n'; } -int32_t GetHeaderOffset(IFX_FileRead* pFile); +int32_t GetHeaderOffset(IFX_SeekableReadStream* pFile); int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key); #endif // CORE_FPDFAPI_PARSER_FPDF_PARSER_UTILITY_H_ diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index 73fec6457e..b760c2ec1c 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -21,7 +21,7 @@ class CCodec_ModuleMgr; class CCodec_PngContext; class CCodec_TiffContext; class CFX_DIBAttribute; -class IFX_FileRead; +class IFX_SeekableReadStream; class IFX_Pause; struct FXBMP_Context; struct FXGIF_Context; @@ -45,7 +45,7 @@ class CCodec_ProgressiveDecoder { explicit CCodec_ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr); ~CCodec_ProgressiveDecoder(); - FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile, + FXCODEC_STATUS LoadImageInfo(IFX_SeekableReadStream* pFile, FXCODEC_IMAGE_TYPE imageType, CFX_DIBAttribute* pAttribute, bool bSkipImageTypeCheck); @@ -125,7 +125,7 @@ class CCodec_ProgressiveDecoder { std::vector<uint8_t> m_pWeightTables; }; - IFX_FileRead* m_pFile; + IFX_SeekableReadStream* m_pFile; CCodec_ModuleMgr* m_pCodecMgr; FXJPEG_Context* m_pJpegContext; FXPNG_Context* m_pPngContext; diff --git a/core/fxcodec/codec/ccodec_tiffmodule.h b/core/fxcodec/codec/ccodec_tiffmodule.h index c6525f32e2..37d40821a6 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.h +++ b/core/fxcodec/codec/ccodec_tiffmodule.h @@ -12,13 +12,13 @@ class CCodec_TiffContext; class CFX_DIBAttribute; class CFX_DIBitmap; -class IFX_FileRead; +class IFX_SeekableReadStream; class CCodec_TiffModule { public: ~CCodec_TiffModule() {} - CCodec_TiffContext* CreateDecoder(IFX_FileRead* file_ptr); + CCodec_TiffContext* CreateDecoder(IFX_SeekableReadStream* file_ptr); bool LoadFrameInfo(CCodec_TiffContext* ctx, int32_t frame, diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 605e1b573f..4de62baad2 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -1296,7 +1296,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( - IFX_FileRead* pFile, + IFX_SeekableReadStream* pFile, FXCODEC_IMAGE_TYPE imageType, CFX_DIBAttribute* pAttribute, bool bSkipImageTypeCheck) { diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp index f4fa01aabc..c76a604e4d 100644 --- a/core/fxcodec/codec/fx_codec_tiff.cpp +++ b/core/fxcodec/codec/fx_codec_tiff.cpp @@ -17,7 +17,7 @@ class CCodec_TiffContext { CCodec_TiffContext(); ~CCodec_TiffContext(); - bool InitDecoder(IFX_FileRead* file_ptr); + bool InitDecoder(IFX_SeekableReadStream* file_ptr); bool LoadFrameInfo(int32_t frame, int32_t* width, int32_t* height, @@ -26,7 +26,7 @@ class CCodec_TiffContext { CFX_DIBAttribute* pAttribute); bool Decode(CFX_DIBitmap* pDIBitmap); - IFX_FileRead* io_in() const { return m_io_in; } + IFX_SeekableReadStream* io_in() const { return m_io_in; } uint32_t offset() const { return m_offset; } void set_offset(uint32_t offset) { m_offset = offset; } void increment_offset(uint32_t offset) { m_offset += offset; } @@ -50,7 +50,7 @@ class CCodec_TiffContext { uint16_t bps, uint16_t spp); - IFX_FileRead* m_io_in; + IFX_SeekableReadStream* m_io_in; uint32_t m_offset; TIFF* m_tif_ctx; }; @@ -193,7 +193,7 @@ CCodec_TiffContext::~CCodec_TiffContext() { TIFFClose(m_tif_ctx); } -bool CCodec_TiffContext::InitDecoder(IFX_FileRead* file_ptr) { +bool CCodec_TiffContext::InitDecoder(IFX_SeekableReadStream* file_ptr) { m_io_in = file_ptr; m_tif_ctx = tiff_open(this, "r"); return !!m_tif_ctx; @@ -435,7 +435,8 @@ bool CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap) { return false; } -CCodec_TiffContext* CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr) { +CCodec_TiffContext* CCodec_TiffModule::CreateDecoder( + IFX_SeekableReadStream* file_ptr) { CCodec_TiffContext* pDecoder = new CCodec_TiffContext; if (!pDecoder->InitDecoder(file_ptr)) { delete pDecoder; diff --git a/core/fxcrt/extension.h b/core/fxcrt/extension.h index 6a437db574..45f6d4f2f0 100644 --- a/core/fxcrt/extension.h +++ b/core/fxcrt/extension.h @@ -44,7 +44,7 @@ class CFX_CRTFileAccess : public IFX_FileAccess { void Release() override; IFX_FileAccess* Retain() override; void GetPath(CFX_WideString& wsPath) override; - IFX_FileStream* CreateFileStream(uint32_t dwModes) override; + IFX_SeekableStream* CreateFileStream(uint32_t dwModes) override; FX_BOOL Init(const CFX_WideStringC& wsPath); @@ -54,13 +54,13 @@ class CFX_CRTFileAccess : public IFX_FileAccess { }; #endif // PDF_ENABLE_XFA -class CFX_CRTFileStream final : public IFX_FileStream { +class CFX_CRTFileStream final : public IFX_SeekableStream { public: explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA); ~CFX_CRTFileStream() override; - // IFX_FileStream: - IFX_FileStream* Retain() override; + // IFX_SeekableStream: + IFX_SeekableStream* Retain() override; void Release() override; FX_FILESIZE GetSize() override; FX_BOOL IsEOF() override; @@ -87,7 +87,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { ~CFX_MemoryStream() override; // IFX_MemoryStream - IFX_FileStream* Retain() override; + IFX_SeekableStream* Retain() override; void Release() override; FX_FILESIZE GetSize() override; FX_BOOL IsEOF() override; diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h index 4cf69f896b..6643d33dce 100644 --- a/core/fxcrt/fx_basic.h +++ b/core/fxcrt/fx_basic.h @@ -121,14 +121,14 @@ class CFX_FileBufferArchive { int32_t AppendString(const CFX_ByteStringC& lpsz); // |pFile| must outlive the CFX_FileBufferArchive. - void AttachFile(IFX_StreamWrite* pFile); + void AttachFile(IFX_WriteStream* pFile); private: static const size_t kBufSize = 32768; size_t m_Length; std::unique_ptr<uint8_t, FxFreeDeleter> m_pBuffer; - IFX_StreamWrite* m_pFile; + IFX_WriteStream* m_pFile; }; class CFX_CharMap { diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index d441f6c0e9..e954224d8a 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -285,7 +285,7 @@ int32_t CFX_FileBufferArchive::AppendString(const CFX_ByteStringC& lpsz) { return AppendBlock(lpsz.raw_str(), lpsz.GetLength()); } -void CFX_FileBufferArchive::AttachFile(IFX_StreamWrite* pFile) { +void CFX_FileBufferArchive::AttachFile(IFX_WriteStream* pFile) { ASSERT(pFile); m_pFile = pFile; } diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h index 959a26bf44..cca80b1142 100644 --- a/core/fxcrt/fx_ext.h +++ b/core/fxcrt/fx_ext.h @@ -18,7 +18,7 @@ // Come up or wait for something better. This appears in this file rather // than fx_stream.h due to include ordering restrictions. using ScopedFileStream = - std::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>>; + std::unique_ptr<IFX_SeekableStream, ReleaseDeleter<IFX_SeekableStream>>; FX_FLOAT FXSYS_tan(FX_FLOAT a); FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x); diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index ca6b6d4066..5ac22bd44e 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -36,7 +36,7 @@ void CFX_CRTFileAccess::GetPath(CFX_WideString& wsPath) { wsPath = m_path; } -IFX_FileStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) { +IFX_SeekableStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) { return FX_CreateFileStream(m_path.c_str(), dwModes); } @@ -85,7 +85,7 @@ CFX_MemoryStream::~CFX_MemoryStream() { m_Blocks.RemoveAll(); } -IFX_FileStream* CFX_MemoryStream::Retain() { +IFX_SeekableStream* CFX_MemoryStream::Retain() { m_dwCount++; return this; } @@ -281,7 +281,7 @@ FX_BOOL CFX_MemoryStream::ExpandBlocks(size_t size) { return TRUE; } -IFX_FileStream* CFX_CRTFileStream::Retain() { +IFX_SeekableStream* CFX_CRTFileStream::Retain() { m_dwCount++; return this; } @@ -336,24 +336,25 @@ IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { } #endif // PDF_ENABLE_XFA -IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, uint32_t dwModes) { +IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename, + uint32_t dwModes) { std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); if (!pFA->Open(filename, dwModes)) return nullptr; return new CFX_CRTFileStream(std::move(pFA)); } -IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, - uint32_t dwModes) { +IFX_SeekableStream* FX_CreateFileStream(const FX_WCHAR* filename, + uint32_t dwModes) { std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); if (!pFA->Open(filename, dwModes)) return nullptr; return new CFX_CRTFileStream(std::move(pFA)); } -IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename) { +IFX_SeekableReadStream* FX_CreateFileRead(const FX_CHAR* filename) { return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); } -IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename) { +IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename) { return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); } IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h index 047fedf9bb..2509ec2cd7 100644 --- a/core/fxcrt/fx_stream.h +++ b/core/fxcrt/fx_stream.h @@ -55,16 +55,26 @@ FX_WCHAR FX_GetFolderSeparator(); #define FX_FILEMODE_ReadOnly 1 #define FX_FILEMODE_Truncate 2 -class IFX_StreamWrite { +class IFX_WriteStream { public: - virtual ~IFX_StreamWrite() {} + virtual ~IFX_WriteStream() {} virtual void Release() = 0; virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0; }; -class IFX_FileWrite : public IFX_StreamWrite { +class IFX_ReadStream { public: - // IFX_StreamWrite: + virtual ~IFX_ReadStream() {} + + virtual void Release() = 0; + virtual FX_BOOL IsEOF() = 0; + virtual FX_FILESIZE GetPosition() = 0; + virtual size_t ReadBlock(void* buffer, size_t size) = 0; +}; + +class IFX_SeekableWriteStream : public IFX_WriteStream { + public: + // IFX_WriteStream: FX_BOOL WriteBlock(const void* pData, size_t size) override; virtual FX_FILESIZE GetSize() = 0; virtual FX_BOOL Flush() = 0; @@ -73,19 +83,9 @@ class IFX_FileWrite : public IFX_StreamWrite { size_t size) = 0; }; -class IFX_StreamRead { - public: - virtual ~IFX_StreamRead() {} - - virtual void Release() = 0; - virtual FX_BOOL IsEOF() = 0; - virtual FX_FILESIZE GetPosition() = 0; - virtual size_t ReadBlock(void* buffer, size_t size) = 0; -}; - -class IFX_FileRead : public IFX_StreamRead { +class IFX_SeekableReadStream : public IFX_ReadStream { public: - // IFX_StreamRead: + // IFX_ReadStream: void Release() override = 0; FX_BOOL IsEOF() override; FX_FILESIZE GetPosition() override; @@ -95,14 +95,15 @@ class IFX_FileRead : public IFX_StreamRead { virtual FX_FILESIZE GetSize() = 0; }; -IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); -IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); +IFX_SeekableReadStream* FX_CreateFileRead(const FX_CHAR* filename); +IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename); -class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { +class IFX_SeekableStream : public IFX_SeekableReadStream, + public IFX_SeekableWriteStream { public: - virtual IFX_FileStream* Retain() = 0; + virtual IFX_SeekableStream* Retain() = 0; - // IFX_FileRead: + // IFX_SeekableReadStream: void Release() override = 0; FX_BOOL IsEOF() override = 0; FX_FILESIZE GetPosition() override = 0; @@ -110,7 +111,7 @@ class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override = 0; FX_FILESIZE GetSize() override = 0; - // IFX_FileWrite: + // IFX_SeekableWriteStream: FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override = 0; @@ -118,8 +119,10 @@ class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { FX_BOOL Flush() override = 0; }; -IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, uint32_t dwModes); -IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, uint32_t dwModes); +IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename, + uint32_t dwModes); +IFX_SeekableStream* FX_CreateFileStream(const FX_WCHAR* filename, + uint32_t dwModes); #ifdef PDF_ENABLE_XFA class IFX_FileAccess { @@ -128,12 +131,12 @@ class IFX_FileAccess { virtual void Release() = 0; virtual IFX_FileAccess* Retain() = 0; virtual void GetPath(CFX_WideString& wsPath) = 0; - virtual IFX_FileStream* CreateFileStream(uint32_t dwModes) = 0; + virtual IFX_SeekableStream* CreateFileStream(uint32_t dwModes) = 0; }; IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath); #endif // PDF_ENABLE_XFA -class IFX_MemoryStream : public IFX_FileStream { +class IFX_MemoryStream : public IFX_SeekableStream { public: virtual FX_BOOL IsConsecutive() const = 0; virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0; @@ -149,9 +152,9 @@ IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, FX_BOOL bTakeOver = FALSE); IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); -class IFX_BufferRead : public IFX_StreamRead { +class IFX_BufferRead : public IFX_ReadStream { public: - // IFX_StreamRead: + // IFX_ReadStream: void Release() override = 0; FX_BOOL IsEOF() override = 0; FX_FILESIZE GetPosition() override = 0; diff --git a/core/fxcrt/fx_xml.h b/core/fxcrt/fx_xml.h index 78f162597f..4ab28f66c5 100644 --- a/core/fxcrt/fx_xml.h +++ b/core/fxcrt/fx_xml.h @@ -58,7 +58,7 @@ class CXML_Element { size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = nullptr); - static CXML_Element* Parse(IFX_FileRead* pFile, + static CXML_Element* Parse(IFX_SeekableReadStream* pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = nullptr); static CXML_Element* Parse(IFX_BufferRead* pBuffer, diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index 563e1c961b..e6c3543378 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -57,7 +57,7 @@ FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() { return 0; } -CXML_DataStmAcc::CXML_DataStmAcc(IFX_FileRead* pFileRead) +CXML_DataStmAcc::CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead) : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) { ASSERT(m_pFileRead); } @@ -132,7 +132,7 @@ FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) { m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); return Init(TRUE); } -FX_BOOL CXML_Parser::Init(IFX_FileRead* pFileRead) { +FX_BOOL CXML_Parser::Init(IFX_SeekableReadStream* pFileRead) { m_pDataAcc = new CXML_DataStmAcc(pFileRead); return Init(TRUE); } @@ -651,7 +651,7 @@ CXML_Element* CXML_Element::Parse(const void* pBuffer, } return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); } -CXML_Element* CXML_Element::Parse(IFX_FileRead* pFile, +CXML_Element* CXML_Element::Parse(IFX_SeekableReadStream* pFile, FX_BOOL bSaveSpaceChars, FX_FILESIZE* pParsedSize) { CXML_Parser parser; diff --git a/core/fxcrt/fxcrt_stream.cpp b/core/fxcrt/fxcrt_stream.cpp index a8c96bf02c..638a183177 100644 --- a/core/fxcrt/fxcrt_stream.cpp +++ b/core/fxcrt/fxcrt_stream.cpp @@ -6,22 +6,22 @@ #include "core/fxcrt/fx_stream.h" -FX_BOOL IFX_FileWrite::WriteBlock(const void* pData, size_t size) { +FX_BOOL IFX_SeekableWriteStream::WriteBlock(const void* pData, size_t size) { return WriteBlock(pData, GetSize(), size); } -FX_BOOL IFX_FileRead::IsEOF() { +FX_BOOL IFX_SeekableReadStream::IsEOF() { return FALSE; } -FX_FILESIZE IFX_FileRead::GetPosition() { +FX_FILESIZE IFX_SeekableReadStream::GetPosition() { return 0; } -size_t IFX_FileRead::ReadBlock(void* buffer, size_t size) { +size_t IFX_SeekableReadStream::ReadBlock(void* buffer, size_t size) { return 0; } -FX_BOOL IFX_FileStream::WriteBlock(const void* buffer, size_t size) { +FX_BOOL IFX_SeekableStream::WriteBlock(const void* buffer, size_t size) { return WriteBlock(buffer, GetSize(), size); } diff --git a/core/fxcrt/xml_int.h b/core/fxcrt/xml_int.h index 47997062cc..aa157c2333 100644 --- a/core/fxcrt/xml_int.h +++ b/core/fxcrt/xml_int.h @@ -37,7 +37,7 @@ class CXML_DataBufAcc : public IFX_BufferRead { class CXML_DataStmAcc : public IFX_BufferRead { public: - explicit CXML_DataStmAcc(IFX_FileRead* pFileRead); + explicit CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead); ~CXML_DataStmAcc() override; // IFX_BufferRead @@ -51,7 +51,7 @@ class CXML_DataStmAcc : public IFX_BufferRead { FX_FILESIZE GetBlockOffset() override; protected: - IFX_FileRead* m_pFileRead; + IFX_SeekableReadStream* m_pFileRead; uint8_t* m_pBuffer; FX_FILESIZE m_nStart; size_t m_dwSize; @@ -63,7 +63,7 @@ class CXML_Parser { ~CXML_Parser(); FX_BOOL Init(uint8_t* pBuffer, size_t size); - FX_BOOL Init(IFX_FileRead* pFileRead); + FX_BOOL Init(IFX_SeekableReadStream* pFileRead); FX_BOOL Init(IFX_BufferRead* pBuffer); FX_BOOL Init(FX_BOOL bOwndedStream); FX_BOOL ReadNextBlock(); diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp index 290551bedf..2deb327392 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp @@ -26,7 +26,8 @@ static unsigned long FPF_SkiaStream_Read(FXFT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count) { - IFX_FileRead* pFileRead = (IFX_FileRead*)stream->descriptor.pointer; + IFX_SeekableReadStream* pFileRead = + (IFX_SeekableReadStream*)stream->descriptor.pointer; if (!pFileRead) return 0; if (count > 0) { @@ -355,7 +356,7 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, return nullptr; } -FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead, +FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_SeekableReadStream* pFileRead, int32_t iFaceIndex) { if (!pFileRead) return nullptr; diff --git a/core/fxge/android/fpf_skiafontmgr.h b/core/fxge/android/fpf_skiafontmgr.h index bd586204c5..74e7adeb5a 100644 --- a/core/fxge/android/fpf_skiafontmgr.h +++ b/core/fxge/android/fpf_skiafontmgr.h @@ -75,7 +75,7 @@ class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { // CFPF_SkiaFontDescriptor int32_t GetType() const override { return FPF_SKIAFONTTYPE_File; } - IFX_FileRead* m_pFile; + IFX_SeekableReadStream* m_pFile; }; class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor { @@ -101,7 +101,8 @@ class CFPF_SkiaFontMgr { uint32_t dwMatch = 0); bool InitFTLibrary(); - FXFT_Face GetFontFace(IFX_FileRead* pFileRead, int32_t iFaceIndex = 0); + FXFT_Face GetFontFace(IFX_SeekableReadStream* pFileRead, + int32_t iFaceIndex = 0); FXFT_Face GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex = 0); FXFT_Face GetFontFace(const uint8_t* pBuffer, size_t szBuffer, diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h index 8dda12af50..a562795784 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -110,7 +110,7 @@ class CFX_Font { CFX_SubstFont* GetSubstFont() const { return m_pSubstFont.get(); } #ifdef PDF_ENABLE_XFA - FX_BOOL LoadFile(IFX_FileRead* pFile, + FX_BOOL LoadFile(IFX_SeekableReadStream* pFile, int nFaceIndex = 0, int* pFaceCount = nullptr); diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp index f58462479f..d1c31d0f51 100644 --- a/core/fxge/ge/cfx_font.cpp +++ b/core/fxge/ge/cfx_font.cpp @@ -39,7 +39,8 @@ unsigned long FTStreamRead(FXFT_Stream stream, if (count == 0) return 0; - IFX_FileRead* pFile = static_cast<IFX_FileRead*>(stream->descriptor.pointer); + IFX_SeekableReadStream* pFile = + static_cast<IFX_SeekableReadStream*>(stream->descriptor.pointer); return pFile->ReadBlock(buffer, offset, count) ? count : 0; } @@ -47,7 +48,7 @@ void FTStreamClose(FXFT_Stream stream) {} FX_BOOL LoadFileImp(FXFT_Library library, FXFT_Face* Face, - IFX_FileRead* pFile, + IFX_SeekableReadStream* pFile, int32_t faceIndex, std::unique_ptr<FXFT_StreamRec>* stream) { std::unique_ptr<FXFT_StreamRec> stream1(new FXFT_StreamRec()); @@ -331,7 +332,7 @@ void CFX_Font::LoadSubst(const CFX_ByteString& face_name, } #ifdef PDF_ENABLE_XFA -FX_BOOL CFX_Font::LoadFile(IFX_FileRead* pFile, +FX_BOOL CFX_Font::LoadFile(IFX_SeekableReadStream* pFile, int nFaceIndex, int* pFaceCount) { m_bEmbedded = FALSE; |