diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-03-10 09:20:03 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-03-10 09:20:03 -0800 |
commit | f04089059b140ad50ed386b509ab200ce84b66e5 (patch) | |
tree | c3fabaf7b5d82a4ec5c21db6ef8723b68c740572 /core/include/fpdfapi | |
parent | a1193aedb8797fcb26f54d7b99e4662ae72e3de9 (diff) | |
download | pdfium-f04089059b140ad50ed386b509ab200ce84b66e5.tar.xz |
Split apart the remainder of fpdf_render_render.cpp into per-class files.
R=dsinclair@chromium.org
Review URL: https://codereview.chromium.org/1778173002 .
Diffstat (limited to 'core/include/fpdfapi')
-rw-r--r-- | core/include/fpdfapi/cfdf_document.h | 36 | ||||
-rw-r--r-- | core/include/fpdfapi/cpdf_document.h | 10 | ||||
-rw-r--r-- | core/include/fpdfapi/fpdf_objects.h | 1 | ||||
-rw-r--r-- | core/include/fpdfapi/fpdf_page.h | 1 | ||||
-rw-r--r-- | core/include/fpdfapi/fpdf_parser.h | 235 | ||||
-rw-r--r-- | core/include/fpdfapi/fpdf_parser_decode.h | 76 | ||||
-rw-r--r-- | core/include/fpdfapi/fpdf_resource.h | 3 | ||||
-rw-r--r-- | core/include/fpdfapi/fpdf_serial.h | 1 | ||||
-rw-r--r-- | core/include/fpdfapi/ipdf_data_avail.h | 80 |
9 files changed, 206 insertions, 237 deletions
diff --git a/core/include/fpdfapi/cfdf_document.h b/core/include/fpdfapi/cfdf_document.h new file mode 100644 index 0000000000..6fb8ab7ba2 --- /dev/null +++ b/core/include/fpdfapi/cfdf_document.h @@ -0,0 +1,36 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_INCLUDE_FPDFAPI_CFDF_DOCUMENT_H_ +#define CORE_INCLUDE_FPDFAPI_CFDF_DOCUMENT_H_ + +#include "core/include/fpdfapi/fpdf_objects.h" +#include "core/include/fxcrt/fx_stream.h" +#include "core/include/fxcrt/fx_system.h" + +class CPDF_Dictionary; + +class CFDF_Document : public CPDF_IndirectObjectHolder { + public: + static CFDF_Document* CreateNewDoc(); + static CFDF_Document* ParseFile(IFX_FileRead* pFile, + FX_BOOL bOwnFile = FALSE); + static CFDF_Document* ParseMemory(const uint8_t* pData, FX_DWORD size); + ~CFDF_Document(); + + FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const; + CPDF_Dictionary* GetRoot() const { return m_pRootDict; } + + protected: + CFDF_Document(); + void ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile); + + CPDF_Dictionary* m_pRootDict; + IFX_FileRead* m_pFile; + FX_BOOL m_bOwnFile; +}; + +#endif // CORE_INCLUDE_FPDFAPI_CFDF_DOCUMENT_H_ diff --git a/core/include/fpdfapi/cpdf_document.h b/core/include/fpdfapi/cpdf_document.h index bba89c822c..c759861cd7 100644 --- a/core/include/fpdfapi/cpdf_document.h +++ b/core/include/fpdfapi/cpdf_document.h @@ -20,6 +20,16 @@ class CPDF_IccProfile; class CPDF_Image; class CPDF_Pattern; +#define FPDFPERM_PRINT 0x0004 +#define FPDFPERM_MODIFY 0x0008 +#define FPDFPERM_EXTRACT 0x0010 +#define FPDFPERM_ANNOT_FORM 0x0020 +#define FPDFPERM_FILL_FORM 0x0100 +#define FPDFPERM_EXTRACT_ACCESS 0x0200 +#define FPDFPERM_ASSEMBLE 0x0400 +#define FPDFPERM_PRINT_HIGH 0x0800 +#define FPDF_PAGE_MAX_NUM 0xFFFFF + class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder { public: CPDF_Document(); diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h index a6fa056e13..42282a1dcc 100644 --- a/core/include/fpdfapi/fpdf_objects.h +++ b/core/include/fpdfapi/fpdf_objects.h @@ -333,6 +333,7 @@ class CPDF_Dictionary : public CPDF_Object { } FX_BOOL KeyExist(const CFX_ByteStringC& key) const; + bool IsSignatureDict() const; // Set* functions invalidate iterators for the element with the key |key|. void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj); diff --git a/core/include/fpdfapi/fpdf_page.h b/core/include/fpdfapi/fpdf_page.h index 7c27340525..534faf2c2b 100644 --- a/core/include/fpdfapi/fpdf_page.h +++ b/core/include/fpdfapi/fpdf_page.h @@ -10,7 +10,6 @@ #include <deque> #include <memory> -#include "core/include/fpdfapi/fpdf_parser.h" #include "core/include/fpdfapi/fpdf_resource.h" #include "core/include/fxge/fx_dib.h" diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h deleted file mode 100644 index 9504061fcf..0000000000 --- a/core/include/fpdfapi/fpdf_parser.h +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ -#define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ - -#include <map> -#include <memory> -#include <set> - -#include "core/include/fpdfapi/fpdf_objects.h" -#include "core/include/fxcrt/fx_basic.h" - -class CFX_Font; -class CFX_Matrix; -class CPDF_ColorSpace; -class IPDF_CryptoHandler; -class CPDF_Document; -class CPDF_DocPageData; -class CPDF_DocRenderData; -class CPDF_Font; -class CPDF_FontEncoding; -class CPDF_IccProfile; -class CPDF_Image; -class CPDF_Object; -class CPDF_Parser; -class CPDF_Pattern; -class CPDF_StandardSecurityHandler; -class CPDF_SyntaxParser; -class IPDF_SecurityHandler; - -#define FPDFPERM_PRINT 0x0004 -#define FPDFPERM_MODIFY 0x0008 -#define FPDFPERM_EXTRACT 0x0010 -#define FPDFPERM_ANNOT_FORM 0x0020 -#define FPDFPERM_FILL_FORM 0x0100 -#define FPDFPERM_EXTRACT_ACCESS 0x0200 -#define FPDFPERM_ASSEMBLE 0x0400 -#define FPDFPERM_PRINT_HIGH 0x0800 -#define FPDF_PAGE_MAX_NUM 0xFFFFF - -// Indexed by 8-bit char code, contains unicode code points. -extern const FX_WORD PDFDocEncoding[256]; - - -CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig); -CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); -CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); -CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, - FX_BOOL bHex = FALSE); -CFX_WideString PDF_DecodeText(const uint8_t* pData, FX_DWORD size); -CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr); -CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1); -CFX_ByteString PDF_EncodeText(const CFX_WideString& str); - -class CFDF_Document : public CPDF_IndirectObjectHolder { - public: - static CFDF_Document* CreateNewDoc(); - static CFDF_Document* ParseFile(IFX_FileRead* pFile, - FX_BOOL bOwnFile = FALSE); - static CFDF_Document* ParseMemory(const uint8_t* pData, FX_DWORD size); - ~CFDF_Document(); - - FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const; - CPDF_Dictionary* GetRoot() const { return m_pRootDict; } - - protected: - CFDF_Document(); - void ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile); - - CPDF_Dictionary* m_pRootDict; - IFX_FileRead* m_pFile; - FX_BOOL m_bOwnFile; -}; - -void FlateEncode(const uint8_t* src_buf, - FX_DWORD src_size, - uint8_t*& dest_buf, - FX_DWORD& dest_size); -void FlateEncode(const uint8_t* src_buf, - FX_DWORD src_size, - int predictor, - int Colors, - int BitsPerComponent, - int Columns, - uint8_t*& dest_buf, - FX_DWORD& dest_size); -FX_DWORD FlateDecode(const uint8_t* src_buf, - FX_DWORD src_size, - uint8_t*& dest_buf, - FX_DWORD& dest_size); -FX_DWORD RunLengthDecode(const uint8_t* src_buf, - FX_DWORD src_size, - uint8_t*& dest_buf, - FX_DWORD& dest_size); -bool IsSignatureDict(const CPDF_Dictionary* pDict); - -class IFX_FileAvail { - public: - virtual ~IFX_FileAvail() {} - virtual FX_BOOL IsDataAvail(FX_FILESIZE offset, FX_DWORD size) = 0; -}; -class IFX_DownloadHints { - public: - virtual ~IFX_DownloadHints() {} - virtual void AddSegment(FX_FILESIZE offset, FX_DWORD size) = 0; -}; - -class IPDF_DataAvail { - public: - // Must match PDF_DATA_* definitions in public/fpdf_dataavail.h, but cannot - // #include that header. fpdfsdk/src/fpdf_dataavail.cpp has static_asserts - // to make sure the two sets of values match. - enum DocAvailStatus { - DataError = -1, // PDF_DATA_ERROR - DataNotAvailable = 0, // PDF_DATA_NOTAVAIL - DataAvailable = 1, // PDF_DATA_AVAIL - }; - - // Must match PDF_*LINEAR* definitions in public/fpdf_dataavail.h, but cannot - // #include that header. fpdfsdk/src/fpdf_dataavail.cpp has static_asserts - // to make sure the two sets of values match. - enum DocLinearizationStatus { - LinearizationUnknown = -1, // PDF_LINEARIZATION_UNKNOWN - NotLinearized = 0, // PDF_NOT_LINEARIZED - Linearized = 1, // PDF_LINEARIZED - }; - - // Must match PDF_FORM_* definitions in public/fpdf_dataavail.h, but cannot - // #include that header. fpdfsdk/src/fpdf_dataavail.cpp has static_asserts - // to make sure the two sets of values match. - enum DocFormStatus { - FormError = -1, // PDF_FORM_ERROR - FormNotAvailable = 0, // PDF_FORM_NOTAVAIL - FormAvailable = 1, // PDF_FORM_AVAIL - FormNotExist = 2, // PDF_FORM_NOTEXIST - }; - - static IPDF_DataAvail* Create(IFX_FileAvail* pFileAvail, - IFX_FileRead* pFileRead); - virtual ~IPDF_DataAvail() {} - - IFX_FileAvail* GetFileAvail() const { return m_pFileAvail; } - IFX_FileRead* GetFileRead() const { return m_pFileRead; } - - virtual DocAvailStatus IsDocAvail(IFX_DownloadHints* pHints) = 0; - virtual void SetDocument(CPDF_Document* pDoc) = 0; - virtual DocAvailStatus IsPageAvail(int iPage, IFX_DownloadHints* pHints) = 0; - virtual FX_BOOL IsLinearized() = 0; - virtual DocFormStatus IsFormAvail(IFX_DownloadHints* pHints) = 0; - virtual DocLinearizationStatus IsLinearizedPDF() = 0; - virtual void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, - FX_DWORD* pSize) = 0; - - protected: - IPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead); - - IFX_FileAvail* m_pFileAvail; - IFX_FileRead* m_pFileRead; -}; - -enum PDF_PAGENODE_TYPE { - PDF_PAGENODE_UNKNOWN = 0, - PDF_PAGENODE_PAGE, - PDF_PAGENODE_PAGES, - PDF_PAGENODE_ARRAY, -}; - -class CPDF_PageNode { - public: - CPDF_PageNode(); - ~CPDF_PageNode(); - - PDF_PAGENODE_TYPE m_type; - FX_DWORD m_dwPageNo; - CFX_ArrayTemplate<CPDF_PageNode*> m_childNode; -}; - -enum PDF_DATAAVAIL_STATUS { - PDF_DATAAVAIL_HEADER = 0, - PDF_DATAAVAIL_FIRSTPAGE, - PDF_DATAAVAIL_FIRSTPAGE_PREPARE, - PDF_DATAAVAIL_HINTTABLE, - PDF_DATAAVAIL_END, - PDF_DATAAVAIL_CROSSREF, - PDF_DATAAVAIL_CROSSREF_ITEM, - PDF_DATAAVAIL_CROSSREF_STREAM, - PDF_DATAAVAIL_TRAILER, - PDF_DATAAVAIL_LOADALLCROSSREF, - PDF_DATAAVAIL_ROOT, - PDF_DATAAVAIL_INFO, - PDF_DATAAVAIL_ACROFORM, - PDF_DATAAVAIL_ACROFORM_SUBOBJECT, - PDF_DATAAVAIL_PAGETREE, - PDF_DATAAVAIL_PAGE, - PDF_DATAAVAIL_PAGE_LATERLOAD, - PDF_DATAAVAIL_RESOURCES, - PDF_DATAAVAIL_DONE, - PDF_DATAAVAIL_ERROR, - PDF_DATAAVAIL_LOADALLFILE, - PDF_DATAAVAIL_TRAILER_APPEND -}; - -// Public for testing. -FX_DWORD A85Decode(const uint8_t* src_buf, - FX_DWORD src_size, - uint8_t*& dest_buf, - FX_DWORD& dest_size); -// Public for testing. -FX_DWORD HexDecode(const uint8_t* src_buf, - FX_DWORD src_size, - uint8_t*& dest_buf, - FX_DWORD& dest_size); -// Public for testing. -FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, - const uint8_t* src_buf, - FX_DWORD src_size, - CPDF_Dictionary* pParams, - FX_DWORD estimated_size, - uint8_t*& dest_buf, - FX_DWORD& dest_size); -FX_BOOL PDF_DataDecode(const uint8_t* src_buf, - FX_DWORD src_size, - const CPDF_Dictionary* pDict, - uint8_t*& dest_buf, - FX_DWORD& dest_size, - CFX_ByteString& ImageEncoding, - CPDF_Dictionary*& pImageParms, - FX_DWORD estimated_size, - FX_BOOL bImageAcc); - -#endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ diff --git a/core/include/fpdfapi/fpdf_parser_decode.h b/core/include/fpdfapi/fpdf_parser_decode.h new file mode 100644 index 0000000000..1217c7ea21 --- /dev/null +++ b/core/include/fpdfapi/fpdf_parser_decode.h @@ -0,0 +1,76 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_DECODE_H_ +#define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_DECODE_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CPDF_Dictionary; + +// Indexed by 8-bit char code, contains unicode code points. +extern const FX_WORD PDFDocEncoding[256]; + +CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig); +CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); +CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); +CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, + FX_BOOL bHex = FALSE); +CFX_WideString PDF_DecodeText(const uint8_t* pData, FX_DWORD size); +CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr); +CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1); +CFX_ByteString PDF_EncodeText(const CFX_WideString& str); + +void FlateEncode(const uint8_t* src_buf, + FX_DWORD src_size, + uint8_t*& dest_buf, + FX_DWORD& dest_size); +void FlateEncode(const uint8_t* src_buf, + FX_DWORD src_size, + int predictor, + int Colors, + int BitsPerComponent, + int Columns, + uint8_t*& dest_buf, + FX_DWORD& dest_size); +FX_DWORD FlateDecode(const uint8_t* src_buf, + FX_DWORD src_size, + uint8_t*& dest_buf, + FX_DWORD& dest_size); +FX_DWORD RunLengthDecode(const uint8_t* src_buf, + FX_DWORD src_size, + uint8_t*& dest_buf, + FX_DWORD& dest_size); + +// Public for testing. +FX_DWORD A85Decode(const uint8_t* src_buf, + FX_DWORD src_size, + uint8_t*& dest_buf, + FX_DWORD& dest_size); +// Public for testing. +FX_DWORD HexDecode(const uint8_t* src_buf, + FX_DWORD src_size, + uint8_t*& dest_buf, + FX_DWORD& dest_size); +// Public for testing. +FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, + const uint8_t* src_buf, + FX_DWORD src_size, + CPDF_Dictionary* pParams, + FX_DWORD estimated_size, + uint8_t*& dest_buf, + FX_DWORD& dest_size); +FX_BOOL PDF_DataDecode(const uint8_t* src_buf, + FX_DWORD src_size, + const CPDF_Dictionary* pDict, + uint8_t*& dest_buf, + FX_DWORD& dest_size, + CFX_ByteString& ImageEncoding, + CPDF_Dictionary*& pImageParms, + FX_DWORD estimated_size, + FX_BOOL bImageAcc); + +#endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_DECODE_H_ diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h index 6bae2ac469..a5acc77762 100644 --- a/core/include/fpdfapi/fpdf_resource.h +++ b/core/include/fpdfapi/fpdf_resource.h @@ -9,7 +9,7 @@ #include <map> -#include "core/include/fpdfapi/fpdf_parser.h" +#include "core/include/fpdfapi/fpdf_objects.h" #include "core/include/fxcrt/fx_system.h" #include "core/include/fxge/fx_font.h" @@ -22,6 +22,7 @@ class CPDF_CIDFont; class CPDF_CMap; class CPDF_Color; class CPDF_ColorSpace; +class CPDF_Document; class CPDF_FontEncoding; class CPDF_Form; class CPDF_Function; diff --git a/core/include/fpdfapi/fpdf_serial.h b/core/include/fpdfapi/fpdf_serial.h index 6ed3756803..8cf3fb8a1e 100644 --- a/core/include/fpdfapi/fpdf_serial.h +++ b/core/include/fpdfapi/fpdf_serial.h @@ -11,6 +11,7 @@ #include "core/include/fpdfapi/fpdf_pageobj.h" class CPDF_XRefStream; +class IPDF_CryptoHandler; CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj); diff --git a/core/include/fpdfapi/ipdf_data_avail.h b/core/include/fpdfapi/ipdf_data_avail.h new file mode 100644 index 0000000000..5b8fd0b5e2 --- /dev/null +++ b/core/include/fpdfapi/ipdf_data_avail.h @@ -0,0 +1,80 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_INCLUDE_FPDFAPI_IPDF_DATA_AVAIL_H_ +#define CORE_INCLUDE_FPDFAPI_IPDF_DATA_AVAIL_H_ + +#include "core/include/fxcrt/fx_stream.h" +#include "core/include/fxcrt/fx_system.h" + +class CPDF_Document; +class CPDF_Object; + +class IPDF_DataAvail { + public: + // Must match PDF_DATA_* definitions in public/fpdf_dataavail.h, but cannot + // #include that header. fpdfsdk/src/fpdf_dataavail.cpp has static_asserts + // to make sure the two sets of values match. + enum DocAvailStatus { + DataError = -1, // PDF_DATA_ERROR + DataNotAvailable = 0, // PDF_DATA_NOTAVAIL + DataAvailable = 1, // PDF_DATA_AVAIL + }; + + // Must match PDF_*LINEAR* definitions in public/fpdf_dataavail.h, but cannot + // #include that header. fpdfsdk/src/fpdf_dataavail.cpp has static_asserts + // to make sure the two sets of values match. + enum DocLinearizationStatus { + LinearizationUnknown = -1, // PDF_LINEARIZATION_UNKNOWN + NotLinearized = 0, // PDF_NOT_LINEARIZED + Linearized = 1, // PDF_LINEARIZED + }; + + // Must match PDF_FORM_* definitions in public/fpdf_dataavail.h, but cannot + // #include that header. fpdfsdk/src/fpdf_dataavail.cpp has static_asserts + // to make sure the two sets of values match. + enum DocFormStatus { + FormError = -1, // PDF_FORM_ERROR + FormNotAvailable = 0, // PDF_FORM_NOTAVAIL + FormAvailable = 1, // PDF_FORM_AVAIL + FormNotExist = 2, // PDF_FORM_NOTEXIST + }; + + class FileAvail { + public: + virtual ~FileAvail(); + virtual FX_BOOL IsDataAvail(FX_FILESIZE offset, FX_DWORD size) = 0; + }; + + class DownloadHints { + public: + virtual ~DownloadHints(); + virtual void AddSegment(FX_FILESIZE offset, FX_DWORD size) = 0; + }; + + static IPDF_DataAvail* Create(FileAvail* pFileAvail, IFX_FileRead* pFileRead); + virtual ~IPDF_DataAvail(); + + FileAvail* GetFileAvail() const { return m_pFileAvail; } + IFX_FileRead* GetFileRead() const { return m_pFileRead; } + + virtual DocAvailStatus IsDocAvail(DownloadHints* pHints) = 0; + virtual void SetDocument(CPDF_Document* pDoc) = 0; + virtual DocAvailStatus IsPageAvail(int iPage, DownloadHints* pHints) = 0; + virtual FX_BOOL IsLinearized() = 0; + virtual DocFormStatus IsFormAvail(DownloadHints* pHints) = 0; + virtual DocLinearizationStatus IsLinearizedPDF() = 0; + virtual void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, + FX_DWORD* pSize) = 0; + + protected: + IPDF_DataAvail(FileAvail* pFileAvail, IFX_FileRead* pFileRead); + + FileAvail* m_pFileAvail; + IFX_FileRead* m_pFileRead; +}; + +#endif // CORE_INCLUDE_FPDFAPI_IPDF_DATA_AVAIL_H_ |