Check the number of component in ICCBased colorspace
[pdfium.git] / core / src / fpdfapi / fpdf_page / pageint.h
index b1a83ec..625e5df 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
-#include "../../../include/fpdfapi/fpdf_pageobj.h"\r
-#define PARSE_STEP_LIMIT               100\r
-#define STREAM_PARSE_BUFSIZE   20480\r
-class CPDF_QuickFontCache;\r
-#ifndef _FPDFAPI_MINI_\r
-class CPDF_StreamParser : public CFX_Object\r
-{\r
-public:\r
-\r
-    CPDF_StreamParser(const FX_BYTE* pData, FX_DWORD dwSize);\r
-    ~CPDF_StreamParser();\r
-\r
-    CPDF_Stream*               ReadInlineStream(CPDF_Document* pDoc, CPDF_Dictionary* pDict, CPDF_Object* pCSObj, FX_BOOL bDecode);\r
-    typedef enum { EndOfData, Number, Keyword, Name, Others } SyntaxType;\r
-\r
-    SyntaxType                 ParseNextElement();\r
-    FX_LPBYTE                  GetWordBuf()\r
-    {\r
-        return m_WordBuffer;\r
-    }\r
-    FX_DWORD                   GetWordSize()\r
-    {\r
-        return m_WordSize;\r
-    }\r
-    CPDF_Object*               GetObject()\r
-    {\r
-        CPDF_Object* pObj = m_pLastObj;\r
-        m_pLastObj = NULL;\r
-        return pObj;\r
-    }\r
-    FX_DWORD                   GetPos()\r
-    {\r
-        return m_Pos;\r
-    }\r
-    void                               SetPos(FX_DWORD pos)\r
-    {\r
-        m_Pos = pos;\r
-    }\r
-\r
-    CPDF_Object*               ReadNextObject(FX_BOOL bAllowNestedArray = FALSE, FX_BOOL bInArray = FALSE);\r
-    void                               SkipPathObject();\r
-protected:\r
-    void                               GetNextWord(FX_BOOL& bIsNumber);\r
-    CFX_ByteString             ReadString();\r
-    CFX_ByteString             ReadHexString();\r
-    const FX_BYTE*             m_pBuf;\r
-    FX_DWORD                   m_Size;\r
-    FX_DWORD                   m_Pos;\r
-    FX_BYTE                            m_WordBuffer[256];\r
-    FX_DWORD                   m_WordSize;\r
-    CPDF_Object*               m_pLastObj;\r
-};\r
-#endif\r
-typedef enum {\r
-    PDFOP_CloseFillStrokePath = 0, PDFOP_FillStrokePath,\r
-    PDFOP_CloseEOFillStrokePath, PDFOP_EOFillStrokePath,\r
-    PDFOP_BeginMarkedContent_Dictionary, PDFOP_BeginImage,\r
-    PDFOP_BeginMarkedContent, PDFOP_BeginText,\r
-    PDFOP_BeginSectionUndefined, PDFOP_CurveTo_123,\r
-    PDFOP_ConcatMatrix, PDFOP_SetColorSpace_Fill,\r
-    PDFOP_SetColorSpace_Stroke, PDFOP_SetDash,\r
-    PDFOP_SetCharWidth, PDFOP_SetCachedDevice,\r
-    PDFOP_ExecuteXObject, PDFOP_MarkPlace_Dictionary,\r
-    PDFOP_EndImage, PDFOP_EndMarkedContent,\r
-    PDFOP_EndText, PDFOP_EndSectionUndefined,\r
-    PDFOP_FillPath, PDFOP_FillPathOld,\r
-    PDFOP_EOFillPath, PDFOP_SetGray_Fill,\r
-    PDFOP_SetGray_Stroke, PDFOP_SetExtendGraphState,\r
-    PDFOP_ClosePath, PDFOP_SetFlat,\r
-    PDFOP_BeginImageData, PDFOP_SetLineJoin,\r
-    PDFOP_SetLineCap, PDFOP_SetCMYKColor_Fill,\r
-    PDFOP_SetCMYKColor_Stroke, PDFOP_LineTo,\r
-    PDFOP_MoveTo, PDFOP_SetMiterLimit,\r
-    PDFOP_MarkPlace, PDFOP_EndPath,\r
-    PDFOP_SaveGraphState, PDFOP_RestoreGraphState,\r
-    PDFOP_Rectangle, PDFOP_SetRGBColor_Fill,\r
-    PDFOP_SetRGBColor_Stroke, PDFOP_SetRenderIntent,\r
-    PDFOP_CloseStrokePath, PDFOP_StrokePath,\r
-    PDFOP_SetColor_Fill, PDFOP_SetColor_Stroke,\r
-    PDFOP_SetColorPS_Fill, PDFOP_SetColorPS_Stroke,\r
-    PDFOP_ShadeFill, PDFOP_SetCharSpace,\r
-    PDFOP_MoveTextPoint, PDFOP_MoveTextPoint_SetLeading,\r
-    PDFOP_SetFont, PDFOP_ShowText,\r
-    PDFOP_ShowText_Positioning, PDFOP_SetTextLeading,\r
-    PDFOP_SetTextMatrix, PDFOP_SetTextRenderMode,\r
-    PDFOP_SetTextRise, PDFOP_SetWordSpace,\r
-    PDFOP_SetHorzScale, PDFOP_MoveToNextLine,\r
-    PDFOP_CurveTo_23, PDFOP_SetLineWidth,\r
-    PDFOP_Clip, PDFOP_EOClip,\r
-    PDFOP_CurveTo_13, PDFOP_NextLineShowText,\r
-    PDFOP_NextLineShowText_Space, PDFOP_Invalid\r
-} PDFOP;\r
-#define PARAM_BUF_SIZE 16\r
-typedef struct {\r
-    int                        m_Type;\r
-    union {\r
-        struct {\r
-            FX_BOOL            m_bInteger;\r
-            union {\r
-                int            m_Integer;\r
-                FX_FLOAT m_Float;\r
-            };\r
-        } m_Number;\r
-        CPDF_Object*   m_pObject;\r
-        struct {\r
-            int                        m_Len;\r
-            char               m_Buffer[32];\r
-        } m_Name;\r
-    };\r
-} _ContentParam;\r
-#if defined(_FPDFAPI_MINI_)\r
-#define _FPDF_MAX_FORM_LEVEL_          17\r
-#else\r
-#define _FPDF_MAX_FORM_LEVEL_          30\r
-#endif\r
-#define _FPDF_MAX_TYPE3_FORM_LEVEL_    4\r
-#define _FPDF_MAX_OBJECT_STACK_SIZE_ 512\r
-class CPDF_StreamContentParser : public CFX_Object\r
-{\r
-public:\r
-    CPDF_StreamContentParser();\r
-    ~CPDF_StreamContentParser();\r
-    FX_BOOL Initialize();\r
-    void       PrepareParse(CPDF_Document* pDoc, CPDF_Dictionary* pPageResources, CPDF_Dictionary* pParentResources,\r
-                         CFX_AffineMatrix* pmtContentToUser,\r
-                         CPDF_PageObjects* pObjList, CPDF_Dictionary* pResources,\r
-                         CFX_FloatRect* pBBox, CPDF_ParseOptions* pOptions,\r
-                         CPDF_AllStates* pAllStates, int level);\r
-    CPDF_Document*             m_pDocument;\r
-    CPDF_Dictionary*   m_pPageResources;\r
-    CPDF_Dictionary*   m_pParentResources;\r
-    CPDF_PageObjects*  m_pObjectList;\r
-    CPDF_Dictionary*   m_pResources;\r
-    int                                        m_Level;\r
-    CFX_AffineMatrix   m_mtContentToUser;\r
-    CFX_FloatRect              m_BBox;\r
-    CPDF_ParseOptions  m_Options;\r
-    _ContentParam              m_ParamBuf1[PARAM_BUF_SIZE];\r
-    FX_DWORD                   m_ParamStartPos;\r
-    FX_DWORD                   m_ParamCount;\r
-    void                               AddNumberParam(FX_LPCSTR str, int len);\r
-    void                               AddObjectParam(CPDF_Object* pObj);\r
-    void                               AddNameParam(FX_LPCSTR name, int size);\r
-    int                                        GetNextParamPos();\r
-    void                               ClearAllParams();\r
-    CPDF_Object*               GetObject(FX_DWORD index);\r
-    CFX_ByteString             GetString(FX_DWORD index);\r
-    FX_FLOAT                   GetNumber(FX_DWORD index);\r
-    FX_FLOAT           GetNumber16(FX_DWORD index);\r
-    int                                        GetInteger(FX_DWORD index)\r
-    {\r
-        return (FX_INT32)(GetNumber(index));\r
-    }\r
-    FX_BOOL                            OnOperator(FX_LPCSTR op);\r
-    void                               BigCaseCaller(int index);\r
-    FX_BOOL                            m_bAbort;\r
-#ifndef _FPDFAPI_MINI_\r
-    CPDF_StreamParser* m_pSyntax;\r
-    FX_DWORD                   GetParsePos()\r
-    {\r
-        return m_pSyntax->GetPos();\r
-    }\r
-#else\r
-    int                                        m_WordState;\r
-    void                               InputData(FX_LPCBYTE src_buf, FX_DWORD src_size);\r
-    void                               Finish();\r
-    void                               StartArray();\r
-    void                               EndArray();\r
-    void                               StartDict();\r
-    void                               EndDict();\r
-    void                               EndName();\r
-    void                               EndNumber();\r
-    void                               EndKeyword();\r
-    void                               EndHexString();\r
-    void                               EndString();\r
-    void                               EndImageDict();\r
-    void                               EndInlineImage();\r
-    FX_LPBYTE                  m_pWordBuf;\r
-    FX_DWORD                   m_WordSize;\r
-    CFX_BinaryBuf              m_StringBuf;\r
-    int                                        m_StringLevel, m_StringState, m_EscCode;\r
-    void                               AddContainer(CPDF_Object* pObject);\r
-    FX_BOOL                            SetToCurObj(CPDF_Object* pObject);\r
-    FX_LPBYTE                  m_pDictName;\r
-    FX_BOOL                            m_bDictName;\r
-    CPDF_Object**              m_pObjectStack;\r
-    FX_BOOL*                   m_pObjectState;\r
-    FX_DWORD                   m_ObjectSize;\r
-    int                                        m_InlineImageState;\r
-    FX_BYTE                            m_InlineWhiteChar;\r
-    CFX_BinaryBuf              m_ImageSrcBuf;\r
-    FX_LPBYTE                  m_pStreamBuf;\r
-#endif\r
-    CPDF_AllStates*            m_pCurStates;\r
-    CPDF_ContentMark   m_CurContentMark;\r
-    CFX_PtrArray               m_ClipTextList;\r
-    CPDF_TextObject*   m_pLastTextObject;\r
-    FX_FLOAT                   m_DefFontSize;\r
-    void                               AddTextObject(CFX_ByteString* pText, FX_FLOAT fInitKerning, FX_FLOAT* pKerning, int count);\r
-\r
-    void                               ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y);\r
-    void                               ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y);\r
-    void                               OnChangeTextMatrix();\r
-#ifndef _FPDFAPI_MINI_\r
-    FX_DWORD                   Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_DWORD max_cost);\r
-    void                               ParsePathObject();\r
-#endif\r
-    int                                        m_CompatCount;\r
-    FX_PATHPOINT*              m_pPathPoints;\r
-    int                                        m_PathPointCount;\r
-    int                                        m_PathAllocSize;\r
-    FX_FLOAT                   m_PathStartX, m_PathStartY;\r
-    FX_FLOAT                   m_PathCurrentX, m_PathCurrentY;\r
-    int                                        m_PathClipType;\r
-    void                               AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag);\r
-    void                               AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h);\r
-    void                               AddPathObject(int FillType, FX_BOOL bStroke);\r
-    CPDF_ImageObject*  AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BOOL bInline);\r
-    void                               AddDuplicateImage();\r
-    void                               AddForm(CPDF_Stream*);\r
-    CFX_ByteString             m_LastImageName;\r
-    CPDF_Image*                        m_pLastImage;\r
-    CFX_BinaryBuf              m_LastImageDict, m_LastImageData;\r
-    CPDF_Dictionary*   m_pLastImageDict;\r
-    CPDF_Dictionary*    m_pLastCloneImageDict;\r
-    FX_BOOL                            m_bReleaseLastDict;\r
-    FX_BOOL                            m_bSameLastDict;\r
-    void                               SetGraphicStates(CPDF_PageObject* pObj, FX_BOOL bColor, FX_BOOL bText, FX_BOOL bGraph);\r
-    FX_BOOL                            m_bColored;\r
-    FX_FLOAT                   m_Type3Data[6];\r
-    FX_BOOL                            m_bResourceMissing;\r
-    CFX_PtrArray               m_StateStack;\r
-    void                               SaveStates(CPDF_AllStates*);\r
-    void                               RestoreStates(CPDF_AllStates*);\r
-    CPDF_Font*                 FindFont(const CFX_ByteString& name);\r
-    CPDF_ColorSpace*   FindColorSpace(const CFX_ByteString& name);\r
-    CPDF_Pattern*              FindPattern(const CFX_ByteString& name, FX_BOOL bShading);\r
-    CPDF_Object*               FindResourceObj(FX_BSTR type, const CFX_ByteString& name);\r
-    void Handle_CloseFillStrokePath();\r
-    void Handle_FillStrokePath();\r
-    void Handle_CloseEOFillStrokePath();\r
-    void Handle_EOFillStrokePath();\r
-    void Handle_BeginMarkedContent_Dictionary();\r
-    void Handle_BeginImage();\r
-    void Handle_BeginMarkedContent();\r
-    void Handle_BeginText();\r
-    void Handle_BeginSectionUndefined();\r
-    void Handle_CurveTo_123();\r
-    void Handle_ConcatMatrix();\r
-    void Handle_SetColorSpace_Fill();\r
-    void Handle_SetColorSpace_Stroke();\r
-    void Handle_SetDash();\r
-    void Handle_SetCharWidth();\r
-    void Handle_SetCachedDevice();\r
-    void Handle_ExecuteXObject();\r
-    void Handle_MarkPlace_Dictionary();\r
-    void Handle_EndImage();\r
-    void Handle_EndMarkedContent();\r
-    void Handle_EndText();\r
-    void Handle_EndSectionUndefined();\r
-    void Handle_FillPath();\r
-    void Handle_FillPathOld();\r
-    void Handle_EOFillPath();\r
-    void Handle_SetGray_Fill();\r
-    void Handle_SetGray_Stroke();\r
-    void Handle_SetExtendGraphState();\r
-    void Handle_ClosePath();\r
-    void Handle_SetFlat();\r
-    void Handle_BeginImageData();\r
-    void Handle_SetLineJoin();\r
-    void Handle_SetLineCap();\r
-    void Handle_SetCMYKColor_Fill();\r
-    void Handle_SetCMYKColor_Stroke();\r
-    void Handle_LineTo();\r
-    void Handle_MoveTo();\r
-    void Handle_SetMiterLimit();\r
-    void Handle_MarkPlace();\r
-    void Handle_EndPath();\r
-    void Handle_SaveGraphState();\r
-    void Handle_RestoreGraphState();\r
-    void Handle_Rectangle();\r
-    void Handle_SetRGBColor_Fill();\r
-    void Handle_SetRGBColor_Stroke();\r
-    void Handle_SetRenderIntent();\r
-    void Handle_CloseStrokePath();\r
-    void Handle_StrokePath();\r
-    void Handle_SetColor_Fill();\r
-    void Handle_SetColor_Stroke();\r
-    void Handle_SetColorPS_Fill();\r
-    void Handle_SetColorPS_Stroke();\r
-    void Handle_ShadeFill();\r
-    void Handle_SetCharSpace();\r
-    void Handle_MoveTextPoint();\r
-    void Handle_MoveTextPoint_SetLeading();\r
-    void Handle_SetFont();\r
-    void Handle_ShowText();\r
-    void Handle_ShowText_Positioning();\r
-    void Handle_SetTextLeading();\r
-    void Handle_SetTextMatrix();\r
-    void Handle_SetTextRenderMode();\r
-    void Handle_SetTextRise();\r
-    void Handle_SetWordSpace();\r
-    void Handle_SetHorzScale();\r
-    void Handle_MoveToNextLine();\r
-    void Handle_CurveTo_23();\r
-    void Handle_SetLineWidth();\r
-    void Handle_Clip();\r
-    void Handle_EOClip();\r
-    void Handle_CurveTo_13();\r
-    void Handle_NextLineShowText();\r
-    void Handle_NextLineShowText_Space();\r
-    void Handle_Invalid();\r
-};\r
-class CPDF_ContentParser : public CFX_Object\r
-{\r
-public:\r
-    CPDF_ContentParser();\r
-    ~CPDF_ContentParser();\r
-    typedef enum { Ready, ToBeContinued, Done } ParseStatus;\r
-    ParseStatus                        GetStatus()\r
-    {\r
-        return m_Status;\r
-    }\r
-    void                               Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions);\r
-    void                               Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,\r
-                              CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level);\r
-    void                               Continue(IFX_Pause* pPause);\r
-    int                                        EstimateProgress();\r
-protected:\r
-    void                               Clear();\r
-    ParseStatus                        m_Status;\r
-    CPDF_PageObjects*  m_pObjects;\r
-    FX_BOOL                            m_bForm;\r
-    CPDF_ParseOptions  m_Options;\r
-    CPDF_Type3Char*            m_pType3Char;\r
-    int                                        m_InternalStage;\r
-    CPDF_StreamAcc*            m_pSingleStream;\r
-    CPDF_StreamAcc**   m_pStreamArray;\r
-    FX_DWORD                   m_nStreams;\r
-    FX_LPBYTE                  m_pData;\r
-    FX_DWORD                   m_Size;\r
-    class CPDF_StreamContentParser*    m_pParser;\r
-    FX_DWORD                   m_CurrentOffset;\r
-    CPDF_StreamFilter* m_pStreamFilter;\r
-};\r
-class CPDF_AllStates : public CPDF_GraphicStates\r
-{\r
-public:\r
-    CPDF_AllStates();\r
-    ~CPDF_AllStates();\r
-    void       Copy(const CPDF_AllStates& src);\r
-    void       ProcessExtGS(CPDF_Dictionary* pGS, CPDF_StreamContentParser* pParser);\r
-    void       SetLineDash(CPDF_Array*, FX_FLOAT, FX_FLOAT scale);\r
-    CFX_AffineMatrix           m_TextMatrix, m_CTM, m_ParentMatrix;\r
-    FX_FLOAT                           m_TextX, m_TextY, m_TextLineX, m_TextLineY;\r
-    FX_FLOAT                           m_TextLeading, m_TextRise, m_TextHorzScale;\r
-};\r
-template <class ObjClass> class CPDF_CountedObject : public CFX_Object\r
-{\r
-public:\r
-    ObjClass   m_Obj;\r
-    FX_DWORD   m_nCount;\r
-};\r
-typedef CFX_MapPtrTemplate<CPDF_Dictionary*, CPDF_CountedObject<CPDF_Font*>*>          CPDF_FontMap;\r
-typedef CFX_MapPtrTemplate<CPDF_Object*, CPDF_CountedObject<CPDF_ColorSpace*>*>                CPDF_ColorSpaceMap;\r
-typedef CFX_MapPtrTemplate<CPDF_Object*, CPDF_CountedObject<CPDF_Pattern*>*>           CPDF_PatternMap;\r
-typedef CFX_MapPtrTemplate<FX_DWORD, CPDF_CountedObject<CPDF_Image*>*>                         CPDF_ImageMap;\r
-typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedObject<CPDF_IccProfile*>*>                CPDF_IccProfileMap;\r
-typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedObject<CPDF_StreamAcc*>*>         CPDF_FontFileMap;\r
-template <class KeyType, class ValueType>\r
-KeyType PDF_DocPageData_FindValue(const CFX_MapPtrTemplate<KeyType, CPDF_CountedObject<ValueType>*> &map, ValueType findValue, CPDF_CountedObject<ValueType>*& findData)\r
-{\r
-    FX_POSITION pos = map.GetStartPosition();\r
-    while (pos) {\r
-        KeyType findKey;\r
-        map.GetNextAssoc(pos, findKey, findData);\r
-        if (findData->m_Obj == findValue) {\r
-            return findKey;\r
-        }\r
-    }\r
-    findData = NULL;\r
-    return (KeyType)(FX_UINTPTR)NULL;\r
-}\r
-template <class KeyType, class ValueType>\r
-FX_BOOL PDF_DocPageData_Release(CFX_MapPtrTemplate<KeyType, CPDF_CountedObject<ValueType>*> &map, KeyType findKey, ValueType findValue, FX_BOOL bForce = FALSE)\r
-{\r
-    if (!findKey && !findValue) {\r
-        return FALSE;\r
-    }\r
-    CPDF_CountedObject<ValueType>* findData = NULL;\r
-    if (!findKey) {\r
-        findKey = PDF_DocPageData_FindValue<KeyType, ValueType>(map, findValue, findData);\r
-    } else if (!map.Lookup(findKey, findData)) {\r
-        return FALSE;\r
-    }\r
-    if (findData && ((-- findData->m_nCount) == 0 || bForce)) {\r
-        delete findData->m_Obj;\r
-        delete findData;\r
-        map.RemoveKey(findKey);\r
-        return TRUE;\r
-    }\r
-    return FALSE;\r
-}\r
-class CPDF_DocPageData : public CFX_Object\r
-{\r
-public:\r
-    CPDF_DocPageData(CPDF_Document *pPDFDoc);\r
-    ~CPDF_DocPageData();\r
-    void                                       Clear(FX_BOOL bRelease = FALSE);\r
-    CPDF_Font*                         GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly);\r
-    CPDF_Font*                         GetStandardFont(FX_BSTR fontName, CPDF_FontEncoding* pEncoding);\r
-    void                                       ReleaseFont(CPDF_Dictionary* pFontDict);\r
-    CPDF_ColorSpace*           GetColorSpace(CPDF_Object* pCSObj, CPDF_Dictionary* pResources);\r
-    CPDF_ColorSpace*           GetCopiedColorSpace(CPDF_Object* pCSObj);\r
-    void                                       ReleaseColorSpace(CPDF_Object* pColorSpace);\r
-    CPDF_Pattern*                      GetPattern(CPDF_Object* pPatternObj, FX_BOOL bShading, const CFX_AffineMatrix* matrix);\r
-    void                                       ReleasePattern(CPDF_Object* pPatternObj);\r
-    CPDF_Image*                                GetImage(CPDF_Object* pImageStream);\r
-    void                                       ReleaseImage(CPDF_Object* pImageStream);\r
-    CPDF_IccProfile*           GetIccProfile(CPDF_Stream* pIccProfileStream, FX_INT32 nComponents);\r
-    void                                       ReleaseIccProfile(CPDF_Stream* pIccProfileStream, CPDF_IccProfile* pIccProfile);\r
-    CPDF_StreamAcc*                    GetFontFileStreamAcc(CPDF_Stream* pFontStream);\r
-    void                                       ReleaseFontFileStreamAcc(CPDF_Stream* pFontStream, FX_BOOL bForce = FALSE);\r
-    CPDF_Document*                     m_pPDFDoc;\r
-    CPDF_FontMap                       m_FontMap;\r
-    CPDF_ColorSpaceMap         m_ColorSpaceMap;\r
-    CPDF_PatternMap                    m_PatternMap;\r
-    CPDF_ImageMap                      m_ImageMap;\r
-    CPDF_IccProfileMap         m_IccProfileMap;\r
-    CFX_MapByteStringToPtr     m_HashProfileMap;\r
-    CPDF_FontFileMap           m_FontFileMap;\r
-};\r
-class CPDF_Function : public CFX_Object\r
-{\r
-public:\r
-    static CPDF_Function*      Load(CPDF_Object* pFuncObj);\r
-    virtual ~CPDF_Function();\r
-    FX_BOOL            Call(FX_FLOAT* inputs, int ninputs, FX_FLOAT* results, int& nresults) const;\r
-    int                        CountInputs()\r
-    {\r
-        return m_nInputs;\r
-    }\r
-    int                        CountOutputs()\r
-    {\r
-        return m_nOutputs;\r
-    }\r
-protected:\r
-    CPDF_Function();\r
-    int                        m_nInputs, m_nOutputs;\r
-    FX_FLOAT*  m_pDomains;\r
-    FX_FLOAT*  m_pRanges;\r
-    FX_BOOL            Init(CPDF_Object* pObj);\r
-    virtual FX_BOOL    v_Init(CPDF_Object* pObj) = 0;\r
-    virtual FX_BOOL    v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const = 0;\r
-};\r
-class CPDF_IccProfile : public CFX_Object\r
-{\r
-public:\r
-    CPDF_IccProfile(FX_LPCBYTE pData, FX_DWORD dwSize, int nComponents);\r
-    ~CPDF_IccProfile();\r
-    FX_BOOL                                    m_bsRGB;\r
-    FX_LPVOID                          m_pTransform;\r
-};\r
-class CPDF_DeviceCS : public CPDF_ColorSpace\r
-{\r
-public:\r
-    CPDF_DeviceCS(int family);\r
-    virtual FX_BOOL    GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const;\r
-    FX_BOOL    SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const;\r
-    FX_BOOL    v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const;\r
-    FX_BOOL    v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k) const;\r
-    virtual void       TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const;\r
-};\r
-class CPDF_PatternCS : public CPDF_ColorSpace\r
-{\r
-public:\r
-    CPDF_PatternCS();\r
-    ~CPDF_PatternCS();\r
-    virtual FX_BOOL            v_Load(CPDF_Document* pDoc, CPDF_Array* pArray);\r
-    virtual FX_BOOL            GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const;\r
-    virtual CPDF_ColorSpace*   GetBaseCS() const\r
-    {\r
-        return m_pBaseCS;\r
-    }\r
-    CPDF_ColorSpace*   m_pBaseCS;\r
-};\r
-#define        MAX_PAGE_OBJECTS_UNIFY_NAMING                           4096\r
-class CPDF_ResourceNaming : public CFX_Object\r
-{\r
-public:\r
-    struct _NamingState : public CFX_Object {\r
-        CFX_ByteString m_Prefix;\r
-        int                            m_nIndex;\r
-    };\r
-    ~CPDF_ResourceNaming();\r
-    CFX_ByteString             GetName(const CPDF_Dictionary* pResList, FX_LPCSTR szType);\r
-protected:\r
-    CFX_MapByteStringToPtr     m_NamingCache;\r
-};\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 _PAGEINT_H_
+#define _PAGEINT_H_
+
+#include "../../../include/fpdfapi/fpdf_pageobj.h"
+#define PARSE_STEP_LIMIT               100
+#define STREAM_PARSE_BUFSIZE   20480
+class CPDF_QuickFontCache;
+#ifndef _FPDFAPI_MINI_
+class CPDF_StreamParser : public CFX_Object
+{
+public:
+
+    CPDF_StreamParser(const FX_BYTE* pData, FX_DWORD dwSize);
+    ~CPDF_StreamParser();
+
+    CPDF_Stream*               ReadInlineStream(CPDF_Document* pDoc, CPDF_Dictionary* pDict, CPDF_Object* pCSObj, FX_BOOL bDecode);
+    typedef enum { EndOfData, Number, Keyword, Name, Others } SyntaxType;
+
+    SyntaxType                 ParseNextElement();
+    FX_LPBYTE                  GetWordBuf()
+    {
+        return m_WordBuffer;
+    }
+    FX_DWORD                   GetWordSize()
+    {
+        return m_WordSize;
+    }
+    CPDF_Object*               GetObject()
+    {
+        CPDF_Object* pObj = m_pLastObj;
+        m_pLastObj = NULL;
+        return pObj;
+    }
+    FX_DWORD                   GetPos()
+    {
+        return m_Pos;
+    }
+    void                               SetPos(FX_DWORD pos)
+    {
+        m_Pos = pos;
+    }
+
+    CPDF_Object*               ReadNextObject(FX_BOOL bAllowNestedArray = FALSE, FX_BOOL bInArray = FALSE);
+    void                               SkipPathObject();
+protected:
+    void                               GetNextWord(FX_BOOL& bIsNumber);
+    CFX_ByteString             ReadString();
+    CFX_ByteString             ReadHexString();
+    const FX_BYTE*             m_pBuf;
+    FX_DWORD                   m_Size;
+    FX_DWORD                   m_Pos;
+    FX_BYTE                            m_WordBuffer[256];
+    FX_DWORD                   m_WordSize;
+    CPDF_Object*               m_pLastObj;
+};
+#endif
+typedef enum {
+    PDFOP_CloseFillStrokePath = 0, PDFOP_FillStrokePath,
+    PDFOP_CloseEOFillStrokePath, PDFOP_EOFillStrokePath,
+    PDFOP_BeginMarkedContent_Dictionary, PDFOP_BeginImage,
+    PDFOP_BeginMarkedContent, PDFOP_BeginText,
+    PDFOP_BeginSectionUndefined, PDFOP_CurveTo_123,
+    PDFOP_ConcatMatrix, PDFOP_SetColorSpace_Fill,
+    PDFOP_SetColorSpace_Stroke, PDFOP_SetDash,
+    PDFOP_SetCharWidth, PDFOP_SetCachedDevice,
+    PDFOP_ExecuteXObject, PDFOP_MarkPlace_Dictionary,
+    PDFOP_EndImage, PDFOP_EndMarkedContent,
+    PDFOP_EndText, PDFOP_EndSectionUndefined,
+    PDFOP_FillPath, PDFOP_FillPathOld,
+    PDFOP_EOFillPath, PDFOP_SetGray_Fill,
+    PDFOP_SetGray_Stroke, PDFOP_SetExtendGraphState,
+    PDFOP_ClosePath, PDFOP_SetFlat,
+    PDFOP_BeginImageData, PDFOP_SetLineJoin,
+    PDFOP_SetLineCap, PDFOP_SetCMYKColor_Fill,
+    PDFOP_SetCMYKColor_Stroke, PDFOP_LineTo,
+    PDFOP_MoveTo, PDFOP_SetMiterLimit,
+    PDFOP_MarkPlace, PDFOP_EndPath,
+    PDFOP_SaveGraphState, PDFOP_RestoreGraphState,
+    PDFOP_Rectangle, PDFOP_SetRGBColor_Fill,
+    PDFOP_SetRGBColor_Stroke, PDFOP_SetRenderIntent,
+    PDFOP_CloseStrokePath, PDFOP_StrokePath,
+    PDFOP_SetColor_Fill, PDFOP_SetColor_Stroke,
+    PDFOP_SetColorPS_Fill, PDFOP_SetColorPS_Stroke,
+    PDFOP_ShadeFill, PDFOP_SetCharSpace,
+    PDFOP_MoveTextPoint, PDFOP_MoveTextPoint_SetLeading,
+    PDFOP_SetFont, PDFOP_ShowText,
+    PDFOP_ShowText_Positioning, PDFOP_SetTextLeading,
+    PDFOP_SetTextMatrix, PDFOP_SetTextRenderMode,
+    PDFOP_SetTextRise, PDFOP_SetWordSpace,
+    PDFOP_SetHorzScale, PDFOP_MoveToNextLine,
+    PDFOP_CurveTo_23, PDFOP_SetLineWidth,
+    PDFOP_Clip, PDFOP_EOClip,
+    PDFOP_CurveTo_13, PDFOP_NextLineShowText,
+    PDFOP_NextLineShowText_Space, PDFOP_Invalid
+} PDFOP;
+#define PARAM_BUF_SIZE 16
+typedef struct {
+    int                        m_Type;
+    union {
+        struct {
+            FX_BOOL            m_bInteger;
+            union {
+                int            m_Integer;
+                FX_FLOAT m_Float;
+            };
+        } m_Number;
+        CPDF_Object*   m_pObject;
+        struct {
+            int                        m_Len;
+            char               m_Buffer[32];
+        } m_Name;
+    };
+} _ContentParam;
+#if defined(_FPDFAPI_MINI_)
+#define _FPDF_MAX_FORM_LEVEL_          17
+#else
+#define _FPDF_MAX_FORM_LEVEL_          30
+#endif
+#define _FPDF_MAX_TYPE3_FORM_LEVEL_    4
+#define _FPDF_MAX_OBJECT_STACK_SIZE_ 512
+class CPDF_StreamContentParser : public CFX_Object
+{
+public:
+    CPDF_StreamContentParser();
+    ~CPDF_StreamContentParser();
+    FX_BOOL Initialize();
+    void       PrepareParse(CPDF_Document* pDoc, CPDF_Dictionary* pPageResources, CPDF_Dictionary* pParentResources,
+                         CFX_AffineMatrix* pmtContentToUser,
+                         CPDF_PageObjects* pObjList, CPDF_Dictionary* pResources,
+                         CFX_FloatRect* pBBox, CPDF_ParseOptions* pOptions,
+                         CPDF_AllStates* pAllStates, int level);
+    CPDF_Document*             m_pDocument;
+    CPDF_Dictionary*   m_pPageResources;
+    CPDF_Dictionary*   m_pParentResources;
+    CPDF_PageObjects*  m_pObjectList;
+    CPDF_Dictionary*   m_pResources;
+    int                                        m_Level;
+    CFX_AffineMatrix   m_mtContentToUser;
+    CFX_FloatRect              m_BBox;
+    CPDF_ParseOptions  m_Options;
+    _ContentParam              m_ParamBuf1[PARAM_BUF_SIZE];
+    FX_DWORD                   m_ParamStartPos;
+    FX_DWORD                   m_ParamCount;
+    void                               AddNumberParam(FX_LPCSTR str, int len);
+    void                               AddObjectParam(CPDF_Object* pObj);
+    void                               AddNameParam(FX_LPCSTR name, int size);
+    int                                        GetNextParamPos();
+    void                               ClearAllParams();
+    CPDF_Object*               GetObject(FX_DWORD index);
+    CFX_ByteString             GetString(FX_DWORD index);
+    FX_FLOAT                   GetNumber(FX_DWORD index);
+    FX_FLOAT           GetNumber16(FX_DWORD index);
+    int                                        GetInteger(FX_DWORD index)
+    {
+        return (FX_INT32)(GetNumber(index));
+    }
+    FX_BOOL                            OnOperator(FX_LPCSTR op);
+    void                               BigCaseCaller(int index);
+    FX_BOOL                            m_bAbort;
+#ifndef _FPDFAPI_MINI_
+    CPDF_StreamParser* m_pSyntax;
+    FX_DWORD                   GetParsePos()
+    {
+        return m_pSyntax->GetPos();
+    }
+#else
+    int                                        m_WordState;
+    void                               InputData(FX_LPCBYTE src_buf, FX_DWORD src_size);
+    void                               Finish();
+    void                               StartArray();
+    void                               EndArray();
+    void                               StartDict();
+    void                               EndDict();
+    void                               EndName();
+    void                               EndNumber();
+    void                               EndKeyword();
+    void                               EndHexString();
+    void                               EndString();
+    void                               EndImageDict();
+    void                               EndInlineImage();
+    FX_LPBYTE                  m_pWordBuf;
+    FX_DWORD                   m_WordSize;
+    CFX_BinaryBuf              m_StringBuf;
+    int                                        m_StringLevel, m_StringState, m_EscCode;
+    void                               AddContainer(CPDF_Object* pObject);
+    FX_BOOL                            SetToCurObj(CPDF_Object* pObject);
+    FX_LPBYTE                  m_pDictName;
+    FX_BOOL                            m_bDictName;
+    CPDF_Object**              m_pObjectStack;
+    FX_BOOL*                   m_pObjectState;
+    FX_DWORD                   m_ObjectSize;
+    int                                        m_InlineImageState;
+    FX_BYTE                            m_InlineWhiteChar;
+    CFX_BinaryBuf              m_ImageSrcBuf;
+    FX_LPBYTE                  m_pStreamBuf;
+#endif
+    CPDF_AllStates*            m_pCurStates;
+    CPDF_ContentMark   m_CurContentMark;
+    CFX_PtrArray               m_ClipTextList;
+    CPDF_TextObject*   m_pLastTextObject;
+    FX_FLOAT                   m_DefFontSize;
+    void                               AddTextObject(CFX_ByteString* pText, FX_FLOAT fInitKerning, FX_FLOAT* pKerning, int count);
+
+    void                               ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y);
+    void                               ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y);
+    void                               OnChangeTextMatrix();
+#ifndef _FPDFAPI_MINI_
+    FX_DWORD                   Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_DWORD max_cost);
+    void                               ParsePathObject();
+#endif
+    int                                        m_CompatCount;
+    FX_PATHPOINT*              m_pPathPoints;
+    int                                        m_PathPointCount;
+    int                                        m_PathAllocSize;
+    FX_FLOAT                   m_PathStartX, m_PathStartY;
+    FX_FLOAT                   m_PathCurrentX, m_PathCurrentY;
+    int                                        m_PathClipType;
+    void                               AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag);
+    void                               AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h);
+    void                               AddPathObject(int FillType, FX_BOOL bStroke);
+    CPDF_ImageObject*  AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BOOL bInline);
+    void                               AddDuplicateImage();
+    void                               AddForm(CPDF_Stream*);
+    CFX_ByteString             m_LastImageName;
+    CPDF_Image*                        m_pLastImage;
+    CFX_BinaryBuf              m_LastImageDict, m_LastImageData;
+    CPDF_Dictionary*   m_pLastImageDict;
+    CPDF_Dictionary*    m_pLastCloneImageDict;
+    FX_BOOL                            m_bReleaseLastDict;
+    FX_BOOL                            m_bSameLastDict;
+    void                               SetGraphicStates(CPDF_PageObject* pObj, FX_BOOL bColor, FX_BOOL bText, FX_BOOL bGraph);
+    FX_BOOL                            m_bColored;
+    FX_FLOAT                   m_Type3Data[6];
+    FX_BOOL                            m_bResourceMissing;
+    CFX_PtrArray               m_StateStack;
+    void                               SaveStates(CPDF_AllStates*);
+    void                               RestoreStates(CPDF_AllStates*);
+    CPDF_Font*                 FindFont(const CFX_ByteString& name);
+    CPDF_ColorSpace*   FindColorSpace(const CFX_ByteString& name);
+    CPDF_Pattern*              FindPattern(const CFX_ByteString& name, FX_BOOL bShading);
+    CPDF_Object*               FindResourceObj(FX_BSTR type, const CFX_ByteString& name);
+    void Handle_CloseFillStrokePath();
+    void Handle_FillStrokePath();
+    void Handle_CloseEOFillStrokePath();
+    void Handle_EOFillStrokePath();
+    void Handle_BeginMarkedContent_Dictionary();
+    void Handle_BeginImage();
+    void Handle_BeginMarkedContent();
+    void Handle_BeginText();
+    void Handle_BeginSectionUndefined();
+    void Handle_CurveTo_123();
+    void Handle_ConcatMatrix();
+    void Handle_SetColorSpace_Fill();
+    void Handle_SetColorSpace_Stroke();
+    void Handle_SetDash();
+    void Handle_SetCharWidth();
+    void Handle_SetCachedDevice();
+    void Handle_ExecuteXObject();
+    void Handle_MarkPlace_Dictionary();
+    void Handle_EndImage();
+    void Handle_EndMarkedContent();
+    void Handle_EndText();
+    void Handle_EndSectionUndefined();
+    void Handle_FillPath();
+    void Handle_FillPathOld();
+    void Handle_EOFillPath();
+    void Handle_SetGray_Fill();
+    void Handle_SetGray_Stroke();
+    void Handle_SetExtendGraphState();
+    void Handle_ClosePath();
+    void Handle_SetFlat();
+    void Handle_BeginImageData();
+    void Handle_SetLineJoin();
+    void Handle_SetLineCap();
+    void Handle_SetCMYKColor_Fill();
+    void Handle_SetCMYKColor_Stroke();
+    void Handle_LineTo();
+    void Handle_MoveTo();
+    void Handle_SetMiterLimit();
+    void Handle_MarkPlace();
+    void Handle_EndPath();
+    void Handle_SaveGraphState();
+    void Handle_RestoreGraphState();
+    void Handle_Rectangle();
+    void Handle_SetRGBColor_Fill();
+    void Handle_SetRGBColor_Stroke();
+    void Handle_SetRenderIntent();
+    void Handle_CloseStrokePath();
+    void Handle_StrokePath();
+    void Handle_SetColor_Fill();
+    void Handle_SetColor_Stroke();
+    void Handle_SetColorPS_Fill();
+    void Handle_SetColorPS_Stroke();
+    void Handle_ShadeFill();
+    void Handle_SetCharSpace();
+    void Handle_MoveTextPoint();
+    void Handle_MoveTextPoint_SetLeading();
+    void Handle_SetFont();
+    void Handle_ShowText();
+    void Handle_ShowText_Positioning();
+    void Handle_SetTextLeading();
+    void Handle_SetTextMatrix();
+    void Handle_SetTextRenderMode();
+    void Handle_SetTextRise();
+    void Handle_SetWordSpace();
+    void Handle_SetHorzScale();
+    void Handle_MoveToNextLine();
+    void Handle_CurveTo_23();
+    void Handle_SetLineWidth();
+    void Handle_Clip();
+    void Handle_EOClip();
+    void Handle_CurveTo_13();
+    void Handle_NextLineShowText();
+    void Handle_NextLineShowText_Space();
+    void Handle_Invalid();
+};
+class CPDF_ContentParser : public CFX_Object
+{
+public:
+    CPDF_ContentParser();
+    ~CPDF_ContentParser();
+    typedef enum { Ready, ToBeContinued, Done } ParseStatus;
+    ParseStatus                        GetStatus()
+    {
+        return m_Status;
+    }
+    void                               Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions);
+    void                               Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
+                              CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level);
+    void                               Continue(IFX_Pause* pPause);
+    int                                        EstimateProgress();
+protected:
+    void                               Clear();
+    ParseStatus                        m_Status;
+    CPDF_PageObjects*  m_pObjects;
+    FX_BOOL                            m_bForm;
+    CPDF_ParseOptions  m_Options;
+    CPDF_Type3Char*            m_pType3Char;
+    int                                        m_InternalStage;
+    CPDF_StreamAcc*            m_pSingleStream;
+    CPDF_StreamAcc**   m_pStreamArray;
+    FX_DWORD                   m_nStreams;
+    FX_LPBYTE                  m_pData;
+    FX_DWORD                   m_Size;
+    class CPDF_StreamContentParser*    m_pParser;
+    FX_DWORD                   m_CurrentOffset;
+    CPDF_StreamFilter* m_pStreamFilter;
+};
+class CPDF_AllStates : public CPDF_GraphicStates
+{
+public:
+    CPDF_AllStates();
+    ~CPDF_AllStates();
+    void       Copy(const CPDF_AllStates& src);
+    void       ProcessExtGS(CPDF_Dictionary* pGS, CPDF_StreamContentParser* pParser);
+    void       SetLineDash(CPDF_Array*, FX_FLOAT, FX_FLOAT scale);
+    CFX_AffineMatrix           m_TextMatrix, m_CTM, m_ParentMatrix;
+    FX_FLOAT                           m_TextX, m_TextY, m_TextLineX, m_TextLineY;
+    FX_FLOAT                           m_TextLeading, m_TextRise, m_TextHorzScale;
+};
+template <class ObjClass> class CPDF_CountedObject : public CFX_Object
+{
+public:
+    ObjClass   m_Obj;
+    FX_DWORD   m_nCount;
+};
+typedef CFX_MapPtrTemplate<CPDF_Dictionary*, CPDF_CountedObject<CPDF_Font*>*>          CPDF_FontMap;
+typedef CFX_MapPtrTemplate<CPDF_Object*, CPDF_CountedObject<CPDF_ColorSpace*>*>                CPDF_ColorSpaceMap;
+typedef CFX_MapPtrTemplate<CPDF_Object*, CPDF_CountedObject<CPDF_Pattern*>*>           CPDF_PatternMap;
+typedef CFX_MapPtrTemplate<FX_DWORD, CPDF_CountedObject<CPDF_Image*>*>                         CPDF_ImageMap;
+typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedObject<CPDF_IccProfile*>*>                CPDF_IccProfileMap;
+typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedObject<CPDF_StreamAcc*>*>         CPDF_FontFileMap;
+template <class KeyType, class ValueType>
+KeyType PDF_DocPageData_FindValue(const CFX_MapPtrTemplate<KeyType, CPDF_CountedObject<ValueType>*> &map, ValueType findValue, CPDF_CountedObject<ValueType>*& findData)
+{
+    FX_POSITION pos = map.GetStartPosition();
+    while (pos) {
+        KeyType findKey;
+        map.GetNextAssoc(pos, findKey, findData);
+        if (findData->m_Obj == findValue) {
+            return findKey;
+        }
+    }
+    findData = NULL;
+    return (KeyType)(FX_UINTPTR)NULL;
+}
+template <class KeyType, class ValueType>
+FX_BOOL PDF_DocPageData_Release(CFX_MapPtrTemplate<KeyType, CPDF_CountedObject<ValueType>*> &map, KeyType findKey, ValueType findValue, FX_BOOL bForce = FALSE)
+{
+    if (!findKey && !findValue) {
+        return FALSE;
+    }
+    CPDF_CountedObject<ValueType>* findData = NULL;
+    if (!findKey) {
+        findKey = PDF_DocPageData_FindValue<KeyType, ValueType>(map, findValue, findData);
+    } else if (!map.Lookup(findKey, findData)) {
+        return FALSE;
+    }
+    if (findData && ((-- findData->m_nCount) == 0 || bForce)) {
+        delete findData->m_Obj;
+        delete findData;
+        map.RemoveKey(findKey);
+        return TRUE;
+    }
+    return FALSE;
+}
+class CPDF_DocPageData : public CFX_Object
+{
+public:
+    CPDF_DocPageData(CPDF_Document *pPDFDoc);
+    ~CPDF_DocPageData();
+    void                        Clear(FX_BOOL bRelease = FALSE);
+    CPDF_Font*                  GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly);
+    CPDF_Font*                  GetStandardFont(FX_BSTR fontName, CPDF_FontEncoding* pEncoding);
+    void                        ReleaseFont(CPDF_Dictionary* pFontDict);
+    CPDF_ColorSpace*            GetColorSpace(CPDF_Object* pCSObj, CPDF_Dictionary* pResources);
+    CPDF_ColorSpace*            GetCopiedColorSpace(CPDF_Object* pCSObj);
+    void                        ReleaseColorSpace(CPDF_Object* pColorSpace);
+    CPDF_Pattern*               GetPattern(CPDF_Object* pPatternObj, FX_BOOL bShading, const CFX_AffineMatrix* matrix);
+    void                        ReleasePattern(CPDF_Object* pPatternObj);
+    CPDF_Image*                 GetImage(CPDF_Object* pImageStream);
+    void                        ReleaseImage(CPDF_Object* pImageStream);
+    CPDF_IccProfile*            GetIccProfile(CPDF_Stream* pIccProfileStream, FX_INT32 nComponents);
+    void                        ReleaseIccProfile(CPDF_Stream* pIccProfileStream, CPDF_IccProfile* pIccProfile);
+    CPDF_StreamAcc*             GetFontFileStreamAcc(CPDF_Stream* pFontStream);
+    void                        ReleaseFontFileStreamAcc(CPDF_Stream* pFontStream, FX_BOOL bForce = FALSE);
+    FX_BOOL                     IsForceClear() const {return m_bForceClear;}
+
+    CPDF_Document*              m_pPDFDoc;
+    CPDF_FontMap                m_FontMap;
+    CPDF_ColorSpaceMap          m_ColorSpaceMap;
+    CPDF_PatternMap             m_PatternMap;
+    CPDF_ImageMap               m_ImageMap;
+    CPDF_IccProfileMap          m_IccProfileMap;
+    CFX_MapByteStringToPtr      m_HashProfileMap;
+    CPDF_FontFileMap            m_FontFileMap;
+    FX_BOOL                     m_bForceClear;
+};
+class CPDF_Function : public CFX_Object
+{
+public:
+    static CPDF_Function*      Load(CPDF_Object* pFuncObj);
+    virtual ~CPDF_Function();
+    FX_BOOL            Call(FX_FLOAT* inputs, int ninputs, FX_FLOAT* results, int& nresults) const;
+    int                        CountInputs()
+    {
+        return m_nInputs;
+    }
+    int                        CountOutputs()
+    {
+        return m_nOutputs;
+    }
+protected:
+    CPDF_Function();
+    int                        m_nInputs, m_nOutputs;
+    FX_FLOAT*  m_pDomains;
+    FX_FLOAT*  m_pRanges;
+    FX_BOOL            Init(CPDF_Object* pObj);
+    virtual FX_BOOL    v_Init(CPDF_Object* pObj) = 0;
+    virtual FX_BOOL    v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const = 0;
+};
+class CPDF_IccProfile : public CFX_Object
+{
+public:
+    CPDF_IccProfile(FX_LPCBYTE pData, FX_DWORD dwSize, int nComponents);
+    ~CPDF_IccProfile();
+    FX_BOOL                                    m_bsRGB;
+    FX_LPVOID                          m_pTransform;
+};
+class CPDF_DeviceCS : public CPDF_ColorSpace
+{
+public:
+    CPDF_DeviceCS(int family);
+    virtual FX_BOOL    GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const;
+    FX_BOOL    SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const;
+    FX_BOOL    v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const;
+    FX_BOOL    v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k) const;
+    virtual void       TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const;
+};
+class CPDF_PatternCS : public CPDF_ColorSpace
+{
+public:
+    CPDF_PatternCS();
+    ~CPDF_PatternCS();
+    virtual FX_BOOL            v_Load(CPDF_Document* pDoc, CPDF_Array* pArray);
+    virtual FX_BOOL            GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const;
+    virtual CPDF_ColorSpace*   GetBaseCS() const
+    {
+        return m_pBaseCS;
+    }
+    CPDF_ColorSpace*   m_pBaseCS;
+};
+#define        MAX_PAGE_OBJECTS_UNIFY_NAMING                           4096
+class CPDF_ResourceNaming : public CFX_Object
+{
+public:
+    struct _NamingState : public CFX_Object {
+        CFX_ByteString m_Prefix;
+        int                            m_nIndex;
+    };
+    ~CPDF_ResourceNaming();
+    CFX_ByteString             GetName(const CPDF_Dictionary* pResList, FX_LPCSTR szType);
+protected:
+    CFX_MapByteStringToPtr     m_NamingCache;
+};
+
+#endif  // _PAGEINT_H_