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

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: address rest of comments 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') | core/src/fpdfdoc/doc_form.cpp » ('J')
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 "../fpdfapi/fpdf_parser.h" 13 #include "../fpdfapi/fpdf_parser.h"
13 #include "../fpdfapi/fpdf_render.h" 14 #include "../fpdfapi/fpdf_render.h"
14 15
15 class CFieldTree; 16 class CFieldTree;
16 class CPDF_AAction; 17 class CPDF_AAction;
17 class CPDF_Action; 18 class CPDF_Action;
18 class CPDF_ActionFields; 19 class CPDF_ActionFields;
19 class CPDF_Annot; 20 class CPDF_Annot;
20 class CPDF_AnnotList; 21 class CPDF_AnnotList;
21 class CPDF_ApSettings; 22 class CPDF_ApSettings;
22 class CPDF_Bookmark; 23 class CPDF_Bookmark;
23 class CPDF_BookmarkTree; 24 class CPDF_BookmarkTree;
24 class CPDF_DefaultAppearance; 25 class CPDF_DefaultAppearance;
25 class CPDF_Dest; 26 class CPDF_Dest;
26 class CPDF_DocJSActions; 27 class CPDF_DocJSActions;
27 class CPDF_FileSpec; 28 class CPDF_FileSpec;
28 class CPDF_FormControl; 29 class CPDF_FormControl;
29 class CPDF_FormField; 30 class CPDF_FormField;
30 class CPDF_FormNotify; 31 class CPDF_FormNotify;
31 class CPDF_IconFit; 32 class CPDF_IconFit;
32 class CPDF_InterForm; 33 class CPDF_InterForm;
33 class CPDF_Link; 34 class CPDF_Link;
34 class CPDF_LinkList;
35 class CPDF_LWinParam; 35 class CPDF_LWinParam;
36 class CPDF_Metadata; 36 class CPDF_Metadata;
37 class CPDF_NumberTree; 37 class CPDF_NumberTree;
38 class CPDF_OCContext; 38 class CPDF_OCContext;
39 class CPDF_Page; 39 class CPDF_Page;
40 class CPDF_RenderOptions; 40 class CPDF_RenderOptions;
41 class CPDF_TextObject; 41 class CPDF_TextObject;
42 class CPDF_ViewerPreferences; 42 class CPDF_ViewerPreferences;
43 class CXML_Element; 43 class CXML_Element;
44 44
(...skipping 305 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 632
637 CPDF_FormField* GetField(FX_DWORD index, 633 CPDF_FormField* GetField(FX_DWORD index,
638 const CFX_WideString& csFieldName = L""); 634 const CFX_WideString& csFieldName = L"");
639 635
640 void GetAllFieldNames(CFX_WideStringArray& allFieldNames); 636 void GetAllFieldNames(CFX_WideStringArray& allFieldNames);
641 637
642 FX_BOOL IsValidFormField(const void* pField); 638 FX_BOOL IsValidFormField(const void* pField);
643 639
644 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; 640 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
645 641
646 FX_DWORD CountControls(CFX_WideString csFieldName = L"");
647
648 CPDF_FormControl* GetControl(FX_DWORD index,
649 CFX_WideString csFieldName = L"");
650
651 FX_BOOL IsValidFormControl(const void* pControl);
652
653 int CountPageControls(CPDF_Page* pPage) const;
654
655 CPDF_FormControl* GetPageControl(CPDF_Page* pPage, int index) const;
656
657 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, 642 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage,
658 FX_FLOAT pdf_x, 643 FX_FLOAT pdf_x,
659 FX_FLOAT pdf_y) const; 644 FX_FLOAT pdf_y,
645 int* z_order) const;
660 646
661 CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const; 647 CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const;
662 648
663 FX_DWORD CountInternalFields(const CFX_WideString& csFieldName = L"") const;
664
665 CPDF_Dictionary* GetInternalField(
666 FX_DWORD index,
667 const CFX_WideString& csFieldName = L"") const;
668
669 CPDF_Document* GetDocument() const { return m_pDocument; } 649 CPDF_Document* GetDocument() const { return m_pDocument; }
670 650
671 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } 651 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; }
672 652
673 FX_BOOL NeedConstructAP(); 653 FX_BOOL NeedConstructAP();
674 654
675 void NeedConstructAP(FX_BOOL bNeedAP); 655 void NeedConstructAP(FX_BOOL bNeedAP);
676 656
677 int CountFieldsInCalculationOrder(); 657 int CountFieldsInCalculationOrder();
678 658
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 FX_BOOL bSimpleFileSpec = FALSE) const; 712 FX_BOOL bSimpleFileSpec = FALSE) const;
733 713
734 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); 714 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE);
735 715
736 FX_BOOL ResetForm(const CFX_PtrArray& fields, 716 FX_BOOL ResetForm(const CFX_PtrArray& fields,
737 FX_BOOL bIncludeOrExclude = TRUE, 717 FX_BOOL bIncludeOrExclude = TRUE,
738 FX_BOOL bNotify = FALSE); 718 FX_BOOL bNotify = FALSE);
739 719
740 FX_BOOL ResetForm(FX_BOOL bNotify = FALSE); 720 FX_BOOL ResetForm(FX_BOOL bNotify = FALSE);
741 721
742 void ReloadForm();
743
744 CPDF_FormNotify* GetFormNotify() const { return m_pFormNotify; } 722 CPDF_FormNotify* GetFormNotify() const { return m_pFormNotify; }
745 723
746 void SetFormNotify(const CPDF_FormNotify* pNotify); 724 void SetFormNotify(const CPDF_FormNotify* pNotify);
747 725
748 int GetPageWithWidget(int iCurPage, FX_BOOL bNext);
749
750 FX_BOOL IsUpdated() { return m_bUpdated; } 726 FX_BOOL IsUpdated() { return m_bUpdated; }
751 727
752 void ClearUpdatedFlag() { m_bUpdated = FALSE; } 728 void ClearUpdatedFlag() { m_bUpdated = FALSE; }
753 729
754 FX_BOOL HasXFAForm() const; 730 FX_BOOL HasXFAForm() const;
755 731
756 void FixPageFields(const CPDF_Page* pPage); 732 void FixPageFields(const CPDF_Page* pPage);
757 733
758 protected: 734 protected:
759 static FX_BOOL m_bUpdateAP; 735 static FX_BOOL m_bUpdateAP;
(...skipping 22 matching lines...) Expand all
782 758
783 int CompareFieldName(const CFX_ByteString& name1, 759 int CompareFieldName(const CFX_ByteString& name1,
784 const CFX_ByteString& name2); 760 const CFX_ByteString& name2);
785 761
786 CPDF_Document* m_pDocument; 762 CPDF_Document* m_pDocument;
787 763
788 FX_BOOL m_bGenerateAP; 764 FX_BOOL m_bGenerateAP;
789 765
790 CPDF_Dictionary* m_pFormDict; 766 CPDF_Dictionary* m_pFormDict;
791 767
792 CFX_MapPtrToPtr m_ControlMap; 768 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap;
793 769
794 CFieldTree* m_pFieldTree; 770 CFieldTree* m_pFieldTree;
795 771
796 CFX_ByteString m_bsEncoding; 772 CFX_ByteString m_bsEncoding;
797 773
798 CPDF_FormNotify* m_pFormNotify; 774 CPDF_FormNotify* m_pFormNotify;
799 775
800 FX_BOOL m_bUpdated; 776 FX_BOOL m_bUpdated;
801 friend class CPDF_FormControl; 777 friend class CPDF_FormControl;
802 friend class CPDF_FormField; 778 friend class CPDF_FormField;
(...skipping 23 matching lines...) Expand all
826 ComboBox, 802 ComboBox,
827 Sign 803 Sign
828 }; 804 };
829 805
830 CFX_WideString GetFullName(); 806 CFX_WideString GetFullName();
831 807
832 Type GetType() { return m_Type; } 808 Type GetType() { return m_Type; }
833 809
834 FX_DWORD GetFlags() { return m_Flags; } 810 FX_DWORD GetFlags() { return m_Flags; }
835 811
836 CPDF_InterForm* GetInterForm() const { return m_pForm; }
837
838 CPDF_Dictionary* GetFieldDict() const { return m_pDict; } 812 CPDF_Dictionary* GetFieldDict() const { return m_pDict; }
839 813
840 void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; } 814 void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; }
841 815
842 FX_BOOL ResetField(FX_BOOL bNotify = FALSE); 816 FX_BOOL ResetField(FX_BOOL bNotify = FALSE);
843 817
844 int CountControls() { return m_ControlList.GetSize(); } 818 int CountControls() { return m_ControlList.GetSize(); }
845 819
846 CPDF_FormControl* GetControl(int index) { 820 CPDF_FormControl* GetControl(int index) {
847 return (CPDF_FormControl*)m_ControlList.GetAt(index); 821 return (CPDF_FormControl*)m_ControlList.GetAt(index);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 class CPDF_FormControl { 968 class CPDF_FormControl {
995 public: 969 public:
996 CPDF_FormField::Type GetType() { return m_pField->GetType(); } 970 CPDF_FormField::Type GetType() { return m_pField->GetType(); }
997 971
998 CPDF_InterForm* GetInterForm() const { return m_pForm; } 972 CPDF_InterForm* GetInterForm() const { return m_pForm; }
999 973
1000 CPDF_FormField* GetField() const { return m_pField; } 974 CPDF_FormField* GetField() const { return m_pField; }
1001 975
1002 CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } 976 CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; }
1003 977
1004 CFX_FloatRect GetRect(); 978 CFX_FloatRect GetRect() const;
1005 979
1006 void DrawControl(CFX_RenderDevice* pDevice, 980 void DrawControl(CFX_RenderDevice* pDevice,
1007 CFX_AffineMatrix* pMatrix, 981 CFX_AffineMatrix* pMatrix,
1008 CPDF_Page* pPage, 982 CPDF_Page* pPage,
1009 CPDF_Annot::AppearanceMode mode, 983 CPDF_Annot::AppearanceMode mode,
1010 const CPDF_RenderOptions* pOptions = NULL); 984 const CPDF_RenderOptions* pOptions = NULL);
1011 985
1012 CFX_ByteString GetCheckedAPState(); 986 CFX_ByteString GetCheckedAPState();
1013 987
1014 CFX_WideString GetExportValue(); 988 CFX_WideString GetExportValue();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 FX_FLOAT fc[4], 1226 FX_FLOAT fc[4],
1253 const CFX_ByteStringC& csEntry); 1227 const CFX_ByteStringC& csEntry);
1254 1228
1255 CFX_WideString GetCaption(const CFX_ByteStringC& csEntry); 1229 CFX_WideString GetCaption(const CFX_ByteStringC& csEntry);
1256 1230
1257 CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry); 1231 CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry);
1258 friend class CPDF_FormControl; 1232 friend class CPDF_FormControl;
1259 }; 1233 };
1260 1234
1261 #endif // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_ 1235 #endif // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfdoc/doc_form.cpp » ('j') | core/src/fpdfdoc/doc_form.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698