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 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 m_pCurStates->m_TextState.GetModify()->m_FontSize = fs; | 1132 m_pCurStates->m_TextState.GetModify()->m_FontSize = fs; |
1133 CPDF_Font* pFont = FindFont(GetString(1)); | 1133 CPDF_Font* pFont = FindFont(GetString(1)); |
1134 if (pFont) { | 1134 if (pFont) { |
1135 m_pCurStates->m_TextState.SetFont(pFont); | 1135 m_pCurStates->m_TextState.SetFont(pFont); |
1136 } | 1136 } |
1137 } | 1137 } |
1138 | 1138 |
1139 CPDF_Object* CPDF_StreamContentParser::FindResourceObj( | 1139 CPDF_Object* CPDF_StreamContentParser::FindResourceObj( |
1140 const CFX_ByteString& type, | 1140 const CFX_ByteString& type, |
1141 const CFX_ByteString& name) { | 1141 const CFX_ByteString& name) { |
1142 if (!m_pResources) { | 1142 if (!m_pResources) |
1143 return NULL; | 1143 return nullptr; |
1144 } | 1144 CPDF_Dictionary* pDict = m_pResources->GetDictBy(type); |
1145 if (m_pResources == m_pPageResources) { | 1145 if (pDict) |
1146 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); | 1146 return pDict->GetDirectObjectBy(name); |
1147 if (!pList) { | 1147 if (m_pResources == m_pPageResources || !m_pPageResources) |
1148 return NULL; | 1148 return nullptr; |
1149 } | 1149 |
1150 CPDF_Object* pRes = pList->GetDirectObjectBy(name); | 1150 CPDF_Dictionary* pPageDict = m_pPageResources->GetDictBy(type); |
1151 return pRes; | 1151 return pPageDict ? pPageDict->GetDirectObjectBy(name) : nullptr; |
1152 } | |
1153 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); | |
1154 if (!pList) { | |
1155 if (!m_pPageResources) { | |
1156 return NULL; | |
1157 } | |
1158 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); | |
1159 if (!pList) { | |
1160 return NULL; | |
1161 } | |
1162 CPDF_Object* pRes = pList->GetDirectObjectBy(name); | |
1163 return pRes; | |
1164 } | |
1165 CPDF_Object* pRes = pList->GetDirectObjectBy(name); | |
1166 return pRes; | |
1167 } | 1152 } |
1168 | 1153 |
1169 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { | 1154 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { |
1170 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); | 1155 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); |
1171 if (!pFontDict) { | 1156 if (!pFontDict) { |
1172 m_bResourceMissing = TRUE; | 1157 m_bResourceMissing = TRUE; |
1173 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); | 1158 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); |
1174 } | 1159 } |
1175 | 1160 |
1176 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); | 1161 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 } else { | 1681 } else { |
1697 PDF_ReplaceAbbr(pElement); | 1682 PDF_ReplaceAbbr(pElement); |
1698 } | 1683 } |
1699 } | 1684 } |
1700 break; | 1685 break; |
1701 } | 1686 } |
1702 default: | 1687 default: |
1703 break; | 1688 break; |
1704 } | 1689 } |
1705 } | 1690 } |
OLD | NEW |