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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && | 701 if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && |
702 m_pLastImage->GetStream()->GetObjNum()) { | 702 m_pLastImage->GetStream()->GetObjNum()) { |
703 AddImage(nullptr, m_pLastImage, FALSE); | 703 AddImage(nullptr, m_pLastImage, FALSE); |
704 return; | 704 return; |
705 } | 705 } |
706 | 706 |
707 if (m_Options.m_bTextOnly) { | 707 if (m_Options.m_bTextOnly) { |
708 if (!m_pResources) | 708 if (!m_pResources) |
709 return; | 709 return; |
710 | 710 |
711 CPDF_Dictionary* pList = m_pResources->GetDict("XObject"); | 711 CPDF_Dictionary* pList = m_pResources->GetDictBy("XObject"); |
712 if (!pList && m_pPageResources && m_pResources != m_pPageResources) | 712 if (!pList && m_pPageResources && m_pResources != m_pPageResources) |
713 pList = m_pPageResources->GetDict("XObject"); | 713 pList = m_pPageResources->GetDictBy("XObject"); |
714 if (!pList) | 714 if (!pList) |
715 return; | 715 return; |
716 CPDF_Reference* pRes = ToReference(pList->GetElement(name)); | 716 CPDF_Reference* pRes = ToReference(pList->GetElement(name)); |
717 if (!pRes) | 717 if (!pRes) |
718 return; | 718 return; |
719 | 719 |
720 FX_BOOL bForm; | 720 FX_BOOL bForm; |
721 if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm) | 721 if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm) |
722 return; | 722 return; |
723 } | 723 } |
724 | 724 |
725 CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name)); | 725 CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name)); |
726 if (!pXObject) { | 726 if (!pXObject) { |
727 m_bResourceMissing = TRUE; | 727 m_bResourceMissing = TRUE; |
728 return; | 728 return; |
729 } | 729 } |
730 | 730 |
731 CFX_ByteStringC type = pXObject->GetDict() | 731 CFX_ByteStringC type = pXObject->GetDict() |
732 ? pXObject->GetDict()->GetConstString("Subtype") | 732 ? pXObject->GetDict()->GetConstStringBy("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->HasImageMask()) | 741 if (!m_pObjectList->HasImageMask()) |
742 m_pObjectList->SetHasImageMask(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()->GetDictBy("Resources"); |
753 CFX_Matrix form_matrix = pStream->GetDict()->GetMatrix("Matrix"); | 753 CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixBy("Matrix"); |
754 form_matrix.Concat(m_pCurStates->m_CTM); | 754 form_matrix.Concat(m_pCurStates->m_CTM); |
755 CPDF_Array* pBBox = pStream->GetDict()->GetArray("BBox"); | 755 CPDF_Array* pBBox = pStream->GetDict()->GetArrayBy("BBox"); |
756 CFX_FloatRect form_bbox; | 756 CFX_FloatRect form_bbox; |
757 CPDF_Path ClipPath; | 757 CPDF_Path ClipPath; |
758 if (pBBox) { | 758 if (pBBox) { |
759 form_bbox = pStream->GetDict()->GetRect("BBox"); | 759 form_bbox = pStream->GetDict()->GetRectBy("BBox"); |
760 ClipPath.New(); | 760 ClipPath.New(); |
761 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, | 761 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, |
762 form_bbox.top); | 762 form_bbox.top); |
763 ClipPath.Transform(&form_matrix); | 763 ClipPath.Transform(&form_matrix); |
764 form_bbox.Transform(&form_matrix); | 764 form_bbox.Transform(&form_matrix); |
765 } | 765 } |
766 CPDF_StreamContentParser parser(m_pDocument, m_pPageResources, m_pResources, | 766 CPDF_StreamContentParser parser(m_pDocument, m_pPageResources, m_pResources, |
767 &m_mtContentToUser, m_pObjectList, | 767 &m_mtContentToUser, m_pObjectList, |
768 pResources, &form_bbox, &m_Options, | 768 pResources, &form_bbox, &m_Options, |
769 m_pCurStates.get(), m_Level + 1); | 769 m_pCurStates.get(), m_Level + 1); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 } | 1242 } |
1243 } | 1243 } |
1244 | 1244 |
1245 CPDF_Object* CPDF_StreamContentParser::FindResourceObj( | 1245 CPDF_Object* CPDF_StreamContentParser::FindResourceObj( |
1246 const CFX_ByteStringC& type, | 1246 const CFX_ByteStringC& type, |
1247 const CFX_ByteString& name) { | 1247 const CFX_ByteString& name) { |
1248 if (!m_pResources) { | 1248 if (!m_pResources) { |
1249 return NULL; | 1249 return NULL; |
1250 } | 1250 } |
1251 if (m_pResources == m_pPageResources) { | 1251 if (m_pResources == m_pPageResources) { |
1252 CPDF_Dictionary* pList = m_pResources->GetDict(type); | 1252 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); |
1253 if (!pList) { | 1253 if (!pList) { |
1254 return NULL; | 1254 return NULL; |
1255 } | 1255 } |
1256 CPDF_Object* pRes = pList->GetElementValue(name); | 1256 CPDF_Object* pRes = pList->GetElementValue(name); |
1257 return pRes; | 1257 return pRes; |
1258 } | 1258 } |
1259 CPDF_Dictionary* pList = m_pResources->GetDict(type); | 1259 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); |
1260 if (!pList) { | 1260 if (!pList) { |
1261 if (!m_pPageResources) { | 1261 if (!m_pPageResources) { |
1262 return NULL; | 1262 return NULL; |
1263 } | 1263 } |
1264 CPDF_Dictionary* pList = m_pPageResources->GetDict(type); | 1264 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); |
1265 if (!pList) { | 1265 if (!pList) { |
1266 return NULL; | 1266 return NULL; |
1267 } | 1267 } |
1268 CPDF_Object* pRes = pList->GetElementValue(name); | 1268 CPDF_Object* pRes = pList->GetElementValue(name); |
1269 return pRes; | 1269 return pRes; |
1270 } | 1270 } |
1271 CPDF_Object* pRes = pList->GetElementValue(name); | 1271 CPDF_Object* pRes = pList->GetElementValue(name); |
1272 return pRes; | 1272 return pRes; |
1273 } | 1273 } |
1274 | 1274 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 } | 1420 } |
1421 int n = pArray->GetCount(); | 1421 int n = pArray->GetCount(); |
1422 int nsegs = 0; | 1422 int nsegs = 0; |
1423 for (int i = 0; i < n; i++) { | 1423 for (int i = 0; i < n; i++) { |
1424 if (pArray->GetElementValue(i)->IsString()) | 1424 if (pArray->GetElementValue(i)->IsString()) |
1425 nsegs++; | 1425 nsegs++; |
1426 } | 1426 } |
1427 if (nsegs == 0) { | 1427 if (nsegs == 0) { |
1428 for (int i = 0; i < n; i++) { | 1428 for (int i = 0; i < n; i++) { |
1429 m_pCurStates->m_TextX -= | 1429 m_pCurStates->m_TextX -= |
1430 FXSYS_Mul(pArray->GetNumber(i), | 1430 FXSYS_Mul(pArray->GetNumberAt(i), |
1431 m_pCurStates->m_TextState.GetFontSize()) / | 1431 m_pCurStates->m_TextState.GetFontSize()) / |
1432 1000; | 1432 1000; |
1433 } | 1433 } |
1434 return; | 1434 return; |
1435 } | 1435 } |
1436 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; | 1436 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; |
1437 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); | 1437 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); |
1438 int iSegment = 0; | 1438 int iSegment = 0; |
1439 FX_FLOAT fInitKerning = 0; | 1439 FX_FLOAT fInitKerning = 0; |
1440 for (int i = 0; i < n; i++) { | 1440 for (int i = 0; i < n; i++) { |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 } else { | 1813 } else { |
1814 PDF_ReplaceAbbr(pElement); | 1814 PDF_ReplaceAbbr(pElement); |
1815 } | 1815 } |
1816 } | 1816 } |
1817 break; | 1817 break; |
1818 } | 1818 } |
1819 default: | 1819 default: |
1820 break; | 1820 break; |
1821 } | 1821 } |
1822 } | 1822 } |
OLD | NEW |