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