Add type cast definitions for CPDF_Stream.
[pdfium.git] / core / include / fpdfapi / fpdf_page.h
index 29b8c68..5f716b2 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#ifndef _FPDF_PAGE_\r
-#define _FPDF_PAGE_\r
-#ifndef _FPDF_PARSER_\r
-#include "fpdf_parser.h"\r
-#endif\r
-#ifndef _FPDF_RESOURCE_\r
-#include "fpdf_resource.h"\r
-#endif\r
-#ifndef _FX_DIB_H_\r
-#include "../fxge/fx_dib.h"\r
-#endif\r
-class CPDF_PageObjects;\r
-class CPDF_Page;\r
-class CPDF_Form;\r
-class CPDF_ParseOptions;\r
-class CPDF_PageObject;\r
-class CPDF_PageRenderCache;\r
-class CPDF_StreamFilter;\r
-class CPDF_AllStates;\r
-class CPDF_ContentParser;\r
-class CPDF_StreamContentParser;\r
-class CPDF_ResourceNaming;\r
-#define PDFTRANS_GROUP                 0x0100\r
-#define PDFTRANS_ISOLATED              0x0200\r
-#define PDFTRANS_KNOCKOUT              0x0400\r
-#define PDF_CONTENT_NOT_PARSED 0\r
-#define PDF_CONTENT_PARSING            1\r
-#define PDF_CONTENT_PARSED             2\r
-class CPDF_PageObjects : public CFX_Object\r
-{\r
-public:\r
-\r
-    CPDF_PageObjects(FX_BOOL bReleaseMembers = TRUE);\r
-\r
-    ~CPDF_PageObjects();\r
-\r
-\r
-\r
-\r
-    void                               ContinueParse(IFX_Pause* pPause);\r
-\r
-    int                                        GetParseState() const\r
-    {\r
-        return m_ParseState;\r
-    }\r
-\r
-    FX_BOOL                            IsParsed() const\r
-    {\r
-        return m_ParseState == PDF_CONTENT_PARSED;\r
-    }\r
-\r
-    int                                        EstimateParseProgress() const;\r
-\r
-\r
-\r
-\r
-    FX_POSITION                        GetFirstObjectPosition() const\r
-    {\r
-        return m_ObjectList.GetHeadPosition();\r
-    }\r
-\r
-    FX_POSITION                        GetLastObjectPosition() const\r
-    {\r
-        return m_ObjectList.GetTailPosition();\r
-    }\r
-\r
-    CPDF_PageObject*   GetNextObject(FX_POSITION& pos) const\r
-    {\r
-        return (CPDF_PageObject*)m_ObjectList.GetNext(pos);\r
-    }\r
-\r
-    CPDF_PageObject*   GetPrevObject(FX_POSITION& pos) const\r
-    {\r
-        return (CPDF_PageObject*)m_ObjectList.GetPrev(pos);\r
-    }\r
-\r
-    CPDF_PageObject*   GetObjectAt(FX_POSITION pos) const\r
-    {\r
-        return (CPDF_PageObject*)m_ObjectList.GetAt(pos);\r
-    }\r
-\r
-    FX_DWORD                   CountObjects() const\r
-    {\r
-        return m_ObjectList.GetCount();\r
-    }\r
-\r
-    int                                        GetObjectIndex(CPDF_PageObject* pObj) const;\r
-\r
-    CPDF_PageObject*   GetObjectByIndex(int index) const;\r
-\r
-\r
-\r
-\r
-\r
-    FX_POSITION                        InsertObject(FX_POSITION posInsertAfter, CPDF_PageObject* pNewObject);\r
-\r
-    void                               Transform(const CFX_AffineMatrix& matrix);\r
-\r
-    FX_BOOL                            BackgroundAlphaNeeded() const\r
-    {\r
-        return m_bBackgroundAlphaNeeded;\r
-    }\r
-\r
-    CFX_FloatRect              CalcBoundingBox() const;\r
-\r
-    CPDF_Dictionary*   m_pFormDict;\r
-\r
-    CPDF_Stream*               m_pFormStream;\r
-\r
-    CPDF_Document*             m_pDocument;\r
-\r
-    CPDF_Dictionary*   m_pPageResources;\r
-\r
-    CPDF_Dictionary*   m_pResources;\r
-\r
-    CFX_FloatRect              m_BBox;\r
-\r
-    int                                        m_Transparency;\r
-\r
-protected:\r
-    friend class               CPDF_ContentParser;\r
-    friend class               CPDF_StreamContentParser;\r
-    friend class               CPDF_AllStates;\r
-\r
-    CFX_PtrList                        m_ObjectList;\r
-\r
-    FX_BOOL                            m_bBackgroundAlphaNeeded;\r
-\r
-    FX_BOOL                            m_bReleaseMembers;\r
-    void                               LoadTransInfo();\r
-    void                ClearCacheObjects();\r
-\r
-    CPDF_ContentParser*        m_pParser;\r
-\r
-    FX_BOOL                            m_ParseState;\r
-};\r
-class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData\r
-{\r
-public:\r
-\r
-    CPDF_Page();\r
-\r
-    ~CPDF_Page();\r
-\r
-    void                               Load(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, FX_BOOL bPageCache = TRUE);\r
-\r
-    void                               StartParse(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE);\r
-\r
-    void                               ParseContent(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE);\r
-\r
-    void                               GetDisplayMatrix(CFX_AffineMatrix& matrix, int xPos, int yPos,\r
-                                         int xSize, int ySize, int iRotate) const;\r
-\r
-    FX_FLOAT                   GetPageWidth() const\r
-    {\r
-        return m_PageWidth;\r
-    }\r
-\r
-    FX_FLOAT                   GetPageHeight() const\r
-    {\r
-        return m_PageHeight;\r
-    }\r
-\r
-    CFX_FloatRect              GetPageBBox() const\r
-    {\r
-        return m_BBox;\r
-    }\r
-\r
-    const CFX_AffineMatrix&    GetPageMatrix() const\r
-    {\r
-        return m_PageMatrix;\r
-    }\r
-\r
-    CPDF_Object*               GetPageAttr(FX_BSTR name) const;\r
-\r
-\r
-\r
-    CPDF_PageRenderCache*      GetRenderCache() const\r
-    {\r
-        return m_pPageRender;\r
-    }\r
-\r
-    void                               ClearRenderCache();\r
-\r
-protected:\r
-    friend class               CPDF_ContentParser;\r
-\r
-    FX_FLOAT                   m_PageWidth;\r
-\r
-    FX_FLOAT                   m_PageHeight;\r
-\r
-    CFX_AffineMatrix   m_PageMatrix;\r
-\r
-    CPDF_PageRenderCache*      m_pPageRender;\r
-};\r
-class CPDF_ParseOptions : public CFX_Object\r
-{\r
-public:\r
-\r
-    CPDF_ParseOptions();\r
-\r
-    FX_BOOL                            m_bTextOnly;\r
-\r
-    FX_BOOL                            m_bMarkedContent;\r
-\r
-    FX_BOOL                            m_bSeparateForm;\r
-\r
-    FX_BOOL                            m_bDecodeInlineImage;\r
-};\r
-class CPDF_Form : public CPDF_PageObjects\r
-{\r
-public:\r
-\r
-    CPDF_Form(CPDF_Document* pDocument, CPDF_Dictionary* pPageResources, CPDF_Stream* pFormStream, CPDF_Dictionary* pParentResources = NULL);\r
-\r
-    ~CPDF_Form();\r
-\r
-    void                               StartParse(CPDF_AllStates* pGraphicStates,  CFX_AffineMatrix* pParentMatrix,\r
-                                   CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level = 0);\r
-\r
-    void                               ParseContent(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,\r
-                                     CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level = 0);\r
-\r
-    CPDF_Form*                 Clone() const;\r
-};\r
-class CPDF_PageContentGenerate : public CFX_Object\r
-{\r
-public:\r
-    CPDF_PageContentGenerate(CPDF_Page* pPage);\r
-    ~CPDF_PageContentGenerate();\r
-    FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject);\r
-    void GenerateContent();\r
-    void TransformContent(CFX_Matrix& matrix);\r
-protected:\r
-    void            ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObject* pImageObj);\r
-    void            ProcessForm(CFX_ByteTextBuf& buf, FX_LPCBYTE data, FX_DWORD size, CFX_Matrix& matrix);\r
-    CFX_ByteString  RealizeResource(CPDF_Object* pResourceObj, const FX_CHAR* szType);\r
-private:\r
-    CPDF_Page*      m_pPage;\r
-    CPDF_Document*  m_pDocument;\r
-    CFX_PtrArray    m_pageObjects;\r
-};\r
-#endif\r
+// Copyright 2014 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_PAGE_H_
+#define CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_
+
+#include "../fxge/fx_dib.h"
+#include "fpdf_parser.h"
+#include "fpdf_resource.h"
+
+class CPDF_PageObjects;
+class CPDF_Page;
+class CPDF_Form;
+class CPDF_ParseOptions;
+class CPDF_PageObject;
+class CPDF_PageRenderCache;
+class CPDF_StreamFilter;
+class CPDF_AllStates;
+class CPDF_ContentParser;
+class CPDF_StreamContentParser;
+#define PDFTRANS_GROUP 0x0100
+#define PDFTRANS_ISOLATED 0x0200
+#define PDFTRANS_KNOCKOUT 0x0400
+
+class CPDF_PageObjects {
+ public:
+  CPDF_PageObjects(FX_BOOL bReleaseMembers = TRUE);
+  ~CPDF_PageObjects();
+
+  void ContinueParse(IFX_Pause* pPause);
+
+  FX_BOOL IsParsed() const { return m_ParseState == CONTENT_PARSED; }
+
+  FX_POSITION GetFirstObjectPosition() const {
+    return m_ObjectList.GetHeadPosition();
+  }
+
+  FX_POSITION GetLastObjectPosition() const {
+    return m_ObjectList.GetTailPosition();
+  }
+
+  CPDF_PageObject* GetNextObject(FX_POSITION& pos) const {
+    return (CPDF_PageObject*)m_ObjectList.GetNext(pos);
+  }
+
+  CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const {
+    return (CPDF_PageObject*)m_ObjectList.GetPrev(pos);
+  }
+
+  CPDF_PageObject* GetObjectAt(FX_POSITION pos) const {
+    return (CPDF_PageObject*)m_ObjectList.GetAt(pos);
+  }
+
+  FX_DWORD CountObjects() const { return m_ObjectList.GetCount(); }
+
+  int GetObjectIndex(CPDF_PageObject* pObj) const;
+
+  CPDF_PageObject* GetObjectByIndex(int index) const;
+
+  FX_POSITION InsertObject(FX_POSITION posInsertAfter,
+                           CPDF_PageObject* pNewObject);
+
+  void Transform(const CFX_AffineMatrix& matrix);
+
+  FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; }
+
+  CFX_FloatRect CalcBoundingBox() const;
+
+  CPDF_Dictionary* m_pFormDict;
+  CPDF_Stream* m_pFormStream;
+  CPDF_Document* m_pDocument;
+  CPDF_Dictionary* m_pPageResources;
+  CPDF_Dictionary* m_pResources;
+  CFX_FloatRect m_BBox;
+  int m_Transparency;
+
+ protected:
+  friend class CPDF_ContentParser;
+  friend class CPDF_StreamContentParser;
+  friend class CPDF_AllStates;
+
+  enum ParseState { CONTENT_NOT_PARSED, CONTENT_PARSING, CONTENT_PARSED };
+
+  void LoadTransInfo();
+  void ClearCacheObjects();
+
+  CFX_PtrList m_ObjectList;
+  FX_BOOL m_bBackgroundAlphaNeeded;
+  FX_BOOL m_bReleaseMembers;
+  CPDF_ContentParser* m_pParser;
+  ParseState m_ParseState;
+};
+
+class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData {
+ public:
+  CPDF_Page();
+
+  ~CPDF_Page();
+
+  void Load(CPDF_Document* pDocument,
+            CPDF_Dictionary* pPageDict,
+            FX_BOOL bPageCache = TRUE);
+
+  void StartParse(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE);
+
+  void ParseContent(CPDF_ParseOptions* pOptions = NULL,
+                    FX_BOOL bReParse = FALSE);
+
+  void GetDisplayMatrix(CFX_AffineMatrix& matrix,
+                        int xPos,
+                        int yPos,
+                        int xSize,
+                        int ySize,
+                        int iRotate) const;
+
+  FX_FLOAT GetPageWidth() const { return m_PageWidth; }
+
+  FX_FLOAT GetPageHeight() const { return m_PageHeight; }
+
+  CFX_FloatRect GetPageBBox() const { return m_BBox; }
+
+  const CFX_AffineMatrix& GetPageMatrix() const { return m_PageMatrix; }
+
+  CPDF_Object* GetPageAttr(const CFX_ByteStringC& name) const;
+
+  CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender; }
+
+  void ClearRenderCache();
+
+ protected:
+  friend class CPDF_ContentParser;
+
+  FX_FLOAT m_PageWidth;
+
+  FX_FLOAT m_PageHeight;
+
+  CFX_AffineMatrix m_PageMatrix;
+
+  CPDF_PageRenderCache* m_pPageRender;
+};
+class CPDF_ParseOptions {
+ public:
+  CPDF_ParseOptions();
+
+  FX_BOOL m_bTextOnly;
+
+  FX_BOOL m_bMarkedContent;
+
+  FX_BOOL m_bSeparateForm;
+
+  FX_BOOL m_bDecodeInlineImage;
+};
+class CPDF_Form : public CPDF_PageObjects {
+ public:
+  CPDF_Form(CPDF_Document* pDocument,
+            CPDF_Dictionary* pPageResources,
+            CPDF_Stream* pFormStream,
+            CPDF_Dictionary* pParentResources = NULL);
+
+  ~CPDF_Form();
+
+  void StartParse(CPDF_AllStates* pGraphicStates,
+                  CFX_AffineMatrix* pParentMatrix,
+                  CPDF_Type3Char* pType3Char,
+                  CPDF_ParseOptions* pOptions,
+                  int level = 0);
+
+  void ParseContent(CPDF_AllStates* pGraphicStates,
+                    CFX_AffineMatrix* pParentMatrix,
+                    CPDF_Type3Char* pType3Char,
+                    CPDF_ParseOptions* pOptions,
+                    int level = 0);
+
+  CPDF_Form* Clone() const;
+};
+class CPDF_PageContentGenerate {
+ public:
+  CPDF_PageContentGenerate(CPDF_Page* pPage);
+  ~CPDF_PageContentGenerate();
+  FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject);
+  void GenerateContent();
+  void TransformContent(CFX_Matrix& matrix);
+
+ protected:
+  void ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObject* pImageObj);
+  void ProcessForm(CFX_ByteTextBuf& buf,
+                   const uint8_t* data,
+                   FX_DWORD size,
+                   CFX_Matrix& matrix);
+  CFX_ByteString RealizeResource(CPDF_Object* pResourceObj,
+                                 const FX_CHAR* szType);
+
+ private:
+  CPDF_Page* m_pPage;
+  CPDF_Document* m_pDocument;
+  CFX_PtrArray m_pageObjects;
+};
+
+#endif  // CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_