Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: xfa/fxfa/parser/cxfa_box.cpp

Issue 1861353002: Split fxfa_objectacc.h into pieces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/cxfa_box.h ('k') | xfa/fxfa/parser/cxfa_calculate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
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/parser/cxfa_box.h"
8
9 #include "xfa/fxfa/parser/cxfa_corner.h"
10 #include "xfa/fxfa/parser/xfa_object.h"
11
12 namespace {
13
14 void GetStrokesInternal(CXFA_Node* pNode,
15 CXFA_StrokeArray& strokes,
16 FX_BOOL bNULL) {
17 strokes.RemoveAll();
18 if (!pNode)
19 return;
20
21 strokes.SetSize(8);
22 int32_t i, j;
23 for (i = 0, j = 0; i < 4; i++) {
24 CXFA_Corner corner =
25 CXFA_Corner(pNode->GetProperty(i, XFA_ELEMENT_Corner, i == 0));
26 if (corner || i == 0)
27 strokes.SetAt(j, corner);
28 else if (bNULL)
29 strokes.SetAt(j, CXFA_Stroke(nullptr));
30 else if (i == 1)
31 strokes.SetAt(j, strokes[0]);
32 else if (i == 2)
33 strokes.SetAt(j, strokes[0]);
34 else
35 strokes.SetAt(j, strokes[2]);
36
37 j++;
38 CXFA_Edge edge = CXFA_Edge(pNode->GetProperty(i, XFA_ELEMENT_Edge, i == 0));
39 if (edge || i == 0)
40 strokes.SetAt(j, edge);
41 else if (bNULL)
42 strokes.SetAt(j, CXFA_Stroke(nullptr));
43 else if (i == 1)
44 strokes.SetAt(j, strokes[1]);
45 else if (i == 2)
46 strokes.SetAt(j, strokes[1]);
47 else
48 strokes.SetAt(j, strokes[3]);
49
50 j++;
51 }
52 }
53
54 static int32_t Style3D(const CXFA_StrokeArray& strokes, CXFA_Stroke& stroke) {
55 int32_t iCount = strokes.GetSize();
56 if (iCount < 1)
57 return 0;
58
59 stroke = strokes[0];
60 for (int32_t i = 1; i < iCount; i++) {
61 CXFA_Stroke find = strokes[i];
62 if (!find)
63 continue;
64
65 if (!stroke)
66 stroke = find;
67 else if (stroke.GetStrokeType() != find.GetStrokeType())
68 stroke = find;
69 break;
70 }
71 int32_t iType = stroke.GetStrokeType();
72 if (iType == XFA_ATTRIBUTEENUM_Lowered || iType == XFA_ATTRIBUTEENUM_Raised ||
73 iType == XFA_ATTRIBUTEENUM_Etched ||
74 iType == XFA_ATTRIBUTEENUM_Embossed) {
75 return iType;
76 }
77 return 0;
78 }
79
80 } // namespace
81
82 int32_t CXFA_Box::GetHand() const {
83 if (!m_pNode)
84 return XFA_ATTRIBUTEENUM_Even;
85 return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
86 }
87
88 int32_t CXFA_Box::GetPresence() const {
89 if (!m_pNode)
90 return XFA_ATTRIBUTEENUM_Hidden;
91 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
92 }
93
94 int32_t CXFA_Box::CountEdges() const {
95 if (!m_pNode)
96 return 0;
97 return m_pNode->CountChildren(XFA_ELEMENT_Edge);
98 }
99
100 CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const {
101 return CXFA_Edge(
102 m_pNode ? m_pNode->GetProperty(nIndex, XFA_ELEMENT_Edge, nIndex == 0)
103 : nullptr);
104 }
105
106 void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const {
107 GetStrokesInternal(m_pNode, strokes, FALSE);
108 }
109
110 FX_BOOL CXFA_Box::IsCircular() const {
111 if (!m_pNode)
112 return FALSE;
113 return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular);
114 }
115
116 FX_BOOL CXFA_Box::GetStartAngle(FX_FLOAT& fStartAngle) const {
117 fStartAngle = 0;
118 if (!m_pNode)
119 return FALSE;
120
121 CXFA_Measurement ms;
122 FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, FALSE);
123 if (bRet)
124 fStartAngle = ms.GetValue();
125
126 return bRet;
127 }
128
129 FX_BOOL CXFA_Box::GetSweepAngle(FX_FLOAT& fSweepAngle) const {
130 fSweepAngle = 360;
131 if (!m_pNode)
132 return FALSE;
133
134 CXFA_Measurement ms;
135 FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, FALSE);
136 if (bRet)
137 fSweepAngle = ms.GetValue();
138
139 return bRet;
140 }
141
142 CXFA_Fill CXFA_Box::GetFill(FX_BOOL bModified) const {
143 if (!m_pNode)
144 return CXFA_Fill(nullptr);
145
146 CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_ELEMENT_Fill, bModified);
147 return CXFA_Fill(pFillNode);
148 }
149
150 CXFA_Margin CXFA_Box::GetMargin() const {
151 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin)
152 : nullptr);
153 }
154
155 int32_t CXFA_Box::Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const {
156 if (IsArc())
157 return 0;
158
159 CXFA_StrokeArray strokes;
160 GetStrokesInternal(m_pNode, strokes, TRUE);
161 CXFA_Stroke stroke(NULL);
162 int32_t iType = Style3D(strokes, stroke);
163 if (iType) {
164 bVisible = stroke.IsVisible();
165 fThickness = stroke.GetThickness();
166 }
167 return iType;
168 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_box.h ('k') | xfa/fxfa/parser/cxfa_calculate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698