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