blob: 82df60ce9f529c220d1cf86dc0c6ee2494658944 [file] [log] [blame]
Dan Sinclair455a4192016-03-16 09:48:56 -04001// 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
dsinclair41872fa2016-10-04 11:29:35 -07007#ifndef CORE_FPDFAPI_PAGE_CPDF_PAGE_H_
8#define CORE_FPDFAPI_PAGE_CPDF_PAGE_H_
Dan Sinclair455a4192016-03-16 09:48:56 -04009
thestig5cc24652016-04-26 11:46:02 -070010#include <memory>
11
dsinclair41872fa2016-10-04 11:29:35 -070012#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
dsinclaira52ab742016-09-29 13:59:29 -070013#include "core/fxcrt/fx_basic.h"
14#include "core/fxcrt/fx_coordinates.h"
15#include "core/fxcrt/fx_system.h"
Dan Sinclair455a4192016-03-16 09:48:56 -040016
Dan Sinclair455a4192016-03-16 09:48:56 -040017class CPDF_Dictionary;
thestig5cc24652016-04-26 11:46:02 -070018class CPDF_Document;
Dan Sinclair455a4192016-03-16 09:48:56 -040019class CPDF_Object;
20class CPDF_PageRenderCache;
weili9f515bc2016-07-24 08:08:24 -070021class CPDF_PageRenderContext;
Dan Sinclair584b1e62016-03-21 09:15:45 -040022
tsepez1e2c5572016-05-25 14:58:09 -070023class CPDF_Page : public CPDF_PageObjectHolder {
Dan Sinclair455a4192016-03-16 09:48:56 -040024 public:
tsepez1e2c5572016-05-25 14:58:09 -070025 class View {}; // Caller implements as desired, empty here due to layering.
26
thestig5cc24652016-04-26 11:46:02 -070027 CPDF_Page(CPDF_Document* pDocument,
28 CPDF_Dictionary* pPageDict,
29 bool bPageCache);
weili868150b2016-06-13 14:57:29 -070030 ~CPDF_Page() override;
Dan Sinclair455a4192016-03-16 09:48:56 -040031
Jane Liu22eb7ae2017-06-26 13:24:23 -040032 // CPDF_PageObjectHolder
33 bool IsPage() const override;
34
thestig5cc24652016-04-26 11:46:02 -070035 void ParseContent();
Dan Sinclair455a4192016-03-16 09:48:56 -040036
Dan Sinclair1b08df12017-02-09 09:17:20 -050037 CFX_Matrix GetDisplayMatrix(int xPos,
38 int yPos,
39 int xSize,
40 int ySize,
41 int iRotate) const;
Dan Sinclair455a4192016-03-16 09:48:56 -040042
Dan Sinclair05df0752017-03-14 14:43:42 -040043 float GetPageWidth() const { return m_PageWidth; }
44 float GetPageHeight() const { return m_PageHeight; }
Dan Sinclair455a4192016-03-16 09:48:56 -040045 CFX_FloatRect GetPageBBox() const { return m_BBox; }
46 const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; }
rbpotterce8e51e2017-04-28 12:42:47 -070047 int GetPageRotation() const;
thestig5cc24652016-04-26 11:46:02 -070048 CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender.get(); }
Dan Sinclair455a4192016-03-16 09:48:56 -040049
weili9f515bc2016-07-24 08:08:24 -070050 CPDF_PageRenderContext* GetRenderContext() const {
51 return m_pRenderContext.get();
tsepez1e2c5572016-05-25 14:58:09 -070052 }
weili9f515bc2016-07-24 08:08:24 -070053 void SetRenderContext(std::unique_ptr<CPDF_PageRenderContext> pContext);
tsepez1e2c5572016-05-25 14:58:09 -070054
55 View* GetView() const { return m_pView; }
56 void SetView(View* pView) { m_pView = pView; }
57
Lei Zhangd9281812017-05-26 10:33:45 -070058 private:
thestig5cc24652016-04-26 11:46:02 -070059 void StartParse();
Dan Sinclair455a4192016-03-16 09:48:56 -040060
Lei Zhangd9281812017-05-26 10:33:45 -070061 CPDF_Object* GetPageAttr(const CFX_ByteString& name) const;
62 CFX_FloatRect GetBox(const CFX_ByteString& name) const;
63
Dan Sinclair05df0752017-03-14 14:43:42 -040064 float m_PageWidth;
65 float m_PageHeight;
Dan Sinclair455a4192016-03-16 09:48:56 -040066 CFX_Matrix m_PageMatrix;
tsepez1e2c5572016-05-25 14:58:09 -070067 View* m_pView;
thestig5cc24652016-04-26 11:46:02 -070068 std::unique_ptr<CPDF_PageRenderCache> m_pPageRender;
weili9f515bc2016-07-24 08:08:24 -070069 std::unique_ptr<CPDF_PageRenderContext> m_pRenderContext;
Dan Sinclair455a4192016-03-16 09:48:56 -040070};
71
dsinclair41872fa2016-10-04 11:29:35 -070072#endif // CORE_FPDFAPI_PAGE_CPDF_PAGE_H_