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

Side by Side Diff: core/fpdfdoc/cpvt_generateap.cpp

Issue 2337673002: Annotations and fields do not have DR (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | fpdfsdk/formfiller/cba_fontmap.cpp » ('j') | fpdfsdk/formfiller/cba_fontmap.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "core/fpdfdoc/cpvt_generateap.h" 7 #include "core/fpdfdoc/cpvt_generateap.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_parser/include/cpdf_dictionary.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
(...skipping 28 matching lines...) Expand all
39 39
40 CPDF_SimpleParser syntax(DA.AsStringC()); 40 CPDF_SimpleParser syntax(DA.AsStringC());
41 syntax.FindTagParamFromStart("Tf", 2); 41 syntax.FindTagParamFromStart("Tf", 2);
42 CFX_ByteString sFontName(syntax.GetWord()); 42 CFX_ByteString sFontName(syntax.GetWord());
43 sFontName = PDF_NameDecode(sFontName); 43 sFontName = PDF_NameDecode(sFontName);
44 if (sFontName.IsEmpty()) 44 if (sFontName.IsEmpty())
45 return false; 45 return false;
46 46
47 FX_FLOAT fFontSize = FX_atof(syntax.GetWord()); 47 FX_FLOAT fFontSize = FX_atof(syntax.GetWord());
48 CPVT_Color crText = CPVT_Color::ParseColor(DA); 48 CPVT_Color crText = CPVT_Color::ParseColor(DA);
49 FX_BOOL bUseFormRes = FALSE; 49 CPDF_Dictionary* pDRDict = pFormDict->GetDictBy("DR");
Tom Sepez 2016/09/12 21:19:22 nit: maybe just early return here if null to avoid
npm 2016/09/12 21:40:11 Done.
50 CPDF_Dictionary* pFontDict = nullptr;
51 CPDF_Dictionary* pDRDict = pAnnotDict->GetDictBy("DR");
52 if (!pDRDict) {
53 pDRDict = pFormDict->GetDictBy("DR");
54 bUseFormRes = TRUE;
55 }
56 CPDF_Dictionary* pDRFontDict = pDRDict ? pDRDict->GetDictBy("Font") : nullptr; 50 CPDF_Dictionary* pDRFontDict = pDRDict ? pDRDict->GetDictBy("Font") : nullptr;
57 if (pDRFontDict) {
58 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
59 if (!pFontDict && !bUseFormRes) {
60 pDRDict = pFormDict->GetDictBy("DR");
61 pDRFontDict = pDRDict->GetDictBy("Font");
62 if (pDRFontDict)
63 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
64 }
65 }
66 if (!pDRFontDict) 51 if (!pDRFontDict)
67 return false; 52 return false;
53 CPDF_Dictionary* pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
Tom Sepez 2016/09/12 21:19:22 nit: I'd put the blank line above this statement r
npm 2016/09/12 21:40:11 Done.
68 54
69 if (!pFontDict) { 55 if (!pFontDict) {
70 pFontDict = new CPDF_Dictionary; 56 pFontDict = new CPDF_Dictionary;
71 pFontDict->SetAtName("Type", "Font"); 57 pFontDict->SetAtName("Type", "Font");
72 pFontDict->SetAtName("Subtype", "Type1"); 58 pFontDict->SetAtName("Subtype", "Type1");
73 pFontDict->SetAtName("BaseFont", "Helvetica"); 59 pFontDict->SetAtName("BaseFont", "Helvetica");
74 pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); 60 pFontDict->SetAtName("Encoding", "WinAnsiEncoding");
75 pDoc->AddIndirectObject(pFontDict); 61 pDoc->AddIndirectObject(pFontDict);
76 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); 62 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict);
77 } 63 }
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 int32_t nFontIndex, 1331 int32_t nFontIndex,
1346 FX_FLOAT fFontSize) { 1332 FX_FLOAT fFontSize) {
1347 CFX_ByteTextBuf sRet; 1333 CFX_ByteTextBuf sRet;
1348 if (pFontMap) { 1334 if (pFontMap) {
1349 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); 1335 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
1350 if (sFontAlias.GetLength() > 0 && fFontSize > 0) 1336 if (sFontAlias.GetLength() > 0 && fFontSize > 0)
1351 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; 1337 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
1352 } 1338 }
1353 return sRet.MakeString(); 1339 return sRet.MakeString();
1354 } 1340 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/formfiller/cba_fontmap.cpp » ('j') | fpdfsdk/formfiller/cba_fontmap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698