summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdf_annotcontext.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-05-03 17:19:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-03 17:19:53 +0000
commit525147a1f6d6cd736a407d1e189ac25d2f4726e8 (patch)
treebdc818c52d902a5a4e8ce8a4f0ba29bd11007b05 /fpdfsdk/cpdf_annotcontext.h
parentccd9421589922b8f35ee5330d7fdac7edea081db (diff)
downloadpdfium-525147a1f6d6cd736a407d1e189ac25d2f4726e8.tar.xz
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 <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdf_annotcontext.h')
-rw-r--r--fpdfsdk/cpdf_annotcontext.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/fpdfsdk/cpdf_annotcontext.h b/fpdfsdk/cpdf_annotcontext.h
new file mode 100644
index 0000000000..38cc91e031
--- /dev/null
+++ b/fpdfsdk/cpdf_annotcontext.h
@@ -0,0 +1,38 @@
+// 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
+
+#ifndef FPDFSDK_CPDF_ANNOTCONTEXT_H_
+#define FPDFSDK_CPDF_ANNOTCONTEXT_H_
+
+#include <memory>
+
+#include "core/fxcrt/unowned_ptr.h"
+
+class CPDF_Dictionary;
+class CPDF_Form;
+class CPDF_Page;
+class CPDF_Stream;
+
+class CPDF_AnnotContext {
+ public:
+ CPDF_AnnotContext(CPDF_Dictionary* pAnnotDict,
+ CPDF_Page* pPage,
+ CPDF_Stream* pStream);
+ ~CPDF_AnnotContext();
+
+ void SetForm(CPDF_Stream* pStream);
+ bool HasForm() const { return !!m_pAnnotForm; }
+ CPDF_Form* GetForm() const { return m_pAnnotForm.get(); }
+ CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict.Get(); }
+ CPDF_Page* GetPage() const { return m_pPage.Get(); }
+
+ private:
+ std::unique_ptr<CPDF_Form> m_pAnnotForm;
+ UnownedPtr<CPDF_Dictionary> m_pAnnotDict;
+ UnownedPtr<CPDF_Page> m_pPage;
+};
+
+#endif // FPDFSDK_CPDF_ANNOTCONTEXT_H_