Chromium Code Reviews| 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) { |
|
Tom Sepez
2016/06/01 22:23:04
nit: no {}
Wei Li
2016/06/01 23:40:12
Done.
| |
| 1143 return NULL; | 1143 return NULL; |
| 1144 } | 1144 } |
| 1145 if (m_pResources == m_pPageResources) { | 1145 if (m_pResources == m_pPageResources) { |
| 1146 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); | 1146 CPDF_Dictionary* pDict = m_pResources->GetDictBy(type); |
| 1147 if (!pList) { | 1147 if (!pDict) |
|
Tom Sepez
2016/06/01 22:23:04
nit: ? operator might be cleaner.
Wei Li
2016/06/01 23:40:12
See below
| |
| 1148 return NULL; | 1148 return nullptr; |
| 1149 } | 1149 CPDF_Object* pRes = pDict->GetDirectObjectBy(name); |
| 1150 CPDF_Object* pRes = pList->GetDirectObjectBy(name); | |
| 1151 return pRes; | 1150 return pRes; |
| 1152 } | 1151 } |
| 1153 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); | 1152 if (CPDF_Dictionary* pDict = m_pResources->GetDictBy(type)) |
|
Tom Sepez
2016/06/01 22:23:04
either way, we're going to get m_pResources->GetDi
Wei Li
2016/06/01 23:40:12
Thanks for suggesting this, now it looks much clea
| |
| 1154 if (!pList) { | 1153 return pDict->GetDirectObjectBy(name); |
| 1155 if (!m_pPageResources) { | 1154 |
| 1156 return NULL; | 1155 if (!m_pPageResources) |
| 1157 } | 1156 return nullptr; |
| 1158 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); | 1157 CPDF_Dictionary* pDict = m_pPageResources->GetDictBy(type); |
|
Tom Sepez
2016/06/01 22:23:04
Then we can call this pPageDict and avoid collisio
Wei Li
2016/06/01 23:40:12
Done.
| |
| 1159 if (!pList) { | 1158 return pDict ? pDict->GetDirectObjectBy(name) : nullptr; |
| 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 } | 1159 } |
| 1168 | 1160 |
| 1169 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { | 1161 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { |
| 1170 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); | 1162 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); |
| 1171 if (!pFontDict) { | 1163 if (!pFontDict) { |
| 1172 m_bResourceMissing = TRUE; | 1164 m_bResourceMissing = TRUE; |
| 1173 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); | 1165 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); |
| 1174 } | 1166 } |
| 1175 | 1167 |
| 1176 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); | 1168 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1696 } else { | 1688 } else { |
| 1697 PDF_ReplaceAbbr(pElement); | 1689 PDF_ReplaceAbbr(pElement); |
| 1698 } | 1690 } |
| 1699 } | 1691 } |
| 1700 break; | 1692 break; |
| 1701 } | 1693 } |
| 1702 default: | 1694 default: |
| 1703 break; | 1695 break; |
| 1704 } | 1696 } |
| 1705 } | 1697 } |
| OLD | NEW |