| 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 _FPDF_OBJECTS_ | 7 #ifndef _FPDF_OBJECTS_ |
| 8 #define _FPDF_OBJECTS_ | 8 #define _FPDF_OBJECTS_ |
| 9 #ifndef _FXCRT_EXTENSION_ | 9 #ifndef _FXCRT_EXTENSION_ |
| 10 #include "../fxcrt/fx_ext.h" | 10 #include "../fxcrt/fx_ext.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 void SetUnicodeText(FX_LPCWSTR pUnico
des, int len = -1); | 85 void SetUnicodeText(FX_LPCWSTR pUnico
des, int len = -1); |
| 86 | 86 |
| 87 int GetDirectType() const; | 87 int GetDirectType() const; |
| 88 | 88 |
| 89 FX_BOOL IsModified() const | 89 FX_BOOL IsModified() const |
| 90 { | 90 { |
| 91 return FALSE; | 91 return FALSE; |
| 92 } | 92 } |
| 93 protected: | 93 protected: |
| 94 CPDF_Object(FX_DWORD type) : m_Type(type), m_ObjNum(0), m_GenNum(0) { } |
| 95 ~CPDF_Object() { } |
| 96 |
| 97 void Destroy(); |
| 98 |
| 94 FX_DWORD m_Type; | 99 FX_DWORD m_Type; |
| 95 CPDF_Object() | |
| 96 { | |
| 97 m_ObjNum = 0; | |
| 98 m_GenNum = 0; | |
| 99 } | |
| 100 | |
| 101 FX_DWORD m_ObjNum; | 100 FX_DWORD m_ObjNum; |
| 102 FX_DWORD m_GenNum; | 101 FX_DWORD m_GenNum; |
| 103 | 102 |
| 104 void Destroy(); | |
| 105 | |
| 106 | |
| 107 ~CPDF_Object() {} | |
| 108 friend class CPDF_IndirectObjects; | 103 friend class CPDF_IndirectObjects; |
| 109 friend class CPDF_Parser; | 104 friend class CPDF_Parser; |
| 110 friend class CPDF_SyntaxParser; | 105 friend class CPDF_SyntaxParser; |
| 111 private: | 106 private: |
| 112 CPDF_Object(const CPDF_Object& src) {} | 107 CPDF_Object(const CPDF_Object& src) {} |
| 113 CPDF_Object* CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visited) const; | 108 CPDF_Object* CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visited) const; |
| 114 }; | 109 }; |
| 115 class CPDF_Boolean : public CPDF_Object | 110 class CPDF_Boolean : public CPDF_Object |
| 116 { | 111 { |
| 117 public: | 112 public: |
| 118 | 113 |
| 119 static CPDF_Boolean* Create(FX_BOOL value) | 114 static CPDF_Boolean* Create(FX_BOOL value) |
| 120 { | 115 { |
| 121 return FX_NEW CPDF_Boolean(value); | 116 return FX_NEW CPDF_Boolean(value); |
| 122 } | 117 } |
| 123 | 118 |
| 124 CPDF_Boolean() | 119 CPDF_Boolean() : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(false) { } |
| 125 { | 120 CPDF_Boolean(FX_BOOL value) : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(value) {
} |
| 126 m_Type = PDFOBJ_BOOLEAN; | |
| 127 } | |
| 128 | |
| 129 CPDF_Boolean(FX_BOOL value) | |
| 130 { | |
| 131 m_Type = PDFOBJ_BOOLEAN; | |
| 132 m_bValue = value; | |
| 133 } | |
| 134 | 121 |
| 135 FX_BOOL Identical(CPDF_Boolean* pOther)
const | 122 FX_BOOL Identical(CPDF_Boolean* pOther)
const |
| 136 { | 123 { |
| 137 return m_bValue == pOther->m_bValue; | 124 return m_bValue == pOther->m_bValue; |
| 138 } | 125 } |
| 139 protected: | 126 protected: |
| 140 | 127 |
| 141 FX_BOOL m_bValue; | 128 FX_BOOL m_bValue; |
| 142 friend class CPDF_Object; | 129 friend class CPDF_Object; |
| 143 }; | 130 }; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 158 static CPDF_Number* Create(FX_BSTR str) | 145 static CPDF_Number* Create(FX_BSTR str) |
| 159 { | 146 { |
| 160 return FX_NEW CPDF_Number(str); | 147 return FX_NEW CPDF_Number(str); |
| 161 } | 148 } |
| 162 | 149 |
| 163 static CPDF_Number* Create(FX_BOOL bInteger, void* pData) | 150 static CPDF_Number* Create(FX_BOOL bInteger, void* pData) |
| 164 { | 151 { |
| 165 return FX_NEW CPDF_Number(bInteger, pData); | 152 return FX_NEW CPDF_Number(bInteger, pData); |
| 166 } | 153 } |
| 167 | 154 |
| 168 CPDF_Number(): m_Integer(0) | 155 CPDF_Number() : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(false), m_Integer(0)
{ } |
| 169 { | |
| 170 m_Type = PDFOBJ_NUMBER; | |
| 171 } | |
| 172 | 156 |
| 173 CPDF_Number(FX_BOOL bInteger, void* pData); | 157 CPDF_Number(FX_BOOL bInteger, void* pData); |
| 174 | 158 |
| 175 CPDF_Number(int value); | 159 CPDF_Number(int value); |
| 176 | 160 |
| 177 CPDF_Number(FX_FLOAT value); | 161 CPDF_Number(FX_FLOAT value); |
| 178 | 162 |
| 179 CPDF_Number(FX_BSTR str); | 163 CPDF_Number(FX_BSTR str); |
| 180 | 164 |
| 181 FX_BOOL Identical(CPDF_Number* pOther) c
onst; | 165 FX_BOOL Identical(CPDF_Number* pOther) c
onst; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 static CPDF_String* Create(const CFX_ByteString& str, FX_BOOL bHex =
FALSE) | 213 static CPDF_String* Create(const CFX_ByteString& str, FX_BOOL bHex =
FALSE) |
| 230 { | 214 { |
| 231 return FX_NEW CPDF_String(str, bHex); | 215 return FX_NEW CPDF_String(str, bHex); |
| 232 } | 216 } |
| 233 | 217 |
| 234 static CPDF_String* Create(const CFX_WideString& str) | 218 static CPDF_String* Create(const CFX_WideString& str) |
| 235 { | 219 { |
| 236 return FX_NEW CPDF_String(str); | 220 return FX_NEW CPDF_String(str); |
| 237 } | 221 } |
| 238 | 222 |
| 239 CPDF_String() | 223 CPDF_String() : CPDF_Object(PDFOBJ_STRING), m_bHex(FALSE) { } |
| 240 { | |
| 241 m_Type = PDFOBJ_STRING; | |
| 242 m_bHex = FALSE; | |
| 243 } | |
| 244 | 224 |
| 245 CPDF_String(const CFX_ByteString& str, FX_BOOL bHex = FALSE) : m_String(str) | 225 CPDF_String(const CFX_ByteString& str, FX_BOOL bHex = FALSE) |
| 246 { | 226 : CPDF_Object(PDFOBJ_STRING), m_String(str), m_bHex(bHex) { |
| 247 m_Type = PDFOBJ_STRING; | |
| 248 m_bHex = bHex; | |
| 249 } | 227 } |
| 250 | 228 |
| 251 CPDF_String(const CFX_WideString& str); | 229 CPDF_String(const CFX_WideString& str); |
| 252 | 230 |
| 253 CFX_ByteString& GetString() | 231 CFX_ByteString& GetString() |
| 254 { | 232 { |
| 255 return m_String; | 233 return m_String; |
| 256 } | 234 } |
| 257 | 235 |
| 258 FX_BOOL Identical(CPDF_String* pOther) c
onst | 236 FX_BOOL Identical(CPDF_String* pOther) c
onst |
| (...skipping 24 matching lines...) Expand all Loading... |
| 283 static CPDF_Name* Create(FX_BSTR str) | 261 static CPDF_Name* Create(FX_BSTR str) |
| 284 { | 262 { |
| 285 return FX_NEW CPDF_Name(str); | 263 return FX_NEW CPDF_Name(str); |
| 286 } | 264 } |
| 287 | 265 |
| 288 static CPDF_Name* Create(FX_LPCSTR str) | 266 static CPDF_Name* Create(FX_LPCSTR str) |
| 289 { | 267 { |
| 290 return FX_NEW CPDF_Name(str); | 268 return FX_NEW CPDF_Name(str); |
| 291 } | 269 } |
| 292 | 270 |
| 293 CPDF_Name(const CFX_ByteString& str) : m_Name(str) | 271 CPDF_Name(const CFX_ByteString& str) : CPDF_Object(PDFOBJ_NAME), m_Name(str)
{ } |
| 294 { | 272 CPDF_Name(FX_BSTR str) : CPDF_Object(PDFOBJ_NAME), m_Name(str) { } |
| 295 m_Type = PDFOBJ_NAME; | 273 CPDF_Name(FX_LPCSTR str) : CPDF_Object(PDFOBJ_NAME), m_Name(str) { } |
| 296 } | |
| 297 | |
| 298 CPDF_Name(FX_BSTR str) : m_Name(str) | |
| 299 { | |
| 300 m_Type = PDFOBJ_NAME; | |
| 301 } | |
| 302 | |
| 303 CPDF_Name(FX_LPCSTR str) : m_Name(str) | |
| 304 { | |
| 305 m_Type = PDFOBJ_NAME; | |
| 306 } | |
| 307 | 274 |
| 308 CFX_ByteString& GetString() | 275 CFX_ByteString& GetString() |
| 309 { | 276 { |
| 310 return m_Name; | 277 return m_Name; |
| 311 } | 278 } |
| 312 | 279 |
| 313 FX_BOOL Identical(CPDF_Name* pOther) con
st | 280 FX_BOOL Identical(CPDF_Name* pOther) con
st |
| 314 { | 281 { |
| 315 return m_Name == pOther->m_Name; | 282 return m_Name == pOther->m_Name; |
| 316 } | 283 } |
| 317 protected: | 284 protected: |
| 318 | 285 |
| 319 CFX_ByteString m_Name; | 286 CFX_ByteString m_Name; |
| 320 friend class CPDF_Object; | 287 friend class CPDF_Object; |
| 321 }; | 288 }; |
| 322 class CPDF_Array : public CPDF_Object | 289 class CPDF_Array : public CPDF_Object |
| 323 { | 290 { |
| 324 public: | 291 public: |
| 325 | 292 |
| 326 static CPDF_Array* Create() | 293 static CPDF_Array* Create() |
| 327 { | 294 { |
| 328 return FX_NEW CPDF_Array(); | 295 return FX_NEW CPDF_Array(); |
| 329 } | 296 } |
| 330 | 297 |
| 331 CPDF_Array() | 298 CPDF_Array() : CPDF_Object(PDFOBJ_ARRAY) { } |
| 332 { | |
| 333 m_Type = PDFOBJ_ARRAY; | |
| 334 } | |
| 335 | 299 |
| 336 FX_DWORD GetCount() const | 300 FX_DWORD GetCount() const |
| 337 { | 301 { |
| 338 return m_Objects.GetSize(); | 302 return m_Objects.GetSize(); |
| 339 } | 303 } |
| 340 | 304 |
| 341 CPDF_Object* GetElement(FX_DWORD index) const; | 305 CPDF_Object* GetElement(FX_DWORD index) const; |
| 342 | 306 |
| 343 CPDF_Object* GetElementValue(FX_DWORD index) const; | 307 CPDF_Object* GetElementValue(FX_DWORD index) const; |
| 344 | 308 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 }; | 385 }; |
| 422 class CPDF_Dictionary : public CPDF_Object | 386 class CPDF_Dictionary : public CPDF_Object |
| 423 { | 387 { |
| 424 public: | 388 public: |
| 425 | 389 |
| 426 static CPDF_Dictionary* Create() | 390 static CPDF_Dictionary* Create() |
| 427 { | 391 { |
| 428 return FX_NEW CPDF_Dictionary(); | 392 return FX_NEW CPDF_Dictionary(); |
| 429 } | 393 } |
| 430 | 394 |
| 431 CPDF_Dictionary() | 395 CPDF_Dictionary() : CPDF_Object(PDFOBJ_DICTIONARY) { } |
| 432 { | |
| 433 m_Type = PDFOBJ_DICTIONARY; | |
| 434 } | |
| 435 | |
| 436 | |
| 437 | 396 |
| 438 CPDF_Object* GetElement(FX_BSTR key) const; | 397 CPDF_Object* GetElement(FX_BSTR key) const; |
| 439 | 398 |
| 440 CPDF_Object* GetElementValue(FX_BSTR key) const; | 399 CPDF_Object* GetElementValue(FX_BSTR key) const; |
| 441 | 400 |
| 442 | 401 |
| 443 | 402 |
| 444 | 403 |
| 445 | 404 |
| 446 CFX_ByteString GetString(FX_BSTR key) const; | 405 CFX_ByteString GetString(FX_BSTR key) const; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 }; | 660 }; |
| 702 class CPDF_Null : public CPDF_Object | 661 class CPDF_Null : public CPDF_Object |
| 703 { | 662 { |
| 704 public: | 663 public: |
| 705 | 664 |
| 706 static CPDF_Null* Create() | 665 static CPDF_Null* Create() |
| 707 { | 666 { |
| 708 return FX_NEW CPDF_Null(); | 667 return FX_NEW CPDF_Null(); |
| 709 } | 668 } |
| 710 | 669 |
| 711 CPDF_Null() | 670 CPDF_Null() : CPDF_Object(PDFOBJ_NULL) { } |
| 712 { | |
| 713 m_Type = PDFOBJ_NULL; | |
| 714 } | |
| 715 }; | 671 }; |
| 716 class CPDF_Reference : public CPDF_Object | 672 class CPDF_Reference : public CPDF_Object |
| 717 { | 673 { |
| 718 public: | 674 public: |
| 719 | 675 |
| 720 static CPDF_Reference* Create(CPDF_IndirectObjects* pDoc, int objnum) | 676 static CPDF_Reference* Create(CPDF_IndirectObjects* pDoc, int objnum) |
| 721 { | 677 { |
| 722 return FX_NEW CPDF_Reference(pDoc, objnum); | 678 return FX_NEW CPDF_Reference(pDoc, objnum); |
| 723 } | 679 } |
| 724 | 680 |
| 725 CPDF_Reference(CPDF_IndirectObjects* pDoc, int objnum) | 681 CPDF_Reference(CPDF_IndirectObjects* pDoc, int objnum) |
| 726 { | 682 : CPDF_Object(PDFOBJ_REFERENCE), m_pObjList(pDoc), m_RefObjNum(objnum) { |
| 727 m_Type = PDFOBJ_REFERENCE; | |
| 728 m_pObjList = pDoc; | |
| 729 m_RefObjNum = objnum; | |
| 730 } | 683 } |
| 731 | 684 |
| 732 CPDF_IndirectObjects* GetObjList() const | 685 CPDF_IndirectObjects* GetObjList() const |
| 733 { | 686 { |
| 734 return m_pObjList; | 687 return m_pObjList; |
| 735 } | 688 } |
| 736 | 689 |
| 737 FX_DWORD GetRefObjNum() const | 690 FX_DWORD GetRefObjNum() const |
| 738 { | 691 { |
| 739 return m_RefObjNum; | 692 return m_RefObjNum; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 } | 736 } |
| 784 protected: | 737 protected: |
| 785 | 738 |
| 786 CFX_MapPtrToPtr m_IndirectObjs; | 739 CFX_MapPtrToPtr m_IndirectObjs; |
| 787 | 740 |
| 788 IPDF_DocParser* m_pParser; | 741 IPDF_DocParser* m_pParser; |
| 789 | 742 |
| 790 FX_DWORD m_LastObjNum; | 743 FX_DWORD m_LastObjNum; |
| 791 }; | 744 }; |
| 792 #endif | 745 #endif |
| OLD | NEW |