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/fpdfapi/fpdf_page/pageint.h" | 7 #include "core/fpdfapi/fpdf_page/pageint.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 if (type != CPDF_StreamParser::Name) { | 559 if (type != CPDF_StreamParser::Name) { |
560 break; | 560 break; |
561 } | 561 } |
562 CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, | 562 CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, |
563 m_pSyntax->GetWordSize() - 1); | 563 m_pSyntax->GetWordSize() - 1); |
564 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( | 564 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( |
565 m_pSyntax->ReadNextObject()); | 565 m_pSyntax->ReadNextObject()); |
566 if (!key.IsEmpty()) { | 566 if (!key.IsEmpty()) { |
567 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; | 567 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; |
568 if (dwObjNum) | 568 if (dwObjNum) |
569 pDict->SetAtReference(key.AsStringC(), m_pDocument, dwObjNum); | 569 pDict->SetAtReference(key, m_pDocument, dwObjNum); |
570 else | 570 else |
571 pDict->SetAt(key.AsStringC(), pObj.release()); | 571 pDict->SetAt(key, pObj.release()); |
572 } | 572 } |
573 } | 573 } |
574 PDF_ReplaceAbbr(pDict); | 574 PDF_ReplaceAbbr(pDict); |
575 CPDF_Object* pCSObj = NULL; | 575 CPDF_Object* pCSObj = NULL; |
576 if (pDict->KeyExist("ColorSpace")) { | 576 if (pDict->KeyExist("ColorSpace")) { |
577 pCSObj = pDict->GetDirectObjectBy("ColorSpace"); | 577 pCSObj = pDict->GetDirectObjectBy("ColorSpace"); |
578 if (pCSObj->IsName()) { | 578 if (pCSObj->IsName()) { |
579 CFX_ByteString name = pCSObj->GetString(); | 579 CFX_ByteString name = pCSObj->GetString(); |
580 if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") { | 580 if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") { |
581 pCSObj = FindResourceObj("ColorSpace", name); | 581 pCSObj = FindResourceObj("ColorSpace", name); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 | 714 |
715 if (m_Options.m_bTextOnly) { | 715 if (m_Options.m_bTextOnly) { |
716 if (!m_pResources) | 716 if (!m_pResources) |
717 return; | 717 return; |
718 | 718 |
719 CPDF_Dictionary* pList = m_pResources->GetDictBy("XObject"); | 719 CPDF_Dictionary* pList = m_pResources->GetDictBy("XObject"); |
720 if (!pList && m_pPageResources && m_pResources != m_pPageResources) | 720 if (!pList && m_pPageResources && m_pResources != m_pPageResources) |
721 pList = m_pPageResources->GetDictBy("XObject"); | 721 pList = m_pPageResources->GetDictBy("XObject"); |
722 if (!pList) | 722 if (!pList) |
723 return; | 723 return; |
724 CPDF_Reference* pRes = ToReference(pList->GetObjectBy(name.AsStringC())); | 724 CPDF_Reference* pRes = ToReference(pList->GetObjectBy(name)); |
725 if (!pRes) | 725 if (!pRes) |
726 return; | 726 return; |
727 | 727 |
728 FX_BOOL bForm; | 728 FX_BOOL bForm; |
729 if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm) | 729 if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm) |
730 return; | 730 return; |
731 } | 731 } |
732 | 732 |
733 CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name)); | 733 CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name)); |
734 if (!pXObject) { | 734 if (!pXObject) { |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 const CFX_ByteStringC& type, | 1251 const CFX_ByteStringC& type, |
1252 const CFX_ByteString& name) { | 1252 const CFX_ByteString& name) { |
1253 if (!m_pResources) { | 1253 if (!m_pResources) { |
1254 return NULL; | 1254 return NULL; |
1255 } | 1255 } |
1256 if (m_pResources == m_pPageResources) { | 1256 if (m_pResources == m_pPageResources) { |
1257 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); | 1257 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); |
1258 if (!pList) { | 1258 if (!pList) { |
1259 return NULL; | 1259 return NULL; |
1260 } | 1260 } |
1261 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); | 1261 CPDF_Object* pRes = pList->GetDirectObjectBy(name); |
1262 return pRes; | 1262 return pRes; |
1263 } | 1263 } |
1264 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); | 1264 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); |
1265 if (!pList) { | 1265 if (!pList) { |
1266 if (!m_pPageResources) { | 1266 if (!m_pPageResources) { |
1267 return NULL; | 1267 return NULL; |
1268 } | 1268 } |
1269 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); | 1269 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); |
1270 if (!pList) { | 1270 if (!pList) { |
1271 return NULL; | 1271 return NULL; |
1272 } | 1272 } |
1273 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); | 1273 CPDF_Object* pRes = pList->GetDirectObjectBy(name); |
1274 return pRes; | 1274 return pRes; |
1275 } | 1275 } |
1276 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); | 1276 CPDF_Object* pRes = pList->GetDirectObjectBy(name); |
1277 return pRes; | 1277 return pRes; |
1278 } | 1278 } |
1279 | 1279 |
1280 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { | 1280 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { |
1281 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); | 1281 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); |
1282 if (!pFontDict) { | 1282 if (!pFontDict) { |
1283 m_bResourceMissing = TRUE; | 1283 m_bResourceMissing = TRUE; |
1284 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); | 1284 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); |
1285 } | 1285 } |
1286 | 1286 |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 op.key = key; | 1787 op.key = key; |
1788 op.replacement = fullname; | 1788 op.replacement = fullname; |
1789 replacements.push_back(op); | 1789 replacements.push_back(op); |
1790 } | 1790 } |
1791 } else { | 1791 } else { |
1792 PDF_ReplaceAbbr(value); | 1792 PDF_ReplaceAbbr(value); |
1793 } | 1793 } |
1794 } | 1794 } |
1795 for (const auto& op : replacements) { | 1795 for (const auto& op : replacements) { |
1796 if (op.is_replace_key) | 1796 if (op.is_replace_key) |
1797 pDict->ReplaceKey(op.key.AsStringC(), op.replacement); | 1797 pDict->ReplaceKey(op.key, op.replacement); |
1798 else | 1798 else |
1799 pDict->SetAtName(op.key.AsStringC(), op.replacement); | 1799 pDict->SetAtName(op.key, op.replacement); |
1800 } | 1800 } |
1801 break; | 1801 break; |
1802 } | 1802 } |
1803 case CPDF_Object::ARRAY: { | 1803 case CPDF_Object::ARRAY: { |
1804 CPDF_Array* pArray = pObj->AsArray(); | 1804 CPDF_Array* pArray = pObj->AsArray(); |
1805 for (size_t i = 0; i < pArray->GetCount(); i++) { | 1805 for (size_t i = 0; i < pArray->GetCount(); i++) { |
1806 CPDF_Object* pElement = pArray->GetObjectAt(i); | 1806 CPDF_Object* pElement = pArray->GetObjectAt(i); |
1807 if (pElement->IsName()) { | 1807 if (pElement->IsName()) { |
1808 CFX_ByteString name = pElement->GetString(); | 1808 CFX_ByteString name = pElement->GetString(); |
1809 CFX_ByteStringC fullname = PDF_FindFullName( | 1809 CFX_ByteStringC fullname = PDF_FindFullName( |
1810 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), | 1810 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), |
1811 name.AsStringC()); | 1811 name.AsStringC()); |
1812 if (!fullname.IsEmpty()) { | 1812 if (!fullname.IsEmpty()) { |
1813 pArray->SetAt(i, new CPDF_Name(fullname)); | 1813 pArray->SetAt(i, new CPDF_Name(fullname)); |
1814 } | 1814 } |
1815 } else { | 1815 } else { |
1816 PDF_ReplaceAbbr(pElement); | 1816 PDF_ReplaceAbbr(pElement); |
1817 } | 1817 } |
1818 } | 1818 } |
1819 break; | 1819 break; |
1820 } | 1820 } |
1821 default: | 1821 default: |
1822 break; | 1822 break; |
1823 } | 1823 } |
1824 } | 1824 } |
OLD | NEW |