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