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 "core/src/fpdfapi/fpdf_page/pageint.h" | 7 #include "core/src/fpdfapi/fpdf_page/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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 CFX_ByteStringC type = pXObject->GetDict() | 731 CFX_ByteStringC type = pXObject->GetDict() |
732 ? pXObject->GetDict()->GetConstString("Subtype") | 732 ? pXObject->GetDict()->GetConstString("Subtype") |
733 : CFX_ByteStringC(); | 733 : CFX_ByteStringC(); |
734 if (type == "Image") { | 734 if (type == "Image") { |
735 if (m_Options.m_bTextOnly) { | 735 if (m_Options.m_bTextOnly) { |
736 return; | 736 return; |
737 } | 737 } |
738 CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE); | 738 CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE); |
739 m_LastImageName = name; | 739 m_LastImageName = name; |
740 m_pLastImage = pObj->m_pImage; | 740 m_pLastImage = pObj->m_pImage; |
741 if (!m_pObjectList->m_bHasImageMask) | 741 if (!m_pObjectList->HasImageMask()) |
742 m_pObjectList->m_bHasImageMask = m_pLastImage->IsMask(); | 742 m_pObjectList->SetHasImageMask(m_pLastImage->IsMask()); |
743 } else if (type == "Form") { | 743 } else if (type == "Form") { |
744 AddForm(pXObject); | 744 AddForm(pXObject); |
745 } else { | 745 } else { |
746 return; | 746 return; |
747 } | 747 } |
748 } | 748 } |
749 | 749 |
750 void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { | 750 void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { |
751 if (!m_Options.m_bSeparateForm) { | 751 if (!m_Options.m_bSeparateForm) { |
752 CPDF_Dictionary* pResources = pStream->GetDict()->GetDict("Resources"); | 752 CPDF_Dictionary* pResources = pStream->GetDict()->GetDict("Resources"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 pFormObj->m_pForm = | 784 pFormObj->m_pForm = |
785 new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_pResources); | 785 new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_pResources); |
786 pFormObj->m_FormMatrix = m_pCurStates->m_CTM; | 786 pFormObj->m_FormMatrix = m_pCurStates->m_CTM; |
787 pFormObj->m_FormMatrix.Concat(m_mtContentToUser); | 787 pFormObj->m_FormMatrix.Concat(m_mtContentToUser); |
788 CPDF_AllStates status; | 788 CPDF_AllStates status; |
789 status.m_GeneralState = m_pCurStates->m_GeneralState; | 789 status.m_GeneralState = m_pCurStates->m_GeneralState; |
790 status.m_GraphState = m_pCurStates->m_GraphState; | 790 status.m_GraphState = m_pCurStates->m_GraphState; |
791 status.m_ColorState = m_pCurStates->m_ColorState; | 791 status.m_ColorState = m_pCurStates->m_ColorState; |
792 status.m_TextState = m_pCurStates->m_TextState; | 792 status.m_TextState = m_pCurStates->m_TextState; |
793 pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1); | 793 pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1); |
794 if (!m_pObjectList->m_bBackgroundAlphaNeeded && | 794 if (!m_pObjectList->BackgroundAlphaNeeded() && |
795 pFormObj->m_pForm->m_bBackgroundAlphaNeeded) { | 795 pFormObj->m_pForm->BackgroundAlphaNeeded()) { |
796 m_pObjectList->m_bBackgroundAlphaNeeded = TRUE; | 796 m_pObjectList->SetBackgroundAlphaNeeded(TRUE); |
797 } | 797 } |
798 pFormObj->CalcBoundingBox(); | 798 pFormObj->CalcBoundingBox(); |
799 SetGraphicStates(pFormObj, TRUE, TRUE, TRUE); | 799 SetGraphicStates(pFormObj, TRUE, TRUE, TRUE); |
800 m_pObjectList->m_ObjectList.AddTail(pFormObj); | 800 m_pObjectList->AddTail(pFormObj); |
801 } | 801 } |
802 | 802 |
803 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, | 803 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, |
804 CPDF_Image* pImage, | 804 CPDF_Image* pImage, |
805 FX_BOOL bInline) { | 805 FX_BOOL bInline) { |
806 if (!pStream && !pImage) { | 806 if (!pStream && !pImage) { |
807 return NULL; | 807 return NULL; |
808 } | 808 } |
809 CFX_Matrix ImageMatrix; | 809 CFX_Matrix ImageMatrix; |
810 ImageMatrix.Copy(m_pCurStates->m_CTM); | 810 ImageMatrix.Copy(m_pCurStates->m_CTM); |
811 ImageMatrix.Concat(m_mtContentToUser); | 811 ImageMatrix.Concat(m_mtContentToUser); |
812 CPDF_ImageObject* pImageObj = new CPDF_ImageObject; | 812 CPDF_ImageObject* pImageObj = new CPDF_ImageObject; |
813 if (pImage) { | 813 if (pImage) { |
814 pImageObj->m_pImage = | 814 pImageObj->m_pImage = |
815 m_pDocument->GetPageData()->GetImage(pImage->GetStream()); | 815 m_pDocument->GetPageData()->GetImage(pImage->GetStream()); |
816 } else if (pStream->GetObjNum()) { | 816 } else if (pStream->GetObjNum()) { |
817 pImageObj->m_pImage = m_pDocument->LoadImageF(pStream); | 817 pImageObj->m_pImage = m_pDocument->LoadImageF(pStream); |
818 } else { | 818 } else { |
819 pImageObj->m_pImage = new CPDF_Image(m_pDocument); | 819 pImageObj->m_pImage = new CPDF_Image(m_pDocument); |
820 pImageObj->m_pImage->LoadImageF(pStream, bInline); | 820 pImageObj->m_pImage->LoadImageF(pStream, bInline); |
821 } | 821 } |
822 SetGraphicStates(pImageObj, pImageObj->m_pImage->IsMask(), FALSE, FALSE); | 822 SetGraphicStates(pImageObj, pImageObj->m_pImage->IsMask(), FALSE, FALSE); |
823 pImageObj->m_Matrix = ImageMatrix; | 823 pImageObj->m_Matrix = ImageMatrix; |
824 pImageObj->CalcBoundingBox(); | 824 pImageObj->CalcBoundingBox(); |
825 m_pObjectList->m_ObjectList.AddTail(pImageObj); | 825 m_pObjectList->AddTail(pImageObj); |
826 return pImageObj; | 826 return pImageObj; |
827 } | 827 } |
828 | 828 |
829 void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() {} | 829 void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() {} |
830 | 830 |
831 void CPDF_StreamContentParser::Handle_EndImage() {} | 831 void CPDF_StreamContentParser::Handle_EndImage() {} |
832 | 832 |
833 void CPDF_StreamContentParser::Handle_EndMarkedContent() { | 833 void CPDF_StreamContentParser::Handle_EndMarkedContent() { |
834 if (!m_Options.m_bMarkedContent) { | 834 if (!m_Options.m_bMarkedContent) { |
835 return; | 835 return; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 if (pShading->IsMeshShading()) { | 1204 if (pShading->IsMeshShading()) { |
1205 bbox.Intersect(GetShadingBBox(ToStream(pShading->m_pShadingObj), | 1205 bbox.Intersect(GetShadingBBox(ToStream(pShading->m_pShadingObj), |
1206 pShading->m_ShadingType, &pObj->m_Matrix, | 1206 pShading->m_ShadingType, &pObj->m_Matrix, |
1207 pShading->m_pFunctions, pShading->m_nFuncs, | 1207 pShading->m_pFunctions, pShading->m_nFuncs, |
1208 pShading->m_pCS)); | 1208 pShading->m_pCS)); |
1209 } | 1209 } |
1210 pObj->m_Left = bbox.left; | 1210 pObj->m_Left = bbox.left; |
1211 pObj->m_Right = bbox.right; | 1211 pObj->m_Right = bbox.right; |
1212 pObj->m_Top = bbox.top; | 1212 pObj->m_Top = bbox.top; |
1213 pObj->m_Bottom = bbox.bottom; | 1213 pObj->m_Bottom = bbox.bottom; |
1214 m_pObjectList->m_ObjectList.AddTail(pObj); | 1214 m_pObjectList->AddTail(pObj); |
1215 } | 1215 } |
1216 | 1216 |
1217 void CPDF_StreamContentParser::Handle_SetCharSpace() { | 1217 void CPDF_StreamContentParser::Handle_SetCharSpace() { |
1218 m_pCurStates->m_TextState.GetModify()->m_CharSpace = GetNumber(0); | 1218 m_pCurStates->m_TextState.GetModify()->m_CharSpace = GetNumber(0); |
1219 } | 1219 } |
1220 | 1220 |
1221 void CPDF_StreamContentParser::Handle_MoveTextPoint() { | 1221 void CPDF_StreamContentParser::Handle_MoveTextPoint() { |
1222 m_pCurStates->m_TextLineX += GetNumber(1); | 1222 m_pCurStates->m_TextLineX += GetNumber(1); |
1223 m_pCurStates->m_TextLineY += GetNumber(0); | 1223 m_pCurStates->m_TextLineY += GetNumber(0); |
1224 m_pCurStates->m_TextX = m_pCurStates->m_TextLineX; | 1224 m_pCurStates->m_TextX = m_pCurStates->m_TextLineX; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 FX_FLOAT x_advance, y_advance; | 1382 FX_FLOAT x_advance, y_advance; |
1383 pText->CalcPositionData(&x_advance, &y_advance, m_pCurStates->m_TextHorzScale, | 1383 pText->CalcPositionData(&x_advance, &y_advance, m_pCurStates->m_TextHorzScale, |
1384 m_Level); | 1384 m_Level); |
1385 m_pCurStates->m_TextX += x_advance; | 1385 m_pCurStates->m_TextX += x_advance; |
1386 m_pCurStates->m_TextY += y_advance; | 1386 m_pCurStates->m_TextY += y_advance; |
1387 if (textmode > 3) { | 1387 if (textmode > 3) { |
1388 CPDF_TextObject* pCopy = new CPDF_TextObject; | 1388 CPDF_TextObject* pCopy = new CPDF_TextObject; |
1389 pCopy->Copy(pText); | 1389 pCopy->Copy(pText); |
1390 m_ClipTextList.Add(pCopy); | 1390 m_ClipTextList.Add(pCopy); |
1391 } | 1391 } |
1392 m_pObjectList->m_ObjectList.AddTail(pText); | 1392 m_pObjectList->AddTail(pText); |
1393 if (pKerning && pKerning[nsegs - 1] != 0) { | 1393 if (pKerning && pKerning[nsegs - 1] != 0) { |
1394 if (!pFont->IsVertWriting()) { | 1394 if (!pFont->IsVertWriting()) { |
1395 m_pCurStates->m_TextX -= | 1395 m_pCurStates->m_TextX -= |
1396 FXSYS_Mul(pKerning[nsegs - 1], | 1396 FXSYS_Mul(pKerning[nsegs - 1], |
1397 m_pCurStates->m_TextState.GetFontSize()) / | 1397 m_pCurStates->m_TextState.GetFontSize()) / |
1398 1000; | 1398 1000; |
1399 } else { | 1399 } else { |
1400 m_pCurStates->m_TextY -= | 1400 m_pCurStates->m_TextY -= |
1401 FXSYS_Mul(pKerning[nsegs - 1], | 1401 FXSYS_Mul(pKerning[nsegs - 1], |
1402 m_pCurStates->m_TextState.GetFontSize()) / | 1402 m_pCurStates->m_TextState.GetFontSize()) / |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 CFX_Matrix matrix = m_pCurStates->m_CTM; | 1617 CFX_Matrix matrix = m_pCurStates->m_CTM; |
1618 matrix.Concat(m_mtContentToUser); | 1618 matrix.Concat(m_mtContentToUser); |
1619 if (bStroke || FillType) { | 1619 if (bStroke || FillType) { |
1620 CPDF_PathObject* pPathObj = new CPDF_PathObject; | 1620 CPDF_PathObject* pPathObj = new CPDF_PathObject; |
1621 pPathObj->m_bStroke = bStroke; | 1621 pPathObj->m_bStroke = bStroke; |
1622 pPathObj->m_FillType = FillType; | 1622 pPathObj->m_FillType = FillType; |
1623 pPathObj->m_Path = Path; | 1623 pPathObj->m_Path = Path; |
1624 pPathObj->m_Matrix = matrix; | 1624 pPathObj->m_Matrix = matrix; |
1625 SetGraphicStates(pPathObj, TRUE, FALSE, TRUE); | 1625 SetGraphicStates(pPathObj, TRUE, FALSE, TRUE); |
1626 pPathObj->CalcBoundingBox(); | 1626 pPathObj->CalcBoundingBox(); |
1627 m_pObjectList->m_ObjectList.AddTail(pPathObj); | 1627 m_pObjectList->AddTail(pPathObj); |
1628 } | 1628 } |
1629 if (PathClipType) { | 1629 if (PathClipType) { |
1630 if (!matrix.IsIdentity()) { | 1630 if (!matrix.IsIdentity()) { |
1631 Path.Transform(&matrix); | 1631 Path.Transform(&matrix); |
1632 matrix.SetIdentity(); | 1632 matrix.SetIdentity(); |
1633 } | 1633 } |
1634 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); | 1634 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); |
1635 } | 1635 } |
1636 } | 1636 } |
1637 | 1637 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 pArray->SetAt(i, new CPDF_Name(fullname)); | 1811 pArray->SetAt(i, new CPDF_Name(fullname)); |
1812 } | 1812 } |
1813 } else { | 1813 } else { |
1814 PDF_ReplaceAbbr(pElement); | 1814 PDF_ReplaceAbbr(pElement); |
1815 } | 1815 } |
1816 } | 1816 } |
1817 break; | 1817 break; |
1818 } | 1818 } |
1819 } | 1819 } |
1820 } | 1820 } |
OLD | NEW |