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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 AddFontToAnnotDict(pFont, sFontAlias); | 148 AddFontToAnnotDict(pFont, sFontAlias); |
149 } | 149 } |
150 | 150 |
151 void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, | 151 void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, |
152 const CFX_ByteString& sAlias) { | 152 const CFX_ByteString& sAlias) { |
153 if (!pFont) | 153 if (!pFont) |
154 return; | 154 return; |
155 | 155 |
156 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP"); | 156 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP"); |
157 if (!pAPDict) { | 157 if (!pAPDict) { |
158 pAPDict = new CPDF_Dictionary; | 158 pAPDict = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
159 m_pAnnotDict->SetFor("AP", pAPDict); | 159 m_pAnnotDict->SetFor("AP", pAPDict); |
160 } | 160 } |
161 | 161 |
162 // to avoid checkbox and radiobutton | 162 // to avoid checkbox and radiobutton |
163 CPDF_Object* pObject = pAPDict->GetObjectFor(m_sAPType); | 163 CPDF_Object* pObject = pAPDict->GetObjectFor(m_sAPType); |
164 if (ToDictionary(pObject)) | 164 if (ToDictionary(pObject)) |
165 return; | 165 return; |
166 | 166 |
167 CPDF_Stream* pStream = pAPDict->GetStreamFor(m_sAPType); | 167 CPDF_Stream* pStream = pAPDict->GetStreamFor(m_sAPType); |
168 if (!pStream) { | 168 if (!pStream) { |
169 pStream = new CPDF_Stream; | 169 pStream = new CPDF_Stream; |
170 pAPDict->SetReferenceFor(m_sAPType, m_pDocument, | 170 pAPDict->SetReferenceFor(m_sAPType, m_pDocument, |
171 m_pDocument->AddIndirectObject(pStream)); | 171 m_pDocument->AddIndirectObject(pStream)); |
172 } | 172 } |
173 | 173 |
174 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 174 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
175 if (!pStreamDict) { | 175 if (!pStreamDict) { |
176 pStreamDict = new CPDF_Dictionary; | 176 pStreamDict = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
177 pStream->InitStream(nullptr, 0, pStreamDict); | 177 pStream->InitStream(nullptr, 0, pStreamDict); |
178 } | 178 } |
179 | 179 |
180 if (pStreamDict) { | 180 if (pStreamDict) { |
181 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); | 181 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); |
182 if (!pStreamResList) { | 182 if (!pStreamResList) { |
183 pStreamResList = new CPDF_Dictionary(); | 183 pStreamResList = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
184 pStreamDict->SetFor("Resources", pStreamResList); | 184 pStreamDict->SetFor("Resources", pStreamResList); |
185 } | 185 } |
186 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); | 186 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); |
187 if (!pStreamResFontList) { | 187 if (!pStreamResFontList) { |
188 pStreamResFontList = new CPDF_Dictionary; | 188 pStreamResFontList = |
| 189 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
189 pStreamResList->SetReferenceFor( | 190 pStreamResList->SetReferenceFor( |
190 "Font", m_pDocument, | 191 "Font", m_pDocument, |
191 m_pDocument->AddIndirectObject(pStreamResFontList)); | 192 m_pDocument->AddIndirectObject(pStreamResFontList)); |
192 } | 193 } |
193 if (!pStreamResFontList->KeyExist(sAlias)) { | 194 if (!pStreamResFontList->KeyExist(sAlias)) { |
194 pStreamResFontList->SetReferenceFor(sAlias, m_pDocument, | 195 pStreamResFontList->SetReferenceFor(sAlias, m_pDocument, |
195 pFont->GetFontDict()->GetObjNum()); | 196 pFont->GetFontDict()->GetObjNum()); |
196 } | 197 } |
197 } | 198 } |
198 } | 199 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 245 |
245 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; | 246 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; |
246 } | 247 } |
247 | 248 |
248 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { | 249 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { |
249 m_sAPType = sAPType; | 250 m_sAPType = sAPType; |
250 | 251 |
251 Reset(); | 252 Reset(); |
252 Initialize(); | 253 Initialize(); |
253 } | 254 } |
OLD | NEW |