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

Side by Side Diff: fpdfsdk/cpdfsdk_baannot.cpp

Issue 2424533003: Revert "Update CPDF_IndirectObjectHolder APIs for unique objects." (Closed)
Patch Set: 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;
319 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 320 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
320 pStream = pDoc->AddIndirectStream(); 321 pParentDict->SetReferenceFor(sAPType, pDoc,
321 pParentDict->SetReferenceFor(sAPType, pDoc, pStream); 322 pDoc->AddIndirectObject(pStream));
322 } 323 }
323 324
324 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 325 CPDF_Dictionary* pStreamDict = pStream->GetDict();
325 if (!pStreamDict) { 326 if (!pStreamDict) {
326 pStreamDict = 327 pStreamDict =
327 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool()); 328 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool());
328 pStreamDict->SetNameFor("Type", "XObject"); 329 pStreamDict->SetNameFor("Type", "XObject");
329 pStreamDict->SetNameFor("Subtype", "Form"); 330 pStreamDict->SetNameFor("Subtype", "Form");
330 pStreamDict->SetIntegerFor("FormType", 1); 331 pStreamDict->SetIntegerFor("FormType", 1);
331 pStream->InitStream(nullptr, 0, pStreamDict); 332 pStream->InitStream(nullptr, 0, pStreamDict);
(...skipping 14 matching lines...) Expand all
346 } 347 }
347 348
348 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { 349 CPDF_Action CPDFSDK_BAAnnot::GetAction() const {
349 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A")); 350 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A"));
350 } 351 }
351 352
352 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) { 353 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
353 CPDF_Dictionary* pDict = action.GetDict(); 354 CPDF_Dictionary* pDict = action.GetDict();
354 if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) { 355 if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) {
355 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 356 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
356 357 m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc,
357 // TODO(tsepez): check |pDict| ownership. 358 pDoc->AddIndirectObject(pDict));
358 m_pAnnot->GetAnnotDict()->SetReferenceFor(
359 "A", pDoc, pDoc->AddIndirectObject(UniqueDictionary(pDict)));
360 } 359 }
361 } 360 }
362 361
363 void CPDFSDK_BAAnnot::RemoveAction() { 362 void CPDFSDK_BAAnnot::RemoveAction() {
364 m_pAnnot->GetAnnotDict()->RemoveFor("A"); 363 m_pAnnot->GetAnnotDict()->RemoveFor("A");
365 } 364 }
366 365
367 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { 366 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const {
368 return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA")); 367 return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA"));
369 } 368 }
(...skipping 24 matching lines...) Expand all
394 CPDF_RenderOptions* pOptions) { 393 CPDF_RenderOptions* pOptions) {
395 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); 394 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
396 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, 395 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device,
397 CPDF_Annot::Normal, nullptr); 396 CPDF_Annot::Normal, nullptr);
398 } 397 }
399 398
400 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { 399 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) {
401 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) 400 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot())
402 pAnnot->SetOpenState(bOpenState); 401 pAnnot->SetOpenState(bOpenState);
403 } 402 }
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