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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 void CBA_FontMap::Reset() | 39 void CBA_FontMap::Reset() |
40 { | 40 { |
41 Empty(); | 41 Empty(); |
42 m_pDefaultFont = NULL; | 42 m_pDefaultFont = NULL; |
43 m_sDefaultFontName = ""; | 43 m_sDefaultFontName = ""; |
44 } | 44 } |
45 | 45 |
46 void CBA_FontMap::Initial(FX_LPCSTR fontname) | 46 void CBA_FontMap::Initial(FX_LPCSTR fontname) |
47 { | 47 { |
48 » FX_INT32 nCharset = DEFAULT_CHARSET; | 48 » int32_t nCharset = DEFAULT_CHARSET; |
49 | 49 |
50 if (!m_pDefaultFont) | 50 if (!m_pDefaultFont) |
51 { | 51 { |
52 m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); | 52 m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); |
53 if (m_pDefaultFont) | 53 if (m_pDefaultFont) |
54 { | 54 { |
55 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->Ge
tSubstFont()) | 55 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->Ge
tSubstFont()) |
56 nCharset = pSubstFont->m_Charset; | 56 nCharset = pSubstFont->m_Charset; |
57 else | 57 else |
58 { | 58 { |
(...skipping 17 matching lines...) Expand all Loading... |
76 ASSERT(pFont != NULL); | 76 ASSERT(pFont != NULL); |
77 | 77 |
78 if (m_pDefaultFont) return; | 78 if (m_pDefaultFont) return; |
79 | 79 |
80 m_pDefaultFont = pFont; | 80 m_pDefaultFont = pFont; |
81 m_sDefaultFontName = sFontName; | 81 m_sDefaultFontName = sFontName; |
82 | 82 |
83 // if (m_sDefaultFontName.IsEmpty()) | 83 // if (m_sDefaultFontName.IsEmpty()) |
84 // m_sDefaultFontName = pFont->GetFontTypeName(); | 84 // m_sDefaultFontName = pFont->GetFontTypeName(); |
85 | 85 |
86 » FX_INT32 nCharset = DEFAULT_CHARSET; | 86 » int32_t nCharset = DEFAULT_CHARSET; |
87 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) | 87 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) |
88 nCharset = pSubstFont->m_Charset; | 88 nCharset = pSubstFont->m_Charset; |
89 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); | 89 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); |
90 } | 90 } |
91 | 91 |
92 CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, FX_INT32
nCharset) | 92 CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, int32_t
nCharset) |
93 { | 93 { |
94 ASSERT(m_pAnnotDict != NULL); | 94 ASSERT(m_pAnnotDict != NULL); |
95 | 95 |
96 if (m_pAnnotDict->GetString("Subtype") == "Widget") | 96 if (m_pAnnotDict->GetString("Subtype") == "Widget") |
97 { | 97 { |
98 CPDF_Document* pDocument = GetDocument(); | 98 CPDF_Document* pDocument = GetDocument(); |
99 ASSERT(pDocument != NULL); | 99 ASSERT(pDocument != NULL); |
100 | 100 |
101 CPDF_Dictionary * pRootDict = pDocument->GetRoot(); | 101 CPDF_Dictionary * pRootDict = pDocument->GetRoot(); |
102 if (!pRootDict) return NULL; | 102 if (!pRootDict) return NULL; |
103 | 103 |
104 CPDF_Dictionary* pAcroFormDict = pRootDict->GetDict("AcroForm"); | 104 CPDF_Dictionary* pAcroFormDict = pRootDict->GetDict("AcroForm"); |
105 if (!pAcroFormDict) return NULL; | 105 if (!pAcroFormDict) return NULL; |
106 | 106 |
107 CPDF_Dictionary * pDRDict = pAcroFormDict->GetDict("DR"); | 107 CPDF_Dictionary * pDRDict = pAcroFormDict->GetDict("DR"); |
108 if (!pDRDict) return NULL; | 108 if (!pDRDict) return NULL; |
109 | 109 |
110 return FindResFontSameCharset(pDRDict, sFontAlias, nCharset); | 110 return FindResFontSameCharset(pDRDict, sFontAlias, nCharset); |
111 } | 111 } |
112 | 112 |
113 return NULL; | 113 return NULL; |
114 } | 114 } |
115 | 115 |
116 CPDF_Document* CBA_FontMap::GetDocument() | 116 CPDF_Document* CBA_FontMap::GetDocument() |
117 { | 117 { |
118 return m_pDocument; | 118 return m_pDocument; |
119 } | 119 } |
120 | 120 |
121 CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, CFX_By
teString& sFontAlias, | 121 CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, CFX_By
teString& sFontAlias, |
122 » » » » » » » » » »
» » » FX_INT32 nCharset) | 122 » » » » » » » » » »
» » » int32_t nCharset) |
123 { | 123 { |
124 if (!pResDict) return NULL; | 124 if (!pResDict) return NULL; |
125 | 125 |
126 CPDF_Document* pDocument = GetDocument(); | 126 CPDF_Document* pDocument = GetDocument(); |
127 ASSERT(pDocument != NULL); | 127 ASSERT(pDocument != NULL); |
128 | 128 |
129 CPDF_Dictionary* pFonts = pResDict->GetDict("Font"); | 129 CPDF_Dictionary* pFonts = pResDict->GetDict("Font"); |
130 if (pFonts == NULL) return NULL; | 130 if (pFonts == NULL) return NULL; |
131 | 131 |
132 CPDF_Font* pFind = NULL; | 132 CPDF_Font* pFind = NULL; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 » » int32_t 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 = FX_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 = FX_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 » » » » int32_t 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) |
227 { | 227 { |
(...skipping 65 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 |