| 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 "fpdfsdk/pdfwindow/PWL_FontMap.h" | 7 #include "fpdfsdk/pdfwindow/PWL_FontMap.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
| 10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" | 10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 "Times-Roman", | 28 "Times-Roman", |
| 29 "Times-Bold", | 29 "Times-Bold", |
| 30 "Times-Italic", | 30 "Times-Italic", |
| 31 "Times-BoldItalic", | 31 "Times-BoldItalic", |
| 32 "Symbol", | 32 "Symbol", |
| 33 "ZapfDingbats"}; | 33 "ZapfDingbats"}; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 CPWL_FontMap::CPWL_FontMap(CFX_SystemHandler* pSystemHandler) | 37 CPWL_FontMap::CPWL_FontMap(CFX_SystemHandler* pSystemHandler) |
| 38 : m_pPDFDoc(nullptr), m_pSystemHandler(pSystemHandler) { | 38 : m_pSystemHandler(pSystemHandler) { |
| 39 ASSERT(m_pSystemHandler); | 39 ASSERT(m_pSystemHandler); |
| 40 } | 40 } |
| 41 | 41 |
| 42 CPWL_FontMap::~CPWL_FontMap() { | 42 CPWL_FontMap::~CPWL_FontMap() { |
| 43 delete m_pPDFDoc; | |
| 44 m_pPDFDoc = nullptr; | |
| 45 | |
| 46 Empty(); | 43 Empty(); |
| 47 } | 44 } |
| 48 | 45 |
| 49 void CPWL_FontMap::SetSystemHandler(CFX_SystemHandler* pSystemHandler) { | 46 void CPWL_FontMap::SetSystemHandler(CFX_SystemHandler* pSystemHandler) { |
| 50 m_pSystemHandler = pSystemHandler; | 47 m_pSystemHandler = pSystemHandler; |
| 51 } | 48 } |
| 52 | 49 |
| 53 CPDF_Document* CPWL_FontMap::GetDocument() { | 50 CPDF_Document* CPWL_FontMap::GetDocument() { |
| 54 if (!m_pPDFDoc) { | 51 if (!m_pPDFDoc) { |
| 55 if (CPDF_ModuleMgr::Get()) { | 52 if (CPDF_ModuleMgr::Get()) { |
| 56 m_pPDFDoc = new CPDF_Document(nullptr); | 53 m_pPDFDoc.reset(new CPDF_Document(nullptr)); |
| 57 m_pPDFDoc->CreateNewDoc(); | 54 m_pPDFDoc->CreateNewDoc(); |
| 58 } | 55 } |
| 59 } | 56 } |
| 60 | 57 |
| 61 return m_pPDFDoc; | 58 return m_pPDFDoc.get(); |
| 62 } | 59 } |
| 63 | 60 |
| 64 CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex) { | 61 CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex) { |
| 65 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) { | 62 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) { |
| 66 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) { | 63 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) { |
| 67 return pData->pFont; | 64 return pData->pFont; |
| 68 } | 65 } |
| 69 } | 66 } |
| 70 | 67 |
| 71 return nullptr; | 68 return nullptr; |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 487 |
| 491 CPWL_DocFontMap::CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, | 488 CPWL_DocFontMap::CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, |
| 492 CPDF_Document* pAttachedDoc) | 489 CPDF_Document* pAttachedDoc) |
| 493 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} | 490 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} |
| 494 | 491 |
| 495 CPWL_DocFontMap::~CPWL_DocFontMap() {} | 492 CPWL_DocFontMap::~CPWL_DocFontMap() {} |
| 496 | 493 |
| 497 CPDF_Document* CPWL_DocFontMap::GetDocument() { | 494 CPDF_Document* CPWL_DocFontMap::GetDocument() { |
| 498 return m_pAttachedDoc; | 495 return m_pAttachedDoc; |
| 499 } | 496 } |
| OLD | NEW |