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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 m_FormMatrix = pSrcObj->m_FormMatrix; | 659 m_FormMatrix = pSrcObj->m_FormMatrix; |
660 } | 660 } |
661 void CPDF_FormObject::CalcBoundingBox() { | 661 void CPDF_FormObject::CalcBoundingBox() { |
662 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); | 662 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); |
663 form_rect.Transform(&m_FormMatrix); | 663 form_rect.Transform(&m_FormMatrix); |
664 m_Left = form_rect.left; | 664 m_Left = form_rect.left; |
665 m_Bottom = form_rect.bottom; | 665 m_Bottom = form_rect.bottom; |
666 m_Right = form_rect.right; | 666 m_Right = form_rect.right; |
667 m_Top = form_rect.top; | 667 m_Top = form_rect.top; |
668 } | 668 } |
669 CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) | 669 CPDF_PageObjects::CPDF_PageObjects() |
670 : m_pFormDict(nullptr), | 670 : m_pFormDict(nullptr), |
671 m_pFormStream(nullptr), | 671 m_pFormStream(nullptr), |
672 m_pDocument(nullptr), | 672 m_pDocument(nullptr), |
673 m_pPageResources(nullptr), | 673 m_pPageResources(nullptr), |
674 m_pResources(nullptr), | 674 m_pResources(nullptr), |
675 m_Transparency(0), | 675 m_Transparency(0), |
676 m_ObjectList(128), | |
677 m_bBackgroundAlphaNeeded(FALSE), | 676 m_bBackgroundAlphaNeeded(FALSE), |
678 m_bHasImageMask(FALSE), | 677 m_bHasImageMask(FALSE), |
679 m_bReleaseMembers(bReleaseMembers), | 678 m_ParseState(CONTENT_NOT_PARSED), |
680 m_pParser(nullptr), | 679 m_ObjectList(128) {} |
681 m_ParseState(CONTENT_NOT_PARSED) {} | |
682 CPDF_PageObjects::~CPDF_PageObjects() { | 680 CPDF_PageObjects::~CPDF_PageObjects() { |
683 delete m_pParser; | |
684 if (!m_bReleaseMembers) { | |
685 return; | |
686 } | |
687 FX_POSITION pos = m_ObjectList.GetHeadPosition(); | 681 FX_POSITION pos = m_ObjectList.GetHeadPosition(); |
688 while (pos) { | 682 while (pos) { |
689 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 683 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
690 } | 684 } |
691 } | 685 } |
692 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) { | 686 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) { |
693 if (!m_pParser) { | 687 if (!m_pParser) { |
694 return; | 688 return; |
695 } | 689 } |
696 m_pParser->Continue(pPause); | 690 m_pParser->Continue(pPause); |
697 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { | 691 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { |
698 m_ParseState = CONTENT_PARSED; | 692 m_ParseState = CONTENT_PARSED; |
699 delete m_pParser; | 693 m_pParser.reset(); |
700 m_pParser = NULL; | |
701 } | 694 } |
702 } | 695 } |
703 FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, | 696 FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, |
704 CPDF_PageObject* pNewObject) { | 697 CPDF_PageObject* pNewObject) { |
705 if (!posInsertAfter) { | 698 if (!posInsertAfter) { |
706 return m_ObjectList.AddHead(pNewObject); | 699 return m_ObjectList.AddHead(pNewObject); |
707 } | 700 } |
708 return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); | 701 return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); |
709 } | 702 } |
710 int CPDF_PageObjects::GetObjectIndex(CPDF_PageObject* pObj) const { | 703 int CPDF_PageObjects::GetObjectIndex(CPDF_PageObject* pObj) const { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 return; | 760 return; |
768 } | 761 } |
769 m_Transparency |= PDFTRANS_GROUP; | 762 m_Transparency |= PDFTRANS_GROUP; |
770 if (pGroup->GetInteger("I")) { | 763 if (pGroup->GetInteger("I")) { |
771 m_Transparency |= PDFTRANS_ISOLATED; | 764 m_Transparency |= PDFTRANS_ISOLATED; |
772 } | 765 } |
773 if (pGroup->GetInteger("K")) { | 766 if (pGroup->GetInteger("K")) { |
774 m_Transparency |= PDFTRANS_KNOCKOUT; | 767 m_Transparency |= PDFTRANS_KNOCKOUT; |
775 } | 768 } |
776 } | 769 } |
777 void CPDF_PageObjects::ClearCacheObjects() { | 770 |
778 m_ParseState = CONTENT_NOT_PARSED; | 771 CPDF_Page::CPDF_Page() : m_pPageRender(nullptr) {} |
779 delete m_pParser; | 772 |
780 m_pParser = NULL; | |
781 if (m_bReleaseMembers) { | |
782 FX_POSITION pos = m_ObjectList.GetHeadPosition(); | |
783 while (pos) { | |
784 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); | |
785 } | |
786 } | |
787 m_ObjectList.RemoveAll(); | |
788 } | |
789 CPDF_Page::CPDF_Page() { | |
790 m_pPageRender = NULL; | |
791 } | |
792 void CPDF_Page::Load(CPDF_Document* pDocument, | 773 void CPDF_Page::Load(CPDF_Document* pDocument, |
793 CPDF_Dictionary* pPageDict, | 774 CPDF_Dictionary* pPageDict, |
794 FX_BOOL bPageCache) { | 775 FX_BOOL bPageCache) { |
795 m_pDocument = (CPDF_Document*)pDocument; | 776 m_pDocument = (CPDF_Document*)pDocument; |
796 m_pFormDict = pPageDict; | 777 m_pFormDict = pPageDict; |
797 if (bPageCache) { | 778 if (bPageCache) { |
798 m_pPageRender = | 779 m_pPageRender = |
799 CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this); | 780 CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this); |
800 } | 781 } |
801 if (!pPageDict) { | 782 if (!pPageDict) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 case 2: | 832 case 2: |
852 m_PageMatrix.Set(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top); | 833 m_PageMatrix.Set(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top); |
853 break; | 834 break; |
854 case 3: | 835 case 3: |
855 m_PageMatrix.Set(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left); | 836 m_PageMatrix.Set(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left); |
856 break; | 837 break; |
857 } | 838 } |
858 m_Transparency = PDFTRANS_ISOLATED; | 839 m_Transparency = PDFTRANS_ISOLATED; |
859 LoadTransInfo(); | 840 LoadTransInfo(); |
860 } | 841 } |
861 void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) { | 842 void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions) { |
862 if (bReParse) { | |
863 ClearCacheObjects(); | |
864 } | |
865 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { | 843 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { |
866 return; | 844 return; |
867 } | 845 } |
868 m_pParser = new CPDF_ContentParser; | 846 m_pParser.reset(new CPDF_ContentParser); |
869 m_pParser->Start(this, pOptions); | 847 m_pParser->Start(this, pOptions); |
870 m_ParseState = CONTENT_PARSING; | 848 m_ParseState = CONTENT_PARSING; |
871 } | 849 } |
872 void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse) { | 850 void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions) { |
873 StartParse(pOptions, bReParse); | 851 StartParse(pOptions); |
874 ContinueParse(NULL); | 852 ContinueParse(nullptr); |
875 } | 853 } |
876 CPDF_Page::~CPDF_Page() { | 854 CPDF_Page::~CPDF_Page() { |
877 if (m_pPageRender) { | 855 if (m_pPageRender) { |
878 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule(); | 856 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule(); |
879 pModule->DestroyPageCache(m_pPageRender); | 857 pModule->DestroyPageCache(m_pPageRender); |
880 } | 858 } |
881 } | 859 } |
882 CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict, | 860 CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict, |
883 const CFX_ByteStringC& name) { | 861 const CFX_ByteStringC& name) { |
884 int level = 0; | 862 int level = 0; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 } | 899 } |
922 CPDF_Form::~CPDF_Form() {} | 900 CPDF_Form::~CPDF_Form() {} |
923 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, | 901 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, |
924 CFX_Matrix* pParentMatrix, | 902 CFX_Matrix* pParentMatrix, |
925 CPDF_Type3Char* pType3Char, | 903 CPDF_Type3Char* pType3Char, |
926 CPDF_ParseOptions* pOptions, | 904 CPDF_ParseOptions* pOptions, |
927 int level) { | 905 int level) { |
928 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { | 906 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { |
929 return; | 907 return; |
930 } | 908 } |
931 m_pParser = new CPDF_ContentParser; | 909 m_pParser.reset(new CPDF_ContentParser); |
932 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions, | 910 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions, |
933 level); | 911 level); |
934 m_ParseState = CONTENT_PARSING; | 912 m_ParseState = CONTENT_PARSING; |
935 } | 913 } |
936 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, | 914 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, |
937 CFX_Matrix* pParentMatrix, | 915 CFX_Matrix* pParentMatrix, |
938 CPDF_Type3Char* pType3Char, | 916 CPDF_Type3Char* pType3Char, |
939 CPDF_ParseOptions* pOptions, | 917 CPDF_ParseOptions* pOptions, |
940 int level) { | 918 int level) { |
941 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); | 919 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 (FX_FLOAT)y0); | 982 (FX_FLOAT)y0); |
1005 matrix = m_PageMatrix; | 983 matrix = m_PageMatrix; |
1006 matrix.Concat(display_matrix); | 984 matrix.Concat(display_matrix); |
1007 } | 985 } |
1008 CPDF_ParseOptions::CPDF_ParseOptions() { | 986 CPDF_ParseOptions::CPDF_ParseOptions() { |
1009 m_bTextOnly = FALSE; | 987 m_bTextOnly = FALSE; |
1010 m_bMarkedContent = TRUE; | 988 m_bMarkedContent = TRUE; |
1011 m_bSeparateForm = TRUE; | 989 m_bSeparateForm = TRUE; |
1012 m_bDecodeInlineImage = FALSE; | 990 m_bDecodeInlineImage = FALSE; |
1013 } | 991 } |
OLD | NEW |