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

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

Issue 2089443002: Convert XFA_ELEMENT to an enum class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More unknown checks Created 4 years, 6 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.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/parser/cxfa_box.h" 7 #include "xfa/fxfa/parser/cxfa_box.h"
8 8
9 #include "xfa/fxfa/parser/cxfa_corner.h" 9 #include "xfa/fxfa/parser/cxfa_corner.h"
10 #include "xfa/fxfa/parser/xfa_object.h" 10 #include "xfa/fxfa/parser/xfa_object.h"
11 11
12 namespace { 12 namespace {
13 13
14 void GetStrokesInternal(CXFA_Node* pNode, 14 void GetStrokesInternal(CXFA_Node* pNode,
15 CXFA_StrokeArray& strokes, 15 CXFA_StrokeArray& strokes,
16 FX_BOOL bNULL) { 16 FX_BOOL bNULL) {
17 strokes.RemoveAll(); 17 strokes.RemoveAll();
18 if (!pNode) 18 if (!pNode)
19 return; 19 return;
20 20
21 strokes.SetSize(8); 21 strokes.SetSize(8);
22 int32_t i, j; 22 int32_t i, j;
23 for (i = 0, j = 0; i < 4; i++) { 23 for (i = 0, j = 0; i < 4; i++) {
24 CXFA_Corner corner = 24 CXFA_Corner corner =
25 CXFA_Corner(pNode->GetProperty(i, XFA_ELEMENT_Corner, i == 0)); 25 CXFA_Corner(pNode->GetProperty(i, XFA_Element::Corner, i == 0));
26 if (corner || i == 0) 26 if (corner || i == 0)
27 strokes.SetAt(j, corner); 27 strokes.SetAt(j, corner);
28 else if (bNULL) 28 else if (bNULL)
29 strokes.SetAt(j, CXFA_Stroke(nullptr)); 29 strokes.SetAt(j, CXFA_Stroke(nullptr));
30 else if (i == 1) 30 else if (i == 1)
31 strokes.SetAt(j, strokes[0]); 31 strokes.SetAt(j, strokes[0]);
32 else if (i == 2) 32 else if (i == 2)
33 strokes.SetAt(j, strokes[0]); 33 strokes.SetAt(j, strokes[0]);
34 else 34 else
35 strokes.SetAt(j, strokes[2]); 35 strokes.SetAt(j, strokes[2]);
36 36
37 j++; 37 j++;
38 CXFA_Edge edge = CXFA_Edge(pNode->GetProperty(i, XFA_ELEMENT_Edge, i == 0)); 38 CXFA_Edge edge =
39 CXFA_Edge(pNode->GetProperty(i, XFA_Element::Edge, i == 0));
39 if (edge || i == 0) 40 if (edge || i == 0)
40 strokes.SetAt(j, edge); 41 strokes.SetAt(j, edge);
41 else if (bNULL) 42 else if (bNULL)
42 strokes.SetAt(j, CXFA_Stroke(nullptr)); 43 strokes.SetAt(j, CXFA_Stroke(nullptr));
43 else if (i == 1) 44 else if (i == 1)
44 strokes.SetAt(j, strokes[1]); 45 strokes.SetAt(j, strokes[1]);
45 else if (i == 2) 46 else if (i == 2)
46 strokes.SetAt(j, strokes[1]); 47 strokes.SetAt(j, strokes[1]);
47 else 48 else
48 strokes.SetAt(j, strokes[3]); 49 strokes.SetAt(j, strokes[3]);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 88
88 int32_t CXFA_Box::GetPresence() const { 89 int32_t CXFA_Box::GetPresence() const {
89 if (!m_pNode) 90 if (!m_pNode)
90 return XFA_ATTRIBUTEENUM_Hidden; 91 return XFA_ATTRIBUTEENUM_Hidden;
91 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); 92 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
92 } 93 }
93 94
94 int32_t CXFA_Box::CountEdges() const { 95 int32_t CXFA_Box::CountEdges() const {
95 if (!m_pNode) 96 if (!m_pNode)
96 return 0; 97 return 0;
97 return m_pNode->CountChildren(XFA_ELEMENT_Edge); 98 return m_pNode->CountChildren(XFA_Element::Edge);
98 } 99 }
99 100
100 CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const { 101 CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const {
101 return CXFA_Edge( 102 return CXFA_Edge(
102 m_pNode ? m_pNode->GetProperty(nIndex, XFA_ELEMENT_Edge, nIndex == 0) 103 m_pNode ? m_pNode->GetProperty(nIndex, XFA_Element::Edge, nIndex == 0)
103 : nullptr); 104 : nullptr);
104 } 105 }
105 106
106 void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const { 107 void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const {
107 GetStrokesInternal(m_pNode, strokes, FALSE); 108 GetStrokesInternal(m_pNode, strokes, FALSE);
108 } 109 }
109 110
110 FX_BOOL CXFA_Box::IsCircular() const { 111 FX_BOOL CXFA_Box::IsCircular() const {
111 if (!m_pNode) 112 if (!m_pNode)
112 return FALSE; 113 return FALSE;
(...skipping 23 matching lines...) Expand all
136 if (bRet) 137 if (bRet)
137 fSweepAngle = ms.GetValue(); 138 fSweepAngle = ms.GetValue();
138 139
139 return bRet; 140 return bRet;
140 } 141 }
141 142
142 CXFA_Fill CXFA_Box::GetFill(FX_BOOL bModified) const { 143 CXFA_Fill CXFA_Box::GetFill(FX_BOOL bModified) const {
143 if (!m_pNode) 144 if (!m_pNode)
144 return CXFA_Fill(nullptr); 145 return CXFA_Fill(nullptr);
145 146
146 CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_ELEMENT_Fill, bModified); 147 CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_Element::Fill, bModified);
147 return CXFA_Fill(pFillNode); 148 return CXFA_Fill(pFillNode);
148 } 149 }
149 150
150 CXFA_Margin CXFA_Box::GetMargin() const { 151 CXFA_Margin CXFA_Box::GetMargin() const {
151 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin) 152 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_Element::Margin)
152 : nullptr); 153 : nullptr);
153 } 154 }
154 155
155 int32_t CXFA_Box::Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const { 156 int32_t CXFA_Box::Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const {
156 if (IsArc()) 157 if (IsArc())
157 return 0; 158 return 0;
158 159
159 CXFA_StrokeArray strokes; 160 CXFA_StrokeArray strokes;
160 GetStrokesInternal(m_pNode, strokes, TRUE); 161 GetStrokesInternal(m_pNode, strokes, TRUE);
161 CXFA_Stroke stroke(NULL); 162 CXFA_Stroke stroke(NULL);
162 int32_t iType = Style3D(strokes, stroke); 163 int32_t iType = Style3D(strokes, stroke);
163 if (iType) { 164 if (iType) {
164 bVisible = stroke.IsVisible(); 165 bVisible = stroke.IsVisible();
165 fThickness = stroke.GetThickness(); 166 fThickness = stroke.GetThickness();
166 } 167 }
167 return iType; 168 return iType;
168 } 169 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_box.h ('k') | xfa/fxfa/parser/cxfa_calculate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698