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
cxfa_ffimage.cpp
Go to the documentation of this file.
1// Copyright 2014 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#include "xfa/fxfa/cxfa_ffimage.h"
8
9#include <utility>
10
11#include "core/fxge/dib/cfx_dibitmap.h"
12#include "xfa/fxfa/cxfa_ffapp.h"
13#include "xfa/fxfa/cxfa_ffdoc.h"
14#include "xfa/fxfa/cxfa_ffpageview.h"
15#include "xfa/fxfa/cxfa_ffwidget.h"
16#include "xfa/fxfa/parser/cxfa_image.h"
17#include "xfa/fxfa/parser/cxfa_para.h"
18#include "xfa/fxfa/parser/cxfa_value.h"
19
20CXFA_FFImage::CXFA_FFImage(CXFA_Node* pNode) : CXFA_FFWidget(pNode) {}
21
22CXFA_FFImage::~CXFA_FFImage() = default;
23
24void CXFA_FFImage::PreFinalize() {
25 GetNode()->SetLayoutImage(nullptr);
26}
27
28bool CXFA_FFImage::IsLoaded() {
29 return !!GetNode()->GetLayoutImage();
30}
31
32bool CXFA_FFImage::LoadWidget() {
33 if (GetNode()->GetLayoutImage())
34 return true;
35
36 return GetNode()->LoadLayoutImage(GetDoc()) && CXFA_FFWidget::LoadWidget();
37}
38
39void CXFA_FFImage::RenderWidget(CFGAS_GEGraphics* pGS,
40 const CFX_Matrix& matrix,
41 HighlightOption highlight) {
42 if (!HasVisibleStatus())
43 return;
44
45 CFX_Matrix mtRotate = GetRotateMatrix();
46 mtRotate.Concat(matrix);
47
48 CXFA_FFWidget::RenderWidget(pGS, mtRotate, highlight);
49
50 RetainPtr<CFX_DIBitmap> pDIBitmap = GetNode()->GetLayoutImage();
51 if (!pDIBitmap)
52 return;
53
55 CXFA_Margin* margin = m_pNode->GetMarginIfExists();
56 XFA_RectWithoutMargin(&rtImage, margin);
57
58 XFA_AttributeValue iHorzAlign = XFA_AttributeValue::Left;
59 XFA_AttributeValue iVertAlign = XFA_AttributeValue::Top;
60 CXFA_Para* para = m_pNode->GetParaIfExists();
61 if (para) {
62 iHorzAlign = para->GetHorizontalAlign();
63 iVertAlign = para->GetVerticalAlign();
64 }
65
66 auto* value = m_pNode->GetFormValueIfExists();
67 if (!value)
68 return;
69
70 CXFA_Image* image = value->GetImageIfExists();
71 if (!image)
72 return;
73
74 XFA_DrawImage(pGS, rtImage, mtRotate, std::move(pDIBitmap),
75 image->GetAspect(), m_pNode->GetLayoutImageDpi(), iHorzAlign,
76 iVertAlign);
77}
void Concat(const CFX_Matrix &right)
bool IsLoaded() override
void RenderWidget(CFGAS_GEGraphics *pGS, const CFX_Matrix &matrix, HighlightOption highlight) override
bool LoadWidget() override
~CXFA_FFImage() override
CFX_Matrix GetRotateMatrix() override
virtual void RenderWidget(CFGAS_GEGraphics *pGS, const CFX_Matrix &matrix, HighlightOption highlight)
CXFA_FFWidget(CXFA_Node *pNode)
bool HasVisibleStatus() const
CXFA_Node * GetNode() const
virtual bool LoadWidget()
CXFA_FFDoc * GetDoc()
CFX_RectF GetRectWithoutRotate()
XFA_AttributeValue GetHorizontalAlign()
Definition cxfa_para.cpp:57
XFA_AttributeValue GetVerticalAlign()
Definition cxfa_para.cpp:63
void XFA_RectWithoutMargin(CFX_RectF *rt, const CXFA_Margin *margin)
XFA_AttributeValue
Definition fxfa_basic.h:60