Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cxfa_ffline.cpp
Go to the documentation of this file.
1
// Copyright 2017 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_ffline.h"
8
9
#
include
"core/fxcrt/notreached.h"
10
#
include
"xfa/fgas/graphics/cfgas_gecolor.h"
11
#
include
"xfa/fgas/graphics/cfgas_gegraphics.h"
12
#
include
"xfa/fgas/graphics/cfgas_gepath.h"
13
#
include
"xfa/fxfa/parser/cxfa_edge.h"
14
#
include
"xfa/fxfa/parser/cxfa_line.h"
15
#
include
"xfa/fxfa/parser/cxfa_value.h"
16
17
namespace
{
18
19
CFX_GraphStateData
::
LineCap
LineCapToFXGE(
XFA_AttributeValue
iLineCap) {
20
switch
(iLineCap) {
21
case
XFA_AttributeValue
::Round:
22
return
CFX_GraphStateData
::
LineCap
::
kRound
;
23
case
XFA_AttributeValue
::Butt:
24
return
CFX_GraphStateData
::
LineCap
::
kButt
;
25
default
:
26
return
CFX_GraphStateData
::
LineCap
::
kSquare
;
27
}
28
}
29
30
}
// namespace
31
32
CXFA_FFLine::CXFA_FFLine(
CXFA_Node
* pNode) :
CXFA_FFWidget
(
pNode
)
{}
33
34
CXFA_FFLine::~
CXFA_FFLine
() =
default
;
35
36
void
CXFA_FFLine::GetRectFromHand(
CFX_RectF
& rect,
37
XFA_AttributeValue
iHand,
38
float
fLineWidth) {
39
float
fHalfWidth = fLineWidth / 2.0f;
40
if
(rect
.
height
< 1.0f) {
41
switch
(iHand) {
42
case
XFA_AttributeValue
::Left:
43
rect
.
top
-= fHalfWidth;
44
break
;
45
case
XFA_AttributeValue
::Right:
46
rect
.
top
+= fHalfWidth;
47
break
;
48
case
XFA_AttributeValue
::Even:
49
break
;
50
default
:
51
NOTREACHED_NORETURN
();
52
}
53
}
else
if
(rect
.
width
< 1.0f) {
54
switch
(iHand) {
55
case
XFA_AttributeValue
::Left:
56
rect
.
left
+= fHalfWidth;
57
break
;
58
case
XFA_AttributeValue
::Right:
59
rect
.
left
+= fHalfWidth;
60
break
;
61
case
XFA_AttributeValue
::Even:
62
break
;
63
default
:
64
NOTREACHED_NORETURN
();
65
}
66
}
else
{
67
switch
(iHand) {
68
case
XFA_AttributeValue
::Left:
69
rect
.
Inflate
(
fHalfWidth
,
fHalfWidth
)
;
70
break
;
71
case
XFA_AttributeValue
::Right:
72
rect
.
Deflate
(
fHalfWidth
,
fHalfWidth
)
;
73
break
;
74
case
XFA_AttributeValue
::Even:
75
break
;
76
default
:
77
NOTREACHED_NORETURN
();
78
}
79
}
80
}
81
82
void
CXFA_FFLine::
RenderWidget
(
CFGAS_GEGraphics
* pGS,
83
const
CFX_Matrix
& matrix,
84
HighlightOption
highlight) {
85
if
(!
HasVisibleStatus
())
86
return
;
87
88
CXFA_Value* value = m_pNode->GetFormValueIfExists();
89
if
(!value)
90
return
;
91
92
FX_ARGB
lineColor = 0xFF000000;
93
float
fLineWidth = 1.0f;
94
XFA_AttributeValue
iStrokeType =
XFA_AttributeValue
::Unknown;
95
XFA_AttributeValue
iCap =
XFA_AttributeValue
::Unknown;
96
CXFA_Line* line = value
->
GetLineIfExists
(
)
;
97
if
(line) {
98
CXFA_Edge* edge = line
->
GetEdgeIfExists
(
)
;
99
if
(edge && !edge
->
IsVisible
())
100
return
;
101
102
if
(edge) {
103
lineColor = edge
->
GetColor
();
104
iStrokeType = edge
->
GetStrokeType
();
105
fLineWidth = edge
->
GetThickness
();
106
iCap = edge
->
GetCapType
();
107
}
108
}
109
110
CFX_Matrix
mtRotate =
GetRotateMatrix
();
111
mtRotate
.
Concat
(
matrix
)
;
112
113
CFX_RectF
rtLine =
GetRectWithoutRotate
();
114
CXFA_Margin* margin = m_pNode->GetMarginIfExists();
115
XFA_RectWithoutMargin
(
&rtLine
,
margin
)
;
116
117
GetRectFromHand(rtLine, line ? line
->
GetHand
(
)
:
XFA_AttributeValue
::Left,
118
fLineWidth);
119
CFGAS_GEPath linePath;
120
if
(line && line
->
GetSlope
(
)
&& rtLine
.
right
(
)
> 0.0f &&
121
rtLine
.
bottom
(
)
> 0.0f) {
122
linePath
.
AddLine
(
rtLine.TopRight()
,
rtLine.BottomLeft()
)
;
123
}
else
{
124
linePath
.
AddLine
(
rtLine.TopLeft()
,
rtLine.BottomRight()
)
;
125
}
126
127
CFGAS_GEGraphics
::
StateRestorer
restorer
(
pGS
)
;
128
pGS
->
SetLineWidth
(
fLineWidth
)
;
129
pGS
->
EnableActOnDash
(
)
;
130
XFA_StrokeTypeSetLineDash
(
pGS
,
iStrokeType
,
iCap
)
;
131
132
pGS
->
SetStrokeColor
(
CFGAS_GEColor
(
lineColor
)
)
;
133
pGS
->
SetLineCap
(
LineCapToFXGE(iCap)
)
;
134
pGS
->
StrokePath
(
linePath
,
mtRotate
)
;
135
}
CFGAS_GEColor
Definition
cfgas_gecolor.h:19
CFGAS_GEColor::CFGAS_GEColor
CFGAS_GEColor(FX_ARGB argb)
Definition
cfgas_gecolor.cpp:9
CFGAS_GEGraphics::StateRestorer
Definition
cfgas_gegraphics.h:28
CFGAS_GEGraphics::StateRestorer::StateRestorer
StateRestorer(CFGAS_GEGraphics *graphics)
Definition
cfgas_gegraphics.cpp:421
CFGAS_GEGraphics
Definition
cfgas_gegraphics.h:26
CFGAS_GEGraphics::SetLineWidth
void SetLineWidth(float lineWidth)
Definition
cfgas_gegraphics.cpp:157
CFGAS_GEGraphics::SetStrokeColor
void SetStrokeColor(const CFGAS_GEColor &color)
Definition
cfgas_gegraphics.cpp:165
CFGAS_GEGraphics::SetLineCap
void SetLineCap(CFX_GraphStateData::LineCap lineCap)
Definition
cfgas_gegraphics.cpp:139
CFGAS_GEGraphics::StrokePath
void StrokePath(const CFGAS_GEPath &path, const CFX_Matrix &matrix)
Definition
cfgas_gegraphics.cpp:173
CFGAS_GEGraphics::EnableActOnDash
void EnableActOnDash()
Definition
cfgas_gegraphics.cpp:161
CFGAS_GEPath::AddLine
void AddLine(const CFX_PointF &p1, const CFX_PointF &p2)
Definition
cfgas_gepath.cpp:78
CFX_GraphStateData
Definition
cfx_graphstatedata.h:16
CFX_GraphStateData::LineCap
LineCap
Definition
cfx_graphstatedata.h:18
CFX_GraphStateData::LineCap::kRound
@ kRound
Definition
cfx_graphstatedata.h:18
CFX_GraphStateData::LineCap::kButt
@ kButt
Definition
cfx_graphstatedata.h:18
CFX_GraphStateData::LineCap::kSquare
@ kSquare
Definition
cfx_graphstatedata.h:18
CFX_Matrix
Definition
fx_coordinates.h:440
CFX_Matrix::Concat
void Concat(const CFX_Matrix &right)
Definition
fx_coordinates.h:480
CFX_RectF
Definition
fx_coordinates.h:276
CFX_RectF::width
float width
Definition
fx_coordinates.h:430
CFX_RectF::left
float left
Definition
fx_coordinates.h:428
CFX_RectF::height
float height
Definition
fx_coordinates.h:431
CFX_RectF::Inflate
void Inflate(float x, float y)
Definition
fx_coordinates.h:331
CFX_RectF::top
float top
Definition
fx_coordinates.h:429
CFX_RectF::bottom
float bottom() const
Definition
fx_coordinates.h:316
CFX_RectF::right
float right() const
Definition
fx_coordinates.h:315
CFX_RectF::Deflate
void Deflate(float x, float y)
Definition
fx_coordinates.h:350
CXFA_FFLine::~CXFA_FFLine
~CXFA_FFLine() override
CXFA_FFLine::RenderWidget
void RenderWidget(CFGAS_GEGraphics *pGS, const CFX_Matrix &matrix, HighlightOption highlight) override
Definition
cxfa_ffline.cpp:82
CXFA_FFWidget
Definition
cxfa_ffwidget.h:69
CXFA_FFWidget::GetRotateMatrix
CFX_Matrix GetRotateMatrix() override
Definition
cxfa_ffwidget.cpp:511
CXFA_FFWidget::CXFA_FFWidget
CXFA_FFWidget(CXFA_Node *pNode)
Definition
cxfa_ffwidget.cpp:195
CXFA_FFWidget::HasVisibleStatus
bool HasVisibleStatus() const
Definition
cxfa_ffwidget.cpp:609
CXFA_FFWidget::HighlightOption
HighlightOption
Definition
cxfa_ffwidget.h:72
CXFA_FFWidget::GetRectWithoutRotate
CFX_RectF GetRectWithoutRotate()
Definition
cxfa_ffwidget.cpp:226
CXFA_Line::GetEdgeIfExists
CXFA_Edge * GetEdgeIfExists()
Definition
cxfa_line.cpp:61
CXFA_Line::GetSlope
bool GetSlope()
Definition
cxfa_line.cpp:57
CXFA_Line::GetHand
XFA_AttributeValue GetHand()
Definition
cxfa_line.cpp:53
CXFA_Node
Definition
cxfa_node.h:94
CXFA_Stroke::GetColor
FX_ARGB GetColor() const
Definition
cxfa_stroke.cpp:114
CXFA_Stroke::GetCapType
XFA_AttributeValue GetCapType()
Definition
cxfa_stroke.cpp:94
CXFA_Stroke::IsVisible
bool IsVisible()
Definition
cxfa_stroke.cpp:87
CXFA_Stroke::GetThickness
float GetThickness() const
Definition
cxfa_stroke.cpp:102
CXFA_Stroke::GetStrokeType
XFA_AttributeValue GetStrokeType()
Definition
cxfa_stroke.cpp:98
CXFA_Value::GetLineIfExists
CXFA_Line * GetLineIfExists() const
Definition
cxfa_value.cpp:76
XFA_RectWithoutMargin
void XFA_RectWithoutMargin(CFX_RectF *rt, const CXFA_Margin *margin)
Definition
cxfa_ffwidget.cpp:179
XFA_StrokeTypeSetLineDash
void XFA_StrokeTypeSetLineDash(CFGAS_GEGraphics *pGraphics, XFA_AttributeValue iStrokeType, XFA_AttributeValue iCapType)
Definition
cxfa_stroke.cpp:23
FX_ARGB
uint32_t FX_ARGB
Definition
fx_dib.h:36
XFA_AttributeValue
XFA_AttributeValue
Definition
fxfa_basic.h:60
NOTREACHED_NORETURN
#define NOTREACHED_NORETURN()
Definition
notreached.h:22
qtwebengine
src
3rdparty
chromium
third_party
pdfium
xfa
fxfa
cxfa_ffline.cpp
Generated on
for Qt by
1.18.0