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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page.cpp

Issue 1701073002: Split CPDF_PageObjectHolder off from CPDF_PageObjectList (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: m_pPage can never be null, remove checks. Created 4 years, 10 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
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 #include "pageint.h" 7 #include "pageint.h"
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_page.h" 10 #include "core/include/fpdfapi/fpdf_page.h"
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 m_FormMatrix = pSrcObj->m_FormMatrix; 663 m_FormMatrix = pSrcObj->m_FormMatrix;
664 } 664 }
665 void CPDF_FormObject::CalcBoundingBox() { 665 void CPDF_FormObject::CalcBoundingBox() {
666 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); 666 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox();
667 form_rect.Transform(&m_FormMatrix); 667 form_rect.Transform(&m_FormMatrix);
668 m_Left = form_rect.left; 668 m_Left = form_rect.left;
669 m_Bottom = form_rect.bottom; 669 m_Bottom = form_rect.bottom;
670 m_Right = form_rect.right; 670 m_Right = form_rect.right;
671 m_Top = form_rect.top; 671 m_Top = form_rect.top;
672 } 672 }
673 CPDF_PageObjectList::CPDF_PageObjectList() 673 CPDF_PageObjectHolder::CPDF_PageObjectHolder()
674 : m_pFormDict(nullptr), 674 : m_pFormDict(nullptr),
675 m_pFormStream(nullptr), 675 m_pFormStream(nullptr),
676 m_pDocument(nullptr), 676 m_pDocument(nullptr),
677 m_pPageResources(nullptr), 677 m_pPageResources(nullptr),
678 m_pResources(nullptr), 678 m_pResources(nullptr),
679 m_Transparency(0), 679 m_Transparency(0),
680 m_bBackgroundAlphaNeeded(FALSE), 680 m_bBackgroundAlphaNeeded(FALSE),
681 m_bHasImageMask(FALSE), 681 m_bHasImageMask(FALSE),
682 m_ParseState(CONTENT_NOT_PARSED), 682 m_ParseState(CONTENT_NOT_PARSED),
683 m_ObjectList(128) {} 683 m_PageObjectList(128) {}
684 CPDF_PageObjectList::~CPDF_PageObjectList() { 684
685 FX_POSITION pos = m_ObjectList.GetHeadPosition(); 685 CPDF_PageObjectHolder::~CPDF_PageObjectHolder() {
686 FX_POSITION pos = m_PageObjectList.GetHeadPosition();
686 while (pos) { 687 while (pos) {
687 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); 688 delete m_PageObjectList.GetNextObject(pos);
688 } 689 }
689 } 690 }
690 void CPDF_PageObjectList::ContinueParse(IFX_Pause* pPause) { 691 void CPDF_PageObjectHolder::ContinueParse(IFX_Pause* pPause) {
691 if (!m_pParser) { 692 if (!m_pParser) {
692 return; 693 return;
693 } 694 }
694 m_pParser->Continue(pPause); 695 m_pParser->Continue(pPause);
695 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { 696 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) {
696 m_ParseState = CONTENT_PARSED; 697 m_ParseState = CONTENT_PARSED;
697 m_pParser.reset(); 698 m_pParser.reset();
698 } 699 }
699 } 700 }
700 FX_POSITION CPDF_PageObjectList::InsertObject(FX_POSITION posInsertAfter, 701 FX_POSITION CPDF_PageObjectList::InsertObject(FX_POSITION posInsertAfter,
701 CPDF_PageObject* pNewObject) { 702 CPDF_PageObject* pNewObject) {
702 if (!posInsertAfter) { 703 if (!posInsertAfter) {
703 return m_ObjectList.AddHead(pNewObject); 704 return AddHead(pNewObject);
704 } 705 }
705 return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); 706 return InsertAfter(posInsertAfter, pNewObject);
706 }
707 int CPDF_PageObjectList::GetObjectIndex(CPDF_PageObject* pObj) const {
708 int index = 0;
709 FX_POSITION pos = m_ObjectList.GetHeadPosition();
710 while (pos) {
711 CPDF_PageObject* pThisObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
712 if (pThisObj == pObj) {
713 return index;
714 }
715 index++;
716 }
717 return -1;
718 } 707 }
719 CPDF_PageObject* CPDF_PageObjectList::GetObjectByIndex(int index) const { 708 CPDF_PageObject* CPDF_PageObjectList::GetObjectByIndex(int index) const {
720 FX_POSITION pos = m_ObjectList.FindIndex(index); 709 FX_POSITION pos = FindIndex(index);
721 return pos ? static_cast<CPDF_PageObject*>(m_ObjectList.GetAt(pos)) : nullptr; 710 return pos ? GetObjectAt(pos) : nullptr;
722 } 711 }
723 void CPDF_PageObjectList::Transform(const CFX_Matrix& matrix) { 712 void CPDF_PageObjectHolder::Transform(const CFX_Matrix& matrix) {
724 FX_POSITION pos = m_ObjectList.GetHeadPosition(); 713 FX_POSITION pos = m_PageObjectList.GetHeadPosition();
725 while (pos) { 714 while (pos) {
726 CPDF_PageObject* pObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos); 715 m_PageObjectList.GetNextObject(pos)->Transform(matrix);
727 pObj->Transform(matrix);
728 } 716 }
729 } 717 }
730 CFX_FloatRect CPDF_PageObjectList::CalcBoundingBox() const { 718 CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const {
731 if (m_ObjectList.GetCount() == 0) { 719 if (m_PageObjectList.GetCount() == 0) {
732 return CFX_FloatRect(0, 0, 0, 0); 720 return CFX_FloatRect(0, 0, 0, 0);
733 } 721 }
734 FX_FLOAT left, right, top, bottom; 722 FX_FLOAT left, right, top, bottom;
735 left = bottom = 1000000 * 1.0f; 723 left = bottom = 1000000 * 1.0f;
736 right = top = -1000000 * 1.0f; 724 right = top = -1000000 * 1.0f;
737 FX_POSITION pos = m_ObjectList.GetHeadPosition(); 725 FX_POSITION pos = m_PageObjectList.GetHeadPosition();
738 while (pos) { 726 while (pos) {
739 CPDF_PageObject* pObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos); 727 CPDF_PageObject* pObj = (CPDF_PageObject*)m_PageObjectList.GetNext(pos);
740 if (left > pObj->m_Left) { 728 if (left > pObj->m_Left) {
741 left = pObj->m_Left; 729 left = pObj->m_Left;
742 } 730 }
743 if (right < pObj->m_Right) { 731 if (right < pObj->m_Right) {
744 right = pObj->m_Right; 732 right = pObj->m_Right;
745 } 733 }
746 if (top < pObj->m_Top) { 734 if (top < pObj->m_Top) {
747 top = pObj->m_Top; 735 top = pObj->m_Top;
748 } 736 }
749 if (bottom > pObj->m_Bottom) { 737 if (bottom > pObj->m_Bottom) {
750 bottom = pObj->m_Bottom; 738 bottom = pObj->m_Bottom;
751 } 739 }
752 } 740 }
753 return CFX_FloatRect(left, bottom, right, top); 741 return CFX_FloatRect(left, bottom, right, top);
754 } 742 }
755 void CPDF_PageObjectList::LoadTransInfo() { 743 void CPDF_PageObjectHolder::LoadTransInfo() {
756 if (!m_pFormDict) { 744 if (!m_pFormDict) {
757 return; 745 return;
758 } 746 }
759 CPDF_Dictionary* pGroup = m_pFormDict->GetDictBy("Group"); 747 CPDF_Dictionary* pGroup = m_pFormDict->GetDictBy("Group");
760 if (!pGroup) { 748 if (!pGroup) {
761 return; 749 return;
762 } 750 }
763 if (pGroup->GetStringBy("S") != "Transparency") { 751 if (pGroup->GetStringBy("S") != "Transparency") {
764 return; 752 return;
765 } 753 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 CFX_Matrix* pParentMatrix, 907 CFX_Matrix* pParentMatrix,
920 CPDF_Type3Char* pType3Char, 908 CPDF_Type3Char* pType3Char,
921 CPDF_ParseOptions* pOptions, 909 CPDF_ParseOptions* pOptions,
922 int level) { 910 int level) {
923 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); 911 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level);
924 ContinueParse(NULL); 912 ContinueParse(NULL);
925 } 913 }
926 CPDF_Form* CPDF_Form::Clone() const { 914 CPDF_Form* CPDF_Form::Clone() const {
927 CPDF_Form* pClone = 915 CPDF_Form* pClone =
928 new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources); 916 new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources);
929 FX_POSITION pos = m_ObjectList.GetHeadPosition(); 917 FX_POSITION pos = m_PageObjectList.GetHeadPosition();
930 while (pos) { 918 while (pos) {
931 CPDF_PageObject* pObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos); 919 CPDF_PageObject* pObj = (CPDF_PageObject*)m_PageObjectList.GetNext(pos);
932 pClone->m_ObjectList.AddTail(pObj->Clone()); 920 pClone->m_PageObjectList.AddTail(pObj->Clone());
933 } 921 }
934 return pClone; 922 return pClone;
935 } 923 }
936 void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix, 924 void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix,
937 int xPos, 925 int xPos,
938 int yPos, 926 int yPos,
939 int xSize, 927 int xSize,
940 int ySize, 928 int ySize,
941 int iRotate) const { 929 int iRotate) const {
942 if (m_PageWidth == 0 || m_PageHeight == 0) { 930 if (m_PageWidth == 0 || m_PageHeight == 0) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 (FX_FLOAT)y0); 974 (FX_FLOAT)y0);
987 matrix = m_PageMatrix; 975 matrix = m_PageMatrix;
988 matrix.Concat(display_matrix); 976 matrix.Concat(display_matrix);
989 } 977 }
990 CPDF_ParseOptions::CPDF_ParseOptions() { 978 CPDF_ParseOptions::CPDF_ParseOptions() {
991 m_bTextOnly = FALSE; 979 m_bTextOnly = FALSE;
992 m_bMarkedContent = TRUE; 980 m_bMarkedContent = TRUE;
993 m_bSeparateForm = TRUE; 981 m_bSeparateForm = TRUE;
994 m_bDecodeInlineImage = FALSE; 982 m_bDecodeInlineImage = FALSE;
995 } 983 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698