Merge to XFA: Make conversions for CPDF_Link explicit.
[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     CPDF_Link() : m_pDict(nullptr) { }
549     explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) { }
550
551     CPDF_Dictionary* GetDict() const { return m_pDict; }
552
553     CFX_FloatRect               GetRect();
554     CPDF_Dest                   GetDest(CPDF_Document* pDoc);
555     CPDF_Action                 GetAction();
556
557 protected:
558     CPDF_Dictionary*    m_pDict;
559 };
560 #define ANNOTFLAG_INVISIBLE                     1
561 #define ANNOTFLAG_HIDDEN                        2
562 #define ANNOTFLAG_PRINT                         4
563 #define ANNOTFLAG_NOZOOM                        8
564 #define ANNOTFLAG_NOROTATE                      0x10
565 #define ANNOTFLAG_NOVIEW                        0x20
566 #define ANNOTFLAG_READONLY                      0x40
567 #define ANNOTFLAG_LOCKED                        0x80
568 #define ANNOTFLAG_TOGGLENOVIEW          0x100
569 class CPDF_Annot : public CFX_PrivateData, public CFX_Object
570 {
571 public:
572
573     CPDF_Annot(CPDF_Dictionary* pDict);
574
575     ~CPDF_Annot();
576
577     CPDF_Dictionary*    m_pAnnotDict;
578
579     CFX_ByteString              GetSubType() const;
580
581     FX_DWORD                    GetFlags() const
582     {
583         return m_pAnnotDict->GetInteger("F");
584     }
585
586     void                                GetRect(CFX_FloatRect& rect) const;
587
588     enum AppearanceMode {
589         Normal,
590         Rollover,
591         Down
592     };
593
594     FX_BOOL                             DrawAppearance(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
595                                        AppearanceMode mode, const CPDF_RenderOptions* pOptions);
596
597     FX_BOOL                             DrawInContext(const CPDF_Page* pPage, const CPDF_RenderContext* pContext,
598                                       const CFX_AffineMatrix* pUser2Device, AppearanceMode mode);
599
600     void                                ClearCachedAP();
601
602
603     void                                DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
604                                    const CPDF_RenderOptions* pOptions);
605
606     CPDF_PageObject*    GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions* pOptions);
607
608
609
610     int                                 CountIRTNotes();
611
612     CPDF_Annot*                 GetIRTNote(int index);
613
614
615     CPDF_Form*                  GetAPForm(const CPDF_Page* pPage, AppearanceMode mode);
616 private:
617
618     CFX_MapPtrToPtr             m_APMap;
619 protected:
620     friend class                CPDF_AnnotList;
621
622     CPDF_AnnotList*             m_pList;
623
624     CPDF_Reference*             NewAnnotRef();
625 };
626 class CPDF_AnnotList : public CFX_Object
627 {
628 public:
629
630     CPDF_AnnotList(CPDF_Page* pPage);
631
632     ~CPDF_AnnotList();
633
634     void        GetAnnotMatrix(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CFX_Matrix &matrix) const;
635
636     void        GetAnnotRect(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CPDF_Rect &rtAnnot) const;
637
638     void                                DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice,
639                                       CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
640                                       CPDF_RenderOptions* pOptions);
641
642     void                                DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext,
643                                       FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
644                                       CPDF_RenderOptions* pOptions)
645     {
646         DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, NULL);
647     }
648
649     void                                DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext,
650                                       FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
651                                       CPDF_RenderOptions* pOptions, FX_RECT *pClipRect)
652     {
653         DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, pClipRect);
654     }
655
656     void                                DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, CPDF_RenderContext* pContext,
657                                       FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_DWORD dwAnnotFlags,
658                                       CPDF_RenderOptions* pOptions, FX_RECT* pClipRect);
659
660
661
662     CPDF_Annot*                 GetAt(int index)
663     {
664         return (CPDF_Annot*)m_AnnotList.GetAt(index);
665     }
666
667     int                                 Count()
668     {
669         return m_AnnotList.GetSize();
670     }
671
672     int                                 GetIndex(CPDF_Annot* pAnnot);
673
674
675     CPDF_Document*              GetDocument() const
676     {
677         return m_pDocument;
678     }
679 protected:
680
681     CFX_PtrArray                m_AnnotList;
682
683     CPDF_Dictionary*    m_pPageDict;
684
685     CPDF_Document*              m_pDocument;
686
687     CFX_PtrArray                m_Borders;
688
689     void                                DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevice,
690                                     CPDF_RenderContext* pContext, FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix,
691                                     FX_BOOL bWidget, CPDF_RenderOptions* pOptions, FX_RECT* clip_rect);
692     friend class                CPDF_Annot;
693 };
694 #define COLORTYPE_TRANSPARENT   0
695 #define COLORTYPE_GRAY                  1
696 #define COLORTYPE_RGB                   2
697 #define COLORTYPE_CMYK                  3
698 class CPDF_DefaultAppearance : public CFX_Object
699 {
700 public:
701
702     CPDF_DefaultAppearance(const CFX_ByteString& csDA = "")
703     {
704         m_csDA = csDA;
705     }
706
707     CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA)
708     {
709         m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA;
710     }
711
712
713     operator CFX_ByteString() const
714     {
715         return m_csDA;
716     }
717
718     const CPDF_DefaultAppearance& operator =(const CFX_ByteString& csDA)
719     {
720         m_csDA = csDA;
721         return *this;
722     }
723
724     const CPDF_DefaultAppearance& operator =(const CPDF_DefaultAppearance& cDA)
725     {
726         m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA;
727         return *this;
728     }
729
730
731
732     FX_BOOL                             HasFont();
733
734     CFX_ByteString              GetFontString();
735
736     void                                GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize);
737
738
739
740
741     FX_BOOL                             HasColor(FX_BOOL bStrokingOperation = FALSE);
742
743     CFX_ByteString              GetColorString(FX_BOOL bStrokingOperation = FALSE);
744
745     void                                GetColor(int& iColorType, FX_FLOAT fc[4], FX_BOOL bStrokingOperation = FALSE);
746
747     void                                GetColor(FX_ARGB& color, int& iColorType, FX_BOOL bStrokingOperation = FALSE);
748
749
750
751
752     FX_BOOL                             HasTextMatrix();
753
754     CFX_ByteString              GetTextMatrixString();
755
756     CFX_AffineMatrix    GetTextMatrix();
757
758 protected:
759
760     CFX_ByteString              m_csDA;
761 };
762 #define FIELDTYPE_UNKNOWN                       0
763 #define FIELDTYPE_PUSHBUTTON            1
764 #define FIELDTYPE_CHECKBOX                      2
765 #define FIELDTYPE_RADIOBUTTON           3
766 #define FIELDTYPE_COMBOBOX                      4
767 #define FIELDTYPE_LISTBOX                       5
768 #define FIELDTYPE_TEXTFIELD                     6
769 #define FIELDTYPE_SIGNATURE                     7
770 class CPDF_InterForm : public CFX_PrivateData, public CFX_Object
771 {
772 public:
773
774     CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bUpdateAP);
775
776     ~CPDF_InterForm();
777
778
779
780     static void                         EnableUpdateAP(FX_BOOL bUpdateAP);
781
782     static FX_BOOL                      UpdatingAPEnabled();
783
784
785     static CFX_ByteString       GenerateNewResourceName(const CPDF_Dictionary* pResDict, FX_LPCSTR csType, int iMinLen = 2, FX_LPCSTR csPrefix = "");
786
787
788
789     static CPDF_Font*           AddSystemDefaultFont(const CPDF_Document* pDocument);
790
791     static CPDF_Font*           AddSystemFont(const CPDF_Document* pDocument, CFX_ByteString csFontName, FX_BYTE iCharSet = 1);
792
793     static CPDF_Font*           AddSystemFont(const CPDF_Document* pDocument, CFX_WideString csFontName, FX_BYTE iCharSet = 1);
794
795     static CPDF_Font*           AddStandardFont(const CPDF_Document* pDocument, CFX_ByteString csFontName);
796
797     static CFX_ByteString       GetNativeFont(FX_BYTE iCharSet, FX_LPVOID pLogFont = NULL);
798
799     static CFX_ByteString       GetNativeFont(FX_LPVOID pLogFont = NULL);
800
801     static FX_BYTE                      GetNativeCharSet();
802
803     static CPDF_Font*           AddNativeFont(FX_BYTE iCharSet, const CPDF_Document* pDocument);
804
805     static CPDF_Font*           AddNativeFont(const CPDF_Document* pDocument);
806
807
808
809
810     FX_BOOL                                     ValidateFieldName(CFX_WideString& csNewFieldName, int iType);
811
812     FX_BOOL                                     ValidateFieldName(const CPDF_FormField* pField, CFX_WideString& csNewFieldName);
813
814     FX_BOOL                                     ValidateFieldName(const CPDF_FormControl* pControl, CFX_WideString& csNewFieldName);
815
816
817
818
819     FX_DWORD                            CountFields(const CFX_WideString &csFieldName = L"");
820
821     CPDF_FormField*                     GetField(FX_DWORD index, const CFX_WideString &csFieldName = L"");
822
823     void                                        GetAllFieldNames(CFX_WideStringArray& allFieldNames);
824
825     FX_BOOL                                     IsValidFormField(const void* pField);
826
827     CPDF_FormField*                     GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
828
829
830
831
832     FX_DWORD                            CountControls(CFX_WideString csFieldName = L"");
833
834     CPDF_FormControl*           GetControl(FX_DWORD index, CFX_WideString csFieldName = L"");
835
836     FX_BOOL                                     IsValidFormControl(const void* pControl);
837
838     int                                         CountPageControls(CPDF_Page* pPage) const;
839
840     CPDF_FormControl*           GetPageControl(CPDF_Page* pPage, int index) const;
841
842
843     CPDF_FormControl*           GetControlAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y) const;
844
845     CPDF_FormControl*           GetControlByDict(CPDF_Dictionary* pWidgetDict) const;
846
847
848
849
850     FX_DWORD                            CountInternalFields(const CFX_WideString& csFieldName = L"") const;
851
852     CPDF_Dictionary*            GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName = L"") const;
853
854
855
856
857
858     CPDF_Document*                      GetDocument() const
859     {
860         return m_pDocument;
861     }
862
863     CPDF_Dictionary*            GetFormDict() const
864     {
865         return m_pFormDict;
866     }
867
868
869
870
871     FX_BOOL                                     NeedConstructAP();
872
873     void                                        NeedConstructAP(FX_BOOL bNeedAP);
874
875
876
877
878     int                                         CountFieldsInCalculationOrder();
879
880     CPDF_FormField*                     GetFieldInCalculationOrder(int index);
881
882     int                                         FindFieldInCalculationOrder(const CPDF_FormField* pField);
883
884
885
886
887     FX_DWORD                            CountFormFonts();
888
889     CPDF_Font*                          GetFormFont(FX_DWORD index, CFX_ByteString& csNameTag);
890
891     CPDF_Font*                          GetFormFont(CFX_ByteString csNameTag);
892
893     CPDF_Font*                          GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag);
894
895     CPDF_Font*                          GetNativeFormFont(FX_BYTE iCharSet, CFX_ByteString& csNameTag);
896
897     CPDF_Font*                          GetNativeFormFont(CFX_ByteString& csNameTag);
898
899     FX_BOOL                                     FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
900
901     FX_BOOL                                     FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag);
902
903     inline FX_BOOL                      FindFormFont(CFX_WideString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag)
904     {
905         return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag);
906     }
907
908
909
910
911
912     void                                        AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
913
914     CPDF_Font*                          AddNativeFormFont(FX_BYTE iCharSet, CFX_ByteString& csNameTag);
915
916     CPDF_Font*                          AddNativeFormFont(CFX_ByteString& csNameTag);
917
918     void                                        RemoveFormFont(const CPDF_Font* pFont);
919
920     void                                        RemoveFormFont(CFX_ByteString csNameTag);
921
922
923
924
925     CPDF_DefaultAppearance      GetDefaultAppearance();
926
927     CPDF_Font*                          GetDefaultFormFont();
928
929
930
931     int                                         GetFormAlignment();
932
933
934
935
936     CPDF_FormField*                     CheckRequiredFields(const CFX_PtrArray *fields = NULL, FX_BOOL bIncludeOrExclude = TRUE) const;
937
938     CFDF_Document*                      ExportToFDF(FX_WSTR pdf_path, FX_BOOL bSimpleFileSpec = FALSE) const;
939
940     CFDF_Document*                      ExportToFDF(FX_WSTR pdf_path, CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bSimpleFileSpec = FALSE) const;
941
942     FX_BOOL                                     ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE);
943
944
945
946
947     FX_BOOL                                     ResetForm(const CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bNotify = FALSE);
948
949     FX_BOOL                                     ResetForm(FX_BOOL bNotify = FALSE);
950
951     void                                        ReloadForm();
952
953     CPDF_FormNotify*            GetFormNotify() const
954     {
955         return m_pFormNotify;
956     }
957
958     void                                        SetFormNotify(const CPDF_FormNotify* pNotify);
959
960
961     int                                         GetPageWithWidget(int iCurPage, FX_BOOL bNext);
962
963
964
965     FX_BOOL                                     IsUpdated()
966     {
967         return m_bUpdated;
968     }
969
970     void                                        ClearUpdatedFlag()
971     {
972         m_bUpdated = FALSE;
973     }
974
975
976     FX_BOOL                                     HasXFAForm() const;
977
978     void                                        FixPageFields(const CPDF_Page* pPage);
979 protected:
980
981     static FX_BOOL                      m_bUpdateAP;
982
983     void                                        LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0);
984
985     CPDF_Object*                        GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name);
986
987     CPDF_FormField*                     AddTerminalField(const CPDF_Dictionary* pFieldDict);
988
989     CPDF_FormControl*           AddControl(const CPDF_FormField* pField, const CPDF_Dictionary* pWidgetDict);
990
991     void                                        FDF_ImportField(CPDF_Dictionary* pField, const CFX_WideString& parent_name, FX_BOOL bNotify = FALSE, int nLevel = 0);
992
993     FX_BOOL                                     ValidateFieldName(CFX_WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl);
994
995     int                                         CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2);
996
997     int                                         CompareFieldName(const CFX_ByteString& name1, const CFX_ByteString& name2);
998
999     CPDF_Document*                      m_pDocument;
1000
1001     FX_BOOL                                     m_bGenerateAP;
1002
1003     CPDF_Dictionary*            m_pFormDict;
1004
1005     CFX_MapPtrToPtr                     m_ControlMap;
1006
1007     CFieldTree *m_pFieldTree;
1008
1009     CFX_ByteString                      m_bsEncoding;
1010
1011     CPDF_FormNotify*            m_pFormNotify;
1012
1013     FX_BOOL                                     m_bUpdated;
1014     friend class CPDF_FormControl;
1015     friend class CPDF_FormField;
1016 };
1017 #define FORMFIELD_READONLY              0x01
1018 #define FORMFIELD_REQUIRED              0x02
1019 #define FORMFIELD_NOEXPORT              0x04
1020 #define FORMRADIO_NOTOGGLEOFF   0x100
1021 #define FORMRADIO_UNISON                0x200
1022 #define FORMTEXT_MULTILINE              0x100
1023 #define FORMTEXT_PASSWORD               0x200
1024 #define FORMTEXT_NOSCROLL               0x400
1025 #define FORMTEXT_COMB                   0x800
1026 #define FORMCOMBO_EDIT                  0x100
1027 #define FORMLIST_MULTISELECT    0x100
1028 class CPDF_FormField : public CFX_Object
1029 {
1030 public:
1031
1032     enum Type {
1033         Unknown,
1034         PushButton,
1035         RadioButton,
1036         CheckBox,
1037         Text,
1038         RichText,
1039         File,
1040         ListBox,
1041         ComboBox,
1042         Sign
1043     };
1044
1045     CFX_WideString                      GetFullName();
1046
1047     Type                                        GetType()
1048     {
1049         return m_Type;
1050     }
1051
1052     FX_DWORD                            GetFlags()
1053     {
1054         return m_Flags;
1055     }
1056
1057     CPDF_InterForm*                     GetInterForm() const
1058     {
1059         return m_pForm;
1060     }
1061
1062     CPDF_Dictionary*            GetFieldDict() const
1063     {
1064         return m_pDict;
1065     }
1066
1067     void                                        SetFieldDict(CPDF_Dictionary* pDict)
1068     {
1069         m_pDict = pDict;
1070     }
1071
1072     FX_BOOL                                     ResetField(FX_BOOL bNotify = FALSE);
1073
1074
1075
1076     int                                         CountControls()
1077     {
1078         return m_ControlList.GetSize();
1079     }
1080
1081     CPDF_FormControl*           GetControl(int index)
1082     {
1083         return (CPDF_FormControl*)m_ControlList.GetAt(index);
1084     }
1085
1086     int                                         GetControlIndex(const CPDF_FormControl* pControl);
1087
1088
1089
1090
1091     int                                         GetFieldType();
1092
1093
1094
1095
1096     CPDF_AAction                        GetAdditionalAction();
1097
1098
1099
1100
1101     CFX_WideString                      GetAlternateName();
1102
1103
1104
1105
1106     CFX_WideString                      GetMappingName();
1107
1108
1109
1110
1111     FX_DWORD                            GetFieldFlags();
1112
1113
1114
1115
1116     CFX_ByteString                      GetDefaultStyle();
1117
1118
1119
1120
1121     CFX_WideString                      GetRichTextString();
1122
1123
1124
1125     CFX_WideString                      GetValue();
1126
1127     CFX_WideString                      GetDefaultValue();
1128
1129     FX_BOOL                                     SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE);
1130
1131
1132
1133
1134
1135     int                                         GetMaxLen();
1136
1137
1138
1139
1140     int                                         CountSelectedItems();
1141
1142     int                                         GetSelectedIndex(int index);
1143
1144     FX_BOOL                                     ClearSelection(FX_BOOL bNotify = FALSE);
1145
1146     FX_BOOL                                     IsItemSelected(int index);
1147
1148     FX_BOOL                                     SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify = FALSE);
1149
1150     FX_BOOL                                     IsItemDefaultSelected(int index);
1151
1152     int                                         GetDefaultSelectedItem();
1153
1154
1155
1156
1157     int                                         CountOptions();
1158
1159     CFX_WideString                      GetOptionLabel(int index);
1160
1161     CFX_WideString                      GetOptionValue(int index);
1162
1163     int                                         FindOption(CFX_WideString csOptLabel);
1164
1165     int                                         FindOptionValue(FX_LPCWSTR csOptValue, int iStartIndex = 0);
1166
1167
1168
1169
1170     FX_BOOL                                     CheckControl(int iControlIndex, FX_BOOL bChecked, FX_BOOL bNotify = FALSE);
1171
1172
1173
1174
1175     int                                         GetTopVisibleIndex();
1176
1177
1178
1179
1180     int                                         CountSelectedOptions();
1181
1182     int                                         GetSelectedOptionIndex(int index);
1183
1184     FX_BOOL                                     IsOptionSelected(int iOptIndex);
1185
1186     FX_BOOL                                     SelectOption(int iOptIndex, FX_BOOL bSelected, FX_BOOL bNotify = FALSE);
1187
1188     FX_BOOL                                     ClearSelectedOptions(FX_BOOL bNotify = FALSE);
1189
1190     FX_BOOL                                     ClearOptions(FX_BOOL bNotify = FALSE);\r
1191
1192     int                                         InsertOption(CFX_WideString csOptLabel, int index = -1, FX_BOOL bNotify = FALSE);\r
1193
1194     FX_FLOAT                            GetFontSize()
1195     {
1196         return m_FontSize;
1197     }
1198
1199     CPDF_Font*                          GetFont()
1200     {
1201         return m_pFont;
1202     }
1203
1204 protected:
1205
1206     CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict);
1207
1208     ~CPDF_FormField();
1209
1210     CPDF_FormField::Type        m_Type;
1211
1212     FX_DWORD                            m_Flags;
1213
1214     CPDF_InterForm*                     m_pForm;
1215
1216     CPDF_Dictionary*            m_pDict;
1217
1218     CFX_PtrArray                        m_ControlList;
1219     friend class                        CPDF_InterForm;
1220     friend class                        CPDF_FormControl;
1221
1222
1223
1224     CFX_WideString                      GetValue(FX_BOOL bDefault);
1225
1226     FX_BOOL                                     SetValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify);
1227
1228
1229     void                                        SyncFieldFlags();
1230
1231     int                                         FindListSel(CPDF_String* str);
1232
1233     CFX_WideString                      GetOptionText(int index, int sub_index);
1234
1235     void                                        LoadDA();
1236
1237     void                                        UpdateAP(CPDF_FormControl* pControl);
1238
1239
1240
1241     CFX_WideString                      GetCheckValue(FX_BOOL bDefault);
1242
1243     FX_BOOL                                     SetCheckValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify);
1244
1245
1246     FX_FLOAT                            m_FontSize;
1247
1248     CPDF_Font*                          m_pFont;
1249 };
1250 CPDF_Object*    FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name, int nLevel = 0);
1251 class CPDF_IconFit : public CFX_Object
1252 {
1253 public:
1254
1255     CPDF_IconFit(CPDF_Dictionary* pDict = NULL)
1256     {
1257         m_pDict = pDict;
1258     }
1259
1260     operator CPDF_Dictionary*() const
1261     {
1262         return m_pDict;
1263     }
1264
1265
1266
1267
1268     enum ScaleMethod {
1269         Always = 0,
1270         Bigger,
1271         Smaller,
1272         Never
1273     };
1274
1275     ScaleMethod                         GetScaleMethod();
1276
1277
1278
1279
1280     FX_BOOL                                     IsProportionalScale();
1281
1282
1283
1284
1285     void                                        GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom);
1286
1287
1288
1289
1290     FX_BOOL                                     GetFittingBounds();
1291
1292
1293     CPDF_Dictionary*            m_pDict;
1294 };
1295
1296 #define TEXTPOS_CAPTION         0
1297 #define TEXTPOS_ICON            1
1298 #define TEXTPOS_BELOW           2
1299 #define TEXTPOS_ABOVE           3
1300 #define TEXTPOS_RIGHT           4
1301 #define TEXTPOS_LEFT            5
1302 #define TEXTPOS_OVERLAID        6
1303 class CPDF_FormControl : public CFX_Object
1304 {
1305 public:
1306
1307     CPDF_FormField::Type        GetType()
1308     {
1309         return m_pField->GetType();
1310     }
1311
1312     CPDF_InterForm*                     GetInterForm() const
1313     {
1314         return m_pForm;
1315     }
1316
1317     CPDF_FormField*                     GetField() const
1318     {
1319         return m_pField;
1320     }
1321
1322     CPDF_Dictionary*            GetWidget() const
1323     {
1324         return m_pWidgetDict;
1325     }
1326
1327     CFX_FloatRect                       GetRect();
1328
1329     void                                        DrawControl(CFX_RenderDevice* pDevice, CFX_AffineMatrix* pMatrix,
1330                                         CPDF_Page* pPage, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions = NULL);
1331
1332
1333
1334     CFX_ByteString                      GetCheckedAPState();
1335
1336     CFX_WideString                      GetExportValue();
1337
1338     FX_BOOL                                     IsChecked();
1339
1340     FX_BOOL                                     IsDefaultChecked();
1341
1342
1343
1344
1345     enum HighlightingMode       {
1346         None = 0,
1347         Invert,
1348         Outline,
1349         Push,
1350         Toggle
1351     };
1352
1353     HighlightingMode            GetHighlightingMode();
1354
1355
1356
1357
1358     FX_BOOL                                     HasMKEntry(CFX_ByteString csEntry);
1359
1360
1361
1362
1363     int                                         GetRotation();
1364
1365
1366
1367
1368     inline FX_ARGB                      GetBorderColor(int& iColorType)
1369     {
1370         return GetColor(iColorType, "BC");
1371     }
1372
1373     inline FX_FLOAT                     GetOriginalBorderColor(int index)
1374     {
1375         return GetOriginalColor(index, "BC");
1376     }
1377
1378     inline void                         GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4])
1379     {
1380         GetOriginalColor(iColorType, fc, "BC");
1381     }
1382
1383
1384
1385
1386     inline FX_ARGB                      GetBackgroundColor(int& iColorType)
1387     {
1388         return GetColor(iColorType, "BG");
1389     }
1390
1391     inline FX_FLOAT                     GetOriginalBackgroundColor(int index)
1392     {
1393         return GetOriginalColor(index, "BG");
1394     }
1395
1396     inline void                         GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4])
1397     {
1398         GetOriginalColor(iColorType, fc, "BG");
1399     }
1400
1401
1402
1403
1404     inline CFX_WideString       GetNormalCaption()
1405     {
1406         return GetCaption("CA");
1407     }
1408
1409
1410
1411
1412     inline CFX_WideString       GetRolloverCaption()
1413     {
1414         return GetCaption("RC");
1415     }
1416
1417
1418
1419
1420     inline CFX_WideString       GetDownCaption()
1421     {
1422         return GetCaption("AC");
1423     }
1424
1425
1426
1427
1428     inline CPDF_Stream*         GetNormalIcon()
1429     {
1430         return GetIcon("I");
1431     }
1432
1433
1434
1435
1436     inline CPDF_Stream*         GetRolloverIcon()
1437     {
1438         return GetIcon("RI");
1439     }
1440
1441
1442
1443
1444     inline CPDF_Stream*         GetDownIcon()
1445     {
1446         return GetIcon("IX");
1447     }
1448
1449
1450
1451
1452     CPDF_IconFit                        GetIconFit();
1453
1454
1455
1456
1457     int                                         GetTextPosition();
1458
1459
1460
1461
1462     CPDF_Action                         GetAction();
1463
1464
1465
1466
1467     CPDF_AAction                        GetAdditionalAction();
1468
1469
1470
1471
1472     CPDF_DefaultAppearance      GetDefaultAppearance();
1473
1474     CPDF_Font*                          GetDefaultControlFont();
1475
1476
1477
1478
1479     int                                         GetControlAlignment();
1480
1481 protected:
1482
1483     CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict);
1484
1485     CFX_ByteString                      GetOnStateName();
1486
1487     void                                        SetOnStateName(const CFX_ByteString& csOn);
1488
1489     void                                        CheckControl(FX_BOOL bChecked);
1490
1491     FX_ARGB                                     GetColor(int& iColorType, CFX_ByteString csEntry);
1492
1493     FX_FLOAT                            GetOriginalColor(int index, CFX_ByteString csEntry);
1494
1495     void                                        GetOriginalColor(int& iColorType, FX_FLOAT fc[4], CFX_ByteString csEntry);
1496
1497     CFX_WideString                      GetCaption(CFX_ByteString csEntry);
1498
1499     CPDF_Stream*                        GetIcon(CFX_ByteString csEntry);
1500
1501     CPDF_ApSettings                     GetMK(FX_BOOL bCreate);
1502
1503     CPDF_InterForm*                     m_pForm;
1504
1505     CPDF_FormField*                     m_pField;
1506
1507     CPDF_Dictionary*            m_pWidgetDict;
1508     friend class                        CPDF_InterForm;
1509     friend class                        CPDF_FormField;
1510 };
1511 class CPDF_FormNotify : public CFX_Object
1512 {
1513 public:
1514
1515     virtual ~CPDF_FormNotify() {}
1516
1517     virtual int         BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue)
1518     {
1519         return 0;
1520     }
1521
1522     virtual int         AfterValueChange(const CPDF_FormField* pField)
1523     {
1524         return 0;
1525     }
1526
1527     virtual int         BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue)
1528     {
1529         return 0;
1530     }
1531
1532     virtual int         AfterSelectionChange(const CPDF_FormField* pField)
1533     {
1534         return 0;
1535     }
1536
1537     virtual int         AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray)
1538     {
1539         return 0;
1540     }
1541
1542     virtual int         BeforeFormReset(const CPDF_InterForm* pForm)
1543     {
1544         return 0;
1545     }
1546
1547     virtual int         AfterFormReset(const CPDF_InterForm* pForm)
1548     {
1549         return 0;
1550     }
1551
1552     virtual int         BeforeFormImportData(const CPDF_InterForm* pForm)
1553     {
1554         return 0;
1555     }
1556
1557     virtual int         AfterFormImportData(const CPDF_InterForm* pForm)
1558     {
1559         return 0;
1560     }
1561 };
1562 FX_BOOL         FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
1563 class CPDF_PageLabel : public CFX_Object
1564 {
1565 public:
1566
1567     CPDF_PageLabel(CPDF_Document* pDocument)
1568     {
1569         m_pDocument = pDocument;
1570     }
1571
1572
1573     CFX_WideString                                      GetLabel(int nPage) const;
1574
1575     FX_INT32                                            GetPageByLabel(FX_BSTR bsLabel) const;
1576
1577
1578     FX_INT32                                            GetPageByLabel(FX_WSTR wsLabel) const;
1579
1580 protected:
1581     CPDF_Document*                                      m_pDocument;
1582 };
1583 class CPDF_Metadata
1584 {
1585 public:
1586
1587     CPDF_Metadata();
1588
1589
1590     ~CPDF_Metadata();
1591
1592     void                                LoadDoc(CPDF_Document *pDoc);
1593
1594
1595     FX_INT32                    GetString(FX_BSTR bsItem, CFX_WideString &wsStr);
1596
1597     CXML_Element*               GetRoot() const;
1598
1599     CXML_Element*               GetRDF() const;
1600
1601 protected:
1602     FX_LPVOID   m_pData;
1603 };
1604 class CPDF_ViewerPreferences
1605 {
1606 public:
1607
1608     CPDF_ViewerPreferences(CPDF_Document *pDoc);
1609
1610
1611     ~CPDF_ViewerPreferences();
1612
1613
1614     FX_BOOL IsDirectionR2L() const;
1615
1616     FX_BOOL PrintScaling() const;
1617
1618     FX_INT32 NumCopies() const;
1619
1620     CPDF_Array* PrintPageRange() const;
1621
1622     CFX_ByteString Duplex() const;
1623
1624 protected:
1625     CPDF_Document*      m_pDoc;
1626 };
1627 class CPDF_ApSettings : public CFX_Object
1628 {
1629 public:
1630
1631     CPDF_ApSettings(CPDF_Dictionary* pDict = NULL)
1632     {
1633         m_pDict = pDict;
1634     }
1635
1636     operator CPDF_Dictionary* () const
1637     {
1638         return m_pDict;
1639     }
1640
1641     FX_BOOL                                     HasMKEntry(FX_BSTR csEntry);
1642
1643
1644
1645     int                                         GetRotation();
1646
1647
1648
1649
1650     inline FX_ARGB                      GetBorderColor(int& iColorType)
1651     {
1652         return GetColor(iColorType, FX_BSTRC("BC"));
1653     }
1654
1655     inline FX_FLOAT                     GetOriginalBorderColor(int index)
1656     {
1657         return GetOriginalColor(index, FX_BSTRC("BC"));
1658     }
1659
1660     inline void                         GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4])
1661     {
1662         GetOriginalColor(iColorType, fc, FX_BSTRC("BC"));
1663     }
1664
1665
1666
1667
1668     inline FX_ARGB                      GetBackgroundColor(int& iColorType)
1669     {
1670         return GetColor(iColorType, FX_BSTRC("BG"));
1671     }
1672
1673     inline FX_FLOAT                     GetOriginalBackgroundColor(int index)
1674     {
1675         return GetOriginalColor(index, FX_BSTRC("BG"));
1676     }
1677
1678     inline void                         GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4])
1679     {
1680         GetOriginalColor(iColorType, fc, FX_BSTRC("BG"));
1681     }
1682
1683
1684
1685
1686     inline CFX_WideString       GetNormalCaption()
1687     {
1688         return GetCaption(FX_BSTRC("CA"));
1689     }
1690
1691
1692
1693
1694     inline CFX_WideString       GetRolloverCaption()
1695     {
1696         return GetCaption(FX_BSTRC("RC"));
1697     }
1698
1699
1700
1701
1702     inline CFX_WideString       GetDownCaption()
1703     {
1704         return GetCaption(FX_BSTRC("AC"));
1705     }
1706
1707
1708
1709
1710     inline CPDF_Stream*         GetNormalIcon()
1711     {
1712         return GetIcon(FX_BSTRC("I"));
1713     }
1714
1715
1716
1717
1718     inline CPDF_Stream*         GetRolloverIcon()
1719     {
1720         return GetIcon(FX_BSTRC("RI"));
1721     }
1722
1723
1724
1725
1726     inline CPDF_Stream*         GetDownIcon()
1727     {
1728         return GetIcon(FX_BSTRC("IX"));
1729     }
1730
1731
1732
1733
1734     CPDF_IconFit                        GetIconFit();
1735
1736
1737
1738
1739     int                                         GetTextPosition();
1740
1741     CPDF_Dictionary*            m_pDict;
1742 protected:
1743
1744     FX_ARGB                                     GetColor(int& iColorType, FX_BSTR csEntry);
1745
1746     FX_FLOAT                            GetOriginalColor(int index, FX_BSTR csEntry);
1747
1748     void                                        GetOriginalColor(int& iColorType, FX_FLOAT fc[4], FX_BSTR csEntry);
1749
1750     CFX_WideString                      GetCaption(FX_BSTR csEntry);
1751
1752     CPDF_Stream*                        GetIcon(FX_BSTR csEntry);
1753     friend class                        CPDF_FormControl;
1754 };
1755 #endif