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 #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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 delete m_pParser; | 682 delete m_pParser; |
683 if (!m_bReleaseMembers) { | 683 if (!m_bReleaseMembers) { |
684 return; | 684 return; |
685 } | 685 } |
686 FX_POSITION pos = m_ObjectList.GetHeadPosition(); | 686 FX_POSITION pos = m_ObjectList.GetHeadPosition(); |
687 while (pos) { | 687 while (pos) { |
688 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 688 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
689 } | 689 } |
690 } | 690 } |
691 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) { | 691 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) { |
692 if (m_pParser == NULL) { | 692 if (!m_pParser) { |
693 return; | 693 return; |
694 } | 694 } |
695 m_pParser->Continue(pPause); | 695 m_pParser->Continue(pPause); |
696 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { | 696 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { |
697 m_ParseState = CONTENT_PARSED; | 697 m_ParseState = CONTENT_PARSED; |
698 delete m_pParser; | 698 delete m_pParser; |
699 m_pParser = NULL; | 699 m_pParser = NULL; |
700 } | 700 } |
701 } | 701 } |
702 FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, | 702 FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, |
(...skipping 10 matching lines...) Expand all Loading... |
713 CPDF_PageObject* pThisObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 713 CPDF_PageObject* pThisObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
714 if (pThisObj == pObj) { | 714 if (pThisObj == pObj) { |
715 return index; | 715 return index; |
716 } | 716 } |
717 index++; | 717 index++; |
718 } | 718 } |
719 return -1; | 719 return -1; |
720 } | 720 } |
721 CPDF_PageObject* CPDF_PageObjects::GetObjectByIndex(int index) const { | 721 CPDF_PageObject* CPDF_PageObjects::GetObjectByIndex(int index) const { |
722 FX_POSITION pos = m_ObjectList.FindIndex(index); | 722 FX_POSITION pos = m_ObjectList.FindIndex(index); |
723 if (pos == NULL) { | 723 return pos ? static_cast<CPDF_PageObject*>(m_ObjectList.GetAt(pos)) : nullptr; |
724 return NULL; | |
725 } | |
726 return (CPDF_PageObject*)m_ObjectList.GetAt(pos); | |
727 } | 724 } |
728 void CPDF_PageObjects::Transform(const CFX_Matrix& matrix) { | 725 void CPDF_PageObjects::Transform(const CFX_Matrix& matrix) { |
729 FX_POSITION pos = m_ObjectList.GetHeadPosition(); | 726 FX_POSITION pos = m_ObjectList.GetHeadPosition(); |
730 while (pos) { | 727 while (pos) { |
731 CPDF_PageObject* pObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 728 CPDF_PageObject* pObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
732 pObj->Transform(matrix); | 729 pObj->Transform(matrix); |
733 } | 730 } |
734 } | 731 } |
735 CFX_FloatRect CPDF_PageObjects::CalcBoundingBox() const { | 732 CFX_FloatRect CPDF_PageObjects::CalcBoundingBox() const { |
736 if (m_ObjectList.GetCount() == 0) { | 733 if (m_ObjectList.GetCount() == 0) { |
(...skipping 14 matching lines...) Expand all Loading... |
751 if (top < pObj->m_Top) { | 748 if (top < pObj->m_Top) { |
752 top = pObj->m_Top; | 749 top = pObj->m_Top; |
753 } | 750 } |
754 if (bottom > pObj->m_Bottom) { | 751 if (bottom > pObj->m_Bottom) { |
755 bottom = pObj->m_Bottom; | 752 bottom = pObj->m_Bottom; |
756 } | 753 } |
757 } | 754 } |
758 return CFX_FloatRect(left, bottom, right, top); | 755 return CFX_FloatRect(left, bottom, right, top); |
759 } | 756 } |
760 void CPDF_PageObjects::LoadTransInfo() { | 757 void CPDF_PageObjects::LoadTransInfo() { |
761 if (m_pFormDict == NULL) { | 758 if (!m_pFormDict) { |
762 return; | 759 return; |
763 } | 760 } |
764 CPDF_Dictionary* pGroup = m_pFormDict->GetDict("Group"); | 761 CPDF_Dictionary* pGroup = m_pFormDict->GetDict("Group"); |
765 if (pGroup == NULL) { | 762 if (!pGroup) { |
766 return; | 763 return; |
767 } | 764 } |
768 if (pGroup->GetString("S") != "Transparency") { | 765 if (pGroup->GetString("S") != "Transparency") { |
769 return; | 766 return; |
770 } | 767 } |
771 m_Transparency |= PDFTRANS_GROUP; | 768 m_Transparency |= PDFTRANS_GROUP; |
772 if (pGroup->GetInteger("I")) { | 769 if (pGroup->GetInteger("I")) { |
773 m_Transparency |= PDFTRANS_ISOLATED; | 770 m_Transparency |= PDFTRANS_ISOLATED; |
774 } | 771 } |
775 if (pGroup->GetInteger("K")) { | 772 if (pGroup->GetInteger("K")) { |
(...skipping 17 matching lines...) Expand all Loading... |
793 } | 790 } |
794 void CPDF_Page::Load(CPDF_Document* pDocument, | 791 void CPDF_Page::Load(CPDF_Document* pDocument, |
795 CPDF_Dictionary* pPageDict, | 792 CPDF_Dictionary* pPageDict, |
796 FX_BOOL bPageCache) { | 793 FX_BOOL bPageCache) { |
797 m_pDocument = (CPDF_Document*)pDocument; | 794 m_pDocument = (CPDF_Document*)pDocument; |
798 m_pFormDict = pPageDict; | 795 m_pFormDict = pPageDict; |
799 if (bPageCache) { | 796 if (bPageCache) { |
800 m_pPageRender = | 797 m_pPageRender = |
801 CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this); | 798 CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this); |
802 } | 799 } |
803 if (pPageDict == NULL) { | 800 if (!pPageDict) { |
804 m_PageWidth = m_PageHeight = 100 * 1.0f; | 801 m_PageWidth = m_PageHeight = 100 * 1.0f; |
805 m_pPageResources = m_pResources = NULL; | 802 m_pPageResources = m_pResources = NULL; |
806 return; | 803 return; |
807 } | 804 } |
808 CPDF_Object* pageAttr = GetPageAttr("Resources"); | 805 CPDF_Object* pageAttr = GetPageAttr("Resources"); |
809 m_pResources = pageAttr ? pageAttr->GetDict() : NULL; | 806 m_pResources = pageAttr ? pageAttr->GetDict() : NULL; |
810 m_pPageResources = m_pResources; | 807 m_pPageResources = m_pResources; |
811 CPDF_Object* pRotate = GetPageAttr("Rotate"); | 808 CPDF_Object* pRotate = GetPageAttr("Rotate"); |
812 int rotate = 0; | 809 int rotate = 0; |
813 if (pRotate) { | 810 if (pRotate) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 } | 902 } |
906 CPDF_Form::CPDF_Form(CPDF_Document* pDoc, | 903 CPDF_Form::CPDF_Form(CPDF_Document* pDoc, |
907 CPDF_Dictionary* pPageResources, | 904 CPDF_Dictionary* pPageResources, |
908 CPDF_Stream* pFormStream, | 905 CPDF_Stream* pFormStream, |
909 CPDF_Dictionary* pParentResources) { | 906 CPDF_Dictionary* pParentResources) { |
910 m_pDocument = pDoc; | 907 m_pDocument = pDoc; |
911 m_pFormStream = pFormStream; | 908 m_pFormStream = pFormStream; |
912 m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL; | 909 m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL; |
913 m_pResources = m_pFormDict->GetDict("Resources"); | 910 m_pResources = m_pFormDict->GetDict("Resources"); |
914 m_pPageResources = pPageResources; | 911 m_pPageResources = pPageResources; |
915 if (m_pResources == NULL) { | 912 if (!m_pResources) { |
916 m_pResources = pParentResources; | 913 m_pResources = pParentResources; |
917 } | 914 } |
918 if (m_pResources == NULL) { | 915 if (!m_pResources) { |
919 m_pResources = pPageResources; | 916 m_pResources = pPageResources; |
920 } | 917 } |
921 m_Transparency = 0; | 918 m_Transparency = 0; |
922 LoadTransInfo(); | 919 LoadTransInfo(); |
923 } | 920 } |
924 CPDF_Form::~CPDF_Form() {} | 921 CPDF_Form::~CPDF_Form() {} |
925 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, | 922 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, |
926 CFX_Matrix* pParentMatrix, | 923 CFX_Matrix* pParentMatrix, |
927 CPDF_Type3Char* pType3Char, | 924 CPDF_Type3Char* pType3Char, |
928 CPDF_ParseOptions* pOptions, | 925 CPDF_ParseOptions* pOptions, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 (FX_FLOAT)y0); | 1003 (FX_FLOAT)y0); |
1007 matrix = m_PageMatrix; | 1004 matrix = m_PageMatrix; |
1008 matrix.Concat(display_matrix); | 1005 matrix.Concat(display_matrix); |
1009 } | 1006 } |
1010 CPDF_ParseOptions::CPDF_ParseOptions() { | 1007 CPDF_ParseOptions::CPDF_ParseOptions() { |
1011 m_bTextOnly = FALSE; | 1008 m_bTextOnly = FALSE; |
1012 m_bMarkedContent = TRUE; | 1009 m_bMarkedContent = TRUE; |
1013 m_bSeparateForm = TRUE; | 1010 m_bSeparateForm = TRUE; |
1014 m_bDecodeInlineImage = FALSE; | 1011 m_bDecodeInlineImage = FALSE; |
1015 } | 1012 } |
OLD | NEW |