Home | History | Annotate | Download | only in fpdf_page
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #include "../../../include/fpdfapi/fpdf_pageobj.h"
      8 #define PARSE_STEP_LIMIT		100
      9 #define STREAM_PARSE_BUFSIZE	20480
     10 class CPDF_QuickFontCache;
     11 #ifndef _FPDFAPI_MINI_
     12 class CPDF_StreamParser : public CFX_Object
     13 {
     14 public:
     15 
     16     CPDF_StreamParser(const FX_BYTE* pData, FX_DWORD dwSize);
     17     ~CPDF_StreamParser();
     18 
     19     CPDF_Stream*		ReadInlineStream(CPDF_Document* pDoc, CPDF_Dictionary* pDict, CPDF_Object* pCSObj, FX_BOOL bDecode);
     20     typedef enum { EndOfData, Number, Keyword, Name, Others } SyntaxType;
     21 
     22     SyntaxType			ParseNextElement();
     23     FX_LPBYTE			GetWordBuf()
     24     {
     25         return m_WordBuffer;
     26     }
     27     FX_DWORD			GetWordSize()
     28     {
     29         return m_WordSize;
     30     }
     31     CPDF_Object*		GetObject()
     32     {
     33         CPDF_Object* pObj = m_pLastObj;
     34         m_pLastObj = NULL;
     35         return pObj;
     36     }
     37     FX_DWORD			GetPos()
     38     {
     39         return m_Pos;
     40     }
     41     void				SetPos(FX_DWORD pos)
     42     {
     43         m_Pos = pos;
     44     }
     45 
     46     CPDF_Object*		ReadNextObject(FX_BOOL bAllowNestedArray = FALSE, FX_BOOL bInArray = FALSE);
     47     void				SkipPathObject();
     48 protected:
     49     void				GetNextWord(FX_BOOL& bIsNumber);
     50     CFX_ByteString		ReadString();
     51     CFX_ByteString		ReadHexString();
     52     const FX_BYTE*		m_pBuf;
     53     FX_DWORD			m_Size;
     54     FX_DWORD			m_Pos;
     55     FX_BYTE				m_WordBuffer[256];
     56     FX_DWORD			m_WordSize;
     57     CPDF_Object*		m_pLastObj;
     58 };
     59 #endif
     60 typedef enum {
     61     PDFOP_CloseFillStrokePath = 0, PDFOP_FillStrokePath,
     62     PDFOP_CloseEOFillStrokePath, PDFOP_EOFillStrokePath,
     63     PDFOP_BeginMarkedContent_Dictionary, PDFOP_BeginImage,
     64     PDFOP_BeginMarkedContent, PDFOP_BeginText,
     65     PDFOP_BeginSectionUndefined, PDFOP_CurveTo_123,
     66     PDFOP_ConcatMatrix, PDFOP_SetColorSpace_Fill,
     67     PDFOP_SetColorSpace_Stroke, PDFOP_SetDash,
     68     PDFOP_SetCharWidth, PDFOP_SetCachedDevice,
     69     PDFOP_ExecuteXObject, PDFOP_MarkPlace_Dictionary,
     70     PDFOP_EndImage, PDFOP_EndMarkedContent,
     71     PDFOP_EndText, PDFOP_EndSectionUndefined,
     72     PDFOP_FillPath, PDFOP_FillPathOld,
     73     PDFOP_EOFillPath, PDFOP_SetGray_Fill,
     74     PDFOP_SetGray_Stroke, PDFOP_SetExtendGraphState,
     75     PDFOP_ClosePath, PDFOP_SetFlat,
     76     PDFOP_BeginImageData, PDFOP_SetLineJoin,
     77     PDFOP_SetLineCap, PDFOP_SetCMYKColor_Fill,
     78     PDFOP_SetCMYKColor_Stroke, PDFOP_LineTo,
     79     PDFOP_MoveTo, PDFOP_SetMiterLimit,
     80     PDFOP_MarkPlace, PDFOP_EndPath,
     81     PDFOP_SaveGraphState, PDFOP_RestoreGraphState,
     82     PDFOP_Rectangle, PDFOP_SetRGBColor_Fill,
     83     PDFOP_SetRGBColor_Stroke, PDFOP_SetRenderIntent,
     84     PDFOP_CloseStrokePath, PDFOP_StrokePath,
     85     PDFOP_SetColor_Fill, PDFOP_SetColor_Stroke,
     86     PDFOP_SetColorPS_Fill, PDFOP_SetColorPS_Stroke,
     87     PDFOP_ShadeFill, PDFOP_SetCharSpace,
     88     PDFOP_MoveTextPoint, PDFOP_MoveTextPoint_SetLeading,
     89     PDFOP_SetFont, PDFOP_ShowText,
     90     PDFOP_ShowText_Positioning, PDFOP_SetTextLeading,
     91     PDFOP_SetTextMatrix, PDFOP_SetTextRenderMode,
     92     PDFOP_SetTextRise, PDFOP_SetWordSpace,
     93     PDFOP_SetHorzScale, PDFOP_MoveToNextLine,
     94     PDFOP_CurveTo_23, PDFOP_SetLineWidth,
     95     PDFOP_Clip, PDFOP_EOClip,
     96     PDFOP_CurveTo_13, PDFOP_NextLineShowText,
     97     PDFOP_NextLineShowText_Space, PDFOP_Invalid
     98 } PDFOP;
     99 #define PARAM_BUF_SIZE	16
    100 typedef struct {
    101     int			m_Type;
    102     union {
    103         struct {
    104             FX_BOOL		m_bInteger;
    105             union {
    106                 int		m_Integer;
    107                 FX_FLOAT m_Float;
    108             };
    109         } m_Number;
    110         CPDF_Object*	m_pObject;
    111         struct {
    112             int			m_Len;
    113             char		m_Buffer[32];
    114         } m_Name;
    115     };
    116 } _ContentParam;
    117 #if defined(_FPDFAPI_MINI_)
    118 #define _FPDF_MAX_FORM_LEVEL_		17
    119 #else
    120 #define _FPDF_MAX_FORM_LEVEL_		30
    121 #endif
    122 #define _FPDF_MAX_TYPE3_FORM_LEVEL_	4
    123 #define _FPDF_MAX_OBJECT_STACK_SIZE_ 512
    124 class CPDF_StreamContentParser : public CFX_Object
    125 {
    126 public:
    127     CPDF_StreamContentParser();
    128     ~CPDF_StreamContentParser();
    129     FX_BOOL Initialize();
    130     void	PrepareParse(CPDF_Document* pDoc, CPDF_Dictionary* pPageResources, CPDF_Dictionary* pParentResources,
    131                          CFX_AffineMatrix* pmtContentToUser,
    132                          CPDF_PageObjects* pObjList, CPDF_Dictionary* pResources,
    133                          CFX_FloatRect* pBBox, CPDF_ParseOptions* pOptions,
    134                          CPDF_AllStates* pAllStates, int level);
    135     CPDF_Document*		m_pDocument;
    136     CPDF_Dictionary*	m_pPageResources;
    137     CPDF_Dictionary*	m_pParentResources;
    138     CPDF_PageObjects*	m_pObjectList;
    139     CPDF_Dictionary*	m_pResources;
    140     int					m_Level;
    141     CFX_AffineMatrix	m_mtContentToUser;
    142     CFX_FloatRect		m_BBox;
    143     CPDF_ParseOptions	m_Options;
    144     _ContentParam		m_ParamBuf1[PARAM_BUF_SIZE];
    145     FX_DWORD			m_ParamStartPos;
    146     FX_DWORD			m_ParamCount;
    147     void				AddNumberParam(FX_LPCSTR str, int len);
    148     void				AddObjectParam(CPDF_Object* pObj);
    149     void				AddNameParam(FX_LPCSTR name, int size);
    150     int					GetNextParamPos();
    151     void				ClearAllParams();
    152     CPDF_Object*		GetObject(FX_DWORD index);
    153     CFX_ByteString		GetString(FX_DWORD index);
    154     FX_FLOAT			GetNumber(FX_DWORD index);
    155     FX_FLOAT		GetNumber16(FX_DWORD index);
    156     int					GetInteger(FX_DWORD index)
    157     {
    158         return (FX_INT32)(GetNumber(index));
    159     }
    160     FX_BOOL				OnOperator(FX_LPCSTR op);
    161     void				BigCaseCaller(int index);
    162     FX_BOOL				m_bAbort;
    163 #ifndef _FPDFAPI_MINI_
    164     CPDF_StreamParser*	m_pSyntax;
    165     FX_DWORD			GetParsePos()
    166     {
    167         return m_pSyntax->GetPos();
    168     }
    169 #else
    170     int					m_WordState;
    171     void				InputData(FX_LPCBYTE src_buf, FX_DWORD src_size);
    172     void				Finish();
    173     void				StartArray();
    174     void				EndArray();
    175     void				StartDict();
    176     void				EndDict();
    177     void				EndName();
    178     void				EndNumber();
    179     void				EndKeyword();
    180     void				EndHexString();
    181     void				EndString();
    182     void				EndImageDict();
    183     void				EndInlineImage();
    184     FX_LPBYTE			m_pWordBuf;
    185     FX_DWORD			m_WordSize;
    186     CFX_BinaryBuf		m_StringBuf;
    187     int					m_StringLevel, m_StringState, m_EscCode;
    188     void				AddContainer(CPDF_Object* pObject);
    189     FX_BOOL				SetToCurObj(CPDF_Object* pObject);
    190     FX_LPBYTE			m_pDictName;
    191     FX_BOOL				m_bDictName;
    192     CPDF_Object**		m_pObjectStack;
    193     FX_BOOL*			m_pObjectState;
    194     FX_DWORD			m_ObjectSize;
    195     int					m_InlineImageState;
    196     FX_BYTE				m_InlineWhiteChar;
    197     CFX_BinaryBuf		m_ImageSrcBuf;
    198     FX_LPBYTE			m_pStreamBuf;
    199 #endif
    200     CPDF_AllStates*		m_pCurStates;
    201     CPDF_ContentMark	m_CurContentMark;
    202     CFX_PtrArray		m_ClipTextList;
    203     CPDF_TextObject*	m_pLastTextObject;
    204     FX_FLOAT			m_DefFontSize;
    205     void				AddTextObject(CFX_ByteString* pText, FX_FLOAT fInitKerning, FX_FLOAT* pKerning, int count);
    206 
    207     void				ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y);
    208     void				ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y);
    209     void				OnChangeTextMatrix();
    210 #ifndef _FPDFAPI_MINI_
    211     FX_DWORD			Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_DWORD max_cost);
    212     void				ParsePathObject();
    213 #endif
    214     int					m_CompatCount;
    215     FX_PATHPOINT*		m_pPathPoints;
    216     int					m_PathPointCount;
    217     int					m_PathAllocSize;
    218     FX_FLOAT			m_PathStartX, m_PathStartY;
    219     FX_FLOAT			m_PathCurrentX, m_PathCurrentY;
    220     int					m_PathClipType;
    221     void				AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag);
    222     void				AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h);
    223     void				AddPathObject(int FillType, FX_BOOL bStroke);
    224     CPDF_ImageObject*	AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BOOL bInline);
    225     void				AddDuplicateImage();
    226     void				AddForm(CPDF_Stream*);
    227     CFX_ByteString		m_LastImageName;
    228     CPDF_Image*			m_pLastImage;
    229     CFX_BinaryBuf		m_LastImageDict, m_LastImageData;
    230     CPDF_Dictionary*	m_pLastImageDict;
    231     CPDF_Dictionary*    m_pLastCloneImageDict;
    232     FX_BOOL				m_bReleaseLastDict;
    233     FX_BOOL				m_bSameLastDict;
    234     void				SetGraphicStates(CPDF_PageObject* pObj, FX_BOOL bColor, FX_BOOL bText, FX_BOOL bGraph);
    235     FX_BOOL				m_bColored;
    236     FX_FLOAT			m_Type3Data[6];
    237     FX_BOOL				m_bResourceMissing;
    238     CFX_PtrArray		m_StateStack;
    239     void				SaveStates(CPDF_AllStates*);
    240     void				RestoreStates(CPDF_AllStates*);
    241     CPDF_Font*			FindFont(const CFX_ByteString& name);
    242     CPDF_ColorSpace*	FindColorSpace(const CFX_ByteString& name);
    243     CPDF_Pattern*		FindPattern(const CFX_ByteString& name, FX_BOOL bShading);
    244     CPDF_Object*		FindResourceObj(FX_BSTR type, const CFX_ByteString& name);
    245     void Handle_CloseFillStrokePath();
    246     void Handle_FillStrokePath();
    247     void Handle_CloseEOFillStrokePath();
    248     void Handle_EOFillStrokePath();
    249     void Handle_BeginMarkedContent_Dictionary();
    250     void Handle_BeginImage();
    251     void Handle_BeginMarkedContent();
    252     void Handle_BeginText();
    253     void Handle_BeginSectionUndefined();
    254     void Handle_CurveTo_123();
    255     void Handle_ConcatMatrix();
    256     void Handle_SetColorSpace_Fill();
    257     void Handle_SetColorSpace_Stroke();
    258     void Handle_SetDash();
    259     void Handle_SetCharWidth();
    260     void Handle_SetCachedDevice();
    261     void Handle_ExecuteXObject();
    262     void Handle_MarkPlace_Dictionary();
    263     void Handle_EndImage();
    264     void Handle_EndMarkedContent();
    265     void Handle_EndText();
    266     void Handle_EndSectionUndefined();
    267     void Handle_FillPath();
    268     void Handle_FillPathOld();
    269     void Handle_EOFillPath();
    270     void Handle_SetGray_Fill();
    271     void Handle_SetGray_Stroke();
    272     void Handle_SetExtendGraphState();
    273     void Handle_ClosePath();
    274     void Handle_SetFlat();
    275     void Handle_BeginImageData();
    276     void Handle_SetLineJoin();
    277     void Handle_SetLineCap();
    278     void Handle_SetCMYKColor_Fill();
    279     void Handle_SetCMYKColor_Stroke();
    280     void Handle_LineTo();
    281     void Handle_MoveTo();
    282     void Handle_SetMiterLimit();
    283     void Handle_MarkPlace();
    284     void Handle_EndPath();
    285     void Handle_SaveGraphState();
    286     void Handle_RestoreGraphState();
    287     void Handle_Rectangle();
    288     void Handle_SetRGBColor_Fill();
    289     void Handle_SetRGBColor_Stroke();
    290     void Handle_SetRenderIntent();
    291     void Handle_CloseStrokePath();
    292     void Handle_StrokePath();
    293     void Handle_SetColor_Fill();
    294     void Handle_SetColor_Stroke();
    295     void Handle_SetColorPS_Fill();
    296     void Handle_SetColorPS_Stroke();
    297     void Handle_ShadeFill();
    298     void Handle_SetCharSpace();
    299     void Handle_MoveTextPoint();
    300     void Handle_MoveTextPoint_SetLeading();
    301     void Handle_SetFont();
    302     void Handle_ShowText();
    303     void Handle_ShowText_Positioning();
    304     void Handle_SetTextLeading();
    305     void Handle_SetTextMatrix();
    306     void Handle_SetTextRenderMode();
    307     void Handle_SetTextRise();
    308     void Handle_SetWordSpace();
    309     void Handle_SetHorzScale();
    310     void Handle_MoveToNextLine();
    311     void Handle_CurveTo_23();
    312     void Handle_SetLineWidth();
    313     void Handle_Clip();
    314     void Handle_EOClip();
    315     void Handle_CurveTo_13();
    316     void Handle_NextLineShowText();
    317     void Handle_NextLineShowText_Space();
    318     void Handle_Invalid();
    319 };
    320 class CPDF_ContentParser : public CFX_Object
    321 {
    322 public:
    323     CPDF_ContentParser();
    324     ~CPDF_ContentParser();
    325     typedef enum { Ready, ToBeContinued, Done } ParseStatus;
    326     ParseStatus			GetStatus()
    327     {
    328         return m_Status;
    329     }
    330     void				Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions);
    331     void				Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
    332                               CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level);
    333     void				Continue(IFX_Pause* pPause);
    334     int					EstimateProgress();
    335 protected:
    336     void				Clear();
    337     ParseStatus			m_Status;
    338     CPDF_PageObjects*	m_pObjects;
    339     FX_BOOL				m_bForm;
    340     CPDF_ParseOptions	m_Options;
    341     CPDF_Type3Char*		m_pType3Char;
    342     int					m_InternalStage;
    343     CPDF_StreamAcc*		m_pSingleStream;
    344     CPDF_StreamAcc**	m_pStreamArray;
    345     FX_DWORD			m_nStreams;
    346     FX_LPBYTE			m_pData;
    347     FX_DWORD			m_Size;
    348     class CPDF_StreamContentParser*	m_pParser;
    349     FX_DWORD			m_CurrentOffset;
    350     CPDF_StreamFilter*	m_pStreamFilter;
    351 };
    352 class CPDF_AllStates : public CPDF_GraphicStates
    353 {
    354 public:
    355     CPDF_AllStates();
    356     ~CPDF_AllStates();
    357     void	Copy(const CPDF_AllStates& src);
    358     void	ProcessExtGS(CPDF_Dictionary* pGS, CPDF_StreamContentParser* pParser);
    359     void	SetLineDash(CPDF_Array*, FX_FLOAT, FX_FLOAT scale);
    360     CFX_AffineMatrix		m_TextMatrix, m_CTM, m_ParentMatrix;
    361     FX_FLOAT				m_TextX, m_TextY, m_TextLineX, m_TextLineY;
    362     FX_FLOAT				m_TextLeading, m_TextRise, m_TextHorzScale;
    363 };
    364 template <class ObjClass> class CPDF_CountedObject : public CFX_Object
    365 {
    366 public:
    367     ObjClass	m_Obj;
    368     FX_DWORD	m_nCount;
    369 };
    370 typedef CFX_MapPtrTemplate<CPDF_Dictionary*, CPDF_CountedObject<CPDF_Font*>*>		CPDF_FontMap;
    371 typedef CFX_MapPtrTemplate<CPDF_Object*, CPDF_CountedObject<CPDF_ColorSpace*>*>		CPDF_ColorSpaceMap;
    372 typedef CFX_MapPtrTemplate<CPDF_Object*, CPDF_CountedObject<CPDF_Pattern*>*>		CPDF_PatternMap;
    373 typedef CFX_MapPtrTemplate<FX_DWORD, CPDF_CountedObject<CPDF_Image*>*>				CPDF_ImageMap;
    374 typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedObject<CPDF_IccProfile*>*>		CPDF_IccProfileMap;
    375 typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedObject<CPDF_StreamAcc*>*>		CPDF_FontFileMap;
    376 template <class KeyType, class ValueType>
    377 KeyType PDF_DocPageData_FindValue(const CFX_MapPtrTemplate<KeyType, CPDF_CountedObject<ValueType>*> &map, ValueType findValue, CPDF_CountedObject<ValueType>*& findData)
    378 {
    379     FX_POSITION pos = map.GetStartPosition();
    380     while (pos) {
    381         KeyType findKey;
    382         map.GetNextAssoc(pos, findKey, findData);
    383         if (findData->m_Obj == findValue) {
    384             return findKey;
    385         }
    386     }
    387     findData = NULL;
    388     return (KeyType)(FX_UINTPTR)NULL;
    389 }
    390 template <class KeyType, class ValueType>
    391 FX_BOOL PDF_DocPageData_Release(CFX_MapPtrTemplate<KeyType, CPDF_CountedObject<ValueType>*> &map, KeyType findKey, ValueType findValue, FX_BOOL bForce = FALSE)
    392 {
    393     if (!findKey && !findValue) {
    394         return FALSE;
    395     }
    396     CPDF_CountedObject<ValueType>* findData = NULL;
    397     if (!findKey) {
    398         findKey = PDF_DocPageData_FindValue<KeyType, ValueType>(map, findValue, findData);
    399     } else if (!map.Lookup(findKey, findData)) {
    400         return FALSE;
    401     }
    402     if (findData && ((-- findData->m_nCount) == 0 || bForce)) {
    403         delete findData->m_Obj;
    404         delete findData;
    405         map.RemoveKey(findKey);
    406         return TRUE;
    407     }
    408     return FALSE;
    409 }
    410 class CPDF_DocPageData : public CFX_Object
    411 {
    412 public:
    413     CPDF_DocPageData(CPDF_Document *pPDFDoc);
    414     ~CPDF_DocPageData();
    415     void					Clear(FX_BOOL bRelease = FALSE);
    416     CPDF_Font*				GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly);
    417     CPDF_Font*				GetStandardFont(FX_BSTR fontName, CPDF_FontEncoding* pEncoding);
    418     void					ReleaseFont(CPDF_Dictionary* pFontDict);
    419     CPDF_ColorSpace*		GetColorSpace(CPDF_Object* pCSObj, CPDF_Dictionary* pResources);
    420     CPDF_ColorSpace*		GetCopiedColorSpace(CPDF_Object* pCSObj);
    421     void					ReleaseColorSpace(CPDF_Object* pColorSpace);
    422     CPDF_Pattern*			GetPattern(CPDF_Object* pPatternObj, FX_BOOL bShading, const CFX_AffineMatrix* matrix);
    423     void					ReleasePattern(CPDF_Object* pPatternObj);
    424     CPDF_Image*				GetImage(CPDF_Object* pImageStream);
    425     void					ReleaseImage(CPDF_Object* pImageStream);
    426     CPDF_IccProfile*		GetIccProfile(CPDF_Stream* pIccProfileStream, FX_INT32 nComponents);
    427     void					ReleaseIccProfile(CPDF_Stream* pIccProfileStream, CPDF_IccProfile* pIccProfile);
    428     CPDF_StreamAcc*			GetFontFileStreamAcc(CPDF_Stream* pFontStream);
    429     void					ReleaseFontFileStreamAcc(CPDF_Stream* pFontStream, FX_BOOL bForce = FALSE);
    430     CPDF_Document*			m_pPDFDoc;
    431     CPDF_FontMap			m_FontMap;
    432     CPDF_ColorSpaceMap		m_ColorSpaceMap;
    433     CPDF_PatternMap			m_PatternMap;
    434     CPDF_ImageMap			m_ImageMap;
    435     CPDF_IccProfileMap		m_IccProfileMap;
    436     CFX_MapByteStringToPtr	m_HashProfileMap;
    437     CPDF_FontFileMap		m_FontFileMap;
    438 };
    439 class CPDF_Function : public CFX_Object
    440 {
    441 public:
    442     static CPDF_Function*	Load(CPDF_Object* pFuncObj);
    443     virtual ~CPDF_Function();
    444     FX_BOOL		Call(FX_FLOAT* inputs, int ninputs, FX_FLOAT* results, int& nresults) const;
    445     int			CountInputs()
    446     {
    447         return m_nInputs;
    448     }
    449     int			CountOutputs()
    450     {
    451         return m_nOutputs;
    452     }
    453 protected:
    454     CPDF_Function();
    455     int			m_nInputs, m_nOutputs;
    456     FX_FLOAT*	m_pDomains;
    457     FX_FLOAT*	m_pRanges;
    458     FX_BOOL		Init(CPDF_Object* pObj);
    459     virtual FX_BOOL	v_Init(CPDF_Object* pObj) = 0;
    460     virtual FX_BOOL	v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const = 0;
    461 };
    462 class CPDF_IccProfile : public CFX_Object
    463 {
    464 public:
    465     CPDF_IccProfile(FX_LPCBYTE pData, FX_DWORD dwSize, int nComponents);
    466     ~CPDF_IccProfile();
    467     FX_BOOL					m_bsRGB;
    468     FX_LPVOID				m_pTransform;
    469 };
    470 class CPDF_DeviceCS : public CPDF_ColorSpace
    471 {
    472 public:
    473     CPDF_DeviceCS(int family);
    474     virtual FX_BOOL	GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const;
    475     FX_BOOL	SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const;
    476     FX_BOOL	v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const;
    477     FX_BOOL	v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k) const;
    478     virtual void	TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const;
    479 };
    480 class CPDF_PatternCS : public CPDF_ColorSpace
    481 {
    482 public:
    483     CPDF_PatternCS();
    484     ~CPDF_PatternCS();
    485     virtual FX_BOOL		v_Load(CPDF_Document* pDoc, CPDF_Array* pArray);
    486     virtual FX_BOOL		GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const;
    487     virtual CPDF_ColorSpace*	GetBaseCS() const
    488     {
    489         return m_pBaseCS;
    490     }
    491     CPDF_ColorSpace*	m_pBaseCS;
    492 };
    493 #define	MAX_PAGE_OBJECTS_UNIFY_NAMING				4096
    494 class CPDF_ResourceNaming : public CFX_Object
    495 {
    496 public:
    497     struct _NamingState : public CFX_Object {
    498         CFX_ByteString	m_Prefix;
    499         int				m_nIndex;
    500     };
    501     ~CPDF_ResourceNaming();
    502     CFX_ByteString		GetName(const CPDF_Dictionary* pResList, FX_LPCSTR szType);
    503 protected:
    504     CFX_MapByteStringToPtr	m_NamingCache;
    505 };
    506