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

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

Issue 1862123003: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, fix new usage. 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/fpdfdoc/cpvt_fontmap.cpp ('k') | core/fpdfdoc/doc_action.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 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 18 matching lines...) Expand all
29 return FALSE; 29 return FALSE;
30 30
31 CFX_ByteString DA; 31 CFX_ByteString DA;
32 if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) 32 if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA"))
33 DA = pDAObj->GetString(); 33 DA = pDAObj->GetString();
34 if (DA.IsEmpty()) 34 if (DA.IsEmpty())
35 DA = pFormDict->GetStringBy("DA"); 35 DA = pFormDict->GetStringBy("DA");
36 if (DA.IsEmpty()) 36 if (DA.IsEmpty())
37 return FALSE; 37 return FALSE;
38 38
39 CPDF_SimpleParser syntax(DA.AsByteStringC()); 39 CPDF_SimpleParser syntax(DA.AsStringC());
40 syntax.FindTagParamFromStart("Tf", 2); 40 syntax.FindTagParamFromStart("Tf", 2);
41 CFX_ByteString sFontName = syntax.GetWord(); 41 CFX_ByteString sFontName = syntax.GetWord();
42 sFontName = PDF_NameDecode(sFontName); 42 sFontName = PDF_NameDecode(sFontName);
43 if (sFontName.IsEmpty()) 43 if (sFontName.IsEmpty())
44 return FALSE; 44 return FALSE;
45 45
46 FX_FLOAT fFontSize = FX_atof(syntax.GetWord()); 46 FX_FLOAT fFontSize = FX_atof(syntax.GetWord());
47 CPVT_Color crText = CPVT_Color::ParseColor(DA); 47 CPVT_Color crText = CPVT_Color::ParseColor(DA);
48 FX_BOOL bUseFormRes = FALSE; 48 FX_BOOL bUseFormRes = FALSE;
49 CPDF_Dictionary* pFontDict = nullptr; 49 CPDF_Dictionary* pFontDict = nullptr;
50 CPDF_Dictionary* pDRDict = pAnnotDict->GetDictBy("DR"); 50 CPDF_Dictionary* pDRDict = pAnnotDict->GetDictBy("DR");
51 if (!pDRDict) { 51 if (!pDRDict) {
52 pDRDict = pFormDict->GetDictBy("DR"); 52 pDRDict = pFormDict->GetDictBy("DR");
53 bUseFormRes = TRUE; 53 bUseFormRes = TRUE;
54 } 54 }
55 CPDF_Dictionary* pDRFontDict = pDRDict ? pDRDict->GetDictBy("Font") : nullptr; 55 CPDF_Dictionary* pDRFontDict = pDRDict ? pDRDict->GetDictBy("Font") : nullptr;
56 if (pDRFontDict) { 56 if (pDRFontDict) {
57 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsByteStringC()); 57 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsStringC());
58 if (!pFontDict && !bUseFormRes) { 58 if (!pFontDict && !bUseFormRes) {
59 pDRDict = pFormDict->GetDictBy("DR"); 59 pDRDict = pFormDict->GetDictBy("DR");
60 pDRFontDict = pDRDict->GetDictBy("Font"); 60 pDRFontDict = pDRDict->GetDictBy("Font");
61 if (pDRFontDict) 61 if (pDRFontDict)
62 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsByteStringC()); 62 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsStringC());
63 } 63 }
64 } 64 }
65 if (!pDRFontDict) 65 if (!pDRFontDict)
66 return FALSE; 66 return FALSE;
67 67
68 if (!pFontDict) { 68 if (!pFontDict) {
69 pFontDict = new CPDF_Dictionary; 69 pFontDict = new CPDF_Dictionary;
70 pFontDict->SetAtName("Type", "Font"); 70 pFontDict->SetAtName("Type", "Font");
71 pFontDict->SetAtName("Subtype", "Type1"); 71 pFontDict->SetAtName("Subtype", "Type1");
72 pFontDict->SetAtName("BaseFont", "Helvetica"); 72 pFontDict->SetAtName("BaseFont", "Helvetica");
73 pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); 73 pFontDict->SetAtName("Encoding", "WinAnsiEncoding");
74 pDoc->AddIndirectObject(pFontDict); 74 pDoc->AddIndirectObject(pFontDict);
75 pDRFontDict->SetAtReference(sFontName.Mid(1).AsByteStringC(), pDoc, 75 pDRFontDict->SetAtReference(sFontName.Mid(1).AsStringC(), pDoc, pFontDict);
76 pFontDict);
77 } 76 }
78 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); 77 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
79 if (!pDefFont) 78 if (!pDefFont)
80 return FALSE; 79 return FALSE;
81 80
82 CFX_FloatRect rcAnnot = pAnnotDict->GetRectBy("Rect"); 81 CFX_FloatRect rcAnnot = pAnnotDict->GetRectBy("Rect");
83 int32_t nRotate = 0; 82 int32_t nRotate = 0;
84 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) 83 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK"))
85 nRotate = pMKDict->GetIntegerBy("R"); 84 nRotate = pMKDict->GetIntegerBy("R");
86 85
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (pStreamDict) { 182 if (pStreamDict) {
184 pStreamDict->SetAtMatrix("Matrix", matrix); 183 pStreamDict->SetAtMatrix("Matrix", matrix);
185 pStreamDict->SetAtRect("BBox", rcBBox); 184 pStreamDict->SetAtRect("BBox", rcBBox);
186 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); 185 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources");
187 if (pStreamResList) { 186 if (pStreamResList) {
188 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font"); 187 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font");
189 if (!pStreamResFontList) { 188 if (!pStreamResFontList) {
190 pStreamResFontList = new CPDF_Dictionary; 189 pStreamResFontList = new CPDF_Dictionary;
191 pStreamResList->SetAt("Font", pStreamResFontList); 190 pStreamResList->SetAt("Font", pStreamResFontList);
192 } 191 }
193 if (!pStreamResFontList->KeyExist(sFontName.AsByteStringC())) 192 if (!pStreamResFontList->KeyExist(sFontName.AsStringC()))
194 pStreamResFontList->SetAtReference(sFontName.AsByteStringC(), pDoc, 193 pStreamResFontList->SetAtReference(sFontName.AsStringC(), pDoc,
195 pFontDict); 194 pFontDict);
196 } else { 195 } else {
197 pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone()); 196 pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone());
198 pStreamResList = pStreamDict->GetDictBy("Resources"); 197 pStreamResList = pStreamDict->GetDictBy("Resources");
199 } 198 }
200 } 199 }
201 switch (nWidgetType) { 200 switch (nWidgetType) {
202 case 0: { 201 case 0: {
203 CFX_WideString swValue = 202 CFX_WideString swValue =
204 FPDF_GetFieldAttr(pAnnotDict, "V") 203 FPDF_GetFieldAttr(pAnnotDict, "V")
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (pStreamDict) { 429 if (pStreamDict) {
431 pStreamDict->SetAtMatrix("Matrix", matrix); 430 pStreamDict->SetAtMatrix("Matrix", matrix);
432 pStreamDict->SetAtRect("BBox", rcBBox); 431 pStreamDict->SetAtRect("BBox", rcBBox);
433 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); 432 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources");
434 if (pStreamResList) { 433 if (pStreamResList) {
435 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font"); 434 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font");
436 if (!pStreamResFontList) { 435 if (!pStreamResFontList) {
437 pStreamResFontList = new CPDF_Dictionary; 436 pStreamResFontList = new CPDF_Dictionary;
438 pStreamResList->SetAt("Font", pStreamResFontList); 437 pStreamResList->SetAt("Font", pStreamResFontList);
439 } 438 }
440 if (!pStreamResFontList->KeyExist(sFontName.AsByteStringC())) 439 if (!pStreamResFontList->KeyExist(sFontName.AsStringC()))
441 pStreamResFontList->SetAtReference(sFontName.AsByteStringC(), pDoc, 440 pStreamResFontList->SetAtReference(sFontName.AsStringC(), pDoc,
442 pFontDict); 441 pFontDict);
443 } else { 442 } else {
444 pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone()); 443 pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone());
445 pStreamResList = pStreamDict->GetDictBy("Resources"); 444 pStreamResList = pStreamDict->GetDictBy("Resources");
446 } 445 }
447 } 446 }
448 } 447 }
449 return TRUE; 448 return TRUE;
450 } 449 }
451 450
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 int32_t nFontIndex, 762 int32_t nFontIndex,
764 FX_FLOAT fFontSize) { 763 FX_FLOAT fFontSize) {
765 CFX_ByteTextBuf sRet; 764 CFX_ByteTextBuf sRet;
766 if (pFontMap) { 765 if (pFontMap) {
767 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); 766 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
768 if (sFontAlias.GetLength() > 0 && fFontSize > 0) 767 if (sFontAlias.GetLength() > 0 && fFontSize > 0)
769 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; 768 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
770 } 769 }
771 return sRet.GetByteString(); 770 return sRet.GetByteString();
772 } 771 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpvt_fontmap.cpp ('k') | core/fpdfdoc/doc_action.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698