| 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/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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictFor(sAPType); | 313 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictFor(sAPType); |
| 314 if (!pAPTypeDict) { | 314 if (!pAPTypeDict) { |
| 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(nullptr, 0, nullptr); | 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 int32_t objnum = pDoc->AddIndirectObject(pStream); |
| 326 pParentDict->SetReferenceFor(sAPType, pDoc, objnum); | 326 pParentDict->SetReferenceFor(sAPType, pDoc, objnum); |
| 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 } |
| 337 | 337 |
| 338 if (pStreamDict) { | 338 if (pStreamDict) { |
| 339 pStreamDict->SetMatrixFor("Matrix", matrix); | 339 pStreamDict->SetMatrixFor("Matrix", matrix); |
| 340 pStreamDict->SetRectFor("BBox", rcBBox); | 340 pStreamDict->SetRectFor("BBox", rcBBox); |
| 341 } | 341 } |
| 342 | 342 |
| 343 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, | 343 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength()); |
| 344 FALSE); | |
| 345 } | 344 } |
| 346 | 345 |
| 347 FX_BOOL CPDFSDK_BAAnnot::IsVisible() const { | 346 FX_BOOL CPDFSDK_BAAnnot::IsVisible() const { |
| 348 uint32_t nFlags = GetFlags(); | 347 uint32_t nFlags = GetFlags(); |
| 349 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || | 348 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || |
| 350 (nFlags & ANNOTFLAG_NOVIEW)); | 349 (nFlags & ANNOTFLAG_NOVIEW)); |
| 351 } | 350 } |
| 352 | 351 |
| 353 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { | 352 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { |
| 354 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A")); | 353 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A")); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 CPDF_RenderOptions* pOptions) { | 399 CPDF_RenderOptions* pOptions) { |
| 401 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); | 400 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); |
| 402 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, | 401 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, |
| 403 CPDF_Annot::Normal, nullptr); | 402 CPDF_Annot::Normal, nullptr); |
| 404 } | 403 } |
| 405 | 404 |
| 406 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { | 405 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { |
| 407 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) | 406 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) |
| 408 pAnnot->SetOpenState(bOpenState); | 407 pAnnot->SetOpenState(bOpenState); |
| 409 } | 408 } |
| OLD | NEW |