7#include "xfa/fxfa/cxfa_ffwidget.h"
13#include "core/fxcodec/fx_codec.h"
14#include "core/fxcodec/progressive_decoder.h"
15#include "core/fxcrt/check.h"
16#include "core/fxcrt/maybe_owned.h"
17#include "core/fxge/cfx_fillrenderoptions.h"
18#include "core/fxge/cfx_path.h"
19#include "core/fxge/cfx_renderdevice.h"
20#include "core/fxge/dib/cfx_dibitmap.h"
21#include "xfa/fgas/graphics/cfgas_gegraphics.h"
22#include "xfa/fwl/fwl_widgethit.h"
23#include "xfa/fxfa/cxfa_eventparam.h"
24#include "xfa/fxfa/cxfa_ffapp.h"
25#include "xfa/fxfa/cxfa_ffdoc.h"
26#include "xfa/fxfa/cxfa_ffdocview.h"
27#include "xfa/fxfa/cxfa_ffpageview.h"
28#include "xfa/fxfa/cxfa_ffwidgethandler.h"
29#include "xfa/fxfa/cxfa_imagerenderer.h"
30#include "xfa/fxfa/layout/cxfa_layoutprocessor.h"
31#include "xfa/fxfa/parser/cxfa_border.h"
32#include "xfa/fxfa/parser/cxfa_box.h"
33#include "xfa/fxfa/parser/cxfa_edge.h"
34#include "xfa/fxfa/parser/cxfa_image.h"
35#include "xfa/fxfa/parser/cxfa_margin.h"
36#include "xfa/fxfa/parser/cxfa_node.h"
50 if (bitmap->GetBuffer().empty()) {
55 XFA_UnitPx2Pt(bitmap->GetWidth(), dpi.width),
56 XFA_UnitPx2Pt(bitmap->GetHeight(), dpi.height));
61 f1 =
std::min(f1, f2);
121 FXCODEC_IMAGE_TYPE type,
123 int32_t& iImageYDpi) {
126 CFX_DIBAttribute dibAttr;
127 pProgressiveDecoder->LoadImageInfo(
std::move(pImageFileRead), type, &dibAttr,
129 switch (dibAttr.m_wDPIUnit) {
130 case CFX_DIBAttribute::kResUnitCentimeter:
131 dibAttr.m_nXDPI =
static_cast<int32_t>(dibAttr.m_nXDPI * 2.54f);
132 dibAttr.m_nYDPI =
static_cast<int32_t>(dibAttr.m_nYDPI * 2.54f);
134 case CFX_DIBAttribute::kResUnitMeter:
136 static_cast<int32_t>(dibAttr.m_nXDPI / (
float)100 * 2.54f);
138 static_cast<int32_t>(dibAttr.m_nYDPI / (
float)100 * 2.54f);
143 iImageXDpi = dibAttr.m_nXDPI > 1 ? dibAttr.m_nXDPI : (96);
144 iImageYDpi = dibAttr.m_nYDPI > 1 ? dibAttr.m_nYDPI : (96);
145 if (pProgressiveDecoder->GetWidth() <= 0 ||
146 pProgressiveDecoder->GetHeight() <= 0) {
150 RetainPtr<CFX_DIBitmap> pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
151 if (!pBitmap->Create(pProgressiveDecoder->GetWidth(),
152 pProgressiveDecoder->GetHeight(),
153 pProgressiveDecoder->GetBitmapFormat())) {
157 pBitmap->Clear(0xffffffff);
159 auto [status, nFrames] = pProgressiveDecoder->GetFrames();
160 if (status != FXCODEC_STATUS::kDecodeReady || nFrames == 0) {
164 status = pProgressiveDecoder->StartDecode(pBitmap);
165 if (status == FXCODEC_STATUS::kError) {
169 while (status == FXCODEC_STATUS::kDecodeToBeContinued) {
170 status = pProgressiveDecoder->ContinueDecode();
171 if (status == FXCODEC_STATUS::kError) {
200 visitor->Trace(m_pLayoutItem);
201 visitor->Trace(m_pDocView);
202 visitor->Trace(m_pPageView);
203 visitor->Trace(m_pNode);
229 switch (m_pNode->GetRotate()) {
261 if (focus == kDrawFocus || !m_pPageView)
263 return m_pPageView->GetPageViewRect();
272 CXFA_Border* border = m_pNode->GetBorderIfExists();
284 return !!m_pPageView;
304 CXFA_FFWidgetHandler* pHandler) {
310 CXFA_FFWidgetHandler* pHandler) {
338 m_pDocView->InvalidateRect(m_pPageView.Get(), rtWidget);
406 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Enter, &eParam);
500 return FormFieldType::kXFA;
512 int32_t iRotate = m_pNode->GetRotate();
552 DCHECK(GetNode()->IsWidgetReady());
557 CXFA_Edge* edge = borderUI->GetEdgeIfExists(0);
571 CXFA_Node* pParentNode = m_pNode->GetParent();
585 if (pChildNode == m_pNode)
588 pChildNode = pChildNode->GetParent();
598 return m_pDocView->GetDoc();
620 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Exit, &eParam);
CFX_RenderDevice * GetRenderDevice()
constexpr CFX_Matrix()=default
CFX_PointF Transform(const CFX_PointF &point) const
CFX_Matrix GetInverse() const
constexpr CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void Concat(const CFX_Matrix &right)
void AppendRect(float left, float bottom, float right, float top)
constexpr CFX_RectF()=default
void Deflate(float off_left, float off_top, float off_right, float off_bottom)
void Inflate(float x, float y)
CFX_RectF & operator=(const CFX_RectF &other)=default
bool Contains(const PointType &p) const
StateRestorer(CFX_RenderDevice *pDevice)
bool SetClip_PathFill(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_FillRenderOptions &fill_options)
void Draw(CFGAS_GEGraphics *pGS, const CFX_RectF &rtWidget, const CFX_Matrix &matrix, bool forceRound)
void SetStatusBits(Mask< XFA_WidgetStatus > val)
CXFA_ContentLayoutItem * GetNext() const
CFX_RectF GetAbsoluteRect() const
bool TestStatusBits(Mask< XFA_WidgetStatus > val) const
void ClearStatusBits(Mask< XFA_WidgetStatus > val)
CXFA_EventParam(XFA_EVENTTYPE type)
CallbackIface * GetAppProvider() const
CFWL_App * GetFWLApp() const
CXFA_FFDoc * GetDoc() const
CXFA_LayoutProcessor * GetLayoutProcessor() const
void DisplayCaret(CXFA_FFWidget *hWidget, bool bVisible, const CFX_RectF *pRtAnchor)
CXFA_FFApp * GetApp() const
CXFA_FFDocView * GetDocView() const
CXFA_Node * GetFormNode() const
CXFA_LayoutItem * GetLayoutItem(CXFA_Node *pFormItem)
float GetBottomInset() const
float GetLeftInset() const
float GetTopInset() const
float GetRightInset() const
bool IsWidgetReady() const
CXFA_Border * GetUIBorder()
CXFA_Margin * GetMarginIfExists() const
bool HasCreatedUIWidget() const
float GetThickness() const
CXFA_FFWidget * GetFFWidget(CXFA_ContentLayoutItem *item)
CXFA_ContentLayoutItem * ToContentLayoutItem(CXFA_LayoutItem *item)
CFX_VTemplate< int32_t > CFX_Vector
CFX_PTemplate< float > CFX_PointF
CFX_STemplate< int32_t > CFX_Size
fxcodec::ProgressiveDecoder ProgressiveDecoder
static constexpr CFX_FillRenderOptions WindingOptions()
fxcrt::WideString WideString