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