From 18ae06d9ae493276b3ddcd37eb19de7aeba1a0e8 Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Tue, 18 Jul 2017 10:15:16 -0400 Subject: Basic APIs and tests for extracting attachments 1. Added API for extracting attachment properties and data. * Expanded the embedder test to cover all the new APIs. Bug=pdfium:174 Change-Id: I09bffd412410e9aea45faca442d2b72eefafef4e Reviewed-on: https://pdfium-review.googlesource.com/7790 Reviewed-by: dsinclair Commit-Queue: dsinclair --- core/fpdfapi/page/cpdf_streamparser.cpp | 35 ++++++++++++++------------------- core/fpdfapi/page/cpdf_streamparser.h | 9 +++++++++ 2 files changed, 24 insertions(+), 20 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index 37ab857816..964d600b3d 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -60,14 +60,17 @@ uint32_t DecodeAllScanlines(std::unique_ptr pDecoder, return pDecoder->GetSrcOffset(); } -uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, - uint32_t limit, - int width, - int height, - const CFX_ByteString& decoder, - CPDF_Dictionary* pParam, - uint8_t** dest_buf, - uint32_t* dest_size) { +} // namespace + +// Static +uint32_t CPDF_StreamParser::DecodeInlineStream(const uint8_t* src_buf, + uint32_t limit, + int width, + int height, + const CFX_ByteString& decoder, + CPDF_Dictionary* pParam, + uint8_t** dest_buf, + uint32_t* dest_size) { if (decoder == "CCITTFaxDecode" || decoder == "CCF") { std::unique_ptr pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); @@ -99,22 +102,14 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, return 0xFFFFFFFF; } -} // namespace - CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize) - : m_pBuf(pData), - m_Size(dwSize), - m_Pos(0), - m_pPool(nullptr) {} + : m_pBuf(pData), m_Size(dwSize), m_Pos(0), m_pPool(nullptr) {} CPDF_StreamParser::CPDF_StreamParser( const uint8_t* pData, uint32_t dwSize, const CFX_WeakPtr& pPool) - : m_pBuf(pData), - m_Size(dwSize), - m_Pos(0), - m_pPool(pPool) {} + : m_pBuf(pData), m_Size(dwSize), m_Pos(0), m_pPool(pPool) {} CPDF_StreamParser::~CPDF_StreamParser() {} @@ -193,8 +188,8 @@ std::unique_ptr CPDF_StreamParser::ReadInlineStream( uint8_t* pIgnore = nullptr; uint32_t dwDestSize = OrigSize; dwStreamSize = - PDF_DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height, - Decoder, pParam, &pIgnore, &dwDestSize); + DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height, + Decoder, pParam, &pIgnore, &dwDestSize); FX_Free(pIgnore); if (static_cast(dwStreamSize) < 0) return nullptr; diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h index fdc418c634..9f9a8eaf12 100644 --- a/core/fpdfapi/page/cpdf_streamparser.h +++ b/core/fpdfapi/page/cpdf_streamparser.h @@ -21,6 +21,15 @@ class CPDF_StreamParser { public: enum SyntaxType { EndOfData, Number, Keyword, Name, Others }; + static uint32_t DecodeInlineStream(const uint8_t* src_buf, + uint32_t limit, + int width, + int height, + const CFX_ByteString& decoder, + CPDF_Dictionary* pParam, + uint8_t** dest_buf, + uint32_t* dest_size); + CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize); CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize, -- cgit v1.2.3