7#include "core/fpdfapi/page/cpdf_page.h"
12#include "constants/page_object.h"
13#include "core/fpdfapi/page/cpdf_contentparser.h"
14#include "core/fpdfapi/page/cpdf_pageimagecache.h"
15#include "core/fpdfapi/page/cpdf_pageobject.h"
16#include "core/fpdfapi/parser/cpdf_array.h"
17#include "core/fpdfapi/parser/cpdf_dictionary.h"
18#include "core/fpdfapi/parser/cpdf_object.h"
19#include "third_party/base/check.h"
20#include "third_party/base/check_op.h"
21#include "third_party/base/containers/contains.h"
27 m_pPDFDocument(pDocument) {
32 GetMutablePageAttr(pdfium::page_object::kResources);
33 m_pResources = pPageAttr ? pPageAttr->GetMutableDict() :
nullptr;
34 m_pPageResources = m_pResources;
52 return m_pPDFDocument;
56 return m_PageSize.width;
60 return m_PageSize.height;
71 if (GetParseState() == ParseState::kNotParsed)
72 StartParse(std::make_unique<CPDF_ContentParser>(
this));
79 return pdfium::WrapRetain(
const_cast<
CPDF_Object*>(GetPageAttr(name).Get()));
83 const ByteString& name)
const {
84 std::set<RetainPtr<
const CPDF_Dictionary>> visited;
85 RetainPtr<
const CPDF_Dictionary> pPageDict = GetDict();
86 while (pPageDict && !pdfium::Contains(visited, pPageDict)) {
91 visited.insert(pPageDict);
97CFX_FloatRect CPDF_Page::GetBox(
const ByteString& name)
const {
99 RetainPtr<
const CPDF_Array> pBox = ToArray(GetPageAttr(name));
101 box = pBox->GetRect();
110 const CFX_PointF& device_point)
const {
118 const CFX_PointF& page_point)
const {
124 if (m_PageSize.width == 0 || m_PageSize.height == 0)
174 CFX_Matrix matrix((x2 - x0) / m_PageSize.width, (y2 - y0) / m_PageSize.width,
175 (x1 - x0) / m_PageSize.height,
176 (y1 - y0) / m_PageSize.height, x0, y0);
177 return m_PageMatrix
* matrix;
182 GetPageAttr(pdfium::page_object::kRotate);
183 int rotate = pRotate ? (pRotate->GetInteger() / 90) % 4 : 0;
184 return (rotate < 0) ? (rotate + 4) : rotate;
188 return GetMutableDict()->GetOrCreateArrayFor(
"Annots");
192 return GetMutableDict()->GetMutableArrayFor(
"Annots");
196 return GetDict()->GetArrayFor(
"Annots");
200 m_pPageImageCache = std::make_unique<CPDF_PageImageCache>(
this);
204 DCHECK(!m_pRenderContext);
206 m_pRenderContext = std::move(pContext);
210 m_pRenderContext.reset();
215 m_pView->ClearPage(
this);
229 m_PageSize.width = m_BBox.Width();
230 m_PageSize.height = m_BBox.Height();
237 std::swap(m_PageSize.width, m_PageSize.height);
245 std::swap(m_PageSize.width, m_PageSize.height);
256 m_pPage->ClearRenderContext();
constexpr CFX_FloatRect(float l, float b, float r, float t)
void Intersect(const CFX_FloatRect &other_rect)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
CFX_Matrix & operator=(const CFX_Matrix &other)=default
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
CFX_Matrix operator*(const CFX_Matrix &right) const
CFX_PointF Transform(const CFX_PointF &point) const
CFX_Matrix GetInverse() const
void LoadTransparencyInfo()
ParseState GetParseState() const
void ContinueParse(PauseIndicatorIface *pPause)
CPDF_Transparency m_Transparency
RenderContextClearer(CPDF_Page *pPage)
RetainPtr< const CPDF_Array > GetAnnotsArray() const
RetainPtr< CPDF_Array > GetOrCreateAnnotsArray()
absl::optional< CFX_PointF > DeviceToPage(const FX_RECT &rect, int rotate, const CFX_PointF &device_point) const override
CPDF_Document * GetDocument() const override
float GetPageHeight() const override
bool IsPage() const override
float GetPageWidth() const override
CPDFXFA_Page * AsXFAPage() override
RetainPtr< CPDF_Array > GetMutableAnnotsArray()
absl::optional< CFX_PointF > PageToDevice(const FX_RECT &rect, int rotate, const CFX_PointF &page_point) const override
void SetRenderContext(std::unique_ptr< RenderContextIface > pContext)
CPDF_Page * AsPDFPage() override
CFX_Matrix GetDisplayMatrix(const FX_RECT &rect, int iRotate) const override
int GetPageRotation() const
void ClearRenderContext()