| 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/include/formfiller/FFL_CBA_Fontmap.h" | 7 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" |
| 8 #include "fpdfsdk/include/formfiller/FormFiller.h" | 8 |
| 9 #include "core/include/fpdfapi/fpdf_page.h" |
| 10 #include "fpdfsdk/include/fsdk_baseannot.h" |
| 9 | 11 |
| 10 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, | 12 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, |
| 11 IFX_SystemHandler* pSystemHandler) | 13 IFX_SystemHandler* pSystemHandler) |
| 12 : CPWL_FontMap(pSystemHandler), | 14 : CPWL_FontMap(pSystemHandler), |
| 13 m_pDocument(NULL), | 15 m_pDocument(NULL), |
| 14 m_pAnnotDict(NULL), | 16 m_pAnnotDict(NULL), |
| 15 m_pDefaultFont(NULL), | 17 m_pDefaultFont(NULL), |
| 16 m_sAPType("N") { | 18 m_sAPType("N") { |
| 17 CPDF_Page* pPage = pAnnot->GetPDFPage(); | 19 CPDF_Page* pPage = pAnnot->GetPDFPage(); |
| 18 | 20 |
| 19 m_pDocument = pPage->m_pDocument; | 21 m_pDocument = pPage->m_pDocument; |
| 20 m_pAnnotDict = pAnnot->GetPDFAnnot()->GetAnnotDict(); | 22 m_pAnnotDict = pAnnot->GetPDFAnnot()->GetAnnotDict(); |
| 21 Initialize(); | 23 Initialize(); |
| 22 } | 24 } |
| 23 | 25 |
| 24 CBA_FontMap::~CBA_FontMap() {} | 26 CBA_FontMap::~CBA_FontMap() {} |
| 25 | 27 |
| 26 void CBA_FontMap::Reset() { | 28 void CBA_FontMap::Reset() { |
| 27 Empty(); | 29 Empty(); |
| 28 m_pDefaultFont = NULL; | 30 m_pDefaultFont = NULL; |
| 29 m_sDefaultFontName = ""; | 31 m_sDefaultFontName = ""; |
| 30 } | 32 } |
| 31 | 33 |
| 32 void CBA_FontMap::Initialize() { | 34 void CBA_FontMap::Initialize() { |
| 33 int32_t nCharset = DEFAULT_CHARSET; | 35 int32_t nCharset = DEFAULT_CHARSET; |
| 34 | 36 |
| 35 if (!m_pDefaultFont) { | 37 if (!m_pDefaultFont) { |
| 36 m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); | 38 m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); |
| 37 if (m_pDefaultFont) { | 39 if (m_pDefaultFont) { |
| 38 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) | 40 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) { |
| 39 nCharset = pSubstFont->m_Charset; | 41 nCharset = pSubstFont->m_Charset; |
| 40 else { | 42 } else { |
| 41 if (m_sDefaultFontName == "Wingdings" || | 43 if (m_sDefaultFontName == "Wingdings" || |
| 42 m_sDefaultFontName == "Wingdings2" || | 44 m_sDefaultFontName == "Wingdings2" || |
| 43 m_sDefaultFontName == "Wingdings3" || | 45 m_sDefaultFontName == "Wingdings3" || |
| 44 m_sDefaultFontName == "Webdings") | 46 m_sDefaultFontName == "Webdings") |
| 45 nCharset = SYMBOL_CHARSET; | 47 nCharset = SYMBOL_CHARSET; |
| 46 else | 48 else |
| 47 nCharset = ANSI_CHARSET; | 49 nCharset = ANSI_CHARSET; |
| 48 } | 50 } |
| 49 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); | 51 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); |
| 50 AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); | 52 AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 264 |
| 263 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; | 265 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; |
| 264 } | 266 } |
| 265 | 267 |
| 266 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { | 268 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { |
| 267 m_sAPType = sAPType; | 269 m_sAPType = sAPType; |
| 268 | 270 |
| 269 Reset(); | 271 Reset(); |
| 270 Initialize(); | 272 Initialize(); |
| 271 } | 273 } |
| OLD | NEW |