blob: a71106bcd851950006b72435537bf2f11d6f5760 [file] [log] [blame]
kumarashishg826308d2023-06-23 13:21:22 +00001// Copyright 2018 The PDFium Authors
Haibo Huang49cc9302020-04-27 16:14:24 -07002// 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#ifndef CORE_FPDFAPI_PAGE_IPDF_PAGE_H_
8#define CORE_FPDFAPI_PAGE_IPDF_PAGE_H_
9
10#include "core/fxcrt/fx_coordinates.h"
11#include "core/fxcrt/retain_ptr.h"
kumarashishg826308d2023-06-23 13:21:22 +000012#include "third_party/abseil-cpp/absl/types/optional.h"
Haibo Huang49cc9302020-04-27 16:14:24 -070013
14class CPDF_Document;
15class CPDF_Page;
16
17// Small layering violation, incomplete type and always null if non-XFA.
18class CPDFXFA_Page;
19
20// Interface implemented by both page types (CPDF_Page and CPDFXFA_Page).
21class IPDF_Page : public Retainable {
22 public:
23 // There are actually 3 cases: a PDF page, an XFA page backed by a PDF page,
24 // and an XFA page not backed by a PDF page. AsPDFPage() will return the
25 // PDF page in either of the first two cases. AsXFAPage() is a straight
26 // downcast and is null if not either of the last two cases. Hence, both
27 // of these may return non-null on a given page.
28 virtual CPDF_Page* AsPDFPage() = 0;
29 virtual CPDFXFA_Page* AsXFAPage() = 0;
30
31 virtual CPDF_Document* GetDocument() const = 0;
32
33 virtual float GetPageWidth() const = 0;
34 virtual float GetPageHeight() const = 0;
35 virtual CFX_Matrix GetDisplayMatrix(const FX_RECT& rect,
36 int iRotate) const = 0;
37
kumarashishg826308d2023-06-23 13:21:22 +000038 virtual absl::optional<CFX_PointF> DeviceToPage(
Haibo Huang49cc9302020-04-27 16:14:24 -070039 const FX_RECT& rect,
40 int rotate,
41 const CFX_PointF& device_point) const = 0;
42
kumarashishg826308d2023-06-23 13:21:22 +000043 virtual absl::optional<CFX_PointF> PageToDevice(
Haibo Huang49cc9302020-04-27 16:14:24 -070044 const FX_RECT& rect,
45 int rotate,
46 const CFX_PointF& page_point) const = 0;
47};
48
49inline CPDF_Page* ToPDFPage(IPDF_Page* pBase) {
50 return pBase ? pBase->AsPDFPage() : nullptr;
51}
52
53inline CPDFXFA_Page* ToXFAPage(IPDF_Page* pBase) {
54 return pBase ? pBase->AsXFAPage() : nullptr;
55}
56
57#endif // CORE_FPDFAPI_PAGE_IPDF_PAGE_H_