1 // Copyright 2014 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/src/foxitlib.h"
8 #include "xfa/src/fxfa/src/common/xfa_utils.h"
9 #include "xfa/src/fxfa/src/common/xfa_object.h"
10 #include "xfa/src/fxfa/src/common/xfa_document.h"
11 #include "xfa/src/fxfa/src/common/xfa_parser.h"
12 #include "xfa/src/fxfa/src/common/xfa_script.h"
13 #include "xfa/src/fxfa/src/common/xfa_docdata.h"
14 #include "xfa/src/fxfa/src/common/xfa_doclayout.h"
15 #include "xfa/src/fxfa/src/common/xfa_localemgr.h"
16 #include "xfa/src/fxfa/src/common/xfa_fm2jsapi.h"
XFA_WStringToColor(const CFX_WideStringC & wsValue)17 static FX_ARGB XFA_WStringToColor(const CFX_WideStringC& wsValue) {
18 uint8_t r = 0, g = 0, b = 0;
19 if (wsValue.GetLength() == 0) {
20 return 0xff000000;
21 }
22 int cc = 0;
23 const FX_WCHAR* str = wsValue.GetPtr();
24 int len = wsValue.GetLength();
25 while (XFA_IsSpace(str[cc]) && cc < len) {
26 cc++;
27 }
28 if (cc >= len) {
29 return 0xff000000;
30 }
31 while (cc < len) {
32 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) {
33 break;
34 }
35 r = r * 10 + str[cc] - '0';
36 cc++;
37 }
38 if (cc < len && str[cc] == ',') {
39 cc++;
40 while (XFA_IsSpace(str[cc]) && cc < len) {
41 cc++;
42 }
43 while (cc < len) {
44 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) {
45 break;
46 }
47 g = g * 10 + str[cc] - '0';
48 cc++;
49 }
50 if (cc < len && str[cc] == ',') {
51 cc++;
52 while (XFA_IsSpace(str[cc]) && cc < len) {
53 cc++;
54 }
55 while (cc < len) {
56 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) {
57 break;
58 }
59 b = b * 10 + str[cc] - '0';
60 cc++;
61 }
62 }
63 }
64 return (0xff << 24) | (r << 16) | (g << 8) | b;
65 }
GetClassID() const66 XFA_ELEMENT CXFA_Data::GetClassID() const {
67 return m_pNode ? m_pNode->GetClassID() : XFA_ELEMENT_UNKNOWN;
68 }
TryMeasure(XFA_ATTRIBUTE eAttr,FX_FLOAT & fValue,FX_BOOL bUseDefault) const69 FX_BOOL CXFA_Data::TryMeasure(XFA_ATTRIBUTE eAttr,
70 FX_FLOAT& fValue,
71 FX_BOOL bUseDefault) const {
72 CXFA_Measurement ms;
73 if (m_pNode->TryMeasure(eAttr, ms, bUseDefault)) {
74 fValue = ms.ToUnit(XFA_UNIT_Pt);
75 return TRUE;
76 }
77 return FALSE;
78 }
SetMeasure(XFA_ATTRIBUTE eAttr,FX_FLOAT fValue)79 FX_BOOL CXFA_Data::SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue) {
80 CXFA_Measurement ms(fValue, XFA_UNIT_Pt);
81 return m_pNode->SetMeasure(eAttr, ms);
82 }
CXFA_Fill(CXFA_Node * pNode)83 CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {}
~CXFA_Fill()84 CXFA_Fill::~CXFA_Fill() {}
GetPresence()85 int32_t CXFA_Fill::GetPresence() {
86 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
87 }
SetColor(FX_ARGB color)88 void CXFA_Fill::SetColor(FX_ARGB color) {
89 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color);
90 CFX_WideString wsColor;
91 int a, r, g, b;
92 ArgbDecode(color, a, r, g, b);
93 wsColor.Format(L"%d,%d,%d", r, g, b);
94 pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
95 }
GetColor(FX_BOOL bText)96 FX_ARGB CXFA_Fill::GetColor(FX_BOOL bText) {
97 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color)) {
98 CFX_WideStringC wsColor;
99 if (pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE)) {
100 return XFA_WStringToColor(wsColor);
101 }
102 }
103 if (bText) {
104 return 0xFF000000;
105 }
106 return 0xFFFFFFFF;
107 }
GetFillType()108 int32_t CXFA_Fill::GetFillType() {
109 CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
110 while (pChild) {
111 int32_t eType = pChild->GetClassID();
112 if (eType != XFA_ELEMENT_Color && eType != XFA_ELEMENT_Extras) {
113 return eType;
114 }
115 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
116 }
117 return XFA_ELEMENT_Solid;
118 }
GetPattern(FX_ARGB & foreColor)119 int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) {
120 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Pattern);
121 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
122 CFX_WideStringC wsColor;
123 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
124 foreColor = XFA_WStringToColor(wsColor);
125 } else {
126 foreColor = 0xFF000000;
127 }
128 return pNode->GetEnum(XFA_ATTRIBUTE_Type);
129 }
GetStipple(FX_ARGB & stippleColor)130 int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) {
131 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Stipple);
132 int32_t eAttr = 50;
133 pNode->TryInteger(XFA_ATTRIBUTE_Rate, eAttr);
134 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
135 CFX_WideStringC wsColor;
136 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
137 stippleColor = XFA_WStringToColor(wsColor);
138 } else {
139 stippleColor = 0xFF000000;
140 }
141 return eAttr;
142 }
GetLinear(FX_ARGB & endColor)143 int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) {
144 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Linear);
145 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight;
146 pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
147 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
148 CFX_WideStringC wsColor;
149 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
150 endColor = XFA_WStringToColor(wsColor);
151 } else {
152 endColor = 0xFF000000;
153 }
154 return eAttr;
155 }
GetRadial(FX_ARGB & endColor)156 int32_t CXFA_Fill::GetRadial(FX_ARGB& endColor) {
157 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Radial);
158 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge;
159 pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
160 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
161 CFX_WideStringC wsColor;
162 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
163 endColor = XFA_WStringToColor(wsColor);
164 } else {
165 endColor = 0xFF000000;
166 }
167 return eAttr;
168 }
SetPresence(int32_t iPresence)169 FX_BOOL CXFA_Fill::SetPresence(int32_t iPresence) {
170 return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence);
171 }
SetFillType(int32_t iType)172 FX_BOOL CXFA_Fill::SetFillType(int32_t iType) {
173 return FALSE;
174 }
SetPattern(int32_t iPattern,FX_ARGB foreColor)175 FX_BOOL CXFA_Fill::SetPattern(int32_t iPattern, FX_ARGB foreColor) {
176 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Pattern);
177 CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color);
178 CFX_WideString wsColor;
179 int a, r, g, b;
180 ArgbDecode(foreColor, a, r, g, b);
181 wsColor.Format(L"%d,%d,%d", r, g, b);
182 pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor);
183 return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iPattern);
184 }
SetStipple(int32_t iStipple,FX_ARGB stippleColor)185 FX_BOOL CXFA_Fill::SetStipple(int32_t iStipple, FX_ARGB stippleColor) {
186 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Stipple);
187 CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color);
188 CFX_WideString wsColor;
189 int a, r, g, b;
190 ArgbDecode(stippleColor, a, r, g, b);
191 wsColor.Format(L"%d,%d,%d", r, g, b);
192 pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor);
193 return pNode->SetEnum(XFA_ATTRIBUTE_Rate, (XFA_ATTRIBUTEENUM)iStipple);
194 }
SetLinear(int32_t iLinear,FX_ARGB endColor)195 FX_BOOL CXFA_Fill::SetLinear(int32_t iLinear, FX_ARGB endColor) {
196 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Linear);
197 CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color);
198 CFX_WideString wsColor;
199 int a, r, g, b;
200 ArgbDecode(endColor, a, r, g, b);
201 wsColor.Format(L"%d,%d,%d", r, g, b);
202 pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor);
203 return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iLinear);
204 }
SetRadial(int32_t iRadial,FX_ARGB endColor)205 FX_BOOL CXFA_Fill::SetRadial(int32_t iRadial, FX_ARGB endColor) {
206 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Radial);
207 CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color);
208 CFX_WideString wsColor;
209 int a, r, g, b;
210 ArgbDecode(endColor, a, r, g, b);
211 wsColor.Format(L"%d,%d,%d", r, g, b);
212 pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor);
213 return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iRadial);
214 }
CXFA_Margin(CXFA_Node * pNode)215 CXFA_Margin::CXFA_Margin(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetLeftInset(FX_FLOAT & fInset,FX_FLOAT fDefInset) const216 FX_BOOL CXFA_Margin::GetLeftInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
217 fInset = fDefInset;
218 return TryMeasure(XFA_ATTRIBUTE_LeftInset, fInset);
219 }
GetTopInset(FX_FLOAT & fInset,FX_FLOAT fDefInset) const220 FX_BOOL CXFA_Margin::GetTopInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
221 fInset = fDefInset;
222 return TryMeasure(XFA_ATTRIBUTE_TopInset, fInset);
223 }
GetRightInset(FX_FLOAT & fInset,FX_FLOAT fDefInset) const224 FX_BOOL CXFA_Margin::GetRightInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
225 fInset = fDefInset;
226 return TryMeasure(XFA_ATTRIBUTE_RightInset, fInset);
227 }
GetBottomInset(FX_FLOAT & fInset,FX_FLOAT fDefInset) const228 FX_BOOL CXFA_Margin::GetBottomInset(FX_FLOAT& fInset,
229 FX_FLOAT fDefInset) const {
230 fInset = fDefInset;
231 return TryMeasure(XFA_ATTRIBUTE_BottomInset, fInset);
232 }
SetLeftInset(FX_FLOAT fInset)233 FX_BOOL CXFA_Margin::SetLeftInset(FX_FLOAT fInset) {
234 return SetMeasure(XFA_ATTRIBUTE_LeftInset, fInset);
235 }
SetTopInset(FX_FLOAT fInset)236 FX_BOOL CXFA_Margin::SetTopInset(FX_FLOAT fInset) {
237 return SetMeasure(XFA_ATTRIBUTE_TopInset, fInset);
238 }
SetRightInset(FX_FLOAT fInset)239 FX_BOOL CXFA_Margin::SetRightInset(FX_FLOAT fInset) {
240 return SetMeasure(XFA_ATTRIBUTE_RightInset, fInset);
241 }
SetBottomInset(FX_FLOAT fInset)242 FX_BOOL CXFA_Margin::SetBottomInset(FX_FLOAT fInset) {
243 return SetMeasure(XFA_ATTRIBUTE_BottomInset, fInset);
244 }
CXFA_Font(CXFA_Node * pNode)245 CXFA_Font::CXFA_Font(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetBaselineShift()246 FX_FLOAT CXFA_Font::GetBaselineShift() {
247 return m_pNode->GetMeasure(XFA_ATTRIBUTE_BaselineShift).ToUnit(XFA_UNIT_Pt);
248 }
GetHorizontalScale()249 FX_FLOAT CXFA_Font::GetHorizontalScale() {
250 CFX_WideString wsValue;
251 m_pNode->TryCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue);
252 int32_t iScale = FXSYS_wtoi((const FX_WCHAR*)wsValue);
253 return iScale > 0 ? (FX_FLOAT)iScale : 100.0f;
254 }
GetVerticalScale()255 FX_FLOAT CXFA_Font::GetVerticalScale() {
256 CFX_WideString wsValue;
257 m_pNode->TryCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue);
258 int32_t iScale = FXSYS_wtoi((const FX_WCHAR*)wsValue);
259 return iScale > 0 ? (FX_FLOAT)iScale : 100.0f;
260 }
GetLetterSpacing()261 FX_FLOAT CXFA_Font::GetLetterSpacing() {
262 CFX_WideStringC wsValue;
263 if (!m_pNode->TryCData(XFA_ATTRIBUTE_LetterSpacing, wsValue)) {
264 return 0;
265 }
266 CXFA_Measurement ms(wsValue);
267 if (ms.GetUnit() == XFA_UNIT_Em) {
268 return ms.GetValue() * GetFontSize();
269 }
270 return ms.ToUnit(XFA_UNIT_Pt);
271 }
GetLineThrough()272 int32_t CXFA_Font::GetLineThrough() {
273 int32_t iValue = 0;
274 m_pNode->TryInteger(XFA_ATTRIBUTE_LineThrough, iValue);
275 return iValue;
276 }
GetLineThroughPeriod()277 int32_t CXFA_Font::GetLineThroughPeriod() {
278 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All;
279 m_pNode->TryEnum(XFA_ATTRIBUTE_LineThroughPeriod, eAttr);
280 return eAttr;
281 }
GetOverline()282 int32_t CXFA_Font::GetOverline() {
283 int32_t iValue = 0;
284 m_pNode->TryInteger(XFA_ATTRIBUTE_Overline, iValue);
285 return iValue;
286 }
GetOverlinePeriod()287 int32_t CXFA_Font::GetOverlinePeriod() {
288 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All;
289 m_pNode->TryEnum(XFA_ATTRIBUTE_OverlinePeriod, eAttr);
290 return eAttr;
291 }
GetUnderline()292 int32_t CXFA_Font::GetUnderline() {
293 int32_t iValue = 0;
294 m_pNode->TryInteger(XFA_ATTRIBUTE_Underline, iValue);
295 return iValue;
296 }
GetUnderlinePeriod()297 int32_t CXFA_Font::GetUnderlinePeriod() {
298 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All;
299 m_pNode->TryEnum(XFA_ATTRIBUTE_UnderlinePeriod, eAttr);
300 return eAttr;
301 }
GetFontSize()302 FX_FLOAT CXFA_Font::GetFontSize() {
303 CXFA_Measurement ms;
304 m_pNode->TryMeasure(XFA_ATTRIBUTE_Size, ms);
305 return ms.ToUnit(XFA_UNIT_Pt);
306 }
GetTypeface(CFX_WideStringC & wsTypeFace)307 void CXFA_Font::GetTypeface(CFX_WideStringC& wsTypeFace) {
308 m_pNode->TryCData(XFA_ATTRIBUTE_Typeface, wsTypeFace);
309 }
IsBold()310 FX_BOOL CXFA_Font::IsBold() {
311 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
312 m_pNode->TryEnum(XFA_ATTRIBUTE_Weight, eAttr);
313 return eAttr == XFA_ATTRIBUTEENUM_Bold;
314 }
IsItalic()315 FX_BOOL CXFA_Font::IsItalic() {
316 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
317 m_pNode->TryEnum(XFA_ATTRIBUTE_Posture, eAttr);
318 return eAttr == XFA_ATTRIBUTEENUM_Italic;
319 }
IsUseKerning()320 FX_BOOL CXFA_Font::IsUseKerning() {
321 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None;
322 m_pNode->TryEnum(XFA_ATTRIBUTE_KerningMode, eAttr);
323 return eAttr == XFA_ATTRIBUTEENUM_Pair;
324 }
SetColor(FX_ARGB color)325 void CXFA_Font::SetColor(FX_ARGB color) {
326 CXFA_Fill fill = m_pNode->GetProperty(0, XFA_ELEMENT_Fill);
327 fill.SetColor(color);
328 }
GetColor()329 FX_ARGB CXFA_Font::GetColor() {
330 if (CXFA_Fill fill = m_pNode->GetChild(0, XFA_ELEMENT_Fill)) {
331 return fill.GetColor(TRUE);
332 }
333 return 0xFF000000;
334 }
SetBaselineShift(FX_FLOAT fBaselineShift)335 FX_BOOL CXFA_Font::SetBaselineShift(FX_FLOAT fBaselineShift) {
336 CXFA_Measurement ms(fBaselineShift, XFA_UNIT_Pt);
337 return m_pNode->SetMeasure(XFA_ATTRIBUTE_BaselineShift, ms);
338 }
SetHorizontalScale(FX_FLOAT fHorizontalScale)339 FX_BOOL CXFA_Font::SetHorizontalScale(FX_FLOAT fHorizontalScale) {
340 CFX_WideString wsValue;
341 wsValue.Format(L"%d", (int32_t)fHorizontalScale);
342 return m_pNode->SetCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue);
343 }
SetVerticalScale(FX_FLOAT fVerticalScale)344 FX_BOOL CXFA_Font::SetVerticalScale(FX_FLOAT fVerticalScale) {
345 CFX_WideString wsValue;
346 wsValue.Format(L"%d", (int32_t)fVerticalScale);
347 return m_pNode->SetCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue);
348 }
SetLetterSpacing(FX_FLOAT fLetterSpacing,XFA_UNIT eUnit)349 FX_BOOL CXFA_Font::SetLetterSpacing(FX_FLOAT fLetterSpacing, XFA_UNIT eUnit) {
350 return FALSE;
351 }
SetLineThrough(int32_t iLineThrough)352 FX_BOOL CXFA_Font::SetLineThrough(int32_t iLineThrough) {
353 return m_pNode->SetInteger(XFA_ATTRIBUTE_LineThrough, iLineThrough);
354 }
SetLineThroughPeriod(int32_t iLineThroughPeriod)355 FX_BOOL CXFA_Font::SetLineThroughPeriod(int32_t iLineThroughPeriod) {
356 return m_pNode->SetEnum(XFA_ATTRIBUTE_LineThroughPeriod,
357 (XFA_ATTRIBUTEENUM)iLineThroughPeriod);
358 }
SetOverline(int32_t iOverline)359 FX_BOOL CXFA_Font::SetOverline(int32_t iOverline) {
360 return m_pNode->SetInteger(XFA_ATTRIBUTE_Overline, iOverline);
361 }
SetOverlinePeriod(int32_t iOverlinePeriod)362 FX_BOOL CXFA_Font::SetOverlinePeriod(int32_t iOverlinePeriod) {
363 return m_pNode->SetEnum(XFA_ATTRIBUTE_OverlinePeriod,
364 (XFA_ATTRIBUTEENUM)iOverlinePeriod);
365 }
SetUnderline(int32_t iUnderline)366 FX_BOOL CXFA_Font::SetUnderline(int32_t iUnderline) {
367 return m_pNode->SetInteger(XFA_ATTRIBUTE_Underline, iUnderline);
368 }
SetUnderlinePeriod(int32_t iUnderlinePeriod)369 FX_BOOL CXFA_Font::SetUnderlinePeriod(int32_t iUnderlinePeriod) {
370 return m_pNode->SetEnum(XFA_ATTRIBUTE_UnderlinePeriod,
371 (XFA_ATTRIBUTEENUM)iUnderlinePeriod);
372 }
CXFA_Caption(CXFA_Node * pNode)373 CXFA_Caption::CXFA_Caption(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetPresence()374 int32_t CXFA_Caption::GetPresence() {
375 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Visible;
376 m_pNode->TryEnum(XFA_ATTRIBUTE_Presence, eAttr);
377 return eAttr;
378 }
GetPlacementType()379 int32_t CXFA_Caption::GetPlacementType() {
380 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
381 m_pNode->TryEnum(XFA_ATTRIBUTE_Placement, eAttr);
382 return eAttr;
383 }
GetReserve()384 FX_FLOAT CXFA_Caption::GetReserve() {
385 CXFA_Measurement ms;
386 m_pNode->TryMeasure(XFA_ATTRIBUTE_Reserve, ms);
387 return ms.ToUnit(XFA_UNIT_Pt);
388 }
GetMargin()389 CXFA_Margin CXFA_Caption::GetMargin() {
390 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin) : NULL);
391 }
GetFont()392 CXFA_Font CXFA_Caption::GetFont() {
393 return CXFA_Font(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Font) : NULL);
394 }
GetValue()395 CXFA_Value CXFA_Caption::GetValue() {
396 return CXFA_Value(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Value) : NULL);
397 }
GetPara()398 CXFA_Para CXFA_Caption::GetPara() {
399 return CXFA_Para(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Para) : NULL);
400 }
SetPresence(int32_t iPresence)401 FX_BOOL CXFA_Caption::SetPresence(int32_t iPresence) {
402 return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence);
403 }
SetPlacementType(int32_t iType)404 FX_BOOL CXFA_Caption::SetPlacementType(int32_t iType) {
405 return m_pNode->SetEnum(XFA_ATTRIBUTE_Placement, (XFA_ATTRIBUTEENUM)iType);
406 }
SetReserve(FX_FLOAT fReserve)407 FX_BOOL CXFA_Caption::SetReserve(FX_FLOAT fReserve) {
408 CXFA_Measurement ms(fReserve, XFA_UNIT_Pt);
409 return m_pNode->SetMeasure(XFA_ATTRIBUTE_Reserve, ms);
410 }
CXFA_Para(CXFA_Node * pNode)411 CXFA_Para::CXFA_Para(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetHorizontalAlign()412 int32_t CXFA_Para::GetHorizontalAlign() {
413 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
414 m_pNode->TryEnum(XFA_ATTRIBUTE_HAlign, eAttr);
415 return eAttr;
416 }
GetVerticalAlign()417 int32_t CXFA_Para::GetVerticalAlign() {
418 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Top;
419 m_pNode->TryEnum(XFA_ATTRIBUTE_VAlign, eAttr);
420 return eAttr;
421 }
GetLineHeight()422 FX_FLOAT CXFA_Para::GetLineHeight() {
423 CXFA_Measurement ms;
424 m_pNode->TryMeasure(XFA_ATTRIBUTE_LineHeight, ms);
425 return ms.ToUnit(XFA_UNIT_Pt);
426 }
GetMarginLeft()427 FX_FLOAT CXFA_Para::GetMarginLeft() {
428 CXFA_Measurement ms;
429 m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginLeft, ms);
430 return ms.ToUnit(XFA_UNIT_Pt);
431 }
GetMarginRight()432 FX_FLOAT CXFA_Para::GetMarginRight() {
433 CXFA_Measurement ms;
434 m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginRight, ms);
435 return ms.ToUnit(XFA_UNIT_Pt);
436 }
GetOrphans()437 int32_t CXFA_Para::GetOrphans() {
438 int32_t iValue = 0;
439 m_pNode->TryInteger(XFA_ATTRIBUTE_Orphans, iValue);
440 return iValue;
441 }
GetRadixOffset()442 FX_FLOAT CXFA_Para::GetRadixOffset() {
443 CXFA_Measurement ms;
444 m_pNode->TryMeasure(XFA_ATTRIBUTE_RadixOffset, ms);
445 return ms.ToUnit(XFA_UNIT_Pt);
446 }
GetSpaceAbove()447 FX_FLOAT CXFA_Para::GetSpaceAbove() {
448 CXFA_Measurement ms;
449 m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceAbove, ms);
450 return ms.ToUnit(XFA_UNIT_Pt);
451 }
GetSpaceBelow()452 FX_FLOAT CXFA_Para::GetSpaceBelow() {
453 CXFA_Measurement ms;
454 m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceBelow, ms);
455 return ms.ToUnit(XFA_UNIT_Pt);
456 }
GetTextIndent()457 FX_FLOAT CXFA_Para::GetTextIndent() {
458 CXFA_Measurement ms;
459 m_pNode->TryMeasure(XFA_ATTRIBUTE_TextIndent, ms);
460 return ms.ToUnit(XFA_UNIT_Pt);
461 }
GetWidows()462 int32_t CXFA_Para::GetWidows() {
463 int32_t iValue = 0;
464 m_pNode->TryInteger(XFA_ATTRIBUTE_Widows, iValue);
465 return iValue;
466 }
SetHorizontalAlign(int32_t iHorizontalAlign)467 FX_BOOL CXFA_Para::SetHorizontalAlign(int32_t iHorizontalAlign) {
468 return m_pNode->SetEnum(XFA_ATTRIBUTE_HAlign,
469 (XFA_ATTRIBUTEENUM)iHorizontalAlign);
470 }
SetVerticalAlign(int32_t iVerticalAlign)471 FX_BOOL CXFA_Para::SetVerticalAlign(int32_t iVerticalAlign) {
472 return m_pNode->SetEnum(XFA_ATTRIBUTE_VAlign,
473 (XFA_ATTRIBUTEENUM)iVerticalAlign);
474 }
SetLineHeight(FX_FLOAT fLineHeight)475 FX_BOOL CXFA_Para::SetLineHeight(FX_FLOAT fLineHeight) {
476 CXFA_Measurement ms;
477 return m_pNode->SetMeasure(XFA_ATTRIBUTE_LineHeight, ms);
478 }
SetMarginLeft(FX_FLOAT fMarginLeft)479 FX_BOOL CXFA_Para::SetMarginLeft(FX_FLOAT fMarginLeft) {
480 CXFA_Measurement ms(fMarginLeft, XFA_UNIT_Pt);
481 return m_pNode->SetMeasure(XFA_ATTRIBUTE_MarginLeft, ms);
482 }
SetMarginRight(FX_FLOAT fMarginRight)483 FX_BOOL CXFA_Para::SetMarginRight(FX_FLOAT fMarginRight) {
484 CXFA_Measurement ms(fMarginRight, XFA_UNIT_Pt);
485 return m_pNode->SetMeasure(XFA_ATTRIBUTE_MarginRight, ms);
486 }
SetOrphans(int32_t iOrphans)487 FX_BOOL CXFA_Para::SetOrphans(int32_t iOrphans) {
488 return m_pNode->SetInteger(XFA_ATTRIBUTE_Orphans, iOrphans);
489 }
SetRadixOffset(FX_FLOAT fRadixOffset)490 FX_BOOL CXFA_Para::SetRadixOffset(FX_FLOAT fRadixOffset) {
491 CXFA_Measurement ms(fRadixOffset, XFA_UNIT_Pt);
492 return m_pNode->SetMeasure(XFA_ATTRIBUTE_RadixOffset, ms);
493 }
SetSpaceAbove(FX_FLOAT fSpaceAbove)494 FX_BOOL CXFA_Para::SetSpaceAbove(FX_FLOAT fSpaceAbove) {
495 CXFA_Measurement ms(fSpaceAbove, XFA_UNIT_Pt);
496 return m_pNode->SetMeasure(XFA_ATTRIBUTE_SpaceAbove, ms);
497 }
SetSpaceBelow(FX_FLOAT fSpaceBelow)498 FX_BOOL CXFA_Para::SetSpaceBelow(FX_FLOAT fSpaceBelow) {
499 CXFA_Measurement ms(fSpaceBelow, XFA_UNIT_Pt);
500 return m_pNode->SetMeasure(XFA_ATTRIBUTE_SpaceBelow, ms);
501 }
SetTextIndent(FX_FLOAT fTextIndent)502 FX_BOOL CXFA_Para::SetTextIndent(FX_FLOAT fTextIndent) {
503 CXFA_Measurement ms(fTextIndent, XFA_UNIT_Pt);
504 return m_pNode->SetMeasure(XFA_ATTRIBUTE_TextIndent, ms);
505 }
SetWidows(int32_t iWidows)506 FX_BOOL CXFA_Para::SetWidows(int32_t iWidows) {
507 return m_pNode->SetInteger(XFA_ATTRIBUTE_Widows, iWidows);
508 }
CXFA_Keep(CXFA_Node * pNode,CXFA_Node * pParent)509 CXFA_Keep::CXFA_Keep(CXFA_Node* pNode, CXFA_Node* pParent)
510 : CXFA_Data(pNode), m_pParent(pParent) {}
GetIntact()511 int32_t CXFA_Keep::GetIntact() {
512 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None;
513 switch (m_pParent->GetClassID()) {
514 case XFA_ELEMENT_Subform: {
515 XFA_ATTRIBUTEENUM eAttrSubForm;
516 m_pParent->TryEnum(XFA_ATTRIBUTE_Layout, eAttrSubForm);
517 if (eAttrSubForm == XFA_ATTRIBUTEENUM_Position ||
518 eAttrSubForm == XFA_ATTRIBUTEENUM_Row) {
519 eAttr = XFA_ATTRIBUTEENUM_ContentArea;
520 }
521 } break;
522 case XFA_ELEMENT_Draw:
523 eAttr = XFA_ATTRIBUTEENUM_ContentArea;
524 break;
525 default:
526 break;
527 }
528 m_pNode->TryEnum(XFA_ATTRIBUTE_Intact, eAttr, FALSE);
529 return eAttr;
530 }
GetNext()531 int32_t CXFA_Keep::GetNext() {
532 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None;
533 m_pNode->TryEnum(XFA_ATTRIBUTE_Next, eAttr);
534 return eAttr;
535 }
GetPrevious()536 int32_t CXFA_Keep::GetPrevious() {
537 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None;
538 m_pNode->TryEnum(XFA_ATTRIBUTE_Previous, eAttr);
539 return eAttr;
540 }
SetIntact(int32_t iIntact)541 FX_BOOL CXFA_Keep::SetIntact(int32_t iIntact) {
542 return m_pNode->SetEnum(XFA_ATTRIBUTE_Intact, (XFA_ATTRIBUTEENUM)iIntact);
543 }
SetNext(int32_t iNext)544 FX_BOOL CXFA_Keep::SetNext(int32_t iNext) {
545 return m_pNode->SetEnum(XFA_ATTRIBUTE_Next, (XFA_ATTRIBUTEENUM)iNext);
546 }
SetPrevious(int32_t iPrevious)547 FX_BOOL CXFA_Keep::SetPrevious(int32_t iPrevious) {
548 return m_pNode->SetEnum(XFA_ATTRIBUTE_Previous, (XFA_ATTRIBUTEENUM)iPrevious);
549 }
CXFA_Event(CXFA_Node * pNode)550 CXFA_Event::CXFA_Event(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetActivity()551 int32_t CXFA_Event::GetActivity() {
552 return m_pNode->GetEnum(XFA_ATTRIBUTE_Activity);
553 }
GetEventType()554 int32_t CXFA_Event::GetEventType() {
555 CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
556 while (pChild) {
557 int32_t eType = pChild->GetClassID();
558 if (eType != XFA_ELEMENT_Extras) {
559 return eType;
560 }
561 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
562 }
563 return XFA_ELEMENT_UNKNOWN;
564 }
GetRef(CFX_WideStringC & wsRef)565 void CXFA_Event::GetRef(CFX_WideStringC& wsRef) {
566 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
567 }
GetExecuteRunAt()568 int32_t CXFA_Event::GetExecuteRunAt() {
569 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute);
570 return pNode->GetEnum(XFA_ATTRIBUTE_RunAt);
571 }
GetExecuteType()572 int32_t CXFA_Event::GetExecuteType() {
573 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute);
574 return pNode->GetEnum(XFA_ATTRIBUTE_ExecuteType);
575 }
GetExecuteConnection(CFX_WideString & wsConnection)576 void CXFA_Event::GetExecuteConnection(CFX_WideString& wsConnection) {
577 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute);
578 CFX_WideStringC cData;
579 pNode->TryCData(XFA_ATTRIBUTE_Connection, cData);
580 wsConnection = cData;
581 }
GetScript()582 CXFA_Script CXFA_Event::GetScript() {
583 return m_pNode->GetChild(0, XFA_ELEMENT_Script);
584 }
GetSubmit()585 CXFA_Submit CXFA_Event::GetSubmit() {
586 return m_pNode->GetChild(0, XFA_ELEMENT_Submit);
587 }
GetSignDataOperation()588 int32_t CXFA_Event::GetSignDataOperation() {
589 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData);
590 return pNode->GetEnum(XFA_ATTRIBUTE_Operation);
591 }
GetSignDataTarget(CFX_WideString & wsTarget)592 void CXFA_Event::GetSignDataTarget(CFX_WideString& wsTarget) {
593 if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData)) {
594 CFX_WideStringC wsCData;
595 pNode->TryCData(XFA_ATTRIBUTE_Target, wsCData);
596 wsTarget = wsCData;
597 }
598 }
SetActivity(int32_t iActivity)599 FX_BOOL CXFA_Event::SetActivity(int32_t iActivity) {
600 return m_pNode->SetEnum(XFA_ATTRIBUTE_Activity, (XFA_ATTRIBUTEENUM)iActivity);
601 }
SetEventType(int32_t iEventType)602 FX_BOOL CXFA_Event::SetEventType(int32_t iEventType) {
603 return FALSE;
604 }
SetExecuteRunAt(int32_t iExecuteRunAt)605 FX_BOOL CXFA_Event::SetExecuteRunAt(int32_t iExecuteRunAt) {
606 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute);
607 return pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iExecuteRunAt);
608 }
SetExecuteType(int32_t iExecuteType)609 FX_BOOL CXFA_Event::SetExecuteType(int32_t iExecuteType) {
610 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute);
611 return pNode->SetEnum(XFA_ATTRIBUTE_ExecuteType,
612 (XFA_ATTRIBUTEENUM)iExecuteType);
613 }
SetExecuteConnection(const CFX_WideString & wsConnection)614 FX_BOOL CXFA_Event::SetExecuteConnection(const CFX_WideString& wsConnection) {
615 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute);
616 return pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection);
617 }
SetSignDataOperation(int32_t iOperation)618 FX_BOOL CXFA_Event::SetSignDataOperation(int32_t iOperation) {
619 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData);
620 return pNode->SetEnum(XFA_ATTRIBUTE_Operation, (XFA_ATTRIBUTEENUM)iOperation);
621 }
SetSignDataTarget(const CFX_WideString & wsTarget)622 FX_BOOL CXFA_Event::SetSignDataTarget(const CFX_WideString& wsTarget) {
623 if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData)) {
624 return pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget);
625 }
626 return FALSE;
627 }
CXFA_Script(CXFA_Node * pNode)628 CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetBinding(CFX_WideString & wsBinding)629 void CXFA_Script::GetBinding(CFX_WideString& wsBinding) {
630 CFX_WideStringC cData;
631 m_pNode->TryCData(XFA_ATTRIBUTE_Binding, cData);
632 wsBinding = cData;
633 }
GetContentType()634 XFA_SCRIPTTYPE CXFA_Script::GetContentType() {
635 CFX_WideStringC cData;
636 if (m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, cData, FALSE)) {
637 if (cData == FX_WSTRC(L"application/x-javascript")) {
638 return XFA_SCRIPTTYPE_Javascript;
639 } else if (cData == FX_WSTRC(L"application/x-formcalc")) {
640 return XFA_SCRIPTTYPE_Formcalc;
641 } else {
642 return XFA_SCRIPTTYPE_Unkown;
643 }
644 }
645 return XFA_SCRIPTTYPE_Formcalc;
646 }
GetRunAt()647 int32_t CXFA_Script::GetRunAt() {
648 return m_pNode->GetEnum(XFA_ATTRIBUTE_RunAt);
649 }
GetExpression(CFX_WideString & wsExpression)650 void CXFA_Script::GetExpression(CFX_WideString& wsExpression) {
651 m_pNode->TryContent(wsExpression);
652 }
SetBinding(const CFX_WideString & wsBinding)653 FX_BOOL CXFA_Script::SetBinding(const CFX_WideString& wsBinding) {
654 return m_pNode->SetCData(XFA_ATTRIBUTE_Binding, wsBinding);
655 }
SetContentType(XFA_SCRIPTTYPE eType)656 FX_BOOL CXFA_Script::SetContentType(XFA_SCRIPTTYPE eType) {
657 CFX_WideString wsType;
658 switch (eType) {
659 case XFA_SCRIPTTYPE_Javascript:
660 wsType = L"application/x-javascript";
661 break;
662 case XFA_SCRIPTTYPE_Formcalc:
663 wsType = L"application/x-formcalc";
664 break;
665 default:
666 break;
667 }
668 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsType);
669 }
SetRunAt(int32_t iRunAt)670 FX_BOOL CXFA_Script::SetRunAt(int32_t iRunAt) {
671 return m_pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iRunAt);
672 }
SetExpression(const CFX_WideString & wsExpression)673 FX_BOOL CXFA_Script::SetExpression(const CFX_WideString& wsExpression) {
674 return m_pNode->SetContent(wsExpression, wsExpression);
675 }
CXFA_Submit(CXFA_Node * pNode)676 CXFA_Submit::CXFA_Submit(CXFA_Node* pNode) : CXFA_Data(pNode) {}
IsSubmitEmbedPDF()677 FX_BOOL CXFA_Submit::IsSubmitEmbedPDF() {
678 return m_pNode->GetBoolean(XFA_ATTRIBUTE_EmbedPDF);
679 }
GetSubmitFormat()680 int32_t CXFA_Submit::GetSubmitFormat() {
681 return m_pNode->GetEnum(XFA_ATTRIBUTE_Format);
682 }
GetSubmitTarget(CFX_WideStringC & wsTarget)683 void CXFA_Submit::GetSubmitTarget(CFX_WideStringC& wsTarget) {
684 m_pNode->TryCData(XFA_ATTRIBUTE_Target, wsTarget);
685 }
GetSubmitTextEncoding()686 XFA_TEXTENCODING CXFA_Submit::GetSubmitTextEncoding() {
687 CFX_WideStringC wsCData;
688 if (!m_pNode->TryCData(XFA_ATTRIBUTE_TextEncoding, wsCData)) {
689 return XFA_TEXTENCODING_None;
690 }
691 CFX_WideString wsValue(wsCData);
692 if (wsValue == L"Big-Five") {
693 return XFA_TEXTENCODING_Big5;
694 } else if (wsValue == L"fontSpecific") {
695 return XFA_TEXTENCODING_FontSpecific;
696 } else if (wsValue == L"GBK") {
697 return XFA_TEXTENCODING_GBK;
698 } else if (wsValue == L"GB-18030") {
699 return XFA_TEXTENCODING_GB18030;
700 } else if (wsValue == L"GB-2312") {
701 return XFA_TEXTENCODING_GB2312;
702 } else if (wsValue == L"ISO-8859-NN") {
703 return XFA_TEXTENCODING_ISO8859NN;
704 } else if (wsValue == L"KSC-5601") {
705 return XFA_TEXTENCODING_KSC5601;
706 } else if (wsValue == L"Shift-JIS") {
707 return XFA_TEXTENCODING_ShiftJIS;
708 } else if (wsValue == L"UCS-2") {
709 return XFA_TEXTENCODING_UCS2;
710 } else if (wsValue == L"UTF-16") {
711 return XFA_TEXTENCODING_UTF16;
712 } else if (wsValue == L"UTF-8") {
713 return XFA_TEXTENCODING_UTF8;
714 }
715 return XFA_TEXTENCODING_None;
716 }
GetSubmitXDPContent(CFX_WideStringC & wsContent)717 void CXFA_Submit::GetSubmitXDPContent(CFX_WideStringC& wsContent) {
718 m_pNode->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent);
719 }
SetSubmitFormat(int32_t iSubmitFormat)720 FX_BOOL CXFA_Submit::SetSubmitFormat(int32_t iSubmitFormat) {
721 return m_pNode->SetEnum(XFA_ATTRIBUTE_Format,
722 (XFA_ATTRIBUTEENUM)iSubmitFormat);
723 }
SetSubmitTarget(const CFX_WideString & wsTarget)724 FX_BOOL CXFA_Submit::SetSubmitTarget(const CFX_WideString& wsTarget) {
725 return m_pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget);
726 }
SetSubmitTextEncoding(XFA_TEXTENCODING eTextEncoding)727 FX_BOOL CXFA_Submit::SetSubmitTextEncoding(XFA_TEXTENCODING eTextEncoding) {
728 CFX_WideString wsValue;
729 switch (eTextEncoding) {
730 case XFA_TEXTENCODING_Big5:
731 wsValue = L"Big-Five";
732 break;
733 case XFA_TEXTENCODING_FontSpecific:
734 wsValue = L"fontSpecific";
735 break;
736 case XFA_TEXTENCODING_GBK:
737 wsValue = L"GBK";
738 break;
739 case XFA_TEXTENCODING_GB18030:
740 wsValue = L"GB-18030";
741 break;
742 case XFA_TEXTENCODING_GB2312:
743 wsValue = L"GB-2312";
744 break;
745 case XFA_TEXTENCODING_ISO8859NN:
746 wsValue = L"ISO-8859-NN";
747 break;
748 case XFA_TEXTENCODING_KSC5601:
749 wsValue = L"KSC-5601";
750 break;
751 case XFA_TEXTENCODING_ShiftJIS:
752 wsValue = L"Shift-JIS";
753 break;
754 case XFA_TEXTENCODING_UCS2:
755 wsValue = L"UCS-2";
756 break;
757 case XFA_TEXTENCODING_UTF16:
758 wsValue = L"UTF-16";
759 break;
760 case XFA_TEXTENCODING_UTF8:
761 wsValue = L"UTF-8";
762 break;
763 default:
764 break;
765 }
766 return m_pNode->SetCData(XFA_ATTRIBUTE_TextEncoding, wsValue);
767 }
SetSubmitXDPContent(const CFX_WideString & wsContent)768 FX_BOOL CXFA_Submit::SetSubmitXDPContent(const CFX_WideString& wsContent) {
769 return m_pNode->SetCData(XFA_ATTRIBUTE_XdpContent, wsContent);
770 }
GetChildValueClassID()771 XFA_ELEMENT CXFA_Value::GetChildValueClassID() {
772 if (!m_pNode) {
773 return XFA_ELEMENT_UNKNOWN;
774 }
775 if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) {
776 return pNode->GetClassID();
777 }
778 return XFA_ELEMENT_UNKNOWN;
779 }
GetChildValueContent(CFX_WideString & wsContent)780 FX_BOOL CXFA_Value::GetChildValueContent(CFX_WideString& wsContent) {
781 if (!m_pNode) {
782 return FALSE;
783 }
784 if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) {
785 return pNode->TryContent(wsContent);
786 }
787 return FALSE;
788 }
GetArc()789 CXFA_Arc CXFA_Value::GetArc() {
790 return m_pNode ? CXFA_Arc(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
791 : NULL;
792 }
GetLine()793 CXFA_Line CXFA_Value::GetLine() {
794 return m_pNode ? CXFA_Line(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
795 : NULL;
796 }
GetRectangle()797 CXFA_Rectangle CXFA_Value::GetRectangle() {
798 return m_pNode ? CXFA_Rectangle(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
799 : NULL;
800 }
GetText()801 CXFA_Text CXFA_Value::GetText() {
802 return m_pNode ? CXFA_Text(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
803 : NULL;
804 }
GetExData()805 CXFA_ExData CXFA_Value::GetExData() {
806 return m_pNode ? CXFA_ExData(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
807 : NULL;
808 }
GetImage()809 CXFA_Image CXFA_Value::GetImage() {
810 return CXFA_Image(
811 m_pNode ? (m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) : NULL, TRUE);
812 }
SetChildValueContent(const CFX_WideString & wsContent,FX_BOOL bNotify,XFA_ELEMENT iType)813 FX_BOOL CXFA_Value::SetChildValueContent(const CFX_WideString& wsContent,
814 FX_BOOL bNotify,
815 XFA_ELEMENT iType) {
816 if (!m_pNode) {
817 return FALSE;
818 }
819 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
820 if (!pNode) {
821 if (iType == XFA_ELEMENT_UNKNOWN) {
822 return FALSE;
823 }
824 pNode = m_pNode->GetProperty(0, iType);
825 }
826 CFX_WideString wsFormatContent(wsContent);
827 CXFA_WidgetData* pContainerWidgetData = pNode->GetContainerWidgetData();
828 if (pContainerWidgetData) {
829 pContainerWidgetData->GetFormatDataValue(wsContent, wsFormatContent);
830 }
831 return pNode->SetContent(wsContent, wsFormatContent, bNotify);
832 }
GetHand()833 int32_t CXFA_Line::GetHand() {
834 return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
835 }
GetSlop()836 FX_BOOL CXFA_Line::GetSlop() {
837 XFA_ATTRIBUTEENUM eSlop = m_pNode->GetEnum(XFA_ATTRIBUTE_Slope);
838 return eSlop == XFA_ATTRIBUTEENUM_Slash;
839 }
GetEdge()840 CXFA_Edge CXFA_Line::GetEdge() {
841 return CXFA_Edge(m_pNode->GetChild(0, XFA_ELEMENT_Edge));
842 }
SetHand(int32_t iHand)843 FX_BOOL CXFA_Line::SetHand(int32_t iHand) {
844 return m_pNode->SetEnum(XFA_ATTRIBUTE_Hand, (XFA_ATTRIBUTEENUM)iHand);
845 }
SetSlop(int32_t iSlop)846 FX_BOOL CXFA_Line::SetSlop(int32_t iSlop) {
847 return m_pNode->SetEnum(XFA_ATTRIBUTE_Slope, (XFA_ATTRIBUTEENUM)iSlop);
848 }
CXFA_Text(CXFA_Node * pNode)849 CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetName(CFX_WideStringC & wsName)850 void CXFA_Text::GetName(CFX_WideStringC& wsName) {
851 m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
852 }
GetMaxChars()853 int32_t CXFA_Text::GetMaxChars() {
854 return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxChars);
855 }
GetRid(CFX_WideStringC & wsRid)856 void CXFA_Text::GetRid(CFX_WideStringC& wsRid) {
857 m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid);
858 }
GetContent(CFX_WideString & wsText)859 void CXFA_Text::GetContent(CFX_WideString& wsText) {
860 m_pNode->TryContent(wsText);
861 }
SetContent(CFX_WideString wsText,FX_BOOL bNotify)862 void CXFA_Text::SetContent(CFX_WideString wsText, FX_BOOL bNotify) {
863 CFX_WideString wsFormatValue(wsText);
864 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData();
865 if (pContainerWidgetData) {
866 pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue);
867 }
868 m_pNode->SetContent(wsText, wsFormatValue, bNotify);
869 }
SetName(const CFX_WideString & wsName)870 FX_BOOL CXFA_Text::SetName(const CFX_WideString& wsName) {
871 return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
872 }
SetMaxChars(int32_t iMaxChars)873 FX_BOOL CXFA_Text::SetMaxChars(int32_t iMaxChars) {
874 return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxChars, iMaxChars);
875 }
SetRid(const CFX_WideString & wsRid)876 FX_BOOL CXFA_Text::SetRid(const CFX_WideString& wsRid) {
877 return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid);
878 }
CXFA_ExData(CXFA_Node * pNode)879 CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetContentType(CFX_WideStringC & wsContentType)880 void CXFA_ExData::GetContentType(CFX_WideStringC& wsContentType) {
881 m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType);
882 }
GetHref(CFX_WideStringC & wsHref)883 void CXFA_ExData::GetHref(CFX_WideStringC& wsHref) {
884 m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref);
885 }
GetMaxLength()886 int32_t CXFA_ExData::GetMaxLength() {
887 return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxLength);
888 }
GetRid(CFX_WideStringC & wsRid)889 void CXFA_ExData::GetRid(CFX_WideStringC& wsRid) {
890 m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid);
891 }
GetTransferEncoding()892 int32_t CXFA_ExData::GetTransferEncoding() {
893 return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding);
894 }
GetContent(CFX_WideString & wsText)895 void CXFA_ExData::GetContent(CFX_WideString& wsText) {
896 m_pNode->TryContent(wsText);
897 }
SetContentType(const CFX_WideString & wsContentType)898 FX_BOOL CXFA_ExData::SetContentType(const CFX_WideString& wsContentType) {
899 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
900 }
SetHref(const CFX_WideString & wsHref)901 FX_BOOL CXFA_ExData::SetHref(const CFX_WideString& wsHref) {
902 return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref);
903 }
SetMaxLength(int32_t iMaxLength)904 FX_BOOL CXFA_ExData::SetMaxLength(int32_t iMaxLength) {
905 return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxLength, iMaxLength);
906 }
SetRid(const CFX_WideString & wsRid)907 FX_BOOL CXFA_ExData::SetRid(const CFX_WideString& wsRid) {
908 return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid);
909 }
SetTransferEncoding(int32_t iTransferEncoding)910 FX_BOOL CXFA_ExData::SetTransferEncoding(int32_t iTransferEncoding) {
911 return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding,
912 (XFA_ATTRIBUTEENUM)iTransferEncoding);
913 }
SetContent(const CFX_WideString & wsText,FX_BOOL bNotify,FX_BOOL bScriptModify,FX_BOOL bSyncData)914 FX_BOOL CXFA_ExData::SetContent(const CFX_WideString& wsText,
915 FX_BOOL bNotify,
916 FX_BOOL bScriptModify,
917 FX_BOOL bSyncData) {
918 CFX_WideString wsFormatValue(wsText);
919 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData();
920 if (pContainerWidgetData) {
921 pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue);
922 }
923 return m_pNode->SetContent(wsText, wsFormatValue, bNotify, bScriptModify,
924 bSyncData);
925 }
CXFA_Image(CXFA_Node * pNode,FX_BOOL bDefValue)926 CXFA_Image::CXFA_Image(CXFA_Node* pNode, FX_BOOL bDefValue)
927 : CXFA_Data(pNode), m_bDefValue(bDefValue) {}
GetAspect()928 int32_t CXFA_Image::GetAspect() {
929 return m_pNode->GetEnum(XFA_ATTRIBUTE_Aspect);
930 }
GetContentType(CFX_WideString & wsContentType)931 FX_BOOL CXFA_Image::GetContentType(CFX_WideString& wsContentType) {
932 return m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType);
933 }
GetHref(CFX_WideString & wsHref)934 FX_BOOL CXFA_Image::GetHref(CFX_WideString& wsHref) {
935 if (m_bDefValue) {
936 return m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref);
937 }
938 return m_pNode->GetAttribute(FX_WSTRC(L"href"), wsHref);
939 }
GetTransferEncoding()940 int32_t CXFA_Image::GetTransferEncoding() {
941 if (m_bDefValue) {
942 return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding);
943 }
944 return XFA_ATTRIBUTEENUM_Base64;
945 }
GetContent(CFX_WideString & wsText)946 FX_BOOL CXFA_Image::GetContent(CFX_WideString& wsText) {
947 return m_pNode->TryContent(wsText);
948 }
SetAspect(int32_t iAspect)949 FX_BOOL CXFA_Image::SetAspect(int32_t iAspect) {
950 return m_pNode->SetEnum(XFA_ATTRIBUTE_Aspect, (XFA_ATTRIBUTEENUM)iAspect);
951 }
SetContentType(const CFX_WideString & wsContentType)952 FX_BOOL CXFA_Image::SetContentType(const CFX_WideString& wsContentType) {
953 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
954 }
SetHref(const CFX_WideString & wsHref)955 FX_BOOL CXFA_Image::SetHref(const CFX_WideString& wsHref) {
956 if (m_bDefValue) {
957 return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref);
958 }
959 return m_pNode->SetAttribute(XFA_ATTRIBUTE_Href, wsHref);
960 }
SetTransferEncoding(int32_t iTransferEncoding)961 FX_BOOL CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) {
962 if (m_bDefValue) {
963 return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding,
964 (XFA_ATTRIBUTEENUM)iTransferEncoding);
965 }
966 return TRUE;
967 }
SetContent(const CFX_WideString & wsText)968 FX_BOOL CXFA_Image::SetContent(const CFX_WideString& wsText) {
969 CFX_WideString wsFormatValue(wsText);
970 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData();
971 if (pContainerWidgetData) {
972 pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue);
973 }
974 return m_pNode->SetContent(wsText, wsFormatValue);
975 }
CXFA_Calculate(CXFA_Node * pNode)976 CXFA_Calculate::CXFA_Calculate(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetOverride()977 int32_t CXFA_Calculate::GetOverride() {
978 XFA_ATTRIBUTEENUM eAtt = XFA_ATTRIBUTEENUM_Error;
979 m_pNode->TryEnum(XFA_ATTRIBUTE_Override, eAtt, FALSE);
980 return eAtt;
981 }
GetScript()982 CXFA_Script CXFA_Calculate::GetScript() {
983 return m_pNode->GetChild(0, XFA_ELEMENT_Script);
984 }
GetMessageText(CFX_WideString & wsMessage)985 void CXFA_Calculate::GetMessageText(CFX_WideString& wsMessage) {
986 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Message)) {
987 CXFA_Text text(pNode->GetChild(0, XFA_ELEMENT_Text));
988 if (text) {
989 text.GetContent(wsMessage);
990 }
991 }
992 }
SetOverride(int32_t iOverride)993 FX_BOOL CXFA_Calculate::SetOverride(int32_t iOverride) {
994 return m_pNode->SetEnum(XFA_ATTRIBUTE_Override, (XFA_ATTRIBUTEENUM)iOverride);
995 }
SetMessageText(const CFX_WideString & wsMessage)996 FX_BOOL CXFA_Calculate::SetMessageText(const CFX_WideString& wsMessage) {
997 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Message)) {
998 CXFA_Node* pChildNode = pNode->GetProperty(0, XFA_ELEMENT_Text);
999 return pChildNode->SetContent(wsMessage, wsMessage);
1000 }
1001 return FALSE;
1002 }
CXFA_Validate(CXFA_Node * pNode)1003 CXFA_Validate::CXFA_Validate(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetFormatTest()1004 int32_t CXFA_Validate::GetFormatTest() {
1005 return m_pNode->GetEnum(XFA_ATTRIBUTE_FormatTest);
1006 }
SetTestValue(int32_t iType,CFX_WideString & wsValue,XFA_ATTRIBUTEENUM eName)1007 FX_BOOL CXFA_Validate::SetTestValue(int32_t iType,
1008 CFX_WideString& wsValue,
1009 XFA_ATTRIBUTEENUM eName) {
1010 XFA_LPCATTRIBUTEENUMINFO pInfo = XFA_GetAttributeEnumByName(wsValue);
1011 if (pInfo) {
1012 eName = pInfo->eName;
1013 }
1014 m_pNode->SetEnum((XFA_ATTRIBUTE)iType, eName, FALSE);
1015 return TRUE;
1016 }
SetFormatTest(CFX_WideString wsValue)1017 FX_BOOL CXFA_Validate::SetFormatTest(CFX_WideString wsValue) {
1018 return SetTestValue(XFA_ATTRIBUTE_FormatTest, wsValue,
1019 XFA_ATTRIBUTEENUM_Warning);
1020 }
SetNullTest(CFX_WideString wsValue)1021 FX_BOOL CXFA_Validate::SetNullTest(CFX_WideString wsValue) {
1022 return SetTestValue(XFA_ATTRIBUTE_NullTest, wsValue,
1023 XFA_ATTRIBUTEENUM_Disabled);
1024 }
GetNullTest()1025 int32_t CXFA_Validate::GetNullTest() {
1026 return m_pNode->GetEnum(XFA_ATTRIBUTE_NullTest);
1027 }
GetScriptTest()1028 int32_t CXFA_Validate::GetScriptTest() {
1029 return m_pNode->GetEnum(XFA_ATTRIBUTE_ScriptTest);
1030 }
GetMessageText(CFX_WideString & wsMessage,const CFX_WideStringC & wsMessageType)1031 void CXFA_Validate::GetMessageText(CFX_WideString& wsMessage,
1032 const CFX_WideStringC& wsMessageType) {
1033 if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, FALSE)) {
1034 CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1035 for (; pItemNode;
1036 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1037 if (pItemNode->GetClassID() != XFA_ELEMENT_Text) {
1038 continue;
1039 }
1040 CFX_WideStringC wsName;
1041 pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
1042 if (wsName.IsEmpty() || wsName == wsMessageType) {
1043 pItemNode->TryContent(wsMessage);
1044 return;
1045 }
1046 }
1047 }
1048 }
SetFormatMessageText(CFX_WideString wsMessage)1049 void CXFA_Validate::SetFormatMessageText(CFX_WideString wsMessage) {
1050 SetMessageText(wsMessage, FX_WSTRC(L"formatTest"));
1051 }
GetFormatMessageText(CFX_WideString & wsMessage)1052 void CXFA_Validate::GetFormatMessageText(CFX_WideString& wsMessage) {
1053 GetMessageText(wsMessage, FX_WSTRC(L"formatTest"));
1054 }
SetNullMessageText(CFX_WideString wsMessage)1055 void CXFA_Validate::SetNullMessageText(CFX_WideString wsMessage) {
1056 SetMessageText(wsMessage, FX_WSTRC(L"nullTest"));
1057 }
GetNullMessageText(CFX_WideString & wsMessage)1058 void CXFA_Validate::GetNullMessageText(CFX_WideString& wsMessage) {
1059 GetMessageText(wsMessage, FX_WSTRC(L"nullTest"));
1060 }
SetMessageText(CFX_WideString & wsMessage,const CFX_WideStringC & wsMessageType)1061 void CXFA_Validate::SetMessageText(CFX_WideString& wsMessage,
1062 const CFX_WideStringC& wsMessageType) {
1063 if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, TRUE)) {
1064 CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1065 for (; pItemNode;
1066 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1067 if (pItemNode->GetClassID() != XFA_ELEMENT_Text) {
1068 continue;
1069 }
1070 CFX_WideStringC wsName;
1071 pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
1072 if (wsName.IsEmpty() || wsName == wsMessageType) {
1073 pItemNode->SetContent(wsMessage, wsMessage, FALSE);
1074 return;
1075 }
1076 }
1077 CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_ELEMENT_Text);
1078 pNode->InsertChild(pTextNode);
1079 pTextNode->SetCData(XFA_ATTRIBUTE_Name, wsMessageType, FALSE);
1080 pTextNode->SetContent(wsMessage, wsMessage, FALSE);
1081 }
1082 }
GetScriptMessageText(CFX_WideString & wsMessage)1083 void CXFA_Validate::GetScriptMessageText(CFX_WideString& wsMessage) {
1084 GetMessageText(wsMessage, FX_WSTRC(L"scriptTest"));
1085 }
SetScriptMessageText(CFX_WideString wsMessage)1086 void CXFA_Validate::SetScriptMessageText(CFX_WideString wsMessage) {
1087 SetMessageText(wsMessage, FX_WSTRC(L"scriptTest"));
1088 }
GetPicture(CFX_WideString & wsPicture)1089 void CXFA_Validate::GetPicture(CFX_WideString& wsPicture) {
1090 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) {
1091 pNode->TryContent(wsPicture);
1092 }
1093 }
GetScript()1094 CXFA_Script CXFA_Validate::GetScript() {
1095 return m_pNode->GetChild(0, XFA_ELEMENT_Script);
1096 }
CXFA_Variables(CXFA_Node * pNode)1097 CXFA_Variables::CXFA_Variables(CXFA_Node* pNode) : CXFA_Data(pNode) {}
CountScripts()1098 int32_t CXFA_Variables::CountScripts() {
1099 return m_pNode->CountChildren(XFA_ELEMENT_Script);
1100 }
GetScript(int32_t nIndex)1101 CXFA_Script CXFA_Variables::GetScript(int32_t nIndex) {
1102 return m_pNode->GetChild(nIndex, XFA_ELEMENT_Script);
1103 }
CXFA_Bind(CXFA_Node * pNode)1104 CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetMatch()1105 int32_t CXFA_Bind::GetMatch() {
1106 return m_pNode->GetEnum(XFA_ATTRIBUTE_Match);
1107 }
GetRef(CFX_WideStringC & wsRef)1108 void CXFA_Bind::GetRef(CFX_WideStringC& wsRef) {
1109 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
1110 }
GetPicture(CFX_WideString & wsPicture)1111 void CXFA_Bind::GetPicture(CFX_WideString& wsPicture) {
1112 if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) {
1113 pPicture->TryContent(wsPicture);
1114 }
1115 }
SetMatch(int32_t iMatch)1116 FX_BOOL CXFA_Bind::SetMatch(int32_t iMatch) {
1117 return m_pNode->SetEnum(XFA_ATTRIBUTE_Match, (XFA_ATTRIBUTEENUM)iMatch);
1118 }
SetRef(const CFX_WideString & wsRef)1119 FX_BOOL CXFA_Bind::SetRef(const CFX_WideString& wsRef) {
1120 return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef);
1121 }
SetPicture(const CFX_WideString & wsPicture)1122 FX_BOOL CXFA_Bind::SetPicture(const CFX_WideString& wsPicture) {
1123 if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) {
1124 return pPicture->SetContent(wsPicture, wsPicture);
1125 }
1126 return FALSE;
1127 }
CXFA_Assist(CXFA_Node * pNode)1128 CXFA_Assist::CXFA_Assist(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetToolTip()1129 CXFA_ToolTip CXFA_Assist::GetToolTip() {
1130 return m_pNode->GetChild(0, XFA_ELEMENT_ToolTip);
1131 }
CXFA_ToolTip(CXFA_Node * pNode)1132 CXFA_ToolTip::CXFA_ToolTip(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetTip(CFX_WideString & wsTip)1133 FX_BOOL CXFA_ToolTip::GetTip(CFX_WideString& wsTip) {
1134 return m_pNode->TryContent(wsTip);
1135 }
SetTip(const CFX_WideString & wsTip)1136 FX_BOOL CXFA_ToolTip::SetTip(const CFX_WideString& wsTip) {
1137 return m_pNode->SetContent(wsTip, wsTip);
1138 }
CXFA_BindItems(CXFA_Node * pNode)1139 CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {}
GetConnection(CFX_WideStringC & wsConnection)1140 void CXFA_BindItems::GetConnection(CFX_WideStringC& wsConnection) {
1141 m_pNode->TryCData(XFA_ATTRIBUTE_Connection, wsConnection);
1142 }
GetLabelRef(CFX_WideStringC & wsLabelRef)1143 void CXFA_BindItems::GetLabelRef(CFX_WideStringC& wsLabelRef) {
1144 m_pNode->TryCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef);
1145 }
GetValueRef(CFX_WideStringC & wsValueRef)1146 void CXFA_BindItems::GetValueRef(CFX_WideStringC& wsValueRef) {
1147 m_pNode->TryCData(XFA_ATTRIBUTE_ValueRef, wsValueRef);
1148 }
GetRef(CFX_WideStringC & wsRef)1149 void CXFA_BindItems::GetRef(CFX_WideStringC& wsRef) {
1150 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
1151 }
SetConnection(const CFX_WideString & wsConnection)1152 FX_BOOL CXFA_BindItems::SetConnection(const CFX_WideString& wsConnection) {
1153 return m_pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection);
1154 }
SetLabelRef(const CFX_WideString & wsLabelRef)1155 FX_BOOL CXFA_BindItems::SetLabelRef(const CFX_WideString& wsLabelRef) {
1156 return m_pNode->SetCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef);
1157 }
SetValueRef(const CFX_WideString & wsValueRef)1158 FX_BOOL CXFA_BindItems::SetValueRef(const CFX_WideString& wsValueRef) {
1159 return m_pNode->SetCData(XFA_ATTRIBUTE_ValueRef, wsValueRef);
1160 }
SetRef(const CFX_WideString & wsRef)1161 FX_BOOL CXFA_BindItems::SetRef(const CFX_WideString& wsRef) {
1162 return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef);
1163 }
GetBreak() const1164 int32_t CXFA_Box::GetBreak() const {
1165 if (!m_pNode) {
1166 return XFA_ATTRIBUTEENUM_Close;
1167 }
1168 return m_pNode->GetEnum(XFA_ATTRIBUTE_Break);
1169 }
GetHand() const1170 int32_t CXFA_Box::GetHand() const {
1171 if (!m_pNode) {
1172 return XFA_ATTRIBUTEENUM_Even;
1173 }
1174 return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
1175 }
GetPresence() const1176 int32_t CXFA_Box::GetPresence() const {
1177 if (!m_pNode) {
1178 return XFA_ATTRIBUTEENUM_Hidden;
1179 }
1180 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
1181 }
CountCorners() const1182 int32_t CXFA_Box::CountCorners() const {
1183 if (!m_pNode) {
1184 return 0;
1185 }
1186 return m_pNode->CountChildren(XFA_ELEMENT_Corner);
1187 }
GetCorner(int32_t nIndex) const1188 CXFA_Corner CXFA_Box::GetCorner(int32_t nIndex) const {
1189 if (!m_pNode) {
1190 return NULL;
1191 }
1192 return CXFA_Corner(
1193 m_pNode->GetProperty(nIndex, XFA_ELEMENT_Corner, nIndex == 0));
1194 }
CountEdges() const1195 int32_t CXFA_Box::CountEdges() const {
1196 if (!m_pNode) {
1197 return 0;
1198 }
1199 return m_pNode->CountChildren(XFA_ELEMENT_Edge);
1200 }
GetEdge(int32_t nIndex) const1201 CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const {
1202 if (!m_pNode) {
1203 return NULL;
1204 }
1205 return CXFA_Edge(m_pNode->GetProperty(nIndex, XFA_ELEMENT_Edge, nIndex == 0));
1206 }
XFA_BOX_GetStrokes(CXFA_Node * pNode,CXFA_StrokeArray & strokes,FX_BOOL bNULL)1207 static void XFA_BOX_GetStrokes(CXFA_Node* pNode,
1208 CXFA_StrokeArray& strokes,
1209 FX_BOOL bNULL) {
1210 strokes.RemoveAll();
1211 if (!pNode) {
1212 return;
1213 }
1214 strokes.SetSize(8);
1215 int32_t i, j;
1216 for (i = 0, j = 0; i < 4; i++) {
1217 CXFA_Corner corner =
1218 CXFA_Corner(pNode->GetProperty(i, XFA_ELEMENT_Corner, i == 0));
1219 if (corner.IsExistInXML() || i == 0) {
1220 strokes.SetAt(j, corner);
1221 } else if (bNULL) {
1222 strokes.SetAt(j, NULL);
1223 } else if (i == 1) {
1224 strokes.SetAt(j, strokes[0]);
1225 } else if (i == 2) {
1226 strokes.SetAt(j, strokes[0]);
1227 } else {
1228 strokes.SetAt(j, strokes[2]);
1229 }
1230 j++;
1231 CXFA_Edge edge = CXFA_Edge(pNode->GetProperty(i, XFA_ELEMENT_Edge, i == 0));
1232 if (edge.IsExistInXML() || i == 0) {
1233 strokes.SetAt(j, edge);
1234 } else if (bNULL) {
1235 strokes.SetAt(j, NULL);
1236 } else if (i == 1) {
1237 strokes.SetAt(j, strokes[1]);
1238 } else if (i == 2) {
1239 strokes.SetAt(j, strokes[1]);
1240 } else {
1241 strokes.SetAt(j, strokes[3]);
1242 }
1243 j++;
1244 }
1245 }
GetStrokes(CXFA_StrokeArray & strokes) const1246 void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const {
1247 XFA_BOX_GetStrokes(m_pNode, strokes, FALSE);
1248 }
IsCircular() const1249 FX_BOOL CXFA_Box::IsCircular() const {
1250 if (!m_pNode) {
1251 return FALSE;
1252 }
1253 return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular);
1254 }
GetStartAngle(FX_FLOAT & fStartAngle) const1255 FX_BOOL CXFA_Box::GetStartAngle(FX_FLOAT& fStartAngle) const {
1256 fStartAngle = 0;
1257 if (!m_pNode) {
1258 return FALSE;
1259 }
1260 CXFA_Measurement ms;
1261 FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, FALSE);
1262 if (bRet) {
1263 fStartAngle = ms.GetValue();
1264 }
1265 return bRet;
1266 }
GetSweepAngle(FX_FLOAT & fSweepAngle) const1267 FX_BOOL CXFA_Box::GetSweepAngle(FX_FLOAT& fSweepAngle) const {
1268 fSweepAngle = 360;
1269 if (!m_pNode) {
1270 return FALSE;
1271 }
1272 CXFA_Measurement ms;
1273 FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, FALSE);
1274 if (bRet) {
1275 fSweepAngle = ms.GetValue();
1276 }
1277 return bRet;
1278 }
GetFill(FX_BOOL bModified) const1279 CXFA_Fill CXFA_Box::GetFill(FX_BOOL bModified) const {
1280 if (!m_pNode) {
1281 return NULL;
1282 }
1283 CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_ELEMENT_Fill, bModified);
1284 return CXFA_Fill(pFillNode);
1285 }
GetMargin() const1286 CXFA_Margin CXFA_Box::GetMargin() const {
1287 if (!m_pNode) {
1288 return NULL;
1289 }
1290 return CXFA_Margin(m_pNode->GetChild(0, XFA_ELEMENT_Margin));
1291 }
XFA_BOX_SameStyles(const CXFA_StrokeArray & strokes)1292 static FX_BOOL XFA_BOX_SameStyles(const CXFA_StrokeArray& strokes) {
1293 int32_t iCount = strokes.GetSize();
1294 if (iCount < 1) {
1295 return TRUE;
1296 }
1297 CXFA_Stroke stroke1 = strokes[0];
1298 for (int32_t i = 1; i < iCount; i++) {
1299 CXFA_Stroke stroke2 = strokes[i];
1300 if (!stroke2.IsExistInXML()) {
1301 continue;
1302 }
1303 if (!stroke1.IsExistInXML()) {
1304 stroke1 = stroke2;
1305 } else if (!stroke1.SameStyles(stroke2)) {
1306 return FALSE;
1307 }
1308 }
1309 return TRUE;
1310 }
SameStyles() const1311 FX_BOOL CXFA_Box::SameStyles() const {
1312 if (IsArc()) {
1313 return TRUE;
1314 }
1315 CXFA_StrokeArray strokes;
1316 XFA_BOX_GetStrokes(m_pNode, strokes, TRUE);
1317 return XFA_BOX_SameStyles(strokes);
1318 }
XFA_BOX_3DStyle(const CXFA_StrokeArray & strokes,CXFA_Stroke & stroke)1319 static int32_t XFA_BOX_3DStyle(const CXFA_StrokeArray& strokes,
1320 CXFA_Stroke& stroke) {
1321 int32_t iCount = strokes.GetSize();
1322 if (iCount < 1) {
1323 return 0;
1324 }
1325 stroke = strokes[0];
1326 for (int32_t i = 1; i < iCount; i++) {
1327 CXFA_Stroke find = strokes[i];
1328 if (!find.IsExistInXML()) {
1329 continue;
1330 }
1331 if (!stroke.IsExistInXML()) {
1332 stroke = find;
1333 } else if (stroke.GetStrokeType() != find.GetStrokeType()) {
1334 stroke = find;
1335 break;
1336 }
1337 }
1338 int32_t iType = stroke.GetStrokeType();
1339 if (iType == XFA_ATTRIBUTEENUM_Lowered || iType == XFA_ATTRIBUTEENUM_Raised ||
1340 iType == XFA_ATTRIBUTEENUM_Etched ||
1341 iType == XFA_ATTRIBUTEENUM_Embossed) {
1342 return iType;
1343 }
1344 return 0;
1345 }
Get3DStyle(FX_BOOL & bVisible,FX_FLOAT & fThickness) const1346 int32_t CXFA_Box::Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const {
1347 if (IsArc()) {
1348 return 0;
1349 }
1350 CXFA_StrokeArray strokes;
1351 XFA_BOX_GetStrokes(m_pNode, strokes, TRUE);
1352 CXFA_Stroke stroke(NULL);
1353 int32_t iType = XFA_BOX_3DStyle(strokes, stroke);
1354 if (iType) {
1355 bVisible = stroke.IsVisible();
1356 fThickness = stroke.GetThickness();
1357 }
1358 return iType;
1359 }
GetPresence() const1360 int32_t CXFA_Stroke::GetPresence() const {
1361 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence)
1362 : XFA_ATTRIBUTEENUM_Invisible;
1363 }
GetCapType() const1364 int32_t CXFA_Stroke::GetCapType() const {
1365 if (!m_pNode) {
1366 return XFA_ATTRIBUTEENUM_Square;
1367 }
1368 return m_pNode->GetEnum(XFA_ATTRIBUTE_Cap);
1369 }
GetStrokeType() const1370