Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 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 |
| 45 class CPDF_NameTree { | 45 class CPDF_NameTree { |
| 46 public: | 46 public: |
| 47 explicit CPDF_NameTree(CPDF_Dictionary* pRoot) { m_pRoot = pRoot; } | 47 explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} |
| 48 | |
| 49 CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteStringC& category); | 48 CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteStringC& category); |
| 50 | 49 |
| 51 CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; | 50 CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; |
| 52 | |
| 53 CPDF_Object* LookupValue(const CFX_ByteString& csName) const; | 51 CPDF_Object* LookupValue(const CFX_ByteString& csName) const; |
| 54 | |
| 55 CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, | 52 CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, |
| 56 const CFX_ByteStringC& sName); | 53 const CFX_ByteStringC& sName); |
| 57 | |
| 58 int GetIndex(const CFX_ByteString& csName) const; | 54 int GetIndex(const CFX_ByteString& csName) const; |
| 59 | |
| 60 int GetCount() const; | 55 int GetCount() const; |
| 61 | |
| 62 CPDF_Dictionary* GetRoot() const { return m_pRoot; } | 56 CPDF_Dictionary* GetRoot() const { return m_pRoot; } |
| 63 | 57 |
| 64 protected: | 58 protected: |
| 65 CPDF_Dictionary* m_pRoot; | 59 CPDF_Dictionary* m_pRoot; |
| 66 }; | 60 }; |
| 61 | |
| 67 class CPDF_BookmarkTree { | 62 class CPDF_BookmarkTree { |
| 68 public: | 63 public: |
| 69 explicit CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {} | 64 explicit CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {} |
| 70 | 65 |
| 71 CPDF_Bookmark GetFirstChild(const CPDF_Bookmark& parent) const; | 66 CPDF_Bookmark GetFirstChild(const CPDF_Bookmark& parent) const; |
| 72 | |
| 73 CPDF_Bookmark GetNextSibling(const CPDF_Bookmark& bookmark) const; | 67 CPDF_Bookmark GetNextSibling(const CPDF_Bookmark& bookmark) const; |
| 74 | |
| 75 CPDF_Document* GetDocument() const { return m_pDocument; } | 68 CPDF_Document* GetDocument() const { return m_pDocument; } |
| 76 | 69 |
| 77 protected: | 70 protected: |
| 78 CPDF_Document* m_pDocument; | 71 CPDF_Document* m_pDocument; |
|
Tom Sepez
2016/03/01 17:53:35
Can this be CPDF_Document* const m_pDocument?
Wei Li
2016/03/01 21:46:53
Yes, done.
| |
| 79 }; | 72 }; |
| 73 | |
| 80 #define PDFBOOKMARK_ITALIC 1 | 74 #define PDFBOOKMARK_ITALIC 1 |
| 81 #define PDFBOOKMARK_BOLD 2 | 75 #define PDFBOOKMARK_BOLD 2 |
| 82 class CPDF_Bookmark { | 76 class CPDF_Bookmark { |
| 83 public: | 77 public: |
| 84 CPDF_Bookmark() : m_pDict(NULL) {} | 78 CPDF_Bookmark() : m_pDict(NULL) {} |
| 85 | |
| 86 explicit CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {} | 79 explicit CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {} |
| 87 | 80 |
| 88 CPDF_Dictionary* GetDict() const { return m_pDict; } | 81 CPDF_Dictionary* GetDict() const { return m_pDict; } |
| 89 | |
| 90 operator bool() const { return m_pDict != NULL; } | |
| 91 | |
| 92 FX_DWORD GetColorRef() const; | 82 FX_DWORD GetColorRef() const; |
| 93 | |
| 94 FX_DWORD GetFontStyle() const; | 83 FX_DWORD GetFontStyle() const; |
| 95 | |
| 96 CFX_WideString GetTitle() const; | 84 CFX_WideString GetTitle() const; |
| 97 | |
| 98 CPDF_Dest GetDest(CPDF_Document* pDocument) const; | 85 CPDF_Dest GetDest(CPDF_Document* pDocument) const; |
| 99 | |
| 100 CPDF_Action GetAction() const; | 86 CPDF_Action GetAction() const; |
| 101 | 87 |
| 88 protected: | |
| 102 CPDF_Dictionary* m_pDict; | 89 CPDF_Dictionary* m_pDict; |
|
Tom Sepez
2016/03/01 17:53:35
ditto
Wei Li
2016/03/01 21:46:53
This one needs to kept non-const since it is easie
Tom Sepez
2016/03/01 23:43:30
Acknowledged.
| |
| 103 }; | 90 }; |
| 91 | |
| 104 #define PDFZOOM_XYZ 1 | 92 #define PDFZOOM_XYZ 1 |
| 105 #define PDFZOOM_FITPAGE 2 | 93 #define PDFZOOM_FITPAGE 2 |
| 106 #define PDFZOOM_FITHORZ 3 | 94 #define PDFZOOM_FITHORZ 3 |
| 107 #define PDFZOOM_FITVERT 4 | 95 #define PDFZOOM_FITVERT 4 |
| 108 #define PDFZOOM_FITRECT 5 | 96 #define PDFZOOM_FITRECT 5 |
| 109 #define PDFZOOM_FITBBOX 6 | 97 #define PDFZOOM_FITBBOX 6 |
| 110 #define PDFZOOM_FITBHORZ 7 | 98 #define PDFZOOM_FITBHORZ 7 |
| 111 #define PDFZOOM_FITBVERT 8 | 99 #define PDFZOOM_FITBVERT 8 |
| 112 class CPDF_Dest { | 100 class CPDF_Dest { |
| 113 public: | 101 public: |
| 114 CPDF_Dest() : m_pObj(nullptr) {} | 102 CPDF_Dest() : m_pObj(nullptr) {} |
| 115 explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) {} | 103 explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) {} |
| 116 | 104 |
| 117 operator bool() const { return m_pObj != NULL; } | |
| 118 CPDF_Object* GetObject() const { return m_pObj; } | 105 CPDF_Object* GetObject() const { return m_pObj; } |
| 119 | |
| 120 CFX_ByteString GetRemoteName(); | 106 CFX_ByteString GetRemoteName(); |
| 121 int GetPageIndex(CPDF_Document* pDoc); | 107 int GetPageIndex(CPDF_Document* pDoc); |
| 122 FX_DWORD GetPageObjNum(); | 108 FX_DWORD GetPageObjNum(); |
| 123 int GetZoomMode(); | 109 int GetZoomMode(); |
| 124 FX_FLOAT GetParam(int index); | 110 FX_FLOAT GetParam(int index); |
| 125 | 111 |
| 126 protected: | 112 protected: |
| 127 CPDF_Object* m_pObj; | 113 CPDF_Object* m_pObj; |
| 128 }; | 114 }; |
| 115 | |
| 129 class CPDF_OCContext : public IPDF_OCContext { | 116 class CPDF_OCContext : public IPDF_OCContext { |
| 130 public: | 117 public: |
| 131 enum UsageType { View = 0, Design, Print, Export }; | 118 enum UsageType { View = 0, Design, Print, Export }; |
| 132 | 119 |
| 133 explicit CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType = View); | 120 explicit CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType = View); |
| 134 ~CPDF_OCContext() override; | 121 ~CPDF_OCContext() override; |
| 135 | 122 |
| 136 CPDF_Document* GetDocument() const { return m_pDocument; } | 123 CPDF_Document* GetDocument() const { return m_pDocument; } |
| 137 | 124 |
| 138 UsageType GetUsageType() const { return m_eUsageType; } | 125 UsageType GetUsageType() const { return m_eUsageType; } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 158 | 145 |
| 159 CPDF_Document* m_pDocument; | 146 CPDF_Document* m_pDocument; |
| 160 | 147 |
| 161 UsageType m_eUsageType; | 148 UsageType m_eUsageType; |
| 162 | 149 |
| 163 std::map<const CPDF_Dictionary*, FX_BOOL> m_OCGStates; | 150 std::map<const CPDF_Dictionary*, FX_BOOL> m_OCGStates; |
| 164 }; | 151 }; |
| 165 | 152 |
| 166 class CPDF_ActionFields { | 153 class CPDF_ActionFields { |
| 167 public: | 154 public: |
| 168 // TODO(thestig): Examine why this cannot be explicit. | 155 explicit CPDF_ActionFields(const CPDF_Action* pAction) : m_pAction(pAction) {} |
| 169 CPDF_ActionFields(const CPDF_Action* pAction) { | |
| 170 m_pAction = (CPDF_Action*)pAction; | |
| 171 } | |
| 172 | |
| 173 // TODO(thestig): Replace this. | |
| 174 operator CPDF_Action*() const { return m_pAction; } | |
| 175 | 156 |
| 176 FX_DWORD GetFieldsCount() const; | 157 FX_DWORD GetFieldsCount() const; |
| 177 | |
| 178 std::vector<CPDF_Object*> GetAllFields() const; | 158 std::vector<CPDF_Object*> GetAllFields() const; |
| 179 | |
| 180 CPDF_Object* GetField(FX_DWORD iIndex) const; | 159 CPDF_Object* GetField(FX_DWORD iIndex) const; |
| 181 | 160 |
| 182 CPDF_Action* m_pAction; | 161 protected: |
| 162 const CPDF_Action* m_pAction; | |
|
Tom Sepez
2016/03/01 17:53:35
ditto
Wei Li
2016/03/01 21:46:53
Done.
| |
| 183 }; | 163 }; |
| 184 | 164 |
| 185 #define PDFNAMED_NEXTPAGE 1 | 165 #define PDFNAMED_NEXTPAGE 1 |
| 186 #define PDFNAMED_PREVPAGE 2 | 166 #define PDFNAMED_PREVPAGE 2 |
| 187 #define PDFNAMED_FIRSTPAGE 3 | 167 #define PDFNAMED_FIRSTPAGE 3 |
| 188 #define PDFNAMED_LASTPAGE 4 | 168 #define PDFNAMED_LASTPAGE 4 |
| 189 #define PDFJS_MAXLENGTH 64 | 169 #define PDFJS_MAXLENGTH 64 |
| 190 class CPDF_Action { | 170 class CPDF_Action { |
| 191 public: | 171 public: |
| 192 enum ActionType { | 172 enum ActionType { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 CPDF_Dest GetDest(CPDF_Document* pDoc) const; | 205 CPDF_Dest GetDest(CPDF_Document* pDoc) const; |
| 226 | 206 |
| 227 CFX_WideString GetFilePath() const; | 207 CFX_WideString GetFilePath() const; |
| 228 | 208 |
| 229 FX_BOOL GetNewWindow() const { return m_pDict->GetBooleanBy("NewWindow"); } | 209 FX_BOOL GetNewWindow() const { return m_pDict->GetBooleanBy("NewWindow"); } |
| 230 | 210 |
| 231 CFX_ByteString GetURI(CPDF_Document* pDoc) const; | 211 CFX_ByteString GetURI(CPDF_Document* pDoc) const; |
| 232 | 212 |
| 233 FX_BOOL GetMouseMap() const { return m_pDict->GetBooleanBy("IsMap"); } | 213 FX_BOOL GetMouseMap() const { return m_pDict->GetBooleanBy("IsMap"); } |
| 234 | 214 |
| 235 CPDF_ActionFields GetWidgets() const { return this; } | |
| 236 | |
| 237 FX_BOOL GetHideStatus() const { return m_pDict->GetBooleanBy("H", TRUE); } | 215 FX_BOOL GetHideStatus() const { return m_pDict->GetBooleanBy("H", TRUE); } |
| 238 | 216 |
| 239 CFX_ByteString GetNamedAction() const { return m_pDict->GetStringBy("N"); } | 217 CFX_ByteString GetNamedAction() const { return m_pDict->GetStringBy("N"); } |
| 240 | 218 |
| 241 FX_DWORD GetFlags() const { return m_pDict->GetIntegerBy("Flags"); } | 219 FX_DWORD GetFlags() const { return m_pDict->GetIntegerBy("Flags"); } |
| 242 | 220 |
| 243 CFX_WideString GetJavaScript() const; | 221 CFX_WideString GetJavaScript() const; |
| 244 | 222 |
| 245 CPDF_Dictionary* GetAnnot() const; | 223 CPDF_Dictionary* GetAnnot() const; |
| 246 | 224 |
| 247 int32_t GetOperationType() const; | 225 int32_t GetOperationType() const; |
| 248 | 226 |
| 249 CPDF_Stream* GetSoundStream() const { return m_pDict->GetStreamBy("Sound"); } | 227 CPDF_Stream* GetSoundStream() const { return m_pDict->GetStreamBy("Sound"); } |
| 250 | 228 |
| 251 FX_FLOAT GetVolume() const { return m_pDict->GetNumberBy("Volume"); } | 229 FX_FLOAT GetVolume() const { return m_pDict->GetNumberBy("Volume"); } |
| 252 | 230 |
| 253 FX_BOOL IsSynchronous() const { return m_pDict->GetBooleanBy("Synchronous"); } | 231 FX_BOOL IsSynchronous() const { return m_pDict->GetBooleanBy("Synchronous"); } |
| 254 | 232 |
| 255 FX_BOOL IsRepeat() const { return m_pDict->GetBooleanBy("Repeat"); } | 233 FX_BOOL IsRepeat() const { return m_pDict->GetBooleanBy("Repeat"); } |
| 256 | 234 |
| 257 FX_BOOL IsMixPlay() const { return m_pDict->GetBooleanBy("Mix"); } | 235 FX_BOOL IsMixPlay() const { return m_pDict->GetBooleanBy("Mix"); } |
| 258 | 236 |
| 259 FX_DWORD GetSubActionsCount() const; | 237 FX_DWORD GetSubActionsCount() const; |
| 260 | 238 |
| 261 CPDF_Action GetSubAction(FX_DWORD iIndex) const; | 239 CPDF_Action GetSubAction(FX_DWORD iIndex) const; |
| 262 | 240 |
| 263 protected: | 241 protected: |
| 264 CPDF_Dictionary* m_pDict; | 242 CPDF_Dictionary* m_pDict; |
| 265 }; | 243 }; |
| 244 | |
| 266 class CPDF_AAction { | 245 class CPDF_AAction { |
| 267 public: | 246 public: |
| 268 // TODO(thestig): Examine why this cannot be explicit. | 247 explicit CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {} |
| 269 CPDF_AAction(CPDF_Dictionary* pDict = NULL) { m_pDict = pDict; } | |
| 270 | 248 |
| 271 operator CPDF_Dictionary*() const { return m_pDict; } | 249 operator CPDF_Dictionary*() const { return m_pDict; } |
| 272 | 250 |
| 273 enum AActionType { | 251 enum AActionType { |
| 274 CursorEnter = 0, | 252 CursorEnter = 0, |
| 275 CursorExit, | 253 CursorExit, |
| 276 ButtonDown, | 254 ButtonDown, |
| 277 ButtonUp, | 255 ButtonUp, |
| 278 GetFocus, | 256 GetFocus, |
| 279 LoseFocus, | 257 LoseFocus, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 CPDF_Document* const m_pDocument; | 442 CPDF_Document* const m_pDocument; |
| 465 std::vector<CPDF_Annot*> m_AnnotList; | 443 std::vector<CPDF_Annot*> m_AnnotList; |
| 466 }; | 444 }; |
| 467 | 445 |
| 468 #define COLORTYPE_TRANSPARENT 0 | 446 #define COLORTYPE_TRANSPARENT 0 |
| 469 #define COLORTYPE_GRAY 1 | 447 #define COLORTYPE_GRAY 1 |
| 470 #define COLORTYPE_RGB 2 | 448 #define COLORTYPE_RGB 2 |
| 471 #define COLORTYPE_CMYK 3 | 449 #define COLORTYPE_CMYK 3 |
| 472 class CPDF_DefaultAppearance { | 450 class CPDF_DefaultAppearance { |
| 473 public: | 451 public: |
| 474 // TODO(thestig): Examine why this cannot be explicit. | 452 explicit CPDF_DefaultAppearance(const CFX_ByteString& csDA) : m_csDA(csDA) {} |
| 475 CPDF_DefaultAppearance(const CFX_ByteString& csDA = "") { m_csDA = csDA; } | |
| 476 | 453 |
| 477 CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) { | 454 CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) { |
| 478 m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA; | 455 m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA; |
| 479 } | 456 } |
| 480 | 457 |
| 481 operator CFX_ByteString() const { return m_csDA; } | 458 operator CFX_ByteString() const { return m_csDA; } |
| 482 | 459 |
| 483 const CPDF_DefaultAppearance& operator=(const CFX_ByteString& csDA) { | 460 const CPDF_DefaultAppearance& operator=(const CFX_ByteString& csDA) { |
| 484 m_csDA = csDA; | 461 m_csDA = csDA; |
| 485 return *this; | 462 return *this; |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 CPDF_Font* m_pFont; | 838 CPDF_Font* m_pFont; |
| 862 | 839 |
| 863 friend class CPDF_InterForm; | 840 friend class CPDF_InterForm; |
| 864 friend class CPDF_FormControl; | 841 friend class CPDF_FormControl; |
| 865 }; | 842 }; |
| 866 CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, | 843 CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, |
| 867 const FX_CHAR* name, | 844 const FX_CHAR* name, |
| 868 int nLevel = 0); | 845 int nLevel = 0); |
| 869 class CPDF_IconFit { | 846 class CPDF_IconFit { |
| 870 public: | 847 public: |
| 871 // TODO(thestig): Examine why this cannot be explicit. | 848 CPDF_IconFit(CPDF_Dictionary* pDict) : m_pDict(pDict) {} |
|
Tom Sepez
2016/03/01 17:53:35
Did you mean to add "explicit" here?
Wei Li
2016/03/01 21:46:53
yes, thank you for spotting this :)
| |
| 872 CPDF_IconFit(CPDF_Dictionary* pDict = NULL) { m_pDict = pDict; } | |
| 873 | 849 |
| 874 operator CPDF_Dictionary*() const { return m_pDict; } | 850 operator CPDF_Dictionary*() const { return m_pDict; } |
|
Tom Sepez
2016/03/01 17:53:35
You might want to try to kill this operator as a f
Wei Li
2016/03/01 21:46:53
Done.
| |
| 875 | 851 |
| 876 enum ScaleMethod { Always = 0, Bigger, Smaller, Never }; | 852 enum ScaleMethod { Always = 0, Bigger, Smaller, Never }; |
|
Tom Sepez
2016/03/01 17:53:34
nit: Maybe put this as the first thing after publi
Wei Li
2016/03/01 21:46:53
Done.
| |
| 877 | 853 |
| 878 ScaleMethod GetScaleMethod(); | 854 ScaleMethod GetScaleMethod(); |
| 879 | 855 |
| 880 FX_BOOL IsProportionalScale(); | 856 FX_BOOL IsProportionalScale(); |
| 881 | 857 |
| 882 void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom); | 858 void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom); |
| 883 | 859 |
| 884 FX_BOOL GetFittingBounds(); | 860 FX_BOOL GetFittingBounds(); |
| 885 | 861 |
| 886 CPDF_Dictionary* m_pDict; | 862 CPDF_Dictionary* m_pDict; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1129 CFX_WideString GetCaption(const CFX_ByteStringC& csEntry) const; | 1105 CFX_WideString GetCaption(const CFX_ByteStringC& csEntry) const; |
| 1130 | 1106 |
| 1131 CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry) const; | 1107 CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry) const; |
| 1132 | 1108 |
| 1133 CPDF_Dictionary* const m_pDict; | 1109 CPDF_Dictionary* const m_pDict; |
| 1134 }; | 1110 }; |
| 1135 | 1111 |
| 1136 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath); | 1112 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath); |
| 1137 | 1113 |
| 1138 #endif // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_ | 1114 #endif // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_ |
| OLD | NEW |