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

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

Issue 1889863002: Make CPDF_Dictionary methods take CFX_ByteString arguments (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: One last caller. 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_annot.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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).AsStringC()); 57 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
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).AsStringC()); 62 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
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).AsStringC(), pDoc, pFontDict); 75 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict);
76 } 76 }
77 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); 77 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
78 if (!pDefFont) 78 if (!pDefFont)
79 return FALSE; 79 return FALSE;
80 80
81 CFX_FloatRect rcAnnot = pAnnotDict->GetRectBy("Rect"); 81 CFX_FloatRect rcAnnot = pAnnotDict->GetRectBy("Rect");
82 int32_t nRotate = 0; 82 int32_t nRotate = 0;
83 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) 83 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK"))
84 nRotate = pMKDict->GetIntegerBy("R"); 84 nRotate = pMKDict->GetIntegerBy("R");
85 85
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (pStreamDict) { 182 if (pStreamDict) {
183 pStreamDict->SetAtMatrix("Matrix", matrix); 183 pStreamDict->SetAtMatrix("Matrix", matrix);
184 pStreamDict->SetAtRect("BBox", rcBBox); 184 pStreamDict->SetAtRect("BBox", rcBBox);
185 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); 185 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources");
186 if (pStreamResList) { 186 if (pStreamResList) {
187 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font"); 187 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font");
188 if (!pStreamResFontList) { 188 if (!pStreamResFontList) {
189 pStreamResFontList = new CPDF_Dictionary; 189 pStreamResFontList = new CPDF_Dictionary;
190 pStreamResList->SetAt("Font", pStreamResFontList); 190 pStreamResList->SetAt("Font", pStreamResFontList);
191 } 191 }
192 if (!pStreamResFontList->KeyExist(sFontName.AsStringC())) 192 if (!pStreamResFontList->KeyExist(sFontName))
193 pStreamResFontList->SetAtReference(sFontName.AsStringC(), pDoc, 193 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict);
194 pFontDict);
195 } else { 194 } else {
196 pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone()); 195 pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone());
197 pStreamResList = pStreamDict->GetDictBy("Resources"); 196 pStreamResList = pStreamDict->GetDictBy("Resources");
198 } 197 }
199 } 198 }
200 switch (nWidgetType) { 199 switch (nWidgetType) {
201 case 0: { 200 case 0: {
202 CFX_WideString swValue = 201 CFX_WideString swValue =
203 FPDF_GetFieldAttr(pAnnotDict, "V") 202 FPDF_GetFieldAttr(pAnnotDict, "V")
204 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() 203 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText()
(...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.AsStringC())) 439 if (!pStreamResFontList->KeyExist(sFontName))
441 pStreamResFontList->SetAtReference(sFontName.AsStringC(), pDoc, 440 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict);
442 pFontDict);
443 } else { 441 } else {
444 pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone()); 442 pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone());
445 pStreamResList = pStreamDict->GetDictBy("Resources"); 443 pStreamResList = pStreamDict->GetDictBy("Resources");
446 } 444 }
447 } 445 }
448 } 446 }
449 return TRUE; 447 return TRUE;
450 } 448 }
451 449
452 } // namespace 450 } // namespace
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 int32_t nFontIndex, 761 int32_t nFontIndex,
764 FX_FLOAT fFontSize) { 762 FX_FLOAT fFontSize) {
765 CFX_ByteTextBuf sRet; 763 CFX_ByteTextBuf sRet;
766 if (pFontMap) { 764 if (pFontMap) {
767 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); 765 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
768 if (sFontAlias.GetLength() > 0 && fFontSize > 0) 766 if (sFontAlias.GetLength() > 0 && fFontSize > 0)
769 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; 767 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
770 } 768 }
771 return sRet.GetByteString(); 769 return sRet.GetByteString();
772 } 770 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpvt_fontmap.cpp ('k') | core/fpdfdoc/doc_annot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698