From 525147a1f6d6cd736a407d1e189ac25d2f4726e8 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 3 May 2018 17:19:53 +0000 Subject: Use strict types in FPDF API, try #3 Rather than messing with actual inheritence, add type-checking wrappers and just blatantly cast to incomplete types. Along the way, this points out places where we would downcast without checking, which I fix. Change-Id: Ieb303eb46ad8522dfe082454f1f10f247ffd52d5 Reviewed-on: https://pdfium-review.googlesource.com/32030 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fpdfsdk/cpdf_annotcontext.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 fpdfsdk/cpdf_annotcontext.cpp (limited to 'fpdfsdk/cpdf_annotcontext.cpp') diff --git a/fpdfsdk/cpdf_annotcontext.cpp b/fpdfsdk/cpdf_annotcontext.cpp new file mode 100644 index 0000000000..d76d5d2f8c --- /dev/null +++ b/fpdfsdk/cpdf_annotcontext.cpp @@ -0,0 +1,35 @@ +// Copyright 2018 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "fpdfsdk/cpdf_annotcontext.h" + +#include "core/fpdfapi/page/cpdf_form.h" +#include "core/fpdfapi/page/cpdf_page.h" +#include "core/fpdfapi/parser/cpdf_dictionary.h" +#include "core/fpdfapi/parser/cpdf_stream.h" +#include "third_party/base/ptr_util.h" + +CPDF_AnnotContext::CPDF_AnnotContext(CPDF_Dictionary* pAnnotDict, + CPDF_Page* pPage, + CPDF_Stream* pStream) + : m_pAnnotDict(pAnnotDict), m_pPage(pPage) { + SetForm(pStream); +} + +CPDF_AnnotContext::~CPDF_AnnotContext() = default; + +void CPDF_AnnotContext::SetForm(CPDF_Stream* pStream) { + if (!pStream) + return; + + // Reset the annotation matrix to be the identity matrix, since the + // appearance stream already takes matrix into account. + pStream->GetDict()->SetMatrixFor("Matrix", CFX_Matrix()); + + m_pAnnotForm = pdfium::MakeUnique( + m_pPage->m_pDocument.Get(), m_pPage->m_pResources.Get(), pStream); + m_pAnnotForm->ParseContent(); +} -- cgit v1.2.3