OLD | NEW |
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 <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 } | 316 } |
317 | 317 |
318 if (!pStream) { | 318 if (!pStream) { |
319 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 319 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
320 pStream = pDoc->NewIndirect<CPDF_Stream>(); | 320 pStream = pDoc->NewIndirect<CPDF_Stream>(); |
321 pParentDict->SetNewFor<CPDF_Reference>(sAPType, pDoc, pStream->GetObjNum()); | 321 pParentDict->SetNewFor<CPDF_Reference>(sAPType, pDoc, pStream->GetObjNum()); |
322 } | 322 } |
323 | 323 |
324 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 324 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
325 if (!pStreamDict) { | 325 if (!pStreamDict) { |
326 pStreamDict = | 326 auto pNewDict = pdfium::MakeUnique<CPDF_Dictionary>( |
327 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool()); | 327 m_pAnnot->GetDocument()->GetByteStringPool()); |
| 328 pStreamDict = pNewDict.get(); |
328 pStreamDict->SetNewFor<CPDF_Name>("Type", "XObject"); | 329 pStreamDict->SetNewFor<CPDF_Name>("Type", "XObject"); |
329 pStreamDict->SetNewFor<CPDF_Name>("Subtype", "Form"); | 330 pStreamDict->SetNewFor<CPDF_Name>("Subtype", "Form"); |
330 pStreamDict->SetNewFor<CPDF_Number>("FormType", 1); | 331 pStreamDict->SetNewFor<CPDF_Number>("FormType", 1); |
331 pStream->InitStream(nullptr, 0, pStreamDict); | 332 pStream->InitStream(nullptr, 0, std::move(pNewDict)); |
332 } | 333 } |
333 | 334 pStreamDict->SetMatrixFor("Matrix", matrix); |
334 if (pStreamDict) { | 335 pStreamDict->SetRectFor("BBox", rcBBox); |
335 pStreamDict->SetMatrixFor("Matrix", matrix); | |
336 pStreamDict->SetRectFor("BBox", rcBBox); | |
337 } | |
338 | |
339 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength()); | 336 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength()); |
340 } | 337 } |
341 | 338 |
342 bool CPDFSDK_BAAnnot::IsVisible() const { | 339 bool CPDFSDK_BAAnnot::IsVisible() const { |
343 uint32_t nFlags = GetFlags(); | 340 uint32_t nFlags = GetFlags(); |
344 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || | 341 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || |
345 (nFlags & ANNOTFLAG_NOVIEW)); | 342 (nFlags & ANNOTFLAG_NOVIEW)); |
346 } | 343 } |
347 | 344 |
348 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { | 345 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 CPDF_RenderOptions* pOptions) { | 390 CPDF_RenderOptions* pOptions) { |
394 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); | 391 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); |
395 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, | 392 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, |
396 CPDF_Annot::Normal, nullptr); | 393 CPDF_Annot::Normal, nullptr); |
397 } | 394 } |
398 | 395 |
399 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { | 396 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { |
400 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) | 397 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) |
401 pAnnot->SetOpenState(bOpenState); | 398 pAnnot->SetOpenState(bOpenState); |
402 } | 399 } |
OLD | NEW |