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_contentlayoutitem.cpp
Go to the documentation of this file.
1
// Copyright 2016 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/layout/cxfa_contentlayoutitem.h"
8
9
#
include
"core/fxcrt/check_op.h"
10
#
include
"fxjs/xfa/cjx_object.h"
11
#
include
"xfa/fxfa/cxfa_ffwidget.h"
12
#
include
"xfa/fxfa/parser/cxfa_margin.h"
13
#
include
"xfa/fxfa/parser/cxfa_node.h"
14
15
CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(
CXFA_Node
* pNode,
16
CXFA_FFWidget
* pWidget)
17
:
CXFA_LayoutItem
(
pNode
,
kContentItem
)
, m_pFFWidget(pWidget) {
18
if
(m_pFFWidget)
19
m_pFFWidget->SetLayoutItem(
this
);
20
}
21
22
CXFA_ContentLayoutItem::~
CXFA_ContentLayoutItem
() =
default
;
23
24
void
CXFA_ContentLayoutItem::
Trace
(
cppgc
::Visitor* visitor)
const
{
25
CXFA_LayoutItem::Trace(visitor);
26
visitor->Trace(m_pPrev);
27
visitor->Trace(m_pNext);
28
visitor->Trace(m_pFFWidget);
29
}
30
31
CXFA_ContentLayoutItem* CXFA_ContentLayoutItem::
GetFirst
() {
32
CXFA_ContentLayoutItem* pCurNode =
this
;
33
while
(
auto
* pPrev = pCurNode
->
GetPrev
(
)
)
34
pCurNode = pPrev;
35
36
return
pCurNode;
37
}
38
39
CXFA_ContentLayoutItem* CXFA_ContentLayoutItem::
GetLast
() {
40
CXFA_ContentLayoutItem* pCurNode =
this
;
41
while
(
auto
* pNext = pCurNode
->
GetNext
(
)
)
42
pCurNode = pNext;
43
44
return
pCurNode;
45
}
46
47
void
CXFA_ContentLayoutItem::
InsertAfter
(CXFA_ContentLayoutItem* pItem) {
48
CHECK_NE
(
this
, pItem);
49
pItem->RemoveSelf();
50
pItem->m_pNext = m_pNext;
51
pItem->m_pPrev =
this
;
52
m_pNext = pItem;
53
if
(pItem->m_pNext)
54
pItem->m_pNext->m_pPrev = pItem;
55
}
56
57
void
CXFA_ContentLayoutItem::RemoveSelf() {
58
if
(m_pNext)
59
m_pNext->m_pPrev = m_pPrev;
60
if
(m_pPrev)
61
m_pPrev->m_pNext = m_pNext;
62
}
63
64
CFX_RectF
CXFA_ContentLayoutItem::
GetRelativeRect
()
const
{
65
return
CFX_RectF(m_sPos, m_sSize);
66
}
67
68
CFX_RectF
CXFA_ContentLayoutItem::
GetAbsoluteRect
()
const
{
69
CFX_PointF
sPos = m_sPos;
70
CFX_SizeF
sSize = m_sSize;
71
72
for
(
CXFA_LayoutItem
* pLayoutItem = GetParent(); pLayoutItem;
73
pLayoutItem = pLayoutItem->GetParent()) {
74
if
(CXFA_ContentLayoutItem* pContent = pLayoutItem
->
AsContentLayoutItem
(
)
) {
75
sPos += pContent->m_sPos;
76
CXFA_Margin* pMarginNode =
77
pContent
->
GetFormNode
()->GetFirstChildByClass<CXFA_Margin>(
78
XFA_Element
::Margin);
79
if
(pMarginNode) {
80
sPos +=
CFX_PointF
(pMarginNode->JSObject()->GetMeasureInUnit(
81
XFA_Attribute
::LeftInset,
XFA_Unit
::
Pt
),
82
pMarginNode->JSObject()->GetMeasureInUnit(
83
XFA_Attribute
::TopInset,
XFA_Unit
::
Pt
));
84
}
85
continue
;
86
}
87
88
if
(pLayoutItem
->
GetFormNode
(
)
->
GetElementType
() ==
89
XFA_Element
::ContentArea) {
90
sPos +=
91
CFX_PointF
(pLayoutItem
->
GetFormNode
(
)
->JSObject()->GetMeasureInUnit(
92
XFA_Attribute
::X,
XFA_Unit
::
Pt
),
93
pLayoutItem
->
GetFormNode
(
)
->JSObject()->GetMeasureInUnit(
94
XFA_Attribute
::Y,
XFA_Unit
::
Pt
));
95
break
;
96
}
97
if
(pLayoutItem
->
GetFormNode
(
)
->
GetElementType
() ==
XFA_Element
::PageArea)
98
break
;
99
}
100
return
CFX_RectF
(sPos, sSize);
101
}
102
103
size_t
CXFA_ContentLayoutItem::
GetIndex
()
const
{
104
size_t szIndex = 0;
105
const
CXFA_ContentLayoutItem* pCurNode =
this
;
106
while
(
auto
* pPrev = pCurNode
->
GetPrev
(
)
) {
107
pCurNode = pPrev;
108
++szIndex;
109
}
110
return
szIndex;
111
}
CHECK_NE
#define CHECK_NE(x, y)
Definition
check_op.h:11
CFX_RectF
Definition
fx_coordinates.h:276
CXFA_ContentLayoutItem::InsertAfter
void InsertAfter(CXFA_ContentLayoutItem *pNext)
Definition
cxfa_contentlayoutitem.cpp:47
CXFA_ContentLayoutItem::GetPrev
CXFA_ContentLayoutItem * GetPrev() const
Definition
cxfa_contentlayoutitem.h:29
CXFA_ContentLayoutItem::GetNext
CXFA_ContentLayoutItem * GetNext() const
Definition
cxfa_contentlayoutitem.h:30
CXFA_ContentLayoutItem::GetAbsoluteRect
CFX_RectF GetAbsoluteRect() const
Definition
cxfa_contentlayoutitem.cpp:68
CXFA_ContentLayoutItem::GetRelativeRect
CFX_RectF GetRelativeRect() const
Definition
cxfa_contentlayoutitem.cpp:64
CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem
~CXFA_ContentLayoutItem() override
CXFA_ContentLayoutItem::GetLast
CXFA_ContentLayoutItem * GetLast()
Definition
cxfa_contentlayoutitem.cpp:39
CXFA_ContentLayoutItem::GetIndex
size_t GetIndex() const
Definition
cxfa_contentlayoutitem.cpp:103
CXFA_ContentLayoutItem::Trace
void Trace(cppgc::Visitor *visitor) const override
Definition
cxfa_contentlayoutitem.cpp:24
CXFA_ContentLayoutItem::GetFirst
CXFA_ContentLayoutItem * GetFirst()
Definition
cxfa_contentlayoutitem.cpp:31
CXFA_FFWidget
Definition
cxfa_ffwidget.h:69
CXFA_LayoutItem
Definition
cxfa_layoutitem.h:20
CXFA_LayoutItem::AsContentLayoutItem
CXFA_ContentLayoutItem * AsContentLayoutItem()
Definition
cxfa_layoutitem.cpp:64
CXFA_LayoutItem::GetFormNode
CXFA_Node * GetFormNode() const
Definition
cxfa_layoutitem.h:40
CXFA_LayoutItem::CXFA_LayoutItem
CXFA_LayoutItem(CXFA_Node *pNode, ItemType type)
Definition
cxfa_layoutitem.cpp:36
CXFA_LayoutItem::kContentItem
@ kContentItem
Definition
cxfa_layoutitem.h:44
CXFA_Node
Definition
cxfa_node.h:94
CXFA_Object::GetElementType
XFA_Element GetElementType() const
Definition
cxfa_object.h:91
CFX_PointF
CFX_PTemplate< float > CFX_PointF
Definition
fx_coordinates.h:51
CFX_SizeF
CFX_STemplate< float > CFX_SizeF
Definition
fx_coordinates.h:115
XFA_Unit
XFA_Unit
Definition
fxfa_basic.h:91
XFA_Unit::Pt
@ Pt
Definition
fxfa_basic.h:94
XFA_Attribute
XFA_Attribute
Definition
fxfa_basic.h:67
XFA_Element
XFA_Element
Definition
fxfa_basic.h:75
cppgc
Definition
heap.h:12
qtwebengine
src
3rdparty
chromium
third_party
pdfium
xfa
fxfa
layout
cxfa_contentlayoutitem.cpp
Generated on
for Qt by
1.18.0