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_FPDFAPI_FPDF_OBJECTS_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 FX_DWORD GetCount() const { return m_Objects.GetSize(); } | 249 FX_DWORD GetCount() const { return m_Objects.GetSize(); } |
250 | 250 |
251 CPDF_Object* GetElement(FX_DWORD index) const; | 251 CPDF_Object* GetElement(FX_DWORD index) const; |
252 | 252 |
253 CPDF_Object* GetElementValue(FX_DWORD index) const; | 253 CPDF_Object* GetElementValue(FX_DWORD index) const; |
254 | 254 |
255 CFX_Matrix GetMatrix(); | 255 CFX_Matrix GetMatrix(); |
256 | 256 |
257 CFX_FloatRect GetRect(); | 257 CFX_FloatRect GetRect(); |
258 | 258 |
259 CFX_ByteString GetString(FX_DWORD index) const; | 259 CFX_ByteString GetStringAt(FX_DWORD index) const; |
260 | 260 |
261 CFX_ByteStringC GetConstString(FX_DWORD index) const; | 261 CFX_ByteStringC GetConstStringAt(FX_DWORD index) const; |
262 | 262 |
263 int GetInteger(FX_DWORD index) const; | 263 int GetIntegerAt(FX_DWORD index) const; |
264 | 264 |
265 FX_FLOAT GetNumber(FX_DWORD index) const; | 265 FX_FLOAT GetNumberAt(FX_DWORD index) const; |
266 | 266 |
267 CPDF_Dictionary* GetDict(FX_DWORD index) const; | 267 CPDF_Dictionary* GetDictAt(FX_DWORD index) const; |
268 | 268 |
269 CPDF_Stream* GetStream(FX_DWORD index) const; | 269 CPDF_Stream* GetStreamAt(FX_DWORD index) const; |
270 | 270 |
271 CPDF_Array* GetArray(FX_DWORD index) const; | 271 CPDF_Array* GetArrayAt(FX_DWORD index) const; |
272 | 272 |
273 FX_FLOAT GetFloat(FX_DWORD index) const { return GetNumber(index); } | 273 FX_FLOAT GetFloatAt(FX_DWORD index) const { return GetNumberAt(index); } |
274 | 274 |
275 void SetAt(FX_DWORD index, | 275 void SetAt(FX_DWORD index, |
276 CPDF_Object* pObj, | 276 CPDF_Object* pObj, |
277 CPDF_IndirectObjectHolder* pObjs = NULL); | 277 CPDF_IndirectObjectHolder* pObjs = NULL); |
278 | 278 |
279 void InsertAt(FX_DWORD index, | 279 void InsertAt(FX_DWORD index, |
280 CPDF_Object* pObj, | 280 CPDF_Object* pObj, |
281 CPDF_IndirectObjectHolder* pObjs = NULL); | 281 CPDF_IndirectObjectHolder* pObjs = NULL); |
282 | 282 |
283 void RemoveAt(FX_DWORD index, int nCount = 1); | 283 void RemoveAt(FX_DWORD index, int nCount = 1); |
284 | 284 |
285 void Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs = NULL); | 285 void Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs = NULL); |
286 | 286 |
287 void AddNumber(FX_FLOAT f); | 287 void AddNumber(FX_FLOAT f); |
288 | 288 |
289 void AddInteger(int i); | 289 void AddInteger(int i); |
290 | 290 |
291 void AddString(const CFX_ByteString& str); | 291 void AddString(const CFX_ByteString& str); |
292 | 292 |
293 void AddName(const CFX_ByteString& str); | 293 void AddName(const CFX_ByteString& str); |
294 | 294 |
295 void AddReference(CPDF_IndirectObjectHolder* pDoc, FX_DWORD objnum); | 295 void AddReference(CPDF_IndirectObjectHolder* pDoc, FX_DWORD objnum); |
296 | 296 |
297 void AddReference(CPDF_IndirectObjectHolder* pDoc, CPDF_Object* obj) { | 297 void AddReference(CPDF_IndirectObjectHolder* pDoc, CPDF_Object* obj) { |
298 AddReference(pDoc, obj->GetObjNum()); | 298 AddReference(pDoc, obj->GetObjNum()); |
299 } | 299 } |
300 | 300 |
301 FX_FLOAT GetNumber16(FX_DWORD index) const { return GetNumber(index); } | 301 FX_FLOAT GetNumber16(FX_DWORD index) const { return GetNumberAt(index); } |
302 | 302 |
303 void AddNumber16(FX_FLOAT value) { AddNumber(value); } | 303 void AddNumber16(FX_FLOAT value) { AddNumber(value); } |
304 | 304 |
305 FX_BOOL Identical(CPDF_Array* pOther) const; | 305 FX_BOOL Identical(CPDF_Array* pOther) const; |
306 | 306 |
307 protected: | 307 protected: |
308 ~CPDF_Array(); | 308 ~CPDF_Array(); |
309 | 309 |
310 CFX_ArrayTemplate<CPDF_Object*> m_Objects; | 310 CFX_ArrayTemplate<CPDF_Object*> m_Objects; |
311 friend class CPDF_Object; | 311 friend class CPDF_Object; |
312 }; | 312 }; |
313 inline CPDF_Array* ToArray(CPDF_Object* obj) { | 313 inline CPDF_Array* ToArray(CPDF_Object* obj) { |
314 return obj ? obj->AsArray() : nullptr; | 314 return obj ? obj->AsArray() : nullptr; |
315 } | 315 } |
316 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { | 316 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { |
317 return obj ? obj->AsArray() : nullptr; | 317 return obj ? obj->AsArray() : nullptr; |
318 } | 318 } |
319 | 319 |
320 class CPDF_Dictionary : public CPDF_Object { | 320 class CPDF_Dictionary : public CPDF_Object { |
321 public: | 321 public: |
322 using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator; | 322 using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator; |
323 using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator; | 323 using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator; |
324 | 324 |
325 CPDF_Dictionary() : CPDF_Object(DICTIONARY) {} | 325 CPDF_Dictionary() : CPDF_Object(DICTIONARY) {} |
326 | 326 |
327 CPDF_Object* GetElement(const CFX_ByteStringC& key) const; | 327 CPDF_Object* GetElement(const CFX_ByteStringC& key) const; |
328 | 328 |
329 CPDF_Object* GetElementValue(const CFX_ByteStringC& key) const; | 329 CPDF_Object* GetElementValue(const CFX_ByteStringC& key) const; |
330 | 330 |
331 CFX_ByteString GetString(const CFX_ByteStringC& key) const; | 331 CFX_ByteString GetStringBy(const CFX_ByteStringC& key) const; |
332 | 332 |
333 CFX_ByteStringC GetConstString(const CFX_ByteStringC& key) const; | 333 CFX_ByteStringC GetConstStringBy(const CFX_ByteStringC& key) const; |
334 | 334 |
335 CFX_ByteString GetString(const CFX_ByteStringC& key, | 335 CFX_ByteString GetStringBy(const CFX_ByteStringC& key, |
336 const CFX_ByteStringC& default_str) const; | 336 const CFX_ByteStringC& default_str) const; |
337 | 337 |
338 CFX_ByteStringC GetConstString(const CFX_ByteStringC& key, | 338 CFX_ByteStringC GetConstStringBy(const CFX_ByteStringC& key, |
339 const CFX_ByteStringC& default_str) const; | 339 const CFX_ByteStringC& default_str) const; |
340 | 340 |
341 CFX_WideString GetUnicodeText(const CFX_ByteStringC& key, | 341 CFX_WideString GetUnicodeTextBy(const CFX_ByteStringC& key, |
342 CFX_CharMap* pCharMap = NULL) const; | 342 CFX_CharMap* pCharMap = NULL) const; |
343 | 343 |
344 int GetInteger(const CFX_ByteStringC& key) const; | 344 int GetIntegerBy(const CFX_ByteStringC& key) const; |
345 | 345 |
346 int GetInteger(const CFX_ByteStringC& key, int default_int) const; | 346 int GetIntegerBy(const CFX_ByteStringC& key, int default_int) const; |
347 | 347 |
348 FX_BOOL GetBoolean(const CFX_ByteStringC& key, | 348 FX_BOOL GetBooleanBy(const CFX_ByteStringC& key, |
349 FX_BOOL bDefault = FALSE) const; | 349 FX_BOOL bDefault = FALSE) const; |
350 | 350 |
351 FX_FLOAT GetNumber(const CFX_ByteStringC& key) const; | 351 FX_FLOAT GetNumberBy(const CFX_ByteStringC& key) const; |
352 | 352 |
353 CPDF_Dictionary* GetDict(const CFX_ByteStringC& key) const; | 353 CPDF_Dictionary* GetDictBy(const CFX_ByteStringC& key) const; |
354 | 354 |
355 CPDF_Stream* GetStream(const CFX_ByteStringC& key) const; | 355 CPDF_Stream* GetStreamBy(const CFX_ByteStringC& key) const; |
356 | 356 |
357 CPDF_Array* GetArray(const CFX_ByteStringC& key) const; | 357 CPDF_Array* GetArrayBy(const CFX_ByteStringC& key) const; |
358 | 358 |
359 CFX_FloatRect GetRect(const CFX_ByteStringC& key) const; | 359 CFX_FloatRect GetRectBy(const CFX_ByteStringC& key) const; |
360 | 360 |
361 CFX_Matrix GetMatrix(const CFX_ByteStringC& key) const; | 361 CFX_Matrix GetMatrixBy(const CFX_ByteStringC& key) const; |
362 | 362 |
363 FX_FLOAT GetFloat(const CFX_ByteStringC& key) const { return GetNumber(key); } | 363 FX_FLOAT GetFloatBy(const CFX_ByteStringC& key) const { |
| 364 return GetNumberBy(key); |
| 365 } |
364 | 366 |
365 FX_BOOL KeyExist(const CFX_ByteStringC& key) const; | 367 FX_BOOL KeyExist(const CFX_ByteStringC& key) const; |
366 | 368 |
367 // Set* functions invalidate iterators for the element with the key |key|. | 369 // Set* functions invalidate iterators for the element with the key |key|. |
368 void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj); | 370 void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj); |
369 | 371 |
370 void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name); | 372 void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name); |
371 | 373 |
372 void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& string); | 374 void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& string); |
373 | 375 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 iterator end() { return m_IndirectObjs.end(); } | 579 iterator end() { return m_IndirectObjs.end(); } |
578 const_iterator end() const { return m_IndirectObjs.end(); } | 580 const_iterator end() const { return m_IndirectObjs.end(); } |
579 | 581 |
580 protected: | 582 protected: |
581 CPDF_Parser* m_pParser; | 583 CPDF_Parser* m_pParser; |
582 FX_DWORD m_LastObjNum; | 584 FX_DWORD m_LastObjNum; |
583 std::map<FX_DWORD, CPDF_Object*> m_IndirectObjs; | 585 std::map<FX_DWORD, CPDF_Object*> m_IndirectObjs; |
584 }; | 586 }; |
585 | 587 |
586 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ | 588 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
OLD | NEW |