fc34f1af4b75e7547340733b7fda71799d2dccda
[pdfium.git] / core / include / fpdfdoc / fpdf_doc.h
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 #ifndef _FPDF_DOC_H_
8 #define _FPDF_DOC_H_
9 #ifndef _FPDF_PARSER_
10 #include "../fpdfapi/fpdf_parser.h"
11 #endif
12 #ifndef _FPDF_RENDER_
13 #include "../fpdfapi/fpdf_render.h"
14 #endif
15 class CPDF_Action;
16 class CPDF_Annot;
17 class CPDF_AnnotList;
18 class CPDF_Bookmark;
19 class CPDF_BookmarkTree;
20 class CPDF_Dest;
21 class CPDF_Link;
22 class CPDF_LinkList;
23 class CPDF_Metadata;
24 class CPDF_NameTree;
25 class CPDF_NumberTree;
26 class CPDF_TextObject;
27 class CPDF_ViewerPreferences;
28 class CPDF_Page;
29 class CPDF_RenderOptions;
30 class CXML_Element;
31 class CPDF_OCContext;
32 class CPDF_DocJSActions;
33 class CPDF_ActionFields;
34 class CPDF_AAction;
35 class CPDF_FileSpec;
36 class CPDF_IconFit;
37 class CPDF_DefaultAppearance;
38 class CPDF_InterForm;
39 class CPDF_FormField;
40 class CPDF_FormNotify;
41 class CPDF_FormControl;
42 class CPDF_LWinParam;
43 class CFieldTree;
44 class CPDF_ApSettings;
45 class CPDF_NameTree : public CFX_Object
46 {
47 public:
48
49     CPDF_NameTree(CPDF_Dictionary* pRoot)
50     {
51         m_pRoot = pRoot;
52     }
53
54     CPDF_NameTree(CPDF_Document* pDoc, FX_BSTR category);
55
56     CPDF_Object*                LookupValue(int nIndex, CFX_ByteString& csName) const;
57
58     CPDF_Object*                LookupValue(const CFX_ByteString& csName) const;
59
60     CPDF_Array*                 LookupNamedDest(CPDF_Document* pDoc, FX_BSTR sName);
61
62     int                                 GetIndex(const CFX_ByteString& csName) const;
63
64     int                                 GetCount() const;
65
66
67     CPDF_Dictionary*    GetRoot() const
68     {
69         return m_pRoot;
70     }
71
72 protected:
73
74     CPDF_Dictionary*            m_pRoot;
75 };
76 class CPDF_BookmarkTree : public CFX_Object
77 {
78 public:
79     CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {}
80
81     CPDF_Bookmark               GetFirstChild(const CPDF_Bookmark& parent) const;
82
83     CPDF_Bookmark               GetNextSibling(const CPDF_Bookmark& bookmark) const;
84
85     CPDF_Document*              GetDocument() const { return m_pDocument; }
86
87 protected:
88     CPDF_Document*              m_pDocument;
89 };
90 #define PDFBOOKMARK_ITALIC                      1
91 #define PDFBOOKMARK_BOLD                        2
92 class CPDF_Bookmark : public CFX_Object
93 {
94 public:
95
96     CPDF_Bookmark() : m_pDict(NULL) {}
97
98     explicit CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
99
100     CPDF_Dictionary* GetDict() const { return m_pDict; }
101
102     operator bool() const { return m_pDict != NULL; }
103
104     FX_DWORD                    GetColorRef() const;
105
106     FX_DWORD                    GetFontStyle() const;
107
108     CFX_WideString              GetTitle() const;
109
110     CPDF_Dest                   GetDest(CPDF_Document* pDocument) const;
111
112     CPDF_Action                 GetAction() const;
113
114     CPDF_Dictionary*    m_pDict;
115 };
116 #define PDFZOOM_XYZ                                     1
117 #define PDFZOOM_FITPAGE                         2
118 #define PDFZOOM_FITHORZ                         3
119 #define PDFZOOM_FITVERT                         4
120 #define PDFZOOM_FITRECT                         5
121 #define PDFZOOM_FITBBOX                         6
122 #define PDFZOOM_FITBHORZ                        7
123 #define PDFZOOM_FITBVERT                        8
124 class CPDF_Dest : public CFX_Object
125 {
126 public:
127
128     CPDF_Dest(CPDF_Object* pObj = NULL)
129     {
130         m_pObj = pObj;
131     }
132
133     operator CPDF_Object* () const
134     {
135         return m_pObj;
136     }
137
138     CFX_ByteString              GetRemoteName();
139
140     int                                 GetPageIndex(CPDF_Document* pDoc);
141
142     FX_DWORD                    GetPageObjNum();
143
144     int                                 GetZoomMode();
145
146     FX_FLOAT                    GetParam(int index);
147
148
149     CPDF_Object*                m_pObj;
150 };
151 class CPDF_OCContext : public CFX_Object, public IPDF_OCContext
152 {
153 public:
154
155     enum UsageType {
156         View = 0,
157         Design,
158         Print,
159         Export
160     };
161
162     CPDF_OCContext(CPDF_Document *pDoc, UsageType eUsageType = View);
163
164     virtual ~CPDF_OCContext();
165
166     CPDF_Document*      GetDocument() const
167     {
168         return m_pDocument;
169     }
170
171     UsageType           GetUsageType() const
172     {
173         return m_eUsageType;
174     }
175
176     FX_BOOL                     CheckOCGVisible(const CPDF_Dictionary *pOCGDict);
177
178     void                        ResetOCContext();
179 protected:
180
181     FX_BOOL                     LoadOCGStateFromConfig(FX_BSTR csConfig, const CPDF_Dictionary *pOCGDict, FX_BOOL &bValidConfig) const;
182
183     FX_BOOL                     LoadOCGState(const CPDF_Dictionary *pOCGDict) const;
184
185     FX_BOOL                     GetOCGVisible(const CPDF_Dictionary *pOCGDict);
186
187     FX_BOOL                     GetOCGVE(CPDF_Array *pExpression, FX_BOOL bFromConfig, int nLevel = 0);
188
189     FX_BOOL                     LoadOCMDState(const CPDF_Dictionary *pOCMDDict, FX_BOOL bFromConfig);
190
191     CPDF_Document               *m_pDocument;
192
193     UsageType                   m_eUsageType;
194
195     CFX_MapPtrTemplate<const CPDF_Dictionary*, void*>   m_OCGStates;
196 };
197 class CPDF_LWinParam : public CFX_Object
198 {
199 public:
200
201     CPDF_LWinParam(CPDF_Dictionary* pDict)
202     {
203         m_pDict = pDict;
204     }
205
206     operator CPDF_Dictionary* () const
207     {
208         return m_pDict;
209     }
210
211     inline CFX_ByteString       GetFileName()
212     {
213         return m_pDict->GetString("F");
214     }
215
216
217     inline CFX_ByteString       GetDefaultDirectory()
218     {
219         return m_pDict->GetString("D");
220     }
221
222
223     inline CFX_ByteString       GetOperation()
224     {
225         return m_pDict->GetString("O");
226     }
227
228
229     inline CFX_ByteString       GetParameter()
230     {
231         return m_pDict->GetString("P");
232     }
233
234     CPDF_Dictionary*            m_pDict;
235 };
236 class CPDF_ActionFields : public CFX_Object
237 {
238 public:
239
240     CPDF_ActionFields(const CPDF_Action* pAction)
241     {
242         m_pAction = (CPDF_Action*)pAction;
243     }
244
245     operator CPDF_Action*() const
246     {
247         return m_pAction;
248     }
249
250     FX_DWORD                            GetFieldsCount() const;
251
252     void                                        GetAllFields(CFX_PtrArray& fieldObjects) const;
253
254     CPDF_Object*                        GetField(FX_DWORD iIndex) const;
255
256     CPDF_Action*                        m_pAction;
257 };
258
259 #define PDFNAMED_NEXTPAGE               1
260 #define PDFNAMED_PREVPAGE               2
261 #define PDFNAMED_FIRSTPAGE              3
262 #define PDFNAMED_LASTPAGE               4
263 #define PDFJS_MAXLENGTH                 64
264 class CPDF_Action : public CFX_Object
265 {
266 public:
267
268     CPDF_Action(CPDF_Dictionary* pDict = NULL)
269     {
270         m_pDict = pDict;
271     }
272
273     operator CPDF_Dictionary* () const
274     {
275         return m_pDict;
276     }
277
278     enum ActionType {
279         Unknown = 0,
280         GoTo,
281         GoToR,
282         GoToE,
283         Launch,
284         Thread,
285         URI,
286         Sound,
287         Movie,
288         Hide,
289         Named,
290         SubmitForm,
291         ResetForm,
292         ImportData,
293         JavaScript,
294         SetOCGState,
295         Rendition,
296         Trans,
297         GoTo3DView
298     };
299
300     CFX_ByteString              GetTypeName() const
301     {
302         return m_pDict->GetString("S");
303     }
304
305     ActionType                  GetType() const;
306
307
308
309     CPDF_Dest                   GetDest(CPDF_Document* pDoc) const;
310
311
312
313
314
315     CFX_WideString              GetFilePath() const;
316
317
318
319
320     FX_BOOL                             GetNewWindow() const
321     {
322         return m_pDict->GetBoolean("NewWindow");
323     }
324
325
326
327
328     CPDF_LWinParam              GetWinParam() const;
329
330
331
332
333     CFX_ByteString              GetURI(CPDF_Document* pDoc) const;
334
335
336
337
338     FX_BOOL                             GetMouseMap() const
339     {
340         return m_pDict->GetBoolean("IsMap");
341     }
342
343
344
345
346     CPDF_ActionFields   GetWidgets() const
347     {
348         return this;
349     }
350
351
352
353
354     FX_BOOL                             GetHideStatus() const
355     {
356         return m_pDict->GetBoolean("H", TRUE);
357     }
358
359
360
361
362     CFX_ByteString              GetNamedAction() const
363     {
364         return m_pDict->GetString("N");
365     }
366
367
368
369
370     FX_DWORD                    GetFlags() const
371     {
372         return m_pDict->GetInteger("Flags");
373     }
374
375
376
377
378     CFX_WideString              GetJavaScript() const;
379
380
381
382
383     CPDF_Dictionary*    GetAnnot() const;
384
385
386
387
388     FX_INT32                    GetOperationType() const;
389
390
391
392
393     CPDF_Stream*                GetSoundStream() const
394     {
395         return m_pDict->GetStream("Sound");
396     }
397
398     FX_FLOAT                    GetVolume() const
399     {
400         return m_pDict->GetNumber("Volume");
401     }
402
403     FX_BOOL                             IsSynchronous() const
404     {
405         return m_pDict->GetBoolean("Synchronous");
406     }
407
408     FX_BOOL                             IsRepeat() const
409     {
410         return m_pDict->GetBoolean("Repeat");
411     }
412
413     FX_BOOL                             IsMixPlay() const
414     {
415         return m_pDict->GetBoolean("Mix");
416     }
417
418
419
420
421     FX_DWORD                    GetSubActionsCount() const;
422
423     CPDF_Action                 GetSubAction(FX_DWORD iIndex) const;
424
425
426     CPDF_Dictionary*    m_pDict;
427 };
428 class CPDF_AAction : public CFX_Object
429 {
430 public:
431
432     CPDF_AAction(CPDF_Dictionary* pDict = NULL)
433     {
434         m_pDict = pDict;
435     }
436
437     operator CPDF_Dictionary*() const
438     {
439         return m_pDict;
440     }
441
442     enum AActionType {
443         CursorEnter = 0,
444         CursorExit,
445         ButtonDown,
446         ButtonUp,
447         GetFocus,
448         LoseFocus,
449         PageOpen,
450         PageClose,
451         PageVisible,
452         PageInvisible,
453         OpenPage,
454         ClosePage,
455         KeyStroke,
456         Format,
457         Validate,
458         Calculate,
459         CloseDocument,
460         SaveDocument,
461         DocumentSaved,
462         PrintDocument,
463         DocumentPrinted
464     };
465
466     FX_BOOL                             ActionExist(AActionType eType) const;
467
468     CPDF_Action                 GetAction(AActionType eType) const;
469
470     FX_POSITION                 GetStartPos() const;
471
472     CPDF_Action                 GetNextAction(FX_POSITION& pos, AActionType& eType) const;
473
474     CPDF_Dictionary*    m_pDict;
475 };
476 class CPDF_DocJSActions : public CFX_Object
477 {
478 public:
479     CPDF_DocJSActions(CPDF_Document* pDoc);
480
481
482     int                                 CountJSActions() const;
483
484     CPDF_Action                 GetJSAction(int index, CFX_ByteString& csName) const;
485
486     CPDF_Action                 GetJSAction(const CFX_ByteString& csName) const;
487
488     int                                 FindJSAction(const CFX_ByteString& csName) const;
489
490
491     CPDF_Document*              GetDocument() const
492     {
493         return m_pDocument;
494     }
495
496 protected:
497
498     CPDF_Document*              m_pDocument;
499 };
500 class CPDF_FileSpec : public CFX_Object
501 {
502 public:
503
504     CPDF_FileSpec();
505
506     CPDF_FileSpec(CPDF_Object *pObj)
507     {
508         m_pObj = pObj;
509     }
510
511     operator CPDF_Object*() const
512     {
513         return m_pObj;
514     }
515
516     FX_BOOL                     IsURL() const;
517
518     FX_BOOL                     GetFileName(CFX_WideString &wsFileName) const;
519
520     CPDF_Stream*        GetFileStream() const;
521
522     void                        SetFileName(FX_WSTR wsFileName, FX_BOOL bURL = FALSE);
523 protected:
524
525     CPDF_Object         *m_pObj;
526 };
527 class CPDF_LinkList : public CFX_Object
528 {
529 public:
530
531     CPDF_LinkList(CPDF_Document* pDoc)
532     {
533         m_pDocument = pDoc;
534     }
535
536     ~CPDF_LinkList();
537
538     CPDF_Link                   GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y);
539
540     int                                 CountLinks(CPDF_Page* pPage);
541
542     CPDF_Link                   GetLink(CPDF_Page* pPage, int index);
543
544     CPDF_Document*              GetDocument() const
545     {
546         return m_pDocument;
547     }
548 protected:
549
550     CPDF_Document*              m_pDocument;
551
552     CFX_MapPtrToPtr             m_PageMap;
553
554     CFX_PtrArray*               GetPageLinks(CPDF_Page* pPage);
555
556     void                                LoadPageLinks(CPDF_Page* pPage, CFX_PtrArray* pList);
557 };
558 class CPDF_Link : public CFX_Object
559 {
560 public:
561
562     CPDF_Link(CPDF_Dictionary* pDict = NULL)
563     {
564         m_pDict = pDict;
565     }
566
567     operator CPDF_Dictionary*() const
568     {
569         return m_pDict;
570     }
571
572     CFX_FloatRect               GetRect();
573
574
575
576     CPDF_Dest                   GetDest(CPDF_Document* pDoc);
577
578     CPDF_Action                 GetAction();
579
580
581     CPDF_Dictionary*    m_pDict;
582 };
583 #define ANNOTFLAG_INVISIBLE                     1
584 #define ANNOTFLAG_HIDDEN                        2
585 #define ANNOTFLAG_PRINT                         4
586 #define ANNOTFLAG_NOZOOM                        8
587 #define ANNOTFLAG_NOROTATE                      0x10
588 #define ANNOTFLAG_NOVIEW                        0x20
589 #define ANNOTFLAG_READONLY                      0x40
590 #define ANNOTFLAG_LOCKED                        0x80
591 #define ANNOTFLAG_TOGGLENOVIEW          0x100
592 class CPDF_Annot : public CFX_PrivateData, public CFX_Object
593 {
594 public:
595
596     CPDF_Annot(CPDF_Dictionary* pDict);
597
598     ~CPDF_Annot();
599
600     CPDF_Dictionary*    m_pAnnotDict;
601
602     CFX_ByteString              GetSubType() const;
603
604     FX_DWORD                    GetFlags() const
605     {
606         return m_pAnnotDict->GetInteger("F");
607     }
608
609     void                                GetRect(CFX_FloatRect& rect) const;
610
611     enum AppearanceMode {
612         Normal,
613         Rollover,
614         Down
615     };
616
617     FX_BOOL                             DrawAppearance(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
618                                        AppearanceMode mode, const CPDF_RenderOptions* pOptions);
619
620     FX_BOOL                             DrawInContext(const CPDF_Page* pPage, const CPDF_RenderContext* pContext,
621                                       const CFX_AffineMatrix* pUser2Device, AppearanceMode mode);
622
623     void                                ClearCachedAP();
624
625
626     void                                DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
627                                    const CPDF_RenderOptions* pOptions);
628
629     CPDF_PageObject*    GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions* pOptions);
630
631
632
633     int                                 CountIRTNotes();
634
635     CPDF_Annot*                 GetIRTNote(int index);
636
637
638     CPDF_Form*                  GetAPForm(const CPDF_Page* pPage, AppearanceMode mode);
639 private:
640
641     CFX_MapPtrToPtr             m_APMap;
642 protected:
643     friend class                CPDF_AnnotList;
644
645     CPDF_AnnotList*             m_pList;
646
647     CPDF_Reference*             NewAnnotRef();
648 };
649 class CPDF_AnnotList : public CFX_Object
650 {
651 public:
652
653     CPDF_AnnotList(CPDF_Page* pPage);
654
655     ~CPDF_AnnotList();
656
657     void        GetAnnotMatrix(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CFX_Matrix &matrix) const;
658
659     void        GetAnnotRect(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CPDF_Rect &rtAnnot) const;
660
661     void                                DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice,
662                                       CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
663                                       CPDF_RenderOptions* pOptions);
664
665     void                                DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext,
666                                       FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
667                                       CPDF_RenderOptions* pOptions)
668     {
669         DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, NULL);
670     }
671
672     void                                DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext,
673                                       FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
674                                       CPDF_RenderOptions* pOptions, FX_RECT *pClipRect)
675     {
676         DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, pClipRect);
677     }
678
679     void                                DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, CPDF_RenderContext* pContext,
680                                       FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_DWORD dwAnnotFlags,
681                                       CPDF_RenderOptions* pOptions, FX_RECT* pClipRect);
682
683
684
685     CPDF_Annot*                 GetAt(int index)
686     {
687         return (CPDF_Annot*)m_AnnotList.GetAt(index);
688     }
689
690     int                                 Count()
691     {
692         return m_AnnotList.GetSize();
693     }
694
695     int                                 GetIndex(CPDF_Annot* pAnnot);
696
697
698     CPDF_Document*              GetDocument() const
699     {
700         return m_pDocument;
701     }
702 protected:
703
704     CFX_PtrArray                m_AnnotList;
705
706     CPDF_Dictionary*    m_pPageDict;
707
708     CPDF_Document*              m_pDocument;
709
710     CFX_PtrArray                m_Borders;
711
712     void                                DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevice,
713                                     CPDF_RenderContext* pContext, FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix,
714                                     FX_BOOL bWidget, CPDF_RenderOptions* pOptions, FX_RECT* clip_rect);
715     friend class                CPDF_Annot;
716 };
717 #define COLORTYPE_TRANSPARENT   0
718 #define COLORTYPE_GRAY                  1
719 #define COLORTYPE_RGB                   2
720 #define COLORTYPE_CMYK                  3
721 class CPDF_DefaultAppearance : public CFX_Object
722 {
723 public:
724
725     CPDF_DefaultAppearance(const CFX_ByteString& csDA = "")
726     {
727         m_csDA = csDA;
728     }
729
730     CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA)
731     {
732         m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA;
733     }
734
735
736     operator CFX_ByteString() const
737     {
738         return m_csDA;
739     }
740
741     const CPDF_DefaultAppearance& operator =(const CFX_ByteString& csDA)
742     {
743         m_csDA = csDA;
744         return *this;
745     }
746
747     const CPDF_DefaultAppearance& operator =(const CPDF_DefaultAppearance& cDA)
748     {
749         m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA;
750         return *this;
751     }
752
753
754
755     FX_BOOL                             HasFont();
756
757     CFX_ByteString              GetFontString();
758
759     void                                GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize);
760
761
762
763
764     FX_BOOL                             HasColor(FX_BOOL bStrokingOperation = FALSE);
765
766     CFX_ByteString              GetColorString(FX_BOOL bStrokingOperation = FALSE);
767
768     void                                GetColor(int& iColorType, FX_FLOAT fc[4], FX_BOOL bStrokingOperation = FALSE);
769
770     void                                GetColor(FX_ARGB& color, int& iColorType, FX_BOOL bStrokingOperation = FALSE);
771
772
773
774
775     FX_BOOL                             HasTextMatrix();
776
777     CFX_ByteString              GetTextMatrixString();
778
779     CFX_AffineMatrix    GetTextMatrix();
780
781 protected:
782
783     CFX_ByteString              m_csDA;
784 };
785 #define FIELDTYPE_UNKNOWN                       0
786 #define FIELDTYPE_PUSHBUTTON            1
787 #define FIELDTYPE_CHECKBOX                      2
788 #define FIELDTYPE_RADIOBUTTON           3
789 #define FIELDTYPE_COMBOBOX                      4
790 #define FIELDTYPE_LISTBOX                       5
791 #define FIELDTYPE_TEXTFIELD                     6
792 #define FIELDTYPE_SIGNATURE                     7
793 class CPDF_InterForm : public CFX_PrivateData, public CFX_Object
794 {
795 public:
796
797     CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bUpdateAP);
798
799     ~CPDF_InterForm();
800
801
802
803     static void                         EnableUpdateAP(FX_BOOL bUpdateAP);
804
805     static FX_BOOL                      UpdatingAPEnabled();
806
807
808     static CFX_ByteString       GenerateNewResourceName(const CPDF_Dictionary* pResDict, FX_LPCSTR csType, int iMinLen = 2, FX_LPCSTR csPrefix = "");
809
810
811
812     static CPDF_Font*           AddSystemDefaultFont(const CPDF_Document* pDocument);
813
814     static CPDF_Font*           AddSystemFont(const CPDF_Document* pDocument, CFX_ByteString csFontName, FX_BYTE iCharSet = 1);
815
816     static CPDF_Font*           AddSystemFont(const CPDF_Document* pDocument, CFX_WideString csFontName, FX_BYTE iCharSet = 1);
817
818     static CPDF_Font*           AddStandardFont(const CPDF_Document* pDocument, CFX_ByteString csFontName);
819
820     static CFX_ByteString       GetNativeFont(FX_BYTE iCharSet, FX_LPVOID pLogFont = NULL);
821
822     static CFX_ByteString       GetNativeFont(FX_LPVOID pLogFont = NULL);
823
824     static FX_BYTE                      GetNativeCharSet();
825
826     static CPDF_Font*           AddNativeFont(FX_BYTE iCharSet, const CPDF_Document* pDocument);
827
828     static CPDF_Font*           AddNativeFont(const CPDF_Document* pDocument);
829
830
831
832
833     FX_BOOL                                     ValidateFieldName(CFX_WideString& csNewFieldName, int iType);
834
835     FX_BOOL                                     ValidateFieldName(const CPDF_FormField* pField, CFX_WideString& csNewFieldName);
836
837     FX_BOOL                                     ValidateFieldName(const CPDF_FormControl* pControl, CFX_WideString& csNewFieldName);
838
839
840
841
842     FX_DWORD                            CountFields(const CFX_WideString &csFieldName = L"");
843
844     CPDF_FormField*                     GetField(FX_DWORD index, const CFX_WideString &csFieldName = L"");
845
846     void                                        GetAllFieldNames(CFX_WideStringArray& allFieldNames);
847
848     FX_BOOL                                     IsValidFormField(const void* pField);
849
850     CPDF_FormField*                     GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
851
852
853
854
855     FX_DWORD                            CountControls(CFX_WideString csFieldName = L"");
856
857     CPDF_FormControl*           GetControl(FX_DWORD index, CFX_WideString csFieldName = L"");
858
859     FX_BOOL                                     IsValidFormControl(const void* pControl);
860
861     int                                         CountPageControls(CPDF_Page* pPage) const;
862
863     CPDF_FormControl*           GetPageControl(CPDF_Page* pPage, int index) const;
864
865
866     CPDF_FormControl*           GetControlAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y) const;
867
868     CPDF_FormControl*           GetControlByDict(CPDF_Dictionary* pWidgetDict) const;
869
870
871
872
873     FX_DWORD                            CountInternalFields(const CFX_WideString& csFieldName = L"") const;
874
875     CPDF_Dictionary*            GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName = L"") const;
876
877
878
879
880
881     CPDF_Document*                      GetDocument() const
882     {
883         return m_pDocument;
884     }
885
886     CPDF_Dictionary*            GetFormDict() const
887     {
888         return m_pFormDict;
889     }
890
891
892
893
894     FX_BOOL                                     NeedConstructAP();
895
896     void                                        NeedConstructAP(FX_BOOL bNeedAP);
897
898
899
900
901     int                                         CountFieldsInCalculationOrder();
902
903     CPDF_FormField*                     GetFieldInCalculationOrder(int index);
904
905     int                                         FindFieldInCalculationOrder(const CPDF_FormField* pField);
906
907
908
909
910     FX_DWORD                            CountFormFonts();
911
912     CPDF_Font*                          GetFormFont(FX_DWORD index, CFX_ByteString& csNameTag);
913
914     CPDF_Font*                          GetFormFont(CFX_ByteString csNameTag);
915
916     CPDF_Font*                          GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag);
917
918     CPDF_Font*                          GetNativeFormFont(FX_BYTE iCharSet, CFX_ByteString& csNameTag);
919
920     CPDF_Font*                          GetNativeFormFont(CFX_ByteString& csNameTag);
921
922     FX_BOOL                                     FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
923
924     FX_BOOL                                     FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag);
925
926     inline FX_BOOL                      FindFormFont(CFX_WideString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag)
927     {
928         return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag);
929     }
930
931
932
933
934
935     void                                        AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
936
937     CPDF_Font*                          AddNativeFormFont(FX_BYTE iCharSet, CFX_ByteString& csNameTag);
938
939     CPDF_Font*                          AddNativeFormFont(CFX_ByteString& csNameTag);
940
941     void                                        RemoveFormFont(const CPDF_Font* pFont);
942
943     void                                        RemoveFormFont(CFX_ByteString csNameTag);
944
945
946
947
948     CPDF_DefaultAppearance      GetDefaultAppearance();
949
950     CPDF_Font*                          GetDefaultFormFont();
951
952
953
954     int                                         GetFormAlignment();
955
956
957
958
959     CPDF_FormField*                     CheckRequiredFields(const CFX_PtrArray *fields = NULL, FX_BOOL bIncludeOrExclude = TRUE) const;
960
961     CFDF_Document*                      ExportToFDF(FX_WSTR pdf_path, FX_BOOL bSimpleFileSpec = FALSE) const;
962
963     CFDF_Document*                      ExportToFDF(FX_WSTR pdf_path, CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bSimpleFileSpec = FALSE) const;
964
965     FX_BOOL                                     ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE);
966
967
968
969
970     FX_BOOL                                     ResetForm(const CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bNotify = FALSE);
971
972     FX_BOOL                                     ResetForm(FX_BOOL bNotify = FALSE);
973
974     void                                        ReloadForm();
975
976     CPDF_FormNotify*            GetFormNotify() const
977     {
978         return m_pFormNotify;
979     }
980
981     void                                        SetFormNotify(const CPDF_FormNotify* pNotify);
982
983
984     int                                         GetPageWithWidget(int iCurPage, FX_BOOL bNext);
985
986
987
988     FX_BOOL                                     IsUpdated()
989     {
990         return m_bUpdated;
991     }
992
993     void                                        ClearUpdatedFlag()
994     {
995         m_bUpdated = FALSE;
996     }
997
998
999     FX_BOOL                                     HasXFAForm() const;
1000
1001     void                                        FixPageFields(const CPDF_Page* pPage);
1002 protected:
1003
1004     static FX_BOOL                      m_bUpdateAP;
1005
1006     void                                        LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0);
1007
1008     CPDF_Object*                        GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name);
1009
1010     CPDF_FormField*                     AddTerminalField(const CPDF_Dictionary* pFieldDict);
1011
1012     CPDF_FormControl*           AddControl(const CPDF_FormField* pField, const CPDF_Dictionary* pWidgetDict);
1013
1014     void                                        FDF_ImportField(CPDF_Dictionary* pField, const CFX_WideString& parent_name, FX_BOOL bNotify = FALSE, int nLevel = 0);
1015
1016     FX_BOOL                                     ValidateFieldName(CFX_WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl);
1017
1018     int                                         CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2);
1019
1020     int                                         CompareFieldName(const CFX_ByteString& name1, const CFX_ByteString& name2);
1021
1022     CPDF_Document*                      m_pDocument;
1023
1024     FX_BOOL                                     m_bGenerateAP;
1025
1026     CPDF_Dictionary*            m_pFormDict;
1027
1028     CFX_MapPtrToPtr                     m_ControlMap;
1029
1030     CFieldTree *m_pFieldTree;
1031
1032     CFX_ByteString                      m_bsEncoding;
1033
1034     CPDF_FormNotify*            m_pFormNotify;
1035
1036     FX_BOOL                                     m_bUpdated;
1037     friend class CPDF_FormControl;
1038     friend class CPDF_FormField;
1039 };
1040 #define FORMFIELD_READONLY              0x01
1041 #define FORMFIELD_REQUIRED              0x02
1042 #define FORMFIELD_NOEXPORT              0x04
1043 #define FORMRADIO_NOTOGGLEOFF   0x100
1044 #define FORMRADIO_UNISON                0x200
1045 #define FORMTEXT_MULTILINE              0x100
1046 #define FORMTEXT_PASSWORD               0x200
1047 #define FORMTEXT_NOSCROLL               0x400
1048 #define FORMTEXT_COMB                   0x800
1049 #define FORMCOMBO_EDIT                  0x100
1050 #define FORMLIST_MULTISELECT    0x100
1051 class CPDF_FormField : public CFX_Object
1052 {
1053 public:
1054
1055     enum Type {
1056         Unknown,
1057         PushButton,
1058         RadioButton,
1059         CheckBox,
1060         Text,
1061         RichText,
1062         File,
1063         ListBox,
1064         ComboBox,
1065         Sign
1066     };
1067
1068     CFX_WideString                      GetFullName();
1069
1070     Type                                        GetType()
1071     {
1072         return m_Type;
1073     }
1074
1075     FX_DWORD                            GetFlags()
1076     {
1077         return m_Flags;
1078     }
1079
1080     CPDF_InterForm*                     GetInterForm() const
1081     {
1082         return m_pForm;
1083     }
1084
1085     CPDF_Dictionary*            GetFieldDict() const
1086     {
1087         return m_pDict;
1088     }
1089
1090     void                                        SetFieldDict(CPDF_Dictionary* pDict)
1091     {
1092         m_pDict = pDict;
1093     }
1094
1095     FX_BOOL                                     ResetField(FX_BOOL bNotify = FALSE);
1096
1097
1098
1099     int                                         CountControls()
1100     {
1101         return m_ControlList.GetSize();
1102     }
1103
1104     CPDF_FormControl*           GetControl(int index)
1105     {
1106         return (CPDF_FormControl*)m_ControlList.GetAt(index);
1107     }
1108
1109     int                                         GetControlIndex(const CPDF_FormControl* pControl);
1110
1111
1112
1113
1114     int                                         GetFieldType();
1115
1116
1117
1118
1119     CPDF_AAction                        GetAdditionalAction();
1120
1121
1122
1123
1124     CFX_WideString                      GetAlternateName();
1125
1126
1127
1128
1129     CFX_WideString                      GetMappingName();
1130
1131
1132
1133
1134     FX_DWORD                            GetFieldFlags();
1135
1136
1137
1138
1139     CFX_ByteString                      GetDefaultStyle();
1140
1141
1142
1143
1144     CFX_WideString                      GetRichTextString();
1145
1146
1147
1148     CFX_WideString                      GetValue();
1149
1150     CFX_WideString                      GetDefaultValue();
1151
1152     FX_BOOL                                     SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE);
1153
1154
1155
1156
1157
1158     int                                         GetMaxLen();
1159
1160
1161
1162
1163     int                                         CountSelectedItems();
1164
1165     int                                         GetSelectedIndex(int index);
1166
1167     FX_BOOL                                     ClearSelection(FX_BOOL bNotify = FALSE);
1168
1169     FX_BOOL                                     IsItemSelected(int index);
1170
1171     FX_BOOL                                     SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify = FALSE);
1172
1173     FX_BOOL                                     IsItemDefaultSelected(int index);
1174
1175     int                                         GetDefaultSelectedItem();
1176
1177
1178
1179
1180     int                                         CountOptions();
1181
1182     CFX_WideString                      GetOptionLabel(int index);
1183
1184     CFX_WideString                      GetOptionValue(int index);
1185
1186     int                                         FindOption(CFX_WideString csOptLabel);
1187
1188     int                                         FindOptionValue(FX_LPCWSTR csOptValue, int iStartIndex = 0);
1189
1190
1191
1192
1193     FX_BOOL                                     CheckControl(int iControlIndex, FX_BOOL bChecked, FX_BOOL bNotify = FALSE);
1194
1195
1196
1197
1198     int                                         GetTopVisibleIndex();
1199
1200
1201
1202
1203     int                                         CountSelectedOptions();
1204
1205     int                                         GetSelectedOptionIndex(int index);
1206
1207     FX_BOOL                                     IsOptionSelected(int iOptIndex);
1208
1209     FX_BOOL                                     SelectOption(int iOptIndex, FX_BOOL bSelected, FX_BOOL bNotify = FALSE);
1210
1211     FX_BOOL                                     ClearSelectedOptions(FX_BOOL bNotify = FALSE);
1212
1213     FX_BOOL                                     ClearOptions(FX_BOOL bNotify = FALSE);\r
1214
1215     int                                         InsertOption(CFX_WideString csOptLabel, int index = -1, FX_BOOL bNotify = FALSE);\r
1216
1217     FX_FLOAT                            GetFontSize()
1218     {
1219         return m_FontSize;
1220     }
1221
1222     CPDF_Font*                          GetFont()
1223     {
1224         return m_pFont;
1225     }
1226
1227 protected:
1228
1229     CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict);
1230
1231     ~CPDF_FormField();
1232
1233     CPDF_FormField::Type        m_Type;
1234
1235     FX_DWORD                            m_Flags;
1236
1237     CPDF_InterForm*                     m_pForm;
1238
1239     CPDF_Dictionary*            m_pDict;
1240
1241     CFX_PtrArray                        m_ControlList;
1242     friend class                        CPDF_InterForm;
1243     friend class                        CPDF_FormControl;
1244
1245
1246
1247     CFX_WideString                      GetValue(FX_BOOL bDefault);
1248
1249     FX_BOOL                                     SetValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify);
1250
1251
1252     void                                        SyncFieldFlags();
1253
1254     int                                         FindListSel(CPDF_String* str);
1255
1256     CFX_WideString                      GetOptionText(int index, int sub_index);
1257
1258     void                                        LoadDA();
1259
1260     void                                        UpdateAP(CPDF_FormControl* pControl);
1261
1262
1263
1264     CFX_WideString                      GetCheckValue(FX_BOOL bDefault);
1265
1266     FX_BOOL                                     SetCheckValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify);
1267
1268
1269     FX_FLOAT                            m_FontSize;
1270
1271     CPDF_Font*                          m_pFont;
1272 };
1273 CPDF_Object*    FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name, int nLevel = 0);
1274 class CPDF_IconFit : public CFX_Object
1275 {
1276 public:
1277
1278     CPDF_IconFit(CPDF_Dictionary* pDict = NULL)
1279     {
1280         m_pDict = pDict;
1281     }
1282
1283     operator CPDF_Dictionary*() const
1284     {
1285         return m_pDict;
1286     }
1287
1288
1289
1290
1291     enum ScaleMethod {
1292         Always = 0,
1293         Bigger,
1294         Smaller,
1295         Never
1296     };
1297
1298     ScaleMethod                         GetScaleMethod();
1299
1300
1301
1302
1303     FX_BOOL                                     IsProportionalScale();
1304
1305
1306
1307
1308     void                                        GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom);
1309
1310
1311
1312
1313     FX_BOOL                                     GetFittingBounds();
1314
1315
1316     CPDF_Dictionary*            m_pDict;
1317 };
1318
1319 #define TEXTPOS_CAPTION         0
1320 #define TEXTPOS_ICON            1
1321 #define TEXTPOS_BELOW           2
1322 #define TEXTPOS_ABOVE           3
1323 #define TEXTPOS_RIGHT           4
1324 #define TEXTPOS_LEFT            5
1325 #define TEXTPOS_OVERLAID        6
1326 class CPDF_FormControl : public CFX_Object
1327 {
1328 public:
1329
1330     CPDF_FormField::Type        GetType()
1331     {
1332         return m_pField->GetType();
1333     }
1334
1335     CPDF_InterForm*                     GetInterForm() const
1336     {
1337         return m_pForm;
1338     }
1339
1340     CPDF_FormField*                     GetField() const
1341     {
1342         return m_pField;
1343     }
1344
1345     CPDF_Dictionary*            GetWidget() const
1346     {
1347         return m_pWidgetDict;
1348     }
1349
1350     CFX_FloatRect                       GetRect();
1351
1352     void                                        DrawControl(CFX_RenderDevice* pDevice, CFX_AffineMatrix* pMatrix,
1353                                         CPDF_Page* pPage, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions = NULL);
1354
1355
1356
1357     CFX_ByteString                      GetCheckedAPState();
1358
1359     CFX_WideString                      GetExportValue();
1360
1361     FX_BOOL                                     IsChecked();
1362
1363     FX_BOOL                                     IsDefaultChecked();
1364
1365
1366
1367
1368     enum HighlightingMode       {
1369         None = 0,
1370         Invert,
1371         Outline,
1372         Push,
1373         Toggle
1374     };
1375
1376     HighlightingMode            GetHighlightingMode();
1377
1378
1379
1380
1381     FX_BOOL                                     HasMKEntry(CFX_ByteString csEntry);
1382
1383
1384
1385
1386     int                                         GetRotation();
1387
1388
1389
1390
1391     inline FX_ARGB                      GetBorderColor(int& iColorType)
1392     {
1393         return GetColor(iColorType, "BC");
1394     }
1395
1396     inline FX_FLOAT                     GetOriginalBorderColor(int index)
1397     {
1398         return GetOriginalColor(index, "BC");
1399     }
1400
1401     inline void                         GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4])
1402     {
1403         GetOriginalColor(iColorType, fc, "BC");
1404     }
1405
1406
1407
1408
1409     inline FX_ARGB                      GetBackgroundColor(int& iColorType)
1410     {
1411         return GetColor(iColorType, "BG");
1412     }
1413
1414     inline FX_FLOAT                     GetOriginalBackgroundColor(int index)
1415     {
1416         return GetOriginalColor(index, "BG");
1417     }
1418
1419     inline void                         GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4])
1420     {
1421         GetOriginalColor(iColorType, fc, "BG");
1422     }
1423
1424
1425
1426
1427     inline CFX_WideString       GetNormalCaption()
1428     {
1429         return GetCaption("CA");
1430     }
1431
1432
1433
1434
1435     inline CFX_WideString       GetRolloverCaption()
1436     {
1437         return GetCaption("RC");
1438     }
1439
1440
1441
1442
1443     inline CFX_WideString       GetDownCaption()
1444     {
1445         return GetCaption("AC");
1446     }
1447
1448
1449
1450
1451     inline CPDF_Stream*         GetNormalIcon()
1452     {
1453         return GetIcon("I");
1454     }
1455
1456
1457
1458
1459     inline CPDF_Stream*         GetRolloverIcon()
1460     {
1461         return GetIcon("RI");
1462     }
1463
1464
1465
1466
1467     inline CPDF_Stream*         GetDownIcon()
1468     {
1469         return GetIcon("IX");
1470     }
1471
1472
1473
1474
1475     CPDF_IconFit                        GetIconFit();
1476
1477
1478
1479
1480     int                                         GetTextPosition();
1481
1482
1483
1484
1485     CPDF_Action                         GetAction();
1486
1487
1488
1489
1490     CPDF_AAction                        GetAdditionalAction();
1491
1492
1493
1494
1495     CPDF_DefaultAppearance      GetDefaultAppearance();
1496
1497     CPDF_Font*                          GetDefaultControlFont();
1498
1499
1500
1501
1502     int                                         GetControlAlignment();
1503
1504 protected:
1505
1506     CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict);
1507
1508     CFX_ByteString                      GetOnStateName();
1509
1510     void                                        SetOnStateName(const CFX_ByteString& csOn);
1511
1512     void                                        CheckControl(FX_BOOL bChecked);
1513
1514     FX_ARGB                                     GetColor(int& iColorType, CFX_ByteString csEntry);
1515
1516     FX_FLOAT                            GetOriginalColor(int index, CFX_ByteString csEntry);
1517
1518     void                                        GetOriginalColor(int& iColorType, FX_FLOAT fc[4], CFX_ByteString csEntry);
1519
1520     CFX_WideString                      GetCaption(CFX_ByteString csEntry);
1521
1522     CPDF_Stream*                        GetIcon(CFX_ByteString csEntry);
1523
1524     CPDF_ApSettings                     GetMK(FX_BOOL bCreate);
1525
1526     CPDF_InterForm*                     m_pForm;
1527
1528     CPDF_FormField*                     m_pField;
1529
1530     CPDF_Dictionary*            m_pWidgetDict;
1531     friend class                        CPDF_InterForm;
1532     friend class                        CPDF_FormField;
1533 };
1534 class CPDF_FormNotify : public CFX_Object
1535 {
1536 public:
1537
1538     virtual ~CPDF_FormNotify() {}
1539
1540     virtual int         BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue)
1541     {
1542         return 0;
1543     }
1544
1545     virtual int         AfterValueChange(const CPDF_FormField* pField)
1546     {
1547         return 0;
1548     }
1549
1550     virtual int         BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue)
1551     {
1552         return 0;
1553     }
1554
1555     virtual int         AfterSelectionChange(const CPDF_FormField* pField)
1556     {
1557         return 0;
1558     }
1559
1560     virtual int         AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray)
1561     {
1562         return 0;
1563     }
1564
1565     virtual int         BeforeFormReset(const CPDF_InterForm* pForm)
1566     {
1567         return 0;
1568     }
1569
1570     virtual int         AfterFormReset(const CPDF_InterForm* pForm)
1571     {
1572         return 0;
1573     }
1574
1575     virtual int         BeforeFormImportData(const CPDF_InterForm* pForm)
1576     {
1577         return 0;
1578     }
1579
1580     virtual int         AfterFormImportData(const CPDF_InterForm* pForm)
1581     {
1582         return 0;
1583     }
1584 };
1585 FX_BOOL         FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
1586 class CPDF_PageLabel : public CFX_Object
1587 {
1588 public:
1589
1590     CPDF_PageLabel(CPDF_Document* pDocument)
1591     {
1592         m_pDocument = pDocument;
1593     }
1594
1595
1596     CFX_WideString                                      GetLabel(int nPage) const;
1597
1598     FX_INT32                                            GetPageByLabel(FX_BSTR bsLabel) const;
1599
1600
1601     FX_INT32                                            GetPageByLabel(FX_WSTR wsLabel) const;
1602
1603 protected:
1604     CPDF_Document*                                      m_pDocument;
1605 };
1606 class CPDF_Metadata
1607 {
1608 public:
1609
1610     CPDF_Metadata();
1611
1612
1613     ~CPDF_Metadata();
1614
1615     void                                LoadDoc(CPDF_Document *pDoc);
1616
1617
1618     FX_INT32                    GetString(FX_BSTR bsItem, CFX_WideString &wsStr);
1619
1620     CXML_Element*               GetRoot() const;
1621
1622     CXML_Element*               GetRDF() const;
1623
1624 protected:
1625     FX_LPVOID   m_pData;
1626 };
1627 class CPDF_ViewerPreferences
1628 {
1629 public:
1630
1631     CPDF_ViewerPreferences(CPDF_Document *pDoc);
1632
1633
1634     ~CPDF_ViewerPreferences();
1635
1636
1637     FX_BOOL IsDirectionR2L() const;
1638
1639     FX_BOOL PrintScaling() const;
1640
1641     FX_INT32 NumCopies() const;
1642
1643     CPDF_Array* PrintPageRange() const;
1644
1645     CFX_ByteString Duplex() const;
1646
1647 protected:
1648     CPDF_Document*      m_pDoc;
1649 };
1650 class CPDF_ApSettings : public CFX_Object
1651 {
1652 public:
1653
1654     CPDF_ApSettings(CPDF_Dictionary* pDict = NULL)
1655     {
1656         m_pDict = pDict;
1657     }
1658
1659     operator CPDF_Dictionary* () const
1660     {
1661         return m_pDict;
1662     }
1663
1664     FX_BOOL                                     HasMKEntry(FX_BSTR csEntry);
1665
1666
1667
1668     int                                         GetRotation();
1669
1670
1671
1672
1673     inline FX_ARGB                      GetBorderColor(int& iColorType)
1674     {
1675         return GetColor(iColorType, FX_BSTRC("BC"));
1676     }
1677
1678     inline FX_FLOAT                     GetOriginalBorderColor(int index)
1679     {
1680         return GetOriginalColor(index, FX_BSTRC("BC"));
1681     }
1682
1683     inline void                         GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4])
1684     {
1685         GetOriginalColor(iColorType, fc, FX_BSTRC("BC"));
1686     }
1687
1688
1689
1690
1691     inline FX_ARGB                      GetBackgroundColor(int& iColorType)
1692     {
1693         return GetColor(iColorType, FX_BSTRC("BG"));
1694     }
1695
1696     inline FX_FLOAT                     GetOriginalBackgroundColor(int index)
1697     {
1698         return GetOriginalColor(index, FX_BSTRC("BG"));
1699     }
1700
1701     inline void                         GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4])
1702     {
1703         GetOriginalColor(iColorType, fc, FX_BSTRC("BG"));
1704     }
1705
1706
1707
1708
1709     inline CFX_WideString       GetNormalCaption()
1710     {
1711         return GetCaption(FX_BSTRC("CA"));
1712     }
1713
1714
1715
1716
1717     inline CFX_WideString       GetRolloverCaption()
1718     {
1719         return GetCaption(FX_BSTRC("RC"));
1720     }
1721
1722
1723
1724
1725     inline CFX_WideString       GetDownCaption()
1726     {
1727         return GetCaption(FX_BSTRC("AC"));
1728     }
1729
1730
1731
1732
1733     inline CPDF_Stream*         GetNormalIcon()
1734     {
1735         return GetIcon(FX_BSTRC("I"));
1736     }
1737
1738
1739
1740
1741     inline CPDF_Stream*         GetRolloverIcon()
1742     {
1743         return GetIcon(FX_BSTRC("RI"));
1744     }
1745
1746
1747
1748
1749     inline CPDF_Stream*         GetDownIcon()
1750     {
1751         return GetIcon(FX_BSTRC("IX"));
1752     }
1753
1754
1755
1756
1757     CPDF_IconFit                        GetIconFit();
1758
1759
1760
1761
1762     int                                         GetTextPosition();
1763
1764     CPDF_Dictionary*            m_pDict;
1765 protected:
1766
1767     FX_ARGB                                     GetColor(int& iColorType, FX_BSTR csEntry);
1768
1769     FX_FLOAT                            GetOriginalColor(int index, FX_BSTR csEntry);
1770
1771     void                                        GetOriginalColor(int& iColorType, FX_FLOAT fc[4], FX_BSTR csEntry);
1772
1773     CFX_WideString                      GetCaption(FX_BSTR csEntry);
1774
1775     CPDF_Stream*                        GetIcon(FX_BSTR csEntry);
1776     friend class                        CPDF_FormControl;
1777 };
1778 #endif