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

Side by Side Diff: fpdfsdk/cpdfsdk_baannot.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/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/cpdfsdk_baannot.h" 7 #include "fpdfsdk/cpdfsdk_baannot.h"
8 8
9 #include "core/fpdfapi/parser/cpdf_array.h" 9 #include "core/fpdfapi/parser/cpdf_array.h"
10 #include "core/fpdfapi/parser/cpdf_document.h" 10 #include "core/fpdfapi/parser/cpdf_document.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (!pAPTypeDict) { 309 if (!pAPTypeDict) {
310 pAPTypeDict = 310 pAPTypeDict =
311 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool()); 311 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool());
312 pAPDict->SetFor(sAPType, pAPTypeDict); 312 pAPDict->SetFor(sAPType, pAPTypeDict);
313 } 313 }
314 pParentDict = pAPTypeDict; 314 pParentDict = pAPTypeDict;
315 pStream = pAPTypeDict->GetStreamFor(sAPState); 315 pStream = pAPTypeDict->GetStreamFor(sAPState);
316 } 316 }
317 317
318 if (!pStream) { 318 if (!pStream) {
319 pStream = new CPDF_Stream;
320 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 319 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
321 pParentDict->SetReferenceFor(sAPType, pDoc, 320 pStream = pDoc->AddIndirectStream();
322 pDoc->AddIndirectObject(pStream)); 321 pParentDict->SetReferenceFor(sAPType, pDoc, pStream);
323 } 322 }
324 323
325 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 324 CPDF_Dictionary* pStreamDict = pStream->GetDict();
326 if (!pStreamDict) { 325 if (!pStreamDict) {
327 pStreamDict = 326 pStreamDict =
328 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool()); 327 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool());
329 pStreamDict->SetNameFor("Type", "XObject"); 328 pStreamDict->SetNameFor("Type", "XObject");
330 pStreamDict->SetNameFor("Subtype", "Form"); 329 pStreamDict->SetNameFor("Subtype", "Form");
331 pStreamDict->SetIntegerFor("FormType", 1); 330 pStreamDict->SetIntegerFor("FormType", 1);
332 pStream->InitStream(nullptr, 0, pStreamDict); 331 pStream->InitStream(nullptr, 0, pStreamDict);
(...skipping 14 matching lines...) Expand all
347 } 346 }
348 347
349 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { 348 CPDF_Action CPDFSDK_BAAnnot::GetAction() const {
350 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A")); 349 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A"));
351 } 350 }
352 351
353 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) { 352 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
354 CPDF_Dictionary* pDict = action.GetDict(); 353 CPDF_Dictionary* pDict = action.GetDict();
355 if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) { 354 if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) {
356 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 355 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
357 m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc, 356
358 pDoc->AddIndirectObject(pDict)); 357 // TODO(tsepez): check |pDict| ownership.
358 m_pAnnot->GetAnnotDict()->SetReferenceFor(
359 "A", pDoc, pDoc->AddIndirectObject(UniqueDictionary(pDict)));
359 } 360 }
360 } 361 }
361 362
362 void CPDFSDK_BAAnnot::RemoveAction() { 363 void CPDFSDK_BAAnnot::RemoveAction() {
363 m_pAnnot->GetAnnotDict()->RemoveFor("A"); 364 m_pAnnot->GetAnnotDict()->RemoveFor("A");
364 } 365 }
365 366
366 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { 367 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const {
367 return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA")); 368 return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA"));
368 } 369 }
(...skipping 24 matching lines...) Expand all
393 CPDF_RenderOptions* pOptions) { 394 CPDF_RenderOptions* pOptions) {
394 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); 395 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
395 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, 396 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device,
396 CPDF_Annot::Normal, nullptr); 397 CPDF_Annot::Normal, nullptr);
397 } 398 }
398 399
399 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { 400 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) {
400 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) 401 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot())
401 pAnnot->SetOpenState(bOpenState); 402 pAnnot->SetOpenState(bOpenState);
402 } 403 }
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