Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: fpdfsdk/formfiller/cba_fontmap.cpp

Issue 1853233002: Make down-conversion explicit from CFX_ByteString to CFX_ByteStringC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix CPDF_Name::GetConstString() Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/win32/fx_win32_device.cpp ('k') | fpdfsdk/fpdf_ext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return; 152 return;
153 153
154 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP"); 154 CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP");
155 155
156 if (!pAPDict) { 156 if (!pAPDict) {
157 pAPDict = new CPDF_Dictionary; 157 pAPDict = new CPDF_Dictionary;
158 m_pAnnotDict->SetAt("AP", pAPDict); 158 m_pAnnotDict->SetAt("AP", pAPDict);
159 } 159 }
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.AsByteStringC());
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.AsByteStringC());
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, m_pDocument, objnum); 170 pAPDict->SetAtReference(m_sAPType.AsByteStringC(), 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) {
181 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); 181 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources");
182 if (!pStreamResList) { 182 if (!pStreamResList) {
183 pStreamResList = new CPDF_Dictionary(); 183 pStreamResList = new CPDF_Dictionary();
184 pStreamDict->SetAt("Resources", pStreamResList); 184 pStreamDict->SetAt("Resources", pStreamResList);
185 } 185 }
186 186
187 if (pStreamResList) { 187 if (pStreamResList) {
188 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font"); 188 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font");
189 if (!pStreamResFontList) { 189 if (!pStreamResFontList) {
190 pStreamResFontList = new CPDF_Dictionary; 190 pStreamResFontList = new CPDF_Dictionary;
191 int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList); 191 int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList);
192 pStreamResList->SetAtReference("Font", m_pDocument, objnum); 192 pStreamResList->SetAtReference("Font", m_pDocument, objnum);
193 } 193 }
194 if (!pStreamResFontList->KeyExist(sAlias)) 194 if (!pStreamResFontList->KeyExist(sAlias.AsByteStringC()))
195 pStreamResFontList->SetAtReference(sAlias, m_pDocument, 195 pStreamResFontList->SetAtReference(sAlias.AsByteStringC(), m_pDocument,
196 pFont->GetFontDict()); 196 pFont->GetFontDict());
197 } 197 }
198 } 198 }
199 } 199 }
200 200
201 CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) { 201 CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
202 CPDF_Dictionary* pAcroFormDict = NULL; 202 CPDF_Dictionary* pAcroFormDict = NULL;
203 const bool bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget"); 203 const bool bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget");
204 if (bWidget) { 204 if (bWidget) {
205 if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot()) 205 if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot())
206 pAcroFormDict = pRootDict->GetDictBy("AcroForm"); 206 pAcroFormDict = pRootDict->GetDictBy("AcroForm");
207 } 207 }
208 208
209 CFX_ByteString sDA; 209 CFX_ByteString sDA;
210 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA"); 210 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA");
211 if (pObj) 211 if (pObj)
212 sDA = pObj->GetString(); 212 sDA = pObj->GetString();
213 213
214 if (bWidget) { 214 if (bWidget) {
215 if (sDA.IsEmpty()) { 215 if (sDA.IsEmpty()) {
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); 224 CPDF_SimpleParser syntax(sDA.AsByteStringC());
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.AsByteStringC());
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 =
237 pNormalDict->GetDictBy("Resources")) 237 pNormalDict->GetDictBy("Resources"))
238 if (CPDF_Dictionary* pResFontDict = 238 if (CPDF_Dictionary* pResFontDict =
239 pNormalResDict->GetDictBy("Font")) 239 pNormalResDict->GetDictBy("Font"))
240 pFontDict = pResFontDict->GetDictBy(sAlias); 240 pFontDict = pResFontDict->GetDictBy(sAlias.AsByteStringC());
241 241
242 if (bWidget) { 242 if (bWidget) {
243 if (!pFontDict) { 243 if (!pFontDict) {
244 if (pAcroFormDict) { 244 if (pAcroFormDict) {
245 if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR")) 245 if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR"))
246 if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) 246 if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
247 pFontDict = pDRFontDict->GetDictBy(sAlias); 247 pFontDict = pDRFontDict->GetDictBy(sAlias.AsByteStringC());
248 } 248 }
249 } 249 }
250 } 250 }
251 } 251 }
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 }
OLDNEW
« no previous file with comments | « core/fxge/win32/fx_win32_device.cpp ('k') | fpdfsdk/fpdf_ext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698