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, IFX_SystemHandler* pSystemHandle
r) : | 10 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, IFX_SystemHandler* pSystemHandle
r) : |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAl
ias) | 166 void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAl
ias) |
167 { | 167 { |
168 if (!pFont) return; | 168 if (!pFont) return; |
169 | 169 |
170 ASSERT(m_pAnnotDict != NULL); | 170 ASSERT(m_pAnnotDict != NULL); |
171 ASSERT(m_pDocument != NULL); | 171 ASSERT(m_pDocument != NULL); |
172 | 172 |
173 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP"); | 173 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP"); |
174 | 174 |
175 » if (pAPDict == NULL) | 175 » if (pAPDict == NULL) |
176 { | 176 { |
177 » » pAPDict = FX_NEW CPDF_Dictionary; | 177 » » pAPDict = new CPDF_Dictionary; |
178 m_pAnnotDict->SetAt("AP", pAPDict); | 178 m_pAnnotDict->SetAt("AP", pAPDict); |
179 } | 179 } |
180 | 180 |
181 //to avoid checkbox and radiobutton | 181 //to avoid checkbox and radiobutton |
182 CPDF_Object* pObject = pAPDict->GetElement(m_sAPType); | 182 CPDF_Object* pObject = pAPDict->GetElement(m_sAPType); |
183 if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY) | 183 if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY) |
184 return; | 184 return; |
185 | 185 |
186 CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType); | 186 CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType); |
187 » if (pStream == NULL) | 187 » if (pStream == NULL) |
188 { | 188 { |
189 » » pStream = FX_NEW CPDF_Stream(NULL, 0, NULL); | 189 » » pStream = new CPDF_Stream(NULL, 0, NULL); |
190 FX_INT32 objnum = m_pDocument->AddIndirectObject(pStream); | 190 FX_INT32 objnum = m_pDocument->AddIndirectObject(pStream); |
191 pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); | 191 pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); |
192 } | 192 } |
193 | 193 |
194 CPDF_Dictionary * pStreamDict = pStream->GetDict(); | 194 CPDF_Dictionary * pStreamDict = pStream->GetDict(); |
195 | 195 |
196 if (!pStreamDict) | 196 if (!pStreamDict) |
197 { | 197 { |
198 » » pStreamDict = FX_NEW CPDF_Dictionary; | 198 » » pStreamDict = new CPDF_Dictionary; |
199 pStream->InitStream(NULL, 0, pStreamDict); | 199 pStream->InitStream(NULL, 0, pStreamDict); |
200 } | 200 } |
201 | 201 |
202 if (pStreamDict) | 202 if (pStreamDict) |
203 { | 203 { |
204 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resource
s"); | 204 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resource
s"); |
205 if (!pStreamResList) | 205 if (!pStreamResList) |
206 { | 206 { |
207 » » » pStreamResList = FX_NEW CPDF_Dictionary(); | 207 » » » pStreamResList = new CPDF_Dictionary(); |
208 pStreamDict->SetAt("Resources", pStreamResList); | 208 pStreamDict->SetAt("Resources", pStreamResList); |
209 } | 209 } |
210 | 210 |
211 if (pStreamResList) | 211 if (pStreamResList) |
212 { | 212 { |
213 CPDF_Dictionary* pStreamResFontList = pStreamResList->Ge
tDict("Font"); | 213 CPDF_Dictionary* pStreamResFontList = pStreamResList->Ge
tDict("Font"); |
214 if (!pStreamResFontList) | 214 if (!pStreamResFontList) |
215 { | 215 { |
216 » » » » pStreamResFontList = FX_NEW CPDF_Dictionary; | 216 » » » » pStreamResFontList = new CPDF_Dictionary; |
217 FX_INT32 objnum = m_pDocument->AddIndirectObject
(pStreamResFontList); | 217 FX_INT32 objnum = m_pDocument->AddIndirectObject
(pStreamResFontList); |
218 pStreamResList->SetAtReference("Font", m_pDocume
nt, objnum); | 218 pStreamResList->SetAtReference("Font", m_pDocume
nt, objnum); |
219 } | 219 } |
220 if (!pStreamResFontList->KeyExist(sAlias)) | 220 if (!pStreamResFontList->KeyExist(sAlias)) |
221 pStreamResFontList->SetAtReference(sAlias, m_pDo
cument, pFont->GetFontDict()); | 221 pStreamResFontList->SetAtReference(sAlias, m_pDo
cument, pFont->GetFontDict()); |
222 } | 222 } |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString &sAlias) | 226 CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString &sAlias) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 293 } |
294 | 294 |
295 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) | 295 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) |
296 { | 296 { |
297 m_sAPType = sAPType; | 297 m_sAPType = sAPType; |
298 | 298 |
299 Reset(); | 299 Reset(); |
300 Initial(); | 300 Initial(); |
301 } | 301 } |
302 | 302 |
OLD | NEW |