| 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 "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "pageint.h" | 9 #include "pageint.h" |
| 10 CPDF_PageObject* CPDF_PageObject::Create(int type) | 10 CPDF_PageObject* CPDF_PageObject::Create(int type) |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 } | 713 } |
| 714 void CPDF_FormObject::CalcBoundingBox() | 714 void CPDF_FormObject::CalcBoundingBox() |
| 715 { | 715 { |
| 716 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); | 716 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); |
| 717 form_rect.Transform(&m_FormMatrix); | 717 form_rect.Transform(&m_FormMatrix); |
| 718 m_Left = form_rect.left; | 718 m_Left = form_rect.left; |
| 719 m_Bottom = form_rect.bottom; | 719 m_Bottom = form_rect.bottom; |
| 720 m_Right = form_rect.right; | 720 m_Right = form_rect.right; |
| 721 m_Top = form_rect.top; | 721 m_Top = form_rect.top; |
| 722 } | 722 } |
| 723 CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) : m_ObjectList(128) | 723 CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) |
| 724 : m_pFormDict(nullptr), |
| 725 m_pFormStream(nullptr), |
| 726 m_pDocument(nullptr), |
| 727 m_pPageResources(nullptr), |
| 728 m_pResources(nullptr), |
| 729 m_Transparency(0), |
| 730 m_ObjectList(128), |
| 731 m_bBackgroundAlphaNeeded(FALSE), |
| 732 m_bReleaseMembers(bReleaseMembers), |
| 733 m_pParser(nullptr), |
| 734 m_ParseState(CONTENT_NOT_PARSED) |
| 724 { | 735 { |
| 725 m_bBackgroundAlphaNeeded = FALSE; | |
| 726 m_bReleaseMembers = bReleaseMembers; | |
| 727 m_ParseState = PDF_CONTENT_NOT_PARSED; | |
| 728 m_pParser = NULL; | |
| 729 m_pFormStream = NULL; | |
| 730 m_pResources = NULL; | |
| 731 } | 736 } |
| 732 CPDF_PageObjects::~CPDF_PageObjects() | 737 CPDF_PageObjects::~CPDF_PageObjects() |
| 733 { | 738 { |
| 734 delete m_pParser; | 739 delete m_pParser; |
| 735 if (!m_bReleaseMembers) { | 740 if (!m_bReleaseMembers) { |
| 736 return; | 741 return; |
| 737 } | 742 } |
| 738 FX_POSITION pos = m_ObjectList.GetHeadPosition(); | 743 FX_POSITION pos = m_ObjectList.GetHeadPosition(); |
| 739 while (pos) { | 744 while (pos) { |
| 740 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 745 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
| 741 } | 746 } |
| 742 } | 747 } |
| 743 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) | 748 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) |
| 744 { | 749 { |
| 745 if (m_pParser == NULL) { | 750 if (m_pParser == NULL) { |
| 746 return; | 751 return; |
| 747 } | 752 } |
| 748 m_pParser->Continue(pPause); | 753 m_pParser->Continue(pPause); |
| 749 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { | 754 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { |
| 750 m_ParseState = PDF_CONTENT_PARSED; | 755 m_ParseState = CONTENT_PARSED; |
| 751 delete m_pParser; | 756 delete m_pParser; |
| 752 m_pParser = NULL; | 757 m_pParser = NULL; |
| 753 } | 758 } |
| 754 } | 759 } |
| 755 int CPDF_PageObjects::EstimateParseProgress() const | |
| 756 { | |
| 757 if (!m_pParser) { | |
| 758 return m_ParseState == PDF_CONTENT_PARSED ? 100 : 0; | |
| 759 } | |
| 760 return m_pParser->EstimateProgress(); | |
| 761 } | |
| 762 FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, CPDF_Page
Object* pNewObject) | 760 FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, CPDF_Page
Object* pNewObject) |
| 763 { | 761 { |
| 764 if (!posInsertAfter) { | 762 if (!posInsertAfter) { |
| 765 return m_ObjectList.AddHead(pNewObject); | 763 return m_ObjectList.AddHead(pNewObject); |
| 766 } | 764 } |
| 767 return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); | 765 return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); |
| 768 } | 766 } |
| 769 int CPDF_PageObjects::GetObjectIndex(CPDF_PageObject* pObj) const | 767 int CPDF_PageObjects::GetObjectIndex(CPDF_PageObject* pObj) const |
| 770 { | 768 { |
| 771 int index = 0; | 769 int index = 0; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 m_Transparency |= PDFTRANS_GROUP; | 834 m_Transparency |= PDFTRANS_GROUP; |
| 837 if (pGroup->GetInteger(FX_BSTRC("I"))) { | 835 if (pGroup->GetInteger(FX_BSTRC("I"))) { |
| 838 m_Transparency |= PDFTRANS_ISOLATED; | 836 m_Transparency |= PDFTRANS_ISOLATED; |
| 839 } | 837 } |
| 840 if (pGroup->GetInteger(FX_BSTRC("K"))) { | 838 if (pGroup->GetInteger(FX_BSTRC("K"))) { |
| 841 m_Transparency |= PDFTRANS_KNOCKOUT; | 839 m_Transparency |= PDFTRANS_KNOCKOUT; |
| 842 } | 840 } |
| 843 } | 841 } |
| 844 void CPDF_PageObjects::ClearCacheObjects() | 842 void CPDF_PageObjects::ClearCacheObjects() |
| 845 { | 843 { |
| 846 m_ParseState = PDF_CONTENT_NOT_PARSED; | 844 m_ParseState = CONTENT_NOT_PARSED; |
| 847 delete m_pParser; | 845 delete m_pParser; |
| 848 m_pParser = NULL; | 846 m_pParser = NULL; |
| 849 if (m_bReleaseMembers) { | 847 if (m_bReleaseMembers) { |
| 850 FX_POSITION pos = m_ObjectList.GetHeadPosition(); | 848 FX_POSITION pos = m_ObjectList.GetHeadPosition(); |
| 851 while (pos) { | 849 while (pos) { |
| 852 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 850 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
| 853 } | 851 } |
| 854 } | 852 } |
| 855 m_ObjectList.RemoveAll(); | 853 m_ObjectList.RemoveAll(); |
| 856 } | 854 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 break; | 921 break; |
| 924 } | 922 } |
| 925 m_Transparency = PDFTRANS_ISOLATED; | 923 m_Transparency = PDFTRANS_ISOLATED; |
| 926 LoadTransInfo(); | 924 LoadTransInfo(); |
| 927 } | 925 } |
| 928 void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) | 926 void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) |
| 929 { | 927 { |
| 930 if (bReParse) { | 928 if (bReParse) { |
| 931 ClearCacheObjects(); | 929 ClearCacheObjects(); |
| 932 } | 930 } |
| 933 if (m_ParseState == PDF_CONTENT_PARSED || m_ParseState == PDF_CONTENT_PARSIN
G) { | 931 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { |
| 934 return; | 932 return; |
| 935 } | 933 } |
| 936 m_pParser = new CPDF_ContentParser; | 934 m_pParser = new CPDF_ContentParser; |
| 937 m_pParser->Start(this, pOptions); | 935 m_pParser->Start(this, pOptions); |
| 938 m_ParseState = PDF_CONTENT_PARSING; | 936 m_ParseState = CONTENT_PARSING; |
| 939 } | 937 } |
| 940 void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) | 938 void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) |
| 941 { | 939 { |
| 942 StartParse(pOptions, bReParse); | 940 StartParse(pOptions, bReParse); |
| 943 ContinueParse(NULL); | 941 ContinueParse(NULL); |
| 944 } | 942 } |
| 945 CPDF_Page::~CPDF_Page() | 943 CPDF_Page::~CPDF_Page() |
| 946 { | 944 { |
| 947 if (m_pPageRender) { | 945 if (m_pPageRender) { |
| 948 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule(); | 946 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 } | 985 } |
| 988 m_Transparency = 0; | 986 m_Transparency = 0; |
| 989 LoadTransInfo(); | 987 LoadTransInfo(); |
| 990 } | 988 } |
| 991 CPDF_Form::~CPDF_Form() | 989 CPDF_Form::~CPDF_Form() |
| 992 { | 990 { |
| 993 } | 991 } |
| 994 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pPa
rentMatrix, | 992 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pPa
rentMatrix, |
| 995 CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptio
ns, int level) | 993 CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptio
ns, int level) |
| 996 { | 994 { |
| 997 if (m_ParseState == PDF_CONTENT_PARSED || m_ParseState == PDF_CONTENT_PARSIN
G) { | 995 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { |
| 998 return; | 996 return; |
| 999 } | 997 } |
| 1000 m_pParser = new CPDF_ContentParser; | 998 m_pParser = new CPDF_ContentParser; |
| 1001 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions,
level); | 999 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions,
level); |
| 1002 m_ParseState = PDF_CONTENT_PARSING; | 1000 m_ParseState = CONTENT_PARSING; |
| 1003 } | 1001 } |
| 1004 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* p
ParentMatrix, | 1002 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* p
ParentMatrix, |
| 1005 CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOpt
ions, int level) | 1003 CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOpt
ions, int level) |
| 1006 { | 1004 { |
| 1007 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); | 1005 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); |
| 1008 ContinueParse(NULL); | 1006 ContinueParse(NULL); |
| 1009 } | 1007 } |
| 1010 CPDF_Form* CPDF_Form::Clone() const | 1008 CPDF_Form* CPDF_Form::Clone() const |
| 1011 { | 1009 { |
| 1012 CPDF_Form* pClone = new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStre
am, m_pResources); | 1010 CPDF_Form* pClone = new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStre
am, m_pResources); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 matrix = m_PageMatrix; | 1066 matrix = m_PageMatrix; |
| 1069 matrix.Concat(display_matrix); | 1067 matrix.Concat(display_matrix); |
| 1070 } | 1068 } |
| 1071 CPDF_ParseOptions::CPDF_ParseOptions() | 1069 CPDF_ParseOptions::CPDF_ParseOptions() |
| 1072 { | 1070 { |
| 1073 m_bTextOnly = FALSE; | 1071 m_bTextOnly = FALSE; |
| 1074 m_bMarkedContent = TRUE; | 1072 m_bMarkedContent = TRUE; |
| 1075 m_bSeparateForm = TRUE; | 1073 m_bSeparateForm = TRUE; |
| 1076 m_bDecodeInlineImage = FALSE; | 1074 m_bDecodeInlineImage = FALSE; |
| 1077 } | 1075 } |
| OLD | NEW |