| 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/formfiller/cba_fontmap.h" | 7 #include "fpdfsdk/formfiller/cba_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_page/include/cpdf_page.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 // to avoid checkbox and radiobutton | 161 // to avoid checkbox and radiobutton |
| 162 CPDF_Object* pObject = pAPDict->GetObjectBy(m_sAPType); | 162 CPDF_Object* pObject = pAPDict->GetObjectBy(m_sAPType); |
| 163 if (ToDictionary(pObject)) | 163 if (ToDictionary(pObject)) |
| 164 return; | 164 return; |
| 165 | 165 |
| 166 CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType); | 166 CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType); |
| 167 if (!pStream) { | 167 if (!pStream) { |
| 168 pStream = new CPDF_Stream(NULL, 0, NULL); | 168 pStream = new CPDF_Stream(NULL, 0, NULL); |
| 169 int32_t objnum = m_pDocument->AddIndirectObject(pStream); | 169 int32_t objnum = m_pDocument->AddIndirectObject(pStream); |
| 170 pAPDict->SetAtReference(m_sAPType.AsStringC(), m_pDocument, objnum); | 170 pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); |
| 171 } | 171 } |
| 172 | 172 |
| 173 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 173 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
| 174 | 174 |
| 175 if (!pStreamDict) { | 175 if (!pStreamDict) { |
| 176 pStreamDict = new CPDF_Dictionary; | 176 pStreamDict = new CPDF_Dictionary; |
| 177 pStream->InitStream(NULL, 0, pStreamDict); | 177 pStream->InitStream(NULL, 0, pStreamDict); |
| 178 } | 178 } |
| 179 | 179 |
| 180 if (pStreamDict) { | 180 if (pStreamDict) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA"); | 216 pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA"); |
| 217 sDA = pObj ? pObj->GetString() : CFX_ByteString(); | 217 sDA = pObj ? pObj->GetString() : CFX_ByteString(); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 CPDF_Dictionary* pFontDict = NULL; | 221 CPDF_Dictionary* pFontDict = NULL; |
| 222 | 222 |
| 223 if (!sDA.IsEmpty()) { | 223 if (!sDA.IsEmpty()) { |
| 224 CPDF_SimpleParser syntax(sDA.AsStringC()); | 224 CPDF_SimpleParser syntax(sDA.AsStringC()); |
| 225 syntax.FindTagParamFromStart("Tf", 2); | 225 syntax.FindTagParamFromStart("Tf", 2); |
| 226 CFX_ByteString sFontName = syntax.GetWord(); | 226 CFX_ByteString sFontName(syntax.GetWord()); |
| 227 sAlias = PDF_NameDecode(sFontName).Mid(1); | 227 sAlias = PDF_NameDecode(sFontName).Mid(1); |
| 228 | 228 |
| 229 if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR")) | 229 if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR")) |
| 230 if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) | 230 if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) |
| 231 pFontDict = pDRFontDict->GetDictBy(sAlias); | 231 pFontDict = pDRFontDict->GetDictBy(sAlias); |
| 232 | 232 |
| 233 if (!pFontDict) | 233 if (!pFontDict) |
| 234 if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP")) | 234 if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP")) |
| 235 if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N")) | 235 if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N")) |
| 236 if (CPDF_Dictionary* pNormalResDict = | 236 if (CPDF_Dictionary* pNormalResDict = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 252 | 252 |
| 253 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; | 253 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; |
| 254 } | 254 } |
| 255 | 255 |
| 256 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { | 256 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { |
| 257 m_sAPType = sAPType; | 257 m_sAPType = sAPType; |
| 258 | 258 |
| 259 Reset(); | 259 Reset(); |
| 260 Initialize(); | 260 Initialize(); |
| 261 } | 261 } |
| OLD | NEW |