Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: core/include/fpdfdoc/fpdf_doc.h

Issue 1278053004: Add new public APIs to find the z-order for links and widgets. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/src/fpdfdoc/doc_form.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_ 7 #ifndef CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
8 #define CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_ 8 #define CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
9 9
10 #include <map> 10 #include <map>
11 #include <vector>
11 12
12 #include "../../../third_party/base/nonstd_unique_ptr.h" 13 #include "../../../third_party/base/nonstd_unique_ptr.h"
13 #include "../fpdfapi/fpdf_parser.h" 14 #include "../fpdfapi/fpdf_parser.h"
14 #include "../fpdfapi/fpdf_render.h" 15 #include "../fpdfapi/fpdf_render.h"
15 16
16 class CFieldTree; 17 class CFieldTree;
17 class CPDF_AAction; 18 class CPDF_AAction;
18 class CPDF_Action; 19 class CPDF_Action;
19 class CPDF_ActionFields; 20 class CPDF_ActionFields;
20 class CPDF_Annot; 21 class CPDF_Annot;
21 class CPDF_AnnotList; 22 class CPDF_AnnotList;
22 class CPDF_ApSettings; 23 class CPDF_ApSettings;
23 class CPDF_Bookmark; 24 class CPDF_Bookmark;
24 class CPDF_BookmarkTree; 25 class CPDF_BookmarkTree;
25 class CPDF_DefaultAppearance; 26 class CPDF_DefaultAppearance;
26 class CPDF_Dest; 27 class CPDF_Dest;
27 class CPDF_DocJSActions; 28 class CPDF_DocJSActions;
28 class CPDF_FileSpec; 29 class CPDF_FileSpec;
29 class CPDF_FormControl; 30 class CPDF_FormControl;
30 class CPDF_FormField; 31 class CPDF_FormField;
31 class CPDF_FormNotify; 32 class CPDF_FormNotify;
32 class CPDF_IconFit; 33 class CPDF_IconFit;
33 class CPDF_InterForm; 34 class CPDF_InterForm;
34 class CPDF_Link; 35 class CPDF_Link;
35 class CPDF_LinkList;
36 class CPDF_LWinParam; 36 class CPDF_LWinParam;
37 class CPDF_Metadata; 37 class CPDF_Metadata;
38 class CPDF_NumberTree; 38 class CPDF_NumberTree;
39 class CPDF_OCContext; 39 class CPDF_OCContext;
40 class CPDF_Page; 40 class CPDF_Page;
41 class CPDF_RenderOptions; 41 class CPDF_RenderOptions;
42 class CPDF_TextObject; 42 class CPDF_TextObject;
43 class CPDF_ViewerPreferences; 43 class CPDF_ViewerPreferences;
44 class CXML_Element; 44 class CXML_Element;
45 45
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 FX_BOOL GetFileName(CFX_WideString& wsFileName) const; 351 FX_BOOL GetFileName(CFX_WideString& wsFileName) const;
352 352
353 CPDF_Stream* GetFileStream() const; 353 CPDF_Stream* GetFileStream() const;
354 354
355 void SetFileName(const CFX_WideStringC& wsFileName, FX_BOOL bURL = FALSE); 355 void SetFileName(const CFX_WideStringC& wsFileName, FX_BOOL bURL = FALSE);
356 356
357 protected: 357 protected:
358 CPDF_Object* m_pObj; 358 CPDF_Object* m_pObj;
359 }; 359 };
360
360 class CPDF_LinkList { 361 class CPDF_LinkList {
361 public: 362 public:
362 CPDF_LinkList(CPDF_Document* pDoc) { m_pDocument = pDoc; } 363 CPDF_LinkList();
363
364 ~CPDF_LinkList(); 364 ~CPDF_LinkList();
365 365
366 CPDF_Link GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y); 366 CPDF_Link GetLinkAtPoint(CPDF_Page* pPage,
367 FX_FLOAT pdf_x,
368 FX_FLOAT pdf_y,
369 int* z_order);
367 370
368 int CountLinks(CPDF_Page* pPage); 371 private:
372 const std::vector<CPDF_Dictionary*>* GetPageLinks(CPDF_Page* pPage);
369 373
370 CPDF_Link GetLink(CPDF_Page* pPage, int index); 374 void LoadPageLinks(CPDF_Page* pPage, std::vector<CPDF_Dictionary*>* pList);
371 375
372 CPDF_Document* GetDocument() const { return m_pDocument; } 376 std::map<FX_DWORD, std::vector<CPDF_Dictionary*>> m_PageMap;
377 };
373 378
374 protected:
375 CPDF_Document* m_pDocument;
376
377 CFX_MapPtrToPtr m_PageMap;
378
379 CFX_PtrArray* GetPageLinks(CPDF_Page* pPage);
380
381 void LoadPageLinks(CPDF_Page* pPage, CFX_PtrArray* pList);
382 };
383 class CPDF_Link { 379 class CPDF_Link {
384 public: 380 public:
385 CPDF_Link() : m_pDict(nullptr) {} 381 CPDF_Link() : m_pDict(nullptr) {}
386 explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {} 382 explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
387 383
388 CPDF_Dictionary* GetDict() const { return m_pDict; } 384 CPDF_Dictionary* GetDict() const { return m_pDict; }
389 385
390 CFX_FloatRect GetRect(); 386 CFX_FloatRect GetRect();
391 CPDF_Dest GetDest(CPDF_Document* pDoc); 387 CPDF_Dest GetDest(CPDF_Document* pDoc);
392 CPDF_Action GetAction(); 388 CPDF_Action GetAction();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 631
636 CPDF_FormField* GetField(FX_DWORD index, 632 CPDF_FormField* GetField(FX_DWORD index,
637 const CFX_WideString& csFieldName = L""); 633 const CFX_WideString& csFieldName = L"");
638 634
639 void GetAllFieldNames(CFX_WideStringArray& allFieldNames); 635 void GetAllFieldNames(CFX_WideStringArray& allFieldNames);
640 636
641 FX_BOOL IsValidFormField(const void* pField); 637 FX_BOOL IsValidFormField(const void* pField);
642 638
643 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; 639 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
644 640
645 FX_DWORD CountControls(CFX_WideString csFieldName = L"");
646
647 CPDF_FormControl* GetControl(FX_DWORD index,
648 CFX_WideString csFieldName = L"");
649
650 FX_BOOL IsValidFormControl(const void* pControl);
651
652 int CountPageControls(CPDF_Page* pPage) const;
653
654 CPDF_FormControl* GetPageControl(CPDF_Page* pPage, int index) const;
655
656 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, 641 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage,
657 FX_FLOAT pdf_x, 642 FX_FLOAT pdf_x,
658 FX_FLOAT pdf_y) const; 643 FX_FLOAT pdf_y,
644 int* z_order) const;
659 645
660 CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const; 646 CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const;
661 647
662 FX_DWORD CountInternalFields(const CFX_WideString& csFieldName = L"") const;
663
664 CPDF_Dictionary* GetInternalField(
665 FX_DWORD index,
666 const CFX_WideString& csFieldName = L"") const;
667
668 CPDF_Document* GetDocument() const { return m_pDocument; } 648 CPDF_Document* GetDocument() const { return m_pDocument; }
669 649
670 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } 650 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; }
671 651
672 FX_BOOL NeedConstructAP(); 652 FX_BOOL NeedConstructAP();
673 653
674 void NeedConstructAP(FX_BOOL bNeedAP); 654 void NeedConstructAP(FX_BOOL bNeedAP);
675 655
676 int CountFieldsInCalculationOrder(); 656 int CountFieldsInCalculationOrder();
677 657
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 FX_BOOL bSimpleFileSpec = FALSE) const; 711 FX_BOOL bSimpleFileSpec = FALSE) const;
732 712
733 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); 713 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE);
734 714
735 FX_BOOL ResetForm(const CFX_PtrArray& fields, 715 FX_BOOL ResetForm(const CFX_PtrArray& fields,
736 FX_BOOL bIncludeOrExclude = TRUE, 716 FX_BOOL bIncludeOrExclude = TRUE,
737 FX_BOOL bNotify = FALSE); 717 FX_BOOL bNotify = FALSE);
738 718
739 FX_BOOL ResetForm(FX_BOOL bNotify = FALSE); 719 FX_BOOL ResetForm(FX_BOOL bNotify = FALSE);
740 720
741 void ReloadForm();
742
743 CPDF_FormNotify* GetFormNotify() const { return m_pFormNotify; } 721 CPDF_FormNotify* GetFormNotify() const { return m_pFormNotify; }
744 722
745 void SetFormNotify(const CPDF_FormNotify* pNotify); 723 void SetFormNotify(const CPDF_FormNotify* pNotify);
746 724
747 int GetPageWithWidget(int iCurPage, FX_BOOL bNext);
748
749 FX_BOOL IsUpdated() { return m_bUpdated; } 725 FX_BOOL IsUpdated() { return m_bUpdated; }
750 726
751 void ClearUpdatedFlag() { m_bUpdated = FALSE; } 727 void ClearUpdatedFlag() { m_bUpdated = FALSE; }
752 728
753 FX_BOOL HasXFAForm() const; 729 FX_BOOL HasXFAForm() const;
754 730
755 void FixPageFields(const CPDF_Page* pPage); 731 void FixPageFields(const CPDF_Page* pPage);
756 732
757 protected: 733 protected:
758 static FX_BOOL m_bUpdateAP; 734 static FX_BOOL m_bUpdateAP;
(...skipping 22 matching lines...) Expand all
781 757
782 int CompareFieldName(const CFX_ByteString& name1, 758 int CompareFieldName(const CFX_ByteString& name1,
783 const CFX_ByteString& name2); 759 const CFX_ByteString& name2);
784 760
785 CPDF_Document* m_pDocument; 761 CPDF_Document* m_pDocument;
786 762
787 FX_BOOL m_bGenerateAP; 763 FX_BOOL m_bGenerateAP;
788 764
789 CPDF_Dictionary* m_pFormDict; 765 CPDF_Dictionary* m_pFormDict;
790 766
791 CFX_MapPtrToPtr m_ControlMap; 767 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap;
792 768
793 CFieldTree* m_pFieldTree; 769 CFieldTree* m_pFieldTree;
794 770
795 CFX_ByteString m_bsEncoding; 771 CFX_ByteString m_bsEncoding;
796 772
797 CPDF_FormNotify* m_pFormNotify; 773 CPDF_FormNotify* m_pFormNotify;
798 774
799 FX_BOOL m_bUpdated; 775 FX_BOOL m_bUpdated;
800 friend class CPDF_FormControl; 776 friend class CPDF_FormControl;
801 friend class CPDF_FormField; 777 friend class CPDF_FormField;
(...skipping 23 matching lines...) Expand all
825 ComboBox, 801 ComboBox,
826 Sign 802 Sign
827 }; 803 };
828 804
829 CFX_WideString GetFullName(); 805 CFX_WideString GetFullName();
830 806
831 Type GetType() { return m_Type; } 807 Type GetType() { return m_Type; }
832 808
833 FX_DWORD GetFlags() { return m_Flags; } 809 FX_DWORD GetFlags() { return m_Flags; }
834 810
835 CPDF_InterForm* GetInterForm() const { return m_pForm; }
836
837 CPDF_Dictionary* GetFieldDict() const { return m_pDict; } 811 CPDF_Dictionary* GetFieldDict() const { return m_pDict; }
838 812
839 void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; } 813 void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; }
840 814
841 FX_BOOL ResetField(FX_BOOL bNotify = FALSE); 815 FX_BOOL ResetField(FX_BOOL bNotify = FALSE);
842 816
843 int CountControls() { return m_ControlList.GetSize(); } 817 int CountControls() { return m_ControlList.GetSize(); }
844 818
845 CPDF_FormControl* GetControl(int index) { 819 CPDF_FormControl* GetControl(int index) {
846 return (CPDF_FormControl*)m_ControlList.GetAt(index); 820 return (CPDF_FormControl*)m_ControlList.GetAt(index);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 class CPDF_FormControl { 967 class CPDF_FormControl {
994 public: 968 public:
995 CPDF_FormField::Type GetType() { return m_pField->GetType(); } 969 CPDF_FormField::Type GetType() { return m_pField->GetType(); }
996 970
997 CPDF_InterForm* GetInterForm() const { return m_pForm; } 971 CPDF_InterForm* GetInterForm() const { return m_pForm; }
998 972
999 CPDF_FormField* GetField() const { return m_pField; } 973 CPDF_FormField* GetField() const { return m_pField; }
1000 974
1001 CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } 975 CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; }
1002 976
1003 CFX_FloatRect GetRect(); 977 CFX_FloatRect GetRect() const;
1004 978
1005 void DrawControl(CFX_RenderDevice* pDevice, 979 void DrawControl(CFX_RenderDevice* pDevice,
1006 CFX_AffineMatrix* pMatrix, 980 CFX_AffineMatrix* pMatrix,
1007 CPDF_Page* pPage, 981 CPDF_Page* pPage,
1008 CPDF_Annot::AppearanceMode mode, 982 CPDF_Annot::AppearanceMode mode,
1009 const CPDF_RenderOptions* pOptions = NULL); 983 const CPDF_RenderOptions* pOptions = NULL);
1010 984
1011 CFX_ByteString GetCheckedAPState(); 985 CFX_ByteString GetCheckedAPState();
1012 986
1013 CFX_WideString GetExportValue(); 987 CFX_WideString GetExportValue();
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 FX_FLOAT fc[4], 1220 FX_FLOAT fc[4],
1247 const CFX_ByteStringC& csEntry); 1221 const CFX_ByteStringC& csEntry);
1248 1222
1249 CFX_WideString GetCaption(const CFX_ByteStringC& csEntry); 1223 CFX_WideString GetCaption(const CFX_ByteStringC& csEntry);
1250 1224
1251 CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry); 1225 CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry);
1252 friend class CPDF_FormControl; 1226 friend class CPDF_FormControl;
1253 }; 1227 };
1254 1228
1255 #endif // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_ 1229 #endif // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfdoc/doc_form.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698