blob: 19dc0f29b1ae949aa8986e1717ab00823aac1a2f [file] [log] [blame]
Lei Zhang94293682016-01-27 18:27:56 -08001// Copyright 2014 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
dsinclair4d29e782016-10-04 14:02:47 -07007#ifndef FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_
8#define FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_
Lei Zhang94293682016-01-27 18:27:56 -08009
thestig9f3dbbc2016-04-13 13:18:21 -070010#include <memory>
11
Tom Sepez9792f162017-05-16 14:11:30 -070012#include "core/fxcrt/cfx_retain_ptr.h"
Tom Sepez797ca5c2017-05-25 12:03:18 -070013#include "core/fxcrt/cfx_unowned_ptr.h"
dsinclaira52ab742016-09-29 13:59:29 -070014#include "core/fxcrt/fx_system.h"
Dan Sinclairaa403d32016-03-15 14:57:22 -040015
weili625ad662016-06-15 11:21:33 -070016class CFX_Matrix;
dsinclair521b7502016-11-02 13:02:28 -070017class CPDFXFA_Context;
weili625ad662016-06-15 11:21:33 -070018class CPDF_Dictionary;
dan sinclair06f49c82016-02-27 08:53:48 -050019class CPDF_Page;
dsinclairdf4bc592016-03-31 20:34:43 -070020class CXFA_FFPageView;
dan sinclair06f49c82016-02-27 08:53:48 -050021
Tom Sepez9792f162017-05-16 14:11:30 -070022class CPDFXFA_Page : public CFX_Retainable {
Lei Zhang94293682016-01-27 18:27:56 -080023 public:
Tom Sepez9792f162017-05-16 14:11:30 -070024 template <typename T, typename... Args>
25 friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
thestig9f3dbbc2016-04-13 13:18:21 -070026
tsepez4cf55152016-11-02 14:37:54 -070027 bool LoadPage();
28 bool LoadPDFPage(CPDF_Dictionary* pageDict);
Tom Sepez797ca5c2017-05-25 12:03:18 -070029 CPDFXFA_Context* GetContext() const { return m_pContext.Get(); }
thestig9f3dbbc2016-04-13 13:18:21 -070030 int GetPageIndex() const { return m_iPageIndex; }
31 CPDF_Page* GetPDFPage() const { return m_pPDFPage.get(); }
32 CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; }
33
dsinclairdf4bc592016-03-31 20:34:43 -070034 void SetXFAPageView(CXFA_FFPageView* pPageView) {
35 m_pXFAPageView = pPageView;
36 }
Lei Zhang94293682016-01-27 18:27:56 -080037
Dan Sinclair05df0752017-03-14 14:43:42 -040038 float GetPageWidth() const;
39 float GetPageHeight() const;
Lei Zhang94293682016-01-27 18:27:56 -080040
41 void DeviceToPage(int start_x,
42 int start_y,
43 int size_x,
44 int size_y,
45 int rotate,
46 int device_x,
47 int device_y,
48 double* page_x,
49 double* page_y);
50 void PageToDevice(int start_x,
51 int start_y,
52 int size_x,
53 int size_y,
54 int rotate,
55 double page_x,
56 double page_y,
57 int* device_x,
58 int* device_y);
59
Dan Sinclair1b08df12017-02-09 09:17:20 -050060 CFX_Matrix GetDisplayMatrix(int xPos,
61 int yPos,
62 int xSize,
63 int ySize,
64 int iRotate) const;
Lei Zhang94293682016-01-27 18:27:56 -080065
66 protected:
thestig9f3dbbc2016-04-13 13:18:21 -070067 // Refcounted class.
Tom Sepez9792f162017-05-16 14:11:30 -070068 CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index);
69 ~CPDFXFA_Page() override;
thestig9f3dbbc2016-04-13 13:18:21 -070070
tsepez4cf55152016-11-02 14:37:54 -070071 bool LoadPDFPage();
72 bool LoadXFAPageView();
Lei Zhang94293682016-01-27 18:27:56 -080073
74 private:
thestig9f3dbbc2016-04-13 13:18:21 -070075 std::unique_ptr<CPDF_Page> m_pPDFPage;
dsinclairdf4bc592016-03-31 20:34:43 -070076 CXFA_FFPageView* m_pXFAPageView;
Tom Sepez797ca5c2017-05-25 12:03:18 -070077 CFX_UnownedPtr<CPDFXFA_Context> const m_pContext;
thestig9f3dbbc2016-04-13 13:18:21 -070078 const int m_iPageIndex;
Lei Zhang94293682016-01-27 18:27:56 -080079};
80
dsinclair4d29e782016-10-04 14:02:47 -070081#endif // FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_