OLD | NEW |
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/cxfa_measurement.h" | 10 #include "xfa/fxfa/parser/cxfa_measurement.h" |
11 #include "xfa/fxfa/parser/xfa_object.h" | 11 #include "xfa/fxfa/parser/xfa_object.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 void GetStrokesInternal(CXFA_Node* pNode, | 15 void GetStrokesInternal(CXFA_Node* pNode, |
16 CXFA_StrokeArray& strokes, | 16 CXFA_StrokeArray& strokes, |
17 FX_BOOL bNull) { | 17 bool bNull) { |
18 strokes.RemoveAll(); | 18 strokes.RemoveAll(); |
19 if (!pNode) | 19 if (!pNode) |
20 return; | 20 return; |
21 | 21 |
22 strokes.SetSize(8); | 22 strokes.SetSize(8); |
23 int32_t i, j; | 23 int32_t i, j; |
24 for (i = 0, j = 0; i < 4; i++) { | 24 for (i = 0, j = 0; i < 4; i++) { |
25 CXFA_Corner corner = | 25 CXFA_Corner corner = |
26 CXFA_Corner(pNode->GetProperty(i, XFA_Element::Corner, i == 0)); | 26 CXFA_Corner(pNode->GetProperty(i, XFA_Element::Corner, i == 0)); |
27 if (corner || i == 0) | 27 if (corner || i == 0) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return m_pNode->CountChildren(XFA_Element::Edge); | 99 return m_pNode->CountChildren(XFA_Element::Edge); |
100 } | 100 } |
101 | 101 |
102 CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const { | 102 CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const { |
103 return CXFA_Edge( | 103 return CXFA_Edge( |
104 m_pNode ? m_pNode->GetProperty(nIndex, XFA_Element::Edge, nIndex == 0) | 104 m_pNode ? m_pNode->GetProperty(nIndex, XFA_Element::Edge, nIndex == 0) |
105 : nullptr); | 105 : nullptr); |
106 } | 106 } |
107 | 107 |
108 void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const { | 108 void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const { |
109 GetStrokesInternal(m_pNode, strokes, FALSE); | 109 GetStrokesInternal(m_pNode, strokes, false); |
110 } | 110 } |
111 | 111 |
112 FX_BOOL CXFA_Box::IsCircular() const { | 112 bool CXFA_Box::IsCircular() const { |
113 if (!m_pNode) | 113 if (!m_pNode) |
114 return FALSE; | 114 return false; |
115 return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular); | 115 return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular); |
116 } | 116 } |
117 | 117 |
118 FX_BOOL CXFA_Box::GetStartAngle(FX_FLOAT& fStartAngle) const { | 118 bool CXFA_Box::GetStartAngle(FX_FLOAT& fStartAngle) const { |
119 fStartAngle = 0; | 119 fStartAngle = 0; |
120 if (!m_pNode) | 120 if (!m_pNode) |
121 return FALSE; | 121 return false; |
122 | 122 |
123 CXFA_Measurement ms; | 123 CXFA_Measurement ms; |
124 FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, FALSE); | 124 bool bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, false); |
125 if (bRet) | 125 if (bRet) |
126 fStartAngle = ms.GetValue(); | 126 fStartAngle = ms.GetValue(); |
127 | 127 |
128 return bRet; | 128 return bRet; |
129 } | 129 } |
130 | 130 |
131 FX_BOOL CXFA_Box::GetSweepAngle(FX_FLOAT& fSweepAngle) const { | 131 bool CXFA_Box::GetSweepAngle(FX_FLOAT& fSweepAngle) const { |
132 fSweepAngle = 360; | 132 fSweepAngle = 360; |
133 if (!m_pNode) | 133 if (!m_pNode) |
134 return FALSE; | 134 return false; |
135 | 135 |
136 CXFA_Measurement ms; | 136 CXFA_Measurement ms; |
137 FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, FALSE); | 137 bool bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, false); |
138 if (bRet) | 138 if (bRet) |
139 fSweepAngle = ms.GetValue(); | 139 fSweepAngle = ms.GetValue(); |
140 | 140 |
141 return bRet; | 141 return bRet; |
142 } | 142 } |
143 | 143 |
144 CXFA_Fill CXFA_Box::GetFill(FX_BOOL bModified) const { | 144 CXFA_Fill CXFA_Box::GetFill(bool bModified) const { |
145 if (!m_pNode) | 145 if (!m_pNode) |
146 return CXFA_Fill(nullptr); | 146 return CXFA_Fill(nullptr); |
147 | 147 |
148 CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_Element::Fill, bModified); | 148 CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_Element::Fill, bModified); |
149 return CXFA_Fill(pFillNode); | 149 return CXFA_Fill(pFillNode); |
150 } | 150 } |
151 | 151 |
152 CXFA_Margin CXFA_Box::GetMargin() const { | 152 CXFA_Margin CXFA_Box::GetMargin() const { |
153 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_Element::Margin) | 153 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_Element::Margin) |
154 : nullptr); | 154 : nullptr); |
155 } | 155 } |
156 | 156 |
157 int32_t CXFA_Box::Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const { | 157 int32_t CXFA_Box::Get3DStyle(bool& bVisible, FX_FLOAT& fThickness) const { |
158 if (IsArc()) | 158 if (IsArc()) |
159 return 0; | 159 return 0; |
160 | 160 |
161 CXFA_StrokeArray strokes; | 161 CXFA_StrokeArray strokes; |
162 GetStrokesInternal(m_pNode, strokes, TRUE); | 162 GetStrokesInternal(m_pNode, strokes, true); |
163 CXFA_Stroke stroke(nullptr); | 163 CXFA_Stroke stroke(nullptr); |
164 int32_t iType = Style3D(strokes, stroke); | 164 int32_t iType = Style3D(strokes, stroke); |
165 if (iType) { | 165 if (iType) { |
166 bVisible = stroke.IsVisible(); | 166 bVisible = stroke.IsVisible(); |
167 fThickness = stroke.GetThickness(); | 167 fThickness = stroke.GetThickness(); |
168 } | 168 } |
169 return iType; | 169 return iType; |
170 } | 170 } |
OLD | NEW |