| 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 "../../include/formfiller/FormFiller.h" | 7 #include "../../include/formfiller/FormFiller.h" |
| 8 #include "../../include/formfiller/FFL_CBA_Fontmap.h" | 8 #include "../../include/formfiller/FFL_CBA_Fontmap.h" |
| 9 | 9 |
| 10 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, | 10 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 CPDF_Font* pFind = NULL; | 130 CPDF_Font* pFind = NULL; |
| 131 | 131 |
| 132 FX_POSITION pos = pFonts->GetStartPos(); | 132 FX_POSITION pos = pFonts->GetStartPos(); |
| 133 while (pos) { | 133 while (pos) { |
| 134 CPDF_Object* pObj = NULL; | 134 CPDF_Object* pObj = NULL; |
| 135 CFX_ByteString csKey; | 135 CFX_ByteString csKey; |
| 136 pObj = pFonts->GetNextElement(pos, csKey); | 136 pObj = pFonts->GetNextElement(pos, csKey); |
| 137 if (pObj == NULL) | 137 if (pObj == NULL) |
| 138 continue; | 138 continue; |
| 139 | 139 |
| 140 CPDF_Object* pDirect = pObj->GetDirect(); | 140 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); |
| 141 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) | 141 if (!pElement) |
| 142 continue; | 142 continue; |
| 143 | |
| 144 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; | |
| 145 if (pElement->GetString("Type") != "Font") | 143 if (pElement->GetString("Type") != "Font") |
| 146 continue; | 144 continue; |
| 147 | 145 |
| 148 CPDF_Font* pFont = pDocument->LoadFont(pElement); | 146 CPDF_Font* pFont = pDocument->LoadFont(pElement); |
| 149 if (pFont == NULL) | 147 if (pFont == NULL) |
| 150 continue; | 148 continue; |
| 151 const CFX_SubstFont* pSubst = pFont->GetSubstFont(); | 149 const CFX_SubstFont* pSubst = pFont->GetSubstFont(); |
| 152 if (pSubst == NULL) | 150 if (pSubst == NULL) |
| 153 continue; | 151 continue; |
| 154 if (pSubst->m_Charset == nCharset) { | 152 if (pSubst->m_Charset == nCharset) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 174 | 172 |
| 175 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP"); | 173 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP"); |
| 176 | 174 |
| 177 if (pAPDict == NULL) { | 175 if (pAPDict == NULL) { |
| 178 pAPDict = new CPDF_Dictionary; | 176 pAPDict = new CPDF_Dictionary; |
| 179 m_pAnnotDict->SetAt("AP", pAPDict); | 177 m_pAnnotDict->SetAt("AP", pAPDict); |
| 180 } | 178 } |
| 181 | 179 |
| 182 // to avoid checkbox and radiobutton | 180 // to avoid checkbox and radiobutton |
| 183 CPDF_Object* pObject = pAPDict->GetElement(m_sAPType); | 181 CPDF_Object* pObject = pAPDict->GetElement(m_sAPType); |
| 184 if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY) | 182 if (ToDictionary(pObject)) |
| 185 return; | 183 return; |
| 186 | 184 |
| 187 CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType); | 185 CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType); |
| 188 if (pStream == NULL) { | 186 if (pStream == NULL) { |
| 189 pStream = new CPDF_Stream(NULL, 0, NULL); | 187 pStream = new CPDF_Stream(NULL, 0, NULL); |
| 190 int32_t objnum = m_pDocument->AddIndirectObject(pStream); | 188 int32_t objnum = m_pDocument->AddIndirectObject(pStream); |
| 191 pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); | 189 pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); |
| 192 } | 190 } |
| 193 | 191 |
| 194 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 192 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 275 |
| 278 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; | 276 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; |
| 279 } | 277 } |
| 280 | 278 |
| 281 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { | 279 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { |
| 282 m_sAPType = sAPType; | 280 m_sAPType = sAPType; |
| 283 | 281 |
| 284 Reset(); | 282 Reset(); |
| 285 Initial(); | 283 Initial(); |
| 286 } | 284 } |
| OLD | NEW |