1// Copyright 2016 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#ifndef CORE_FPDFAPI_PAGE_CPDF_PAGE_H_
8#define CORE_FPDFAPI_PAGE_CPDF_PAGE_H_
9
10#include <memory>
11
12#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
13#include "core/fxcrt/fx_coordinates.h"
14#include "core/fxcrt/fx_system.h"
15
16class CPDF_Dictionary;
17class CPDF_Document;
18class CPDF_Object;
19class CPDF_PageRenderCache;
20class CPDF_PageRenderContext;
21
22class CPDF_Page : public CPDF_PageObjectHolder {
23 public:
24  class View {};  // Caller implements as desired, empty here due to layering.
25
26  CPDF_Page(CPDF_Document* pDocument,
27            CPDF_Dictionary* pPageDict,
28            bool bPageCache);
29  ~CPDF_Page() override;
30
31  // CPDF_PageObjectHolder
32  bool IsPage() const override;
33
34  void ParseContent();
35
36  CFX_Matrix GetDisplayMatrix(int xPos,
37                              int yPos,
38                              int xSize,
39                              int ySize,
40                              int iRotate) const;
41
42  float GetPageWidth() const { return m_PageWidth; }
43  float GetPageHeight() const { return m_PageHeight; }
44  CFX_FloatRect GetPageBBox() const { return m_BBox; }
45  int GetPageRotation() const;
46  CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender.get(); }
47
48  CPDF_PageRenderContext* GetRenderContext() const {
49    return m_pRenderContext.get();
50  }
51  void SetRenderContext(std::unique_ptr<CPDF_PageRenderContext> pContext);
52
53  View* GetView() const { return m_pView; }
54  void SetView(View* pView) { m_pView = pView; }
55
56 private:
57  void StartParse();
58
59  CPDF_Object* GetPageAttr(const ByteString& name) const;
60  CFX_FloatRect GetBox(const ByteString& name) const;
61
62  float m_PageWidth;
63  float m_PageHeight;
64  CFX_Matrix m_PageMatrix;
65  View* m_pView;
66  std::unique_ptr<CPDF_PageRenderCache> m_pPageRender;
67  std::unique_ptr<CPDF_PageRenderContext> m_pRenderContext;
68};
69
70#endif  // CORE_FPDFAPI_PAGE_CPDF_PAGE_H_
71