| 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/page/cpdf_docpagedata.h" | 7 #include "core/fpdfapi/page/cpdf_docpagedata.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
| 10 #include <set> | 11 #include <set> |
| 11 | 12 |
| 12 #include "core/fdrm/crypto/fx_crypt.h" | 13 #include "core/fdrm/crypto/fx_crypt.h" |
| 13 #include "core/fpdfapi/cpdf_modulemgr.h" | 14 #include "core/fpdfapi/cpdf_modulemgr.h" |
| 14 #include "core/fpdfapi/font/cpdf_type1font.h" | 15 #include "core/fpdfapi/font/cpdf_type1font.h" |
| 15 #include "core/fpdfapi/font/font_int.h" | 16 #include "core/fpdfapi/font/font_int.h" |
| 16 #include "core/fpdfapi/page/cpdf_image.h" | 17 #include "core/fpdfapi/page/cpdf_image.h" |
| 17 #include "core/fpdfapi/page/cpdf_pagemodule.h" | 18 #include "core/fpdfapi/page/cpdf_pagemodule.h" |
| 18 #include "core/fpdfapi/page/cpdf_pattern.h" | 19 #include "core/fpdfapi/page/cpdf_pattern.h" |
| 19 #include "core/fpdfapi/page/cpdf_shadingpattern.h" | 20 #include "core/fpdfapi/page/cpdf_shadingpattern.h" |
| 20 #include "core/fpdfapi/page/cpdf_tilingpattern.h" | 21 #include "core/fpdfapi/page/cpdf_tilingpattern.h" |
| 21 #include "core/fpdfapi/parser/cpdf_array.h" | 22 #include "core/fpdfapi/parser/cpdf_array.h" |
| 22 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 23 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
| 23 #include "core/fpdfapi/parser/cpdf_document.h" | 24 #include "core/fpdfapi/parser/cpdf_document.h" |
| 25 #include "core/fpdfapi/parser/cpdf_name.h" |
| 24 #include "core/fpdfapi/parser/cpdf_stream_acc.h" | 26 #include "core/fpdfapi/parser/cpdf_stream_acc.h" |
| 25 #include "third_party/base/stl_util.h" | 27 #include "third_party/base/stl_util.h" |
| 26 | 28 |
| 27 CPDF_DocPageData::CPDF_DocPageData(CPDF_Document* pPDFDoc) | 29 CPDF_DocPageData::CPDF_DocPageData(CPDF_Document* pPDFDoc) |
| 28 : m_pPDFDoc(pPDFDoc), m_bForceClear(false) {} | 30 : m_pPDFDoc(pPDFDoc), m_bForceClear(false) {} |
| 29 | 31 |
| 30 CPDF_DocPageData::~CPDF_DocPageData() { | 32 CPDF_DocPageData::~CPDF_DocPageData() { |
| 31 Clear(false); | 33 Clear(false); |
| 32 Clear(true); | 34 Clear(true); |
| 33 | 35 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 continue; | 171 continue; |
| 170 | 172 |
| 171 CPDF_Type1Font* pT1Font = pFont->AsType1Font(); | 173 CPDF_Type1Font* pT1Font = pFont->AsType1Font(); |
| 172 if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding)) | 174 if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding)) |
| 173 continue; | 175 continue; |
| 174 | 176 |
| 175 return fontData->AddRef(); | 177 return fontData->AddRef(); |
| 176 } | 178 } |
| 177 | 179 |
| 178 CPDF_Dictionary* pDict = m_pPDFDoc->NewIndirect<CPDF_Dictionary>(); | 180 CPDF_Dictionary* pDict = m_pPDFDoc->NewIndirect<CPDF_Dictionary>(); |
| 179 pDict->SetNameFor("Type", "Font"); | 181 pDict->SetNewFor<CPDF_Name>("Type", "Font"); |
| 180 pDict->SetNameFor("Subtype", "Type1"); | 182 pDict->SetNewFor<CPDF_Name>("Subtype", "Type1"); |
| 181 pDict->SetNameFor("BaseFont", fontName); | 183 pDict->SetNewFor<CPDF_Name>("BaseFont", fontName); |
| 182 if (pEncoding) { | 184 if (pEncoding) { |
| 183 pDict->SetFor("Encoding", | 185 pDict->SetFor( |
| 184 pEncoding->Realize(m_pPDFDoc->GetByteStringPool())); | 186 "Encoding", |
| 187 pdfium::WrapUnique(pEncoding->Realize(m_pPDFDoc->GetByteStringPool()))); |
| 185 } | 188 } |
| 186 | 189 |
| 187 std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pDict); | 190 std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pDict); |
| 188 if (!pFont) | 191 if (!pFont) |
| 189 return nullptr; | 192 return nullptr; |
| 190 | 193 |
| 191 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont.release()); | 194 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont.release()); |
| 192 m_FontMap[pDict] = fontData; | 195 m_FontMap[pDict] = fontData; |
| 193 return fontData->AddRef(); | 196 return fontData->AddRef(); |
| 194 } | 197 } |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 } | 530 } |
| 528 | 531 |
| 529 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( | 532 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( |
| 530 CPDF_Object* pPatternObj) const { | 533 CPDF_Object* pPatternObj) const { |
| 531 if (!pPatternObj) | 534 if (!pPatternObj) |
| 532 return nullptr; | 535 return nullptr; |
| 533 | 536 |
| 534 auto it = m_PatternMap.find(pPatternObj); | 537 auto it = m_PatternMap.find(pPatternObj); |
| 535 return it != m_PatternMap.end() ? it->second : nullptr; | 538 return it != m_PatternMap.end() ? it->second : nullptr; |
| 536 } | 539 } |
| OLD | NEW |