| 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 | 760 int CPDF_PageObjects::EstimateParseProgress() const |
| 756 { | 761 { |
| 757 if (!m_pParser) { | 762 if (!m_pParser) { |
| 758 return m_ParseState == PDF_CONTENT_PARSED ? 100 : 0; | 763 return m_ParseState == CONTENT_PARSED ? 100 : 0; |
| 759 } | 764 } |
| 760 return m_pParser->EstimateProgress(); | 765 return m_pParser->EstimateProgress(); |
| 761 } | 766 } |
| 762 FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, CPDF_Page
Object* pNewObject) | 767 FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, CPDF_Page
Object* pNewObject) |
| 763 { | 768 { |
| 764 if (!posInsertAfter) { | 769 if (!posInsertAfter) { |
| 765 return m_ObjectList.AddHead(pNewObject); | 770 return m_ObjectList.AddHead(pNewObject); |
| 766 } | 771 } |
| 767 return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); | 772 return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); |
| 768 } | 773 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 m_Transparency |= PDFTRANS_GROUP; | 841 m_Transparency |= PDFTRANS_GROUP; |
| 837 if (pGroup->GetInteger(FX_BSTRC("I"))) { | 842 if (pGroup->GetInteger(FX_BSTRC("I"))) { |
| 838 m_Transparency |= PDFTRANS_ISOLATED; | 843 m_Transparency |= PDFTRANS_ISOLATED; |
| 839 } | 844 } |
| 840 if (pGroup->GetInteger(FX_BSTRC("K"))) { | 845 if (pGroup->GetInteger(FX_BSTRC("K"))) { |
| 841 m_Transparency |= PDFTRANS_KNOCKOUT; | 846 m_Transparency |= PDFTRANS_KNOCKOUT; |
| 842 } | 847 } |
| 843 } | 848 } |
| 844 void CPDF_PageObjects::ClearCacheObjects() | 849 void CPDF_PageObjects::ClearCacheObjects() |
| 845 { | 850 { |
| 846 m_ParseState = PDF_CONTENT_NOT_PARSED; | 851 m_ParseState = CONTENT_NOT_PARSED; |
| 847 delete m_pParser; | 852 delete m_pParser; |
| 848 m_pParser = NULL; | 853 m_pParser = NULL; |
| 849 if (m_bReleaseMembers) { | 854 if (m_bReleaseMembers) { |
| 850 FX_POSITION pos = m_ObjectList.GetHeadPosition(); | 855 FX_POSITION pos = m_ObjectList.GetHeadPosition(); |
| 851 while (pos) { | 856 while (pos) { |
| 852 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 857 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
| 853 } | 858 } |
| 854 } | 859 } |
| 855 m_ObjectList.RemoveAll(); | 860 m_ObjectList.RemoveAll(); |
| 856 } | 861 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 break; | 928 break; |
| 924 } | 929 } |
| 925 m_Transparency = PDFTRANS_ISOLATED; | 930 m_Transparency = PDFTRANS_ISOLATED; |
| 926 LoadTransInfo(); | 931 LoadTransInfo(); |
| 927 } | 932 } |
| 928 void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) | 933 void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) |
| 929 { | 934 { |
| 930 if (bReParse) { | 935 if (bReParse) { |
| 931 ClearCacheObjects(); | 936 ClearCacheObjects(); |
| 932 } | 937 } |
| 933 if (m_ParseState == PDF_CONTENT_PARSED || m_ParseState == PDF_CONTENT_PARSIN
G) { | 938 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { |
| 934 return; | 939 return; |
| 935 } | 940 } |
| 936 m_pParser = new CPDF_ContentParser; | 941 m_pParser = new CPDF_ContentParser; |
| 937 m_pParser->Start(this, pOptions); | 942 m_pParser->Start(this, pOptions); |
| 938 m_ParseState = PDF_CONTENT_PARSING; | 943 m_ParseState = CONTENT_PARSING; |
| 939 } | 944 } |
| 940 void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) | 945 void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) |
| 941 { | 946 { |
| 942 StartParse(pOptions, bReParse); | 947 StartParse(pOptions, bReParse); |
| 943 ContinueParse(NULL); | 948 ContinueParse(NULL); |
| 944 } | 949 } |
| 945 CPDF_Page::~CPDF_Page() | 950 CPDF_Page::~CPDF_Page() |
| 946 { | 951 { |
| 947 if (m_pPageRender) { | 952 if (m_pPageRender) { |
| 948 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule(); | 953 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 } | 992 } |
| 988 m_Transparency = 0; | 993 m_Transparency = 0; |
| 989 LoadTransInfo(); | 994 LoadTransInfo(); |
| 990 } | 995 } |
| 991 CPDF_Form::~CPDF_Form() | 996 CPDF_Form::~CPDF_Form() |
| 992 { | 997 { |
| 993 } | 998 } |
| 994 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pPa
rentMatrix, | 999 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pPa
rentMatrix, |
| 995 CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptio
ns, int level) | 1000 CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptio
ns, int level) |
| 996 { | 1001 { |
| 997 if (m_ParseState == PDF_CONTENT_PARSED || m_ParseState == PDF_CONTENT_PARSIN
G) { | 1002 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { |
| 998 return; | 1003 return; |
| 999 } | 1004 } |
| 1000 m_pParser = new CPDF_ContentParser; | 1005 m_pParser = new CPDF_ContentParser; |
| 1001 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions,
level); | 1006 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions,
level); |
| 1002 m_ParseState = PDF_CONTENT_PARSING; | 1007 m_ParseState = CONTENT_PARSING; |
| 1003 } | 1008 } |
| 1004 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* p
ParentMatrix, | 1009 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* p
ParentMatrix, |
| 1005 CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOpt
ions, int level) | 1010 CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOpt
ions, int level) |
| 1006 { | 1011 { |
| 1007 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); | 1012 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); |
| 1008 ContinueParse(NULL); | 1013 ContinueParse(NULL); |
| 1009 } | 1014 } |
| 1010 CPDF_Form* CPDF_Form::Clone() const | 1015 CPDF_Form* CPDF_Form::Clone() const |
| 1011 { | 1016 { |
| 1012 CPDF_Form* pClone = new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStre
am, m_pResources); | 1017 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; | 1073 matrix = m_PageMatrix; |
| 1069 matrix.Concat(display_matrix); | 1074 matrix.Concat(display_matrix); |
| 1070 } | 1075 } |
| 1071 CPDF_ParseOptions::CPDF_ParseOptions() | 1076 CPDF_ParseOptions::CPDF_ParseOptions() |
| 1072 { | 1077 { |
| 1073 m_bTextOnly = FALSE; | 1078 m_bTextOnly = FALSE; |
| 1074 m_bMarkedContent = TRUE; | 1079 m_bMarkedContent = TRUE; |
| 1075 m_bSeparateForm = TRUE; | 1080 m_bSeparateForm = TRUE; |
| 1076 m_bDecodeInlineImage = FALSE; | 1081 m_bDecodeInlineImage = FALSE; |
| 1077 } | 1082 } |
| OLD | NEW |