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