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

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

Issue 2419173002: Update CPDF_IndirectObjectHolder APIs for unique objects (Closed)
Patch Set: Fix issues Created 4 years, 2 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/cpdf_formfield_unittest.cpp ('k') | core/fpdfdoc/cpvt_fontmap.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 <vector> 7 #include <vector>
8 8
9 #include "core/fpdfapi/font/cpdf_font.h" 9 #include "core/fpdfapi/font/cpdf_font.h"
10 #include "core/fpdfapi/font/cpdf_fontencoding.h" 10 #include "core/fpdfapi/font/cpdf_fontencoding.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 void AddFont(CPDF_Dictionary*& pFormDict, 52 void AddFont(CPDF_Dictionary*& pFormDict,
53 CPDF_Document* pDocument, 53 CPDF_Document* pDocument,
54 const CPDF_Font* pFont, 54 const CPDF_Font* pFont,
55 CFX_ByteString& csNameTag); 55 CFX_ByteString& csNameTag);
56 56
57 void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { 57 void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
58 if (!pDocument) 58 if (!pDocument)
59 return; 59 return;
60 60
61 if (!pFormDict) { 61 if (!pFormDict) {
62 pFormDict = new CPDF_Dictionary(pDocument->GetByteStringPool()); 62 pFormDict =
63 pDocument->GetRoot()->SetReferenceFor( 63 pDocument->AddIndirectDictionary(pDocument->GetByteStringPool());
64 "AcroForm", pDocument, pDocument->AddIndirectObject(pFormDict)); 64 pDocument->GetRoot()->SetReferenceFor("AcroForm", pDocument, pFormDict);
65 } 65 }
66 66
67 CFX_ByteString csDA; 67 CFX_ByteString csDA;
68 if (!pFormDict->KeyExist("DR")) { 68 if (!pFormDict->KeyExist("DR")) {
69 CFX_ByteString csBaseName; 69 CFX_ByteString csBaseName;
70 CFX_ByteString csDefault; 70 CFX_ByteString csDefault;
71 uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); 71 uint8_t charSet = CPDF_InterForm::GetNativeCharSet();
72 CPDF_Font* pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); 72 CPDF_Font* pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica");
73 if (pFont) { 73 if (pFont) {
74 AddFont(pFormDict, pDocument, pFont, csBaseName); 74 AddFont(pFormDict, pDocument, pFont, csBaseName);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (!pFonts) { 267 if (!pFonts) {
268 pFonts = new CPDF_Dictionary(pDocument->GetByteStringPool()); 268 pFonts = new CPDF_Dictionary(pDocument->GetByteStringPool());
269 pDR->SetFor("Font", pFonts); 269 pDR->SetFor("Font", pFonts);
270 } 270 }
271 if (csNameTag.IsEmpty()) 271 if (csNameTag.IsEmpty())
272 csNameTag = pFont->GetBaseFont(); 272 csNameTag = pFont->GetBaseFont();
273 273
274 csNameTag.Remove(' '); 274 csNameTag.Remove(' ');
275 csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, 275 csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4,
276 csNameTag.c_str()); 276 csNameTag.c_str());
277 pFonts->SetReferenceFor(csNameTag, pDocument, 277 pFonts->SetReferenceFor(csNameTag, pDocument, pFont->GetFontDict());
278 pFont->GetFontDict()->GetObjNum());
279 } 278 }
280 279
281 CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, 280 CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict,
282 CPDF_Document* pDocument, 281 CPDF_Document* pDocument,
283 uint8_t charSet, 282 uint8_t charSet,
284 CFX_ByteString& csNameTag) { 283 CFX_ByteString& csNameTag) {
285 if (!pFormDict) 284 if (!pFormDict)
286 InitDict(pFormDict, pDocument); 285 InitDict(pFormDict, pDocument);
287 286
288 CFX_ByteString csTemp; 287 CFX_ByteString csTemp;
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 else if (iType == FIELDTYPE_LISTBOX) 1312 else if (iType == FIELDTYPE_LISTBOX)
1314 m_pFormNotify->AfterSelectionChange(pField); 1313 m_pFormNotify->AfterSelectionChange(pField);
1315 else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) 1314 else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD)
1316 m_pFormNotify->AfterValueChange(pField); 1315 m_pFormNotify->AfterValueChange(pField);
1317 } 1316 }
1318 } 1317 }
1319 1318
1320 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { 1319 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) {
1321 m_pFormNotify = pNotify; 1320 m_pFormNotify = pNotify;
1322 } 1321 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_formfield_unittest.cpp ('k') | core/fpdfdoc/cpvt_fontmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698