1 // Copyright 2018 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "core/fpdfapi/page/cpdf_annotcontext.h" 8 9 #include <utility> 10 11 #include "core/fpdfapi/page/cpdf_form.h" 12 #include "core/fpdfapi/page/cpdf_page.h" 13 #include "core/fpdfapi/parser/cpdf_dictionary.h" 14 #include "core/fpdfapi/parser/cpdf_stream.h" 15 #include "third_party/base/check.h" 16 CPDF_AnnotContext(RetainPtr<CPDF_Dictionary> pAnnotDict,IPDF_Page * pPage)17CPDF_AnnotContext::CPDF_AnnotContext(RetainPtr<CPDF_Dictionary> pAnnotDict, 18 IPDF_Page* pPage) 19 : m_pAnnotDict(std::move(pAnnotDict)), m_pPage(pPage) { 20 DCHECK(m_pAnnotDict); 21 DCHECK(m_pPage); 22 DCHECK(m_pPage->AsPDFPage()); 23 } 24 25 CPDF_AnnotContext::~CPDF_AnnotContext() = default; 26 SetForm(RetainPtr<CPDF_Stream> pStream)27void CPDF_AnnotContext::SetForm(RetainPtr<CPDF_Stream> pStream) { 28 if (!pStream) 29 return; 30 31 // Reset the annotation matrix to be the identity matrix, since the 32 // appearance stream already takes matrix into account. 33 pStream->GetMutableDict()->SetMatrixFor("Matrix", CFX_Matrix()); 34 35 m_pAnnotForm = std::make_unique<CPDF_Form>( 36 m_pPage->GetDocument(), m_pPage->AsPDFPage()->GetMutableResources(), 37 pStream); 38 m_pAnnotForm->ParseContent(); 39 } 40