Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_page.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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#include <optional>
12#include <utility>
13
14#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
15#include "core/fpdfapi/page/ipdf_page.h"
16#include "core/fxcrt/fx_coordinates.h"
17#include "core/fxcrt/fx_memory.h"
18#include "core/fxcrt/observed_ptr.h"
19#include "core/fxcrt/retain_ptr.h"
20#include "core/fxcrt/unowned_ptr.h"
21
22class CPDF_Array;
23class CPDF_Dictionary;
24class CPDF_Document;
25class CPDF_Object;
27
28class CPDF_Page final : public IPDF_Page, public CPDF_PageObjectHolder {
29 public:
30 // Caller implements as desired, exists here due to layering.
31 class View : public Observable {
32 public:
33 virtual void ClearPage(CPDF_Page* pPage) = 0;
34 };
35
36 // Data for the render layer to attach to this page.
38 public:
39 virtual ~RenderContextIface() = default;
40 };
41
43 public:
44 FX_STACK_ALLOCATED();
45 explicit RenderContextClearer(CPDF_Page* pPage);
47
48 private:
49 UnownedPtr<CPDF_Page> const m_pPage;
50 };
51
53
54 // IPDF_Page:
55 CPDF_Page* AsPDFPage() override;
56 CPDFXFA_Page* AsXFAPage() override;
57 CPDF_Document* GetDocument() const override;
58 float GetPageWidth() const override;
59 float GetPageHeight() const override;
60 CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int iRotate) const override;
61 std::optional<CFX_PointF> DeviceToPage(
62 const FX_RECT& rect,
63 int rotate,
64 const CFX_PointF& device_point) const override;
65 std::optional<CFX_PointF> PageToDevice(
66 const FX_RECT& rect,
67 int rotate,
68 const CFX_PointF& page_point) const override;
69
70 // CPDF_PageObjectHolder:
71 bool IsPage() const override;
72
73 void ParseContent();
74 const CFX_SizeF& GetPageSize() const { return m_PageSize; }
75 const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; }
76 int GetPageRotation() const;
77
80 RetainPtr<const CPDF_Array> GetAnnotsArray() const;
81
82 void AddPageImageCache();
83 CPDF_PageImageCache* GetPageImageCache() { return m_pPageImageCache.get(); }
84 RenderContextIface* GetRenderContext() { return m_pRenderContext.get(); }
85
86 // `pContext` cannot be null. `SetRenderContext()` cannot be called if the
87 // page already has a render context. Use `ClearRenderContext()` to reset the
88 // render context.
89 void SetRenderContext(std::unique_ptr<RenderContextIface> pContext);
90 void ClearRenderContext();
91
92 void SetView(View* pView) { m_pView.Reset(pView); }
93 void ClearView();
94 void UpdateDimensions();
95
96 private:
97 CPDF_Page(CPDF_Document* pDocument, RetainPtr<CPDF_Dictionary> pPageDict);
98 ~CPDF_Page() override;
99
100 RetainPtr<CPDF_Object> GetMutablePageAttr(const ByteString& name);
101 RetainPtr<const CPDF_Object> GetPageAttr(const ByteString& name) const;
102 CFX_FloatRect GetBox(const ByteString& name) const;
103
104 CFX_SizeF m_PageSize;
105 CFX_Matrix m_PageMatrix;
106 UnownedPtr<CPDF_Document> const m_pPDFDocument;
107 std::unique_ptr<CPDF_PageImageCache> m_pPageImageCache;
108 std::unique_ptr<RenderContextIface> m_pRenderContext;
109 ObservedPtr<View> m_pView;
110};
111
112#endif // CORE_FPDFAPI_PAGE_CPDF_PAGE_H_
fxcrt::ByteString ByteString
Definition bytestring.h:180
#define DCHECK
Definition check.h:33
void Scale(float sx, float sy)
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition cpdf_array.h:29
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
bool ExportNPagesToOne(pdfium::span< const uint32_t > page_indices, const CFX_SizeF &dest_page_size, size_t pages_on_x_axis, size_t pages_on_y_axis)
static ByteString GenerateSubPageContentStreamForTesting(const ByteString &xobject_name, const NupPageSettings &settings)
CPDF_NPageToOneExporter(CPDF_Document *dest_doc, CPDF_Document *src_doc)
std::unique_ptr< XObjectContext > CreateXObjectContextFromPage(int src_page_index)
virtual CPDF_Stream * AsMutableStream()
const CPDF_Stream * AsStream() const
static bool CopyInheritable(RetainPtr< CPDF_Dictionary > dest_page_dict, RetainPtr< const CPDF_Dictionary > src_page_dict, const ByteString &key)
CPDF_Document * dest()
const CPDF_Document * dest() const
static RetainPtr< const CPDF_Object > PageDictGetInheritableTag(RetainPtr< const CPDF_Dictionary > dict, const ByteString &src_tag)
CPDF_PageOrganizer(CPDF_Document *dest_doc, CPDF_Document *src_doc)
const CPDF_Document * src() const
CPDF_Document * src()
bool UpdateReference(RetainPtr< CPDF_Object > obj)
void AddObjectMapping(uint32_t old_page_obj_num, uint32_t new_page_obj_num)
RenderContextClearer(CPDF_Page *pPage)
virtual ~RenderContextIface()=default
virtual void ClearPage(CPDF_Page *pPage)=0
RetainPtr< const CPDF_Array > GetAnnotsArray() const
RetainPtr< CPDF_Array > GetOrCreateAnnotsArray()
CPDF_Document * GetDocument() const override
Definition cpdf_page.cpp:51
float GetPageHeight() const override
Definition cpdf_page.cpp:59
void UpdateDimensions()
std::optional< CFX_PointF > DeviceToPage(const FX_RECT &rect, int rotate, const CFX_PointF &device_point) const override
~CPDF_Page() override
bool IsPage() const override
Definition cpdf_page.cpp:63
float GetPageWidth() const override
Definition cpdf_page.cpp:55
CPDFXFA_Page * AsXFAPage() override
Definition cpdf_page.cpp:47
const CFX_Matrix & GetPageMatrix() const
Definition cpdf_page.h:75
RenderContextIface * GetRenderContext()
Definition cpdf_page.h:84
void ParseContent()
Definition cpdf_page.cpp:67
const CFX_SizeF & GetPageSize() const
Definition cpdf_page.h:74
void SetView(View *pView)
Definition cpdf_page.h:92
RetainPtr< CPDF_Array > GetMutableAnnotsArray()
void ClearView()
void SetRenderContext(std::unique_ptr< RenderContextIface > pContext)
CPDF_Page * AsPDFPage() override
Definition cpdf_page.cpp:43
void AddPageImageCache()
std::optional< CFX_PointF > PageToDevice(const FX_RECT &rect, int rotate, const CFX_PointF &page_point) const override
CFX_Matrix GetDisplayMatrix(const FX_RECT &rect, int iRotate) const override
int GetPageRotation() const
CPDF_PageImageCache * GetPageImageCache()
Definition cpdf_page.h:83
void ClearRenderContext()
bool HasFilter() const
static constexpr int kFileBufSize
Definition cpdf_stream.h:25
bool IsMemoryBased() const
Definition cpdf_stream.h:62
void TakeData(DataVector< uint8_t > data)
RetainPtr< CPDF_Object > Clone() const override
~CPDF_Stream() override
size_t GetRawSize() const
CPDF_Stream * AsMutableStream() override
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
bool IsFileBased() const
Definition cpdf_stream.h:59
void SetDataFromStringstreamAndRemoveFilter(fxcrt::ostringstream *stream)
Type GetType() const override
void SetDataAndRemoveFilter(pdfium::span< const uint8_t > pData)
void SetDataFromStringstream(fxcrt::ostringstream *stream)
DataVector< uint8_t > ReadAllRawData() const
void SetData(pdfium::span< const uint8_t > pData)
pdfium::span< const uint8_t > GetInMemoryRawData() const
RetainPtr< CPDF_Object > CloneNonCyclic(bool bDirect, std::set< const CPDF_Object * > *pVisited) const override
WideString GetUnicodeText() const override
const CPDF_Dictionary * GetDictInternal() const override
void InitStreamFromFile(RetainPtr< IFX_SeekableReadStream > file)
static ByteString Format(const char *pFormat,...)
ByteString & operator+=(const char *str)
const CPDF_Stream * ToStream(const CPDF_Object *obj)
RetainPtr< CPDF_Stream > ToStream(RetainPtr< CPDF_Object > obj)
CPDF_Stream * ToStream(CPDF_Object *obj)
CFX_PTemplate< float > CFX_PointF
CFX_STemplate< float > CFX_SizeF
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
const char kMediaBox[]
const char kContents[]
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:222
fxcrt::ByteStringView ByteStringView
UnownedPtr< CPDF_Document > dest_doc
RetainPtr< CPDF_Stream > xobject
fxcrt::WideString WideString
Definition widestring.h:207