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

Side by Side Diff: fpdfsdk/cpdfsdk_baannot.cpp

Issue 2361713002: Remove some objnum locals with AddIndirectObject (Closed)
Patch Set: Same treatment for arrays 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 | « core/fpdfdoc/cpvt_generateap.cpp ('k') | fpdfsdk/cpdfsdk_widget.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 "fpdfsdk/include/cpdfsdk_baannot.h" 7 #include "fpdfsdk/include/cpdfsdk_baannot.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 pAPTypeDict = new CPDF_Dictionary; 315 pAPTypeDict = new CPDF_Dictionary;
316 pAPDict->SetFor(sAPType, pAPTypeDict); 316 pAPDict->SetFor(sAPType, pAPTypeDict);
317 } 317 }
318 pParentDict = pAPTypeDict; 318 pParentDict = pAPTypeDict;
319 pStream = pAPTypeDict->GetStreamFor(sAPState); 319 pStream = pAPTypeDict->GetStreamFor(sAPState);
320 } 320 }
321 321
322 if (!pStream) { 322 if (!pStream) {
323 pStream = new CPDF_Stream; 323 pStream = new CPDF_Stream;
324 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 324 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
325 int32_t objnum = pDoc->AddIndirectObject(pStream); 325 pParentDict->SetReferenceFor(sAPType, pDoc,
326 pParentDict->SetReferenceFor(sAPType, pDoc, objnum); 326 pDoc->AddIndirectObject(pStream));
327 } 327 }
328 328
329 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 329 CPDF_Dictionary* pStreamDict = pStream->GetDict();
330 if (!pStreamDict) { 330 if (!pStreamDict) {
331 pStreamDict = new CPDF_Dictionary; 331 pStreamDict = new CPDF_Dictionary;
332 pStreamDict->SetNameFor("Type", "XObject"); 332 pStreamDict->SetNameFor("Type", "XObject");
333 pStreamDict->SetNameFor("Subtype", "Form"); 333 pStreamDict->SetNameFor("Subtype", "Form");
334 pStreamDict->SetIntegerFor("FormType", 1); 334 pStreamDict->SetIntegerFor("FormType", 1);
335 pStream->InitStream(nullptr, 0, pStreamDict); 335 pStream->InitStream(nullptr, 0, pStreamDict);
336 } 336 }
(...skipping 10 matching lines...) Expand all
347 uint32_t nFlags = GetFlags(); 347 uint32_t nFlags = GetFlags();
348 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || 348 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) ||
349 (nFlags & ANNOTFLAG_NOVIEW)); 349 (nFlags & ANNOTFLAG_NOVIEW));
350 } 350 }
351 351
352 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { 352 CPDF_Action CPDFSDK_BAAnnot::GetAction() const {
353 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A")); 353 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A"));
354 } 354 }
355 355
356 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) { 356 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
357 ASSERT(action.GetDict()); 357 CPDF_Dictionary* pDict = action.GetDict();
358 if (action.GetDict() != m_pAnnot->GetAnnotDict()->GetDictFor("A")) { 358 if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) {
359 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 359 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
360 CPDF_Dictionary* pDict = action.GetDict(); 360 m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc,
361 if (pDict && pDict->GetObjNum() == 0) { 361 pDoc->AddIndirectObject(pDict));
362 pDoc->AddIndirectObject(pDict);
363 }
364 m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc, pDict->GetObjNum());
365 } 362 }
366 } 363 }
367 364
368 void CPDFSDK_BAAnnot::RemoveAction() { 365 void CPDFSDK_BAAnnot::RemoveAction() {
369 m_pAnnot->GetAnnotDict()->RemoveFor("A"); 366 m_pAnnot->GetAnnotDict()->RemoveFor("A");
370 } 367 }
371 368
372 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { 369 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const {
373 return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA")); 370 return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA"));
374 } 371 }
(...skipping 24 matching lines...) Expand all
399 CPDF_RenderOptions* pOptions) { 396 CPDF_RenderOptions* pOptions) {
400 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); 397 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
401 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, 398 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device,
402 CPDF_Annot::Normal, nullptr); 399 CPDF_Annot::Normal, nullptr);
403 } 400 }
404 401
405 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { 402 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) {
406 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) 403 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot())
407 pAnnot->SetOpenState(bOpenState); 404 pAnnot->SetOpenState(bOpenState);
408 } 405 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpvt_generateap.cpp ('k') | fpdfsdk/cpdfsdk_widget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698