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