7#include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
12#include "core/fpdfapi/page/cpdf_page.h"
13#include "core/fpdfapi/page/cpdf_pageimagecache.h"
14#include "core/fpdfapi/parser/cpdf_document.h"
15#include "fpdfsdk/cpdfsdk_pageview.h"
16#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
17#include "fpdfsdk/fpdfxfa/cpdfxfa_widget.h"
18#include "third_party/base/check.h"
19#include "xfa/fgas/graphics/cfgas_gegraphics.h"
20#include "xfa/fxfa/cxfa_ffdocview.h"
21#include "xfa/fxfa/cxfa_ffpageview.h"
22#include "xfa/fxfa/cxfa_ffwidget.h"
23#include "xfa/fxfa/cxfa_ffwidgethandler.h"
28 XFA_WidgetStatus::kVisible,
29 XFA_WidgetStatus::kViewable,
30 XFA_WidgetStatus::kFocused,
34 CXFA_FFPageView* pFFPageView,
35 CPDFSDK_PageView* pPageView) {
39 ObservedPtr<CPDFSDK_PageView> pWatchedPageView(pPageView);
44 return pWatchedPageView ? pIterator :
nullptr;
48 CXFA_FFPageView* pFFPageView,
68 return pWidgetIterator;
73CPDFXFA_Page::CPDFXFA_Page(
CPDF_Document* pDocument,
int page_index)
74 : m_pDocument(pDocument), m_iPageIndex(page_index) {
75 DCHECK(m_pDocument->GetExtension());
76 DCHECK(m_iPageIndex >= 0);
82 return m_pPDFPage.Get();
93bool CPDFXFA_Page::LoadPDFPage() {
95 GetDocument()->GetMutablePageDictionary(m_iPageIndex);
99 if (!m_pPDFPage || m_pPDFPage->GetDict() != pDict)
106 auto* pContext =
static_cast<CPDFXFA_Context*>(m_pDocument->GetExtension());
112 auto* pContext =
static_cast<CPDFXFA_Context*>(m_pDocument->GetExtension());
113 switch (pContext->GetFormType()) {
117 return LoadPDFPage();
126 pdfium::MakeRetain<CPDF_Page>(GetDocument(), std::move(pPageDict));
127 m_pPDFPage->AddPageImageCache();
128 m_pPDFPage->ParseContent();
133 if (!m_pPDFPage && !pPageView)
136 auto* pContext =
static_cast<CPDFXFA_Context*>(m_pDocument->GetExtension());
137 switch (pContext->GetFormType()) {
138 case FormType::kNone:
139 case FormType::kAcroForm:
140 case FormType::kXFAForeground:
142 return m_pPDFPage->GetPageWidth();
155 if (!m_pPDFPage && !pPageView)
158 auto* pContext =
static_cast<CPDFXFA_Context*>(m_pDocument->GetExtension());
159 switch (pContext->GetFormType()) {
160 case FormType::kNone:
161 case FormType::kAcroForm:
162 case FormType::kXFAForeground:
164 return m_pPDFPage->GetPageHeight();
178 const CFX_PointF& device_point)
const {
180 if (!m_pPDFPage && !pPageView)
181 return absl::nullopt;
190 const CFX_PointF& page_point)
const {
192 if (!m_pPDFPage && !pPageView)
193 return absl::nullopt;
202 if (!m_pPDFPage && !pPageView)
205 auto* pContext =
static_cast<CPDFXFA_Context*>(m_pDocument->GetExtension());
206 switch (pContext->GetFormType()) {
207 case FormType::kNone:
208 case FormType::kAcroForm:
209 case FormType::kXFAForeground:
211 return m_pPDFPage->GetDisplayMatrix(rect, iRotate);
225 if (!pWidgetIterator)
235 if (!pWidgetIterator)
243 CPDFSDK_PageView* page_view)
const {
246 if (!pWidgetIterator)
253 CPDFSDK_PageView* page_view)
const {
256 if (!pWidgetIterator)
259 return page_view->GetAnnotForFFWidget(pWidgetIterator
->MoveToLast());
274 CXFA_FFPageWidgetIterator pWidgetIterator(pPageView,
278 while ((pXFAAnnot = pWidgetIterator
.MoveToNext()) !=
nullptr) {
279 if (pXFAAnnot->GetFormFieldType() == FormFieldType::kXFA)
300 CXFA_FFPageWidgetIterator pWidgetIterator(
325 mtUser2Device
, false);
CFGAS_GEGraphics(CFX_RenderDevice *renderDevice)
void SetClipRect(const CFX_RectF &rect)
bool Contains(const CFX_PointF &point) const
void Inflate(float x, float y)
CFX_PointF Transform(const CFX_PointF &point) const
CFX_Matrix GetInverse() const
CFX_FloatRect ToFloatRect() const
bool IntersectWith(const CFX_RectF &rt) const
CFX_RectF(const FX_RECT &that)
CPDFSDK_PageView * GetPageView() const
absl::optional< CFX_PointF > PageToDevice(const FX_RECT &rect, int rotate, const CFX_PointF &page_point) const override
CXFA_FFPageView * GetXFAPageView() const
CPDF_Document * GetDocument() const override
CFX_Matrix GetDisplayMatrix(const FX_RECT &rect, int iRotate) const override
CPDFXFA_Page * AsXFAPage() override
CPDF_Page * AsPDFPage() override
float GetPageWidth() const override
CPDFSDK_Annot * GetLastXFAAnnot(CPDFSDK_PageView *page_view) const
CPDFSDK_Annot * GetPrevXFAAnnot(CPDFSDK_Annot *pSDKAnnot) const
CPDFSDK_Annot * GetFirstXFAAnnot(CPDFSDK_PageView *page_view) const
CPDFSDK_Annot * GetNextXFAAnnot(CPDFSDK_Annot *pSDKAnnot) const
absl::optional< CFX_PointF > DeviceToPage(const FX_RECT &rect, int rotate, const CFX_PointF &device_point) const override
void DrawFocusAnnot(CFX_RenderDevice *pDevice, CPDFSDK_Annot *pAnnot, const CFX_Matrix &mtUser2Device, const FX_RECT &rtClip)
int HasFormFieldAtPoint(const CFX_PointF &point) const
float GetPageHeight() const override
void LoadPDFPageFromDict(RetainPtr< CPDF_Dictionary > pPageDict)
CXFA_FFWidgetHandler * GetWidgetHandler()
CXFA_FFPageView * GetPageView(int32_t nIndex) const
CXFA_FFDocView * GetDocView() const
CFX_Matrix GetDisplayMatrix(const FX_RECT &rtDisp, int32_t iRotate) const
CXFA_FFWidget::IteratorIface * CreateGCedTraverseWidgetIterator(Mask< XFA_WidgetStatus > dwWidgetFilter)
CFX_RectF GetPageViewRect() const
CXFA_FFWidget * MoveToNext() override
CPDFXFA_Widget * ToXFAWidget(CPDFSDK_Annot *pAnnot)