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

Side by Side Diff: core/include/fpdfapi/fpdf_objects.h

Issue 1415163009: Cleanup CPDF_Stream: (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 1 month 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/fpdfapi/fpdf_edit/fpdf_edit_image.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_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 "../fxcrt/fx_coordinates.h" 10 #include "../fxcrt/fx_coordinates.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 }; 459 };
460 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) { 460 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) {
461 return obj ? obj->AsDictionary() : nullptr; 461 return obj ? obj->AsDictionary() : nullptr;
462 } 462 }
463 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) { 463 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) {
464 return obj ? obj->AsDictionary() : nullptr; 464 return obj ? obj->AsDictionary() : nullptr;
465 } 465 }
466 466
467 class CPDF_Stream : public CPDF_Object { 467 class CPDF_Stream : public CPDF_Object {
468 public: 468 public:
469 static CPDF_Stream* Create(uint8_t* pData,
470 FX_DWORD size,
471 CPDF_Dictionary* pDict) {
472 return new CPDF_Stream(pData, size, pDict);
473 }
474
475 CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict); 469 CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict);
476 470
477 CPDF_Dictionary* GetDict() const { return m_pDict; } 471 CPDF_Dictionary* GetDict() const { return m_pDict; }
478 472
479 void SetData(const uint8_t* pData, 473 void SetData(const uint8_t* pData,
480 FX_DWORD size, 474 FX_DWORD size,
481 FX_BOOL bCompressed, 475 FX_BOOL bCompressed,
482 FX_BOOL bKeepBuf); 476 FX_BOOL bKeepBuf);
483 477
484 void InitStream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict); 478 void InitStream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict);
485 479
486 void InitStream(IFX_FileRead* pFile, CPDF_Dictionary* pDict); 480 void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict);
487 481
488 FX_BOOL Identical(CPDF_Stream* pOther) const; 482 FX_BOOL Identical(CPDF_Stream* pOther) const;
489 483
490 FX_DWORD GetRawSize() const { return m_dwSize; } 484 FX_DWORD GetRawSize() const { return m_dwSize; }
491 485
492 FX_BOOL ReadRawData(FX_FILESIZE start_pos, 486 FX_BOOL ReadRawData(FX_FILESIZE start_pos,
493 uint8_t* pBuf, 487 uint8_t* pBuf,
494 FX_DWORD buf_size) const; 488 FX_DWORD buf_size) const;
495 489
496 FX_BOOL IsMemoryBased() const { return m_GenNum == (FX_DWORD)-1; } 490 FX_BOOL IsMemoryBased() const { return m_GenNum == kMemoryBasedGenNum; }
497 491
498 protected: 492 protected:
493 friend class CPDF_Object;
494 friend class CPDF_StreamAcc;
495
496 static const FX_DWORD kMemoryBasedGenNum = (FX_DWORD)-1;
499 ~CPDF_Stream(); 497 ~CPDF_Stream();
500 498
499 void InitStreamInternal(CPDF_Dictionary* pDict);
500
501 CPDF_Dictionary* m_pDict; 501 CPDF_Dictionary* m_pDict;
502 502
503 FX_DWORD m_dwSize; 503 FX_DWORD m_dwSize;
504 504
505 FX_DWORD m_GenNum; 505 FX_DWORD m_GenNum;
506 506
507 union { 507 union {
508 uint8_t* m_pDataBuf; 508 uint8_t* m_pDataBuf;
509 509
510 IFX_FileRead* m_pFile; 510 IFX_FileRead* m_pFile;
511 }; 511 };
512
513 FX_FILESIZE m_FileOffset;
514
515 CPDF_CryptoHandler* m_pCryptoHandler;
516
517 void InitStream(CPDF_Dictionary* pDict);
518 friend class CPDF_Object;
519 friend class CPDF_StreamAcc;
520 friend class CPDF_AttachmentAcc;
521 }; 512 };
522 inline CPDF_Stream* ToStream(CPDF_Object* obj) { 513 inline CPDF_Stream* ToStream(CPDF_Object* obj) {
523 return obj ? obj->AsStream() : nullptr; 514 return obj ? obj->AsStream() : nullptr;
524 } 515 }
525 inline const CPDF_Stream* ToStream(const CPDF_Object* obj) { 516 inline const CPDF_Stream* ToStream(const CPDF_Object* obj) {
526 return obj ? obj->AsStream() : nullptr; 517 return obj ? obj->AsStream() : nullptr;
527 } 518 }
528 519
529 class CPDF_StreamAcc { 520 class CPDF_StreamAcc {
530 public: 521 public:
531 CPDF_StreamAcc(); 522 CPDF_StreamAcc();
532 523
533 ~CPDF_StreamAcc(); 524 ~CPDF_StreamAcc();
534 525
535 void LoadAllData(const CPDF_Stream* pStream, 526 void LoadAllData(const CPDF_Stream* pStream,
536 FX_BOOL bRawAccess = FALSE, 527 FX_BOOL bRawAccess = FALSE,
537 FX_DWORD estimated_size = 0, 528 FX_DWORD estimated_size = 0,
538 FX_BOOL bImageAcc = FALSE); 529 FX_BOOL bImageAcc = FALSE);
539 530
540 const CPDF_Stream* GetStream() const { return m_pStream; } 531 const CPDF_Stream* GetStream() const { return m_pStream; }
541 532
542 CPDF_Dictionary* GetDict() const { 533 CPDF_Dictionary* GetDict() const {
543 return m_pStream ? m_pStream->GetDict() : NULL; 534 return m_pStream ? m_pStream->GetDict() : nullptr;
544 } 535 }
545 536
546 const uint8_t* GetData() const; 537 const uint8_t* GetData() const;
547 538
548 FX_DWORD GetSize() const; 539 FX_DWORD GetSize() const;
549 540
550 uint8_t* DetachData(); 541 uint8_t* DetachData();
551 542
552 const CFX_ByteString& GetImageDecoder() { return m_ImageDecoder; } 543 const CFX_ByteString& GetImageDecoder() { return m_ImageDecoder; }
553 544
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 625
635 protected: 626 protected:
636 CFX_MapPtrToPtr m_IndirectObjs; 627 CFX_MapPtrToPtr m_IndirectObjs;
637 628
638 CPDF_Parser* m_pParser; 629 CPDF_Parser* m_pParser;
639 630
640 FX_DWORD m_LastObjNum; 631 FX_DWORD m_LastObjNum;
641 }; 632 };
642 633
643 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ 634 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698