• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 PDFium Authors. All rights reserved.
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 "core/fpdfapi/page/cpdf_form.h"
10 #include "core/fpdfapi/page/cpdf_page.h"
11 #include "core/fpdfapi/parser/cpdf_dictionary.h"
12 #include "core/fpdfapi/parser/cpdf_stream.h"
13 #include "third_party/base/ptr_util.h"
14 
CPDF_AnnotContext(CPDF_Dictionary * pAnnotDict,CPDF_Page * pPage)15 CPDF_AnnotContext::CPDF_AnnotContext(CPDF_Dictionary* pAnnotDict,
16                                      CPDF_Page* pPage)
17     : m_pAnnotDict(pAnnotDict), m_pPage(pPage) {
18   ASSERT(m_pAnnotDict);
19   ASSERT(m_pPage);
20 }
21 
22 CPDF_AnnotContext::~CPDF_AnnotContext() = default;
23 
SetForm(CPDF_Stream * pStream)24 void CPDF_AnnotContext::SetForm(CPDF_Stream* pStream) {
25   if (!pStream)
26     return;
27 
28   // Reset the annotation matrix to be the identity matrix, since the
29   // appearance stream already takes matrix into account.
30   pStream->GetDict()->SetMatrixFor("Matrix", CFX_Matrix());
31 
32   m_pAnnotForm = pdfium::MakeUnique<CPDF_Form>(
33       m_pPage->GetDocument(), m_pPage->m_pResources.Get(), pStream);
34   m_pAnnotForm->ParseContent();
35 }
36