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" 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 } 66 XFA_ELEMENT CXFA_Data::GetClassID() const { 67 return m_pNode ? m_pNode->GetClassID() : XFA_ELEMENT_UNKNOWN; 68 } 69 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 } 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 } 83 CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {} 84 CXFA_Fill::~CXFA_Fill() {} 85 int32_t CXFA_Fill::GetPresence() { 86 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); 87 } 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 } 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 } 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 } 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 } 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 } 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 } 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 } 169 FX_BOOL CXFA_Fill::SetPresence(int32_t iPresence) { 170 return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); 171 } 172 FX_BOOL CXFA_Fill::SetFillType(int32_t iType) { 173 return FALSE; 174 } 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 } 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 } 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 } 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 } 215 CXFA_Margin::CXFA_Margin(CXFA_Node* pNode) : CXFA_Data(pNode) {} 216 FX_BOOL CXFA_Margin::GetLeftInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const { 217 fInset = fDefInset; 218 return TryMeasure(XFA_ATTRIBUTE_LeftInset, fInset); 219 } 220 FX_BOOL CXFA_Margin::GetTopInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const { 221 fInset = fDefInset; 222 return TryMeasure(XFA_ATTRIBUTE_TopInset, fInset); 223 } 224 FX_BOOL CXFA_Margin::GetRightInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const { 225 fInset = fDefInset; 226 return TryMeasure(XFA_ATTRIBUTE_RightInset, fInset); 227 } 228 FX_BOOL CXFA_Margin::GetBottomInset(FX_FLOAT& fInset, 229 FX_FLOAT fDefInset) const { 230 fInset = fDefInset; 231 return TryMeasure(XFA_ATTRIBUTE_BottomInset, fInset); 232 } 233 FX_BOOL CXFA_Margin::SetLeftInset(FX_FLOAT fInset) { 234 return SetMeasure(XFA_ATTRIBUTE_LeftInset, fInset); 235 } 236 FX_BOOL CXFA_Margin::SetTopInset(FX_FLOAT fInset) { 237 return SetMeasure(XFA_ATTRIBUTE_TopInset, fInset); 238 } 239 FX_BOOL CXFA_Margin::SetRightInset(FX_FLOAT fInset) { 240 return SetMeasure(XFA_ATTRIBUTE_RightInset, fInset); 241 } 242 FX_BOOL CXFA_Margin::SetBottomInset(FX_FLOAT fInset) { 243 return SetMeasure(XFA_ATTRIBUTE_BottomInset, fInset); 244 } 245 CXFA_Font::CXFA_Font(CXFA_Node* pNode) : CXFA_Data(pNode) {} 246 FX_FLOAT CXFA_Font::GetBaselineShift() { 247 return m_pNode->GetMeasure(XFA_ATTRIBUTE_BaselineShift).ToUnit(XFA_UNIT_Pt); 248 } 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 } 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 } 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 } 272 int32_t CXFA_Font::GetLineThrough() { 273 int32_t iValue = 0; 274 m_pNode->TryInteger(XFA_ATTRIBUTE_LineThrough, iValue); 275 return iValue; 276 } 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 } 282 int32_t CXFA_Font::GetOverline() { 283 int32_t iValue = 0; 284 m_pNode->TryInteger(XFA_ATTRIBUTE_Overline, iValue); 285 return iValue; 286 } 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 } 292 int32_t CXFA_Font::GetUnderline() { 293 int32_t iValue = 0; 294 m_pNode->TryInteger(XFA_ATTRIBUTE_Underline, iValue); 295 return iValue; 296 } 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 } 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 } 307 void CXFA_Font::GetTypeface(CFX_WideStringC& wsTypeFace) { 308 m_pNode->TryCData(XFA_ATTRIBUTE_Typeface, wsTypeFace); 309 } 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 } 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 } 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 } 325 void CXFA_Font::SetColor(FX_ARGB color) { 326 CXFA_Fill fill = m_pNode->GetProperty(0, XFA_ELEMENT_Fill); 327 fill.SetColor(color); 328 } 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 } 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 } 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 } 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 } 349 FX_BOOL CXFA_Font::SetLetterSpacing(FX_FLOAT fLetterSpacing, XFA_UNIT eUnit) { 350 return FALSE; 351 } 352 FX_BOOL CXFA_Font::SetLineThrough(int32_t iLineThrough) { 353 return m_pNode->SetInteger(XFA_ATTRIBUTE_LineThrough, iLineThrough); 354 } 355 FX_BOOL CXFA_Font::SetLineThroughPeriod(int32_t iLineThroughPeriod) { 356 return m_pNode->SetEnum(XFA_ATTRIBUTE_LineThroughPeriod, 357 (XFA_ATTRIBUTEENUM)iLineThroughPeriod); 358 } 359 FX_BOOL CXFA_Font::SetOverline(int32_t iOverline) { 360 return m_pNode->SetInteger(XFA_ATTRIBUTE_Overline, iOverline); 361 } 362 FX_BOOL CXFA_Font::SetOverlinePeriod(int32_t iOverlinePeriod) { 363 return m_pNode->SetEnum(XFA_ATTRIBUTE_OverlinePeriod, 364 (XFA_ATTRIBUTEENUM)iOverlinePeriod); 365 } 366 FX_BOOL CXFA_Font::SetUnderline(int32_t iUnderline) { 367 return m_pNode->SetInteger(XFA_ATTRIBUTE_Underline, iUnderline); 368 } 369 FX_BOOL CXFA_Font::SetUnderlinePeriod(int32_t iUnderlinePeriod) { 370 return m_pNode->SetEnum(XFA_ATTRIBUTE_UnderlinePeriod, 371 (XFA_ATTRIBUTEENUM)iUnderlinePeriod); 372 } 373 CXFA_Caption::CXFA_Caption(CXFA_Node* pNode) : CXFA_Data(pNode) {} 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 } 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 } 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 } 389 CXFA_Margin CXFA_Caption::GetMargin() { 390 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin) : NULL); 391 } 392 CXFA_Font CXFA_Caption::GetFont() { 393 return CXFA_Font(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Font) : NULL); 394 } 395 CXFA_Value CXFA_Caption::GetValue() { 396 return CXFA_Value(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Value) : NULL); 397 } 398 CXFA_Para CXFA_Caption::GetPara() { 399 return CXFA_Para(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Para) : NULL); 400 } 401 FX_BOOL CXFA_Caption::SetPresence(int32_t iPresence) { 402 return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); 403 } 404 FX_BOOL CXFA_Caption::SetPlacementType(int32_t iType) { 405 return m_pNode->SetEnum(XFA_ATTRIBUTE_Placement, (XFA_ATTRIBUTEENUM)iType); 406 } 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 } 411 CXFA_Para::CXFA_Para(CXFA_Node* pNode) : CXFA_Data(pNode) {} 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 } 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 } 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 } 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 } 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 } 437 int32_t CXFA_Para::GetOrphans() { 438 int32_t iValue = 0; 439 m_pNode->TryInteger(XFA_ATTRIBUTE_Orphans, iValue); 440 return iValue; 441 } 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 } 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 } 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 } 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 } 462 int32_t CXFA_Para::GetWidows() { 463 int32_t iValue = 0; 464 m_pNode->TryInteger(XFA_ATTRIBUTE_Widows, iValue); 465 return iValue; 466 } 467 FX_BOOL CXFA_Para::SetHorizontalAlign(int32_t iHorizontalAlign) { 468 return m_pNode->SetEnum(XFA_ATTRIBUTE_HAlign, 469 (XFA_ATTRIBUTEENUM)iHorizontalAlign); 470 } 471 FX_BOOL CXFA_Para::SetVerticalAlign(int32_t iVerticalAlign) { 472 return m_pNode->SetEnum(XFA_ATTRIBUTE_VAlign, 473 (XFA_ATTRIBUTEENUM)iVerticalAlign); 474 } 475 FX_BOOL CXFA_Para::SetLineHeight(FX_FLOAT fLineHeight) { 476 CXFA_Measurement ms; 477 return m_pNode->SetMeasure(XFA_ATTRIBUTE_LineHeight, ms); 478 } 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 } 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 } 487 FX_BOOL CXFA_Para::SetOrphans(int32_t iOrphans) { 488 return m_pNode->SetInteger(XFA_ATTRIBUTE_Orphans, iOrphans); 489 } 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 } 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 } 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 } 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 } 506 FX_BOOL CXFA_Para::SetWidows(int32_t iWidows) { 507 return m_pNode->SetInteger(XFA_ATTRIBUTE_Widows, iWidows); 508 } 509 CXFA_Keep::CXFA_Keep(CXFA_Node* pNode, CXFA_Node* pParent) 510 : CXFA_Data(pNode), m_pParent(pParent) {} 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 } 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 } 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 } 541 FX_BOOL CXFA_Keep::SetIntact(int32_t iIntact) { 542 return m_pNode->SetEnum(XFA_ATTRIBUTE_Intact, (XFA_ATTRIBUTEENUM)iIntact); 543 } 544 FX_BOOL CXFA_Keep::SetNext(int32_t iNext) { 545 return m_pNode->SetEnum(XFA_ATTRIBUTE_Next, (XFA_ATTRIBUTEENUM)iNext); 546 } 547 FX_BOOL CXFA_Keep::SetPrevious(int32_t iPrevious) { 548 return m_pNode->SetEnum(XFA_ATTRIBUTE_Previous, (XFA_ATTRIBUTEENUM)iPrevious); 549 } 550 CXFA_Event::CXFA_Event(CXFA_Node* pNode) : CXFA_Data(pNode) {} 551 int32_t CXFA_Event::GetActivity() { 552 return m_pNode->GetEnum(XFA_ATTRIBUTE_Activity); 553 } 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 } 565 void CXFA_Event::GetRef(CFX_WideStringC& wsRef) { 566 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef); 567 } 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 } 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 } 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 } 582 CXFA_Script CXFA_Event::GetScript() { 583 return m_pNode->GetChild(0, XFA_ELEMENT_Script); 584 } 585 CXFA_Submit CXFA_Event::GetSubmit() { 586 return m_pNode->GetChild(0, XFA_ELEMENT_Submit); 587 } 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 } 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 } 599 FX_BOOL CXFA_Event::SetActivity(int32_t iActivity) { 600 return m_pNode->SetEnum(XFA_ATTRIBUTE_Activity, (XFA_ATTRIBUTEENUM)iActivity); 601 } 602 FX_BOOL CXFA_Event::SetEventType(int32_t iEventType) { 603 return FALSE; 604 } 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 } 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 } 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 } 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 } 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 } 628 CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {} 629 void CXFA_Script::GetBinding(CFX_WideString& wsBinding) { 630 CFX_WideStringC cData; 631 m_pNode->TryCData(XFA_ATTRIBUTE_Binding, cData); 632 wsBinding = cData; 633 } 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 } 647 int32_t CXFA_Script::GetRunAt() { 648 return m_pNode->GetEnum(XFA_ATTRIBUTE_RunAt); 649 } 650 void CXFA_Script::GetExpression(CFX_WideString& wsExpression) { 651 m_pNode->TryContent(wsExpression); 652 } 653 FX_BOOL CXFA_Script::SetBinding(const CFX_WideString& wsBinding) { 654 return m_pNode->SetCData(XFA_ATTRIBUTE_Binding, wsBinding); 655 } 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 } 670 FX_BOOL CXFA_Script::SetRunAt(int32_t iRunAt) { 671 return m_pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iRunAt); 672 } 673 FX_BOOL CXFA_Script::SetExpression(const CFX_WideString& wsExpression) { 674 return m_pNode->SetContent(wsExpression, wsExpression); 675 } 676 CXFA_Submit::CXFA_Submit(CXFA_Node* pNode) : CXFA_Data(pNode) {} 677 FX_BOOL CXFA_Submit::IsSubmitEmbedPDF() { 678 return m_pNode->GetBoolean(XFA_ATTRIBUTE_EmbedPDF); 679 } 680 int32_t CXFA_Submit::GetSubmitFormat() { 681 return m_pNode->GetEnum(XFA_ATTRIBUTE_Format); 682 } 683 void CXFA_Submit::GetSubmitTarget(CFX_WideStringC& wsTarget) { 684 m_pNode->TryCData(XFA_ATTRIBUTE_Target, wsTarget); 685 } 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 } 717 void CXFA_Submit::GetSubmitXDPContent(CFX_WideStringC& wsContent) { 718 m_pNode->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent); 719 } 720 FX_BOOL CXFA_Submit::SetSubmitFormat(int32_t iSubmitFormat) { 721 return m_pNode->SetEnum(XFA_ATTRIBUTE_Format, 722 (XFA_ATTRIBUTEENUM)iSubmitFormat); 723 } 724 FX_BOOL CXFA_Submit::SetSubmitTarget(const CFX_WideString& wsTarget) { 725 return m_pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget); 726 } 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 } 768 FX_BOOL CXFA_Submit::SetSubmitXDPContent(const CFX_WideString& wsContent) { 769 return m_pNode->SetCData(XFA_ATTRIBUTE_XdpContent, wsContent); 770 } 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 } 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 } 789 CXFA_Arc CXFA_Value::GetArc() { 790 return m_pNode ? CXFA_Arc(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) 791 : NULL; 792 } 793 CXFA_Line CXFA_Value::GetLine() { 794 return m_pNode ? CXFA_Line(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) 795 : NULL; 796 } 797 CXFA_Rectangle CXFA_Value::GetRectangle() { 798 return m_pNode ? CXFA_Rectangle(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) 799 : NULL; 800 } 801 CXFA_Text CXFA_Value::GetText() { 802 return m_pNode ? CXFA_Text(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) 803 : NULL; 804 } 805 CXFA_ExData CXFA_Value::GetExData() { 806 return m_pNode ? CXFA_ExData(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) 807 : NULL; 808 } 809 CXFA_Image CXFA_Value::GetImage() { 810 return CXFA_Image( 811 m_pNode ? (m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) : NULL, TRUE); 812 } 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 } 833 int32_t CXFA_Line::GetHand() { 834 return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand); 835 } 836 FX_BOOL CXFA_Line::GetSlop() { 837 XFA_ATTRIBUTEENUM eSlop = m_pNode->GetEnum(XFA_ATTRIBUTE_Slope); 838 return eSlop == XFA_ATTRIBUTEENUM_Slash; 839 } 840 CXFA_Edge CXFA_Line::GetEdge() { 841 return CXFA_Edge(m_pNode->GetChild(0, XFA_ELEMENT_Edge)); 842 } 843 FX_BOOL CXFA_Line::SetHand(int32_t iHand) { 844 return m_pNode->SetEnum(XFA_ATTRIBUTE_Hand, (XFA_ATTRIBUTEENUM)iHand); 845 } 846 FX_BOOL CXFA_Line::SetSlop(int32_t iSlop) { 847 return m_pNode->SetEnum(XFA_ATTRIBUTE_Slope, (XFA_ATTRIBUTEENUM)iSlop); 848 } 849 CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {} 850 void CXFA_Text::GetName(CFX_WideStringC& wsName) { 851 m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); 852 } 853 int32_t CXFA_Text::GetMaxChars() { 854 return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxChars); 855 } 856 void CXFA_Text::GetRid(CFX_WideStringC& wsRid) { 857 m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid); 858 } 859 void CXFA_Text::GetContent(CFX_WideString& wsText) { 860 m_pNode->TryContent(wsText); 861 } 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 } 870 FX_BOOL CXFA_Text::SetName(const CFX_WideString& wsName) { 871 return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); 872 } 873 FX_BOOL CXFA_Text::SetMaxChars(int32_t iMaxChars) { 874 return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxChars, iMaxChars); 875 } 876 FX_BOOL CXFA_Text::SetRid(const CFX_WideString& wsRid) { 877 return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid); 878 } 879 CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {} 880 void CXFA_ExData::GetContentType(CFX_WideStringC& wsContentType) { 881 m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType); 882 } 883 void CXFA_ExData::GetHref(CFX_WideStringC& wsHref) { 884 m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref); 885 } 886 int32_t CXFA_ExData::GetMaxLength() { 887 return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxLength); 888 } 889 void CXFA_ExData::GetRid(CFX_WideStringC& wsRid) { 890 m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid); 891 } 892 int32_t CXFA_ExData::GetTransferEncoding() { 893 return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding); 894 } 895 void CXFA_ExData::GetContent(CFX_WideString& wsText) { 896 m_pNode->TryContent(wsText); 897 } 898 FX_BOOL CXFA_ExData::SetContentType(const CFX_WideString& wsContentType) { 899 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); 900 } 901 FX_BOOL CXFA_ExData::SetHref(const CFX_WideString& wsHref) { 902 return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref); 903 } 904 FX_BOOL CXFA_ExData::SetMaxLength(int32_t iMaxLength) { 905 return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxLength, iMaxLength); 906 } 907 FX_BOOL CXFA_ExData::SetRid(const CFX_WideString& wsRid) { 908 return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid); 909 } 910 FX_BOOL CXFA_ExData::SetTransferEncoding(int32_t iTransferEncoding) { 911 return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding, 912 (XFA_ATTRIBUTEENUM)iTransferEncoding); 913 } 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 } 926 CXFA_Image::CXFA_Image(CXFA_Node* pNode, FX_BOOL bDefValue) 927 : CXFA_Data(pNode), m_bDefValue(bDefValue) {} 928 int32_t CXFA_Image::GetAspect() { 929 return m_pNode->GetEnum(XFA_ATTRIBUTE_Aspect); 930 } 931 FX_BOOL CXFA_Image::GetContentType(CFX_WideString& wsContentType) { 932 return m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType); 933 } 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 } 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 } 946 FX_BOOL CXFA_Image::GetContent(CFX_WideString& wsText) { 947 return m_pNode->TryContent(wsText); 948 } 949 FX_BOOL CXFA_Image::SetAspect(int32_t iAspect) { 950 return m_pNode->SetEnum(XFA_ATTRIBUTE_Aspect, (XFA_ATTRIBUTEENUM)iAspect); 951 } 952 FX_BOOL CXFA_Image::SetContentType(const CFX_WideString& wsContentType) { 953 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); 954 } 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 } 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 } 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 } 976 CXFA_Calculate::CXFA_Calculate(CXFA_Node* pNode) : CXFA_Data(pNode) {} 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 } 982 CXFA_Script CXFA_Calculate::GetScript() { 983 return m_pNode->GetChild(0, XFA_ELEMENT_Script); 984 } 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 } 993 FX_BOOL CXFA_Calculate::SetOverride(int32_t iOverride) { 994 return m_pNode->SetEnum(XFA_ATTRIBUTE_Override, (XFA_ATTRIBUTEENUM)iOverride); 995 } 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 } 1003 CXFA_Validate::CXFA_Validate(CXFA_Node* pNode) : CXFA_Data(pNode) {} 1004 int32_t CXFA_Validate::GetFormatTest() { 1005 return m_pNode->GetEnum(XFA_ATTRIBUTE_FormatTest); 1006 } 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 } 1017 FX_BOOL CXFA_Validate::SetFormatTest(CFX_WideString wsValue) { 1018 return SetTestValue(XFA_ATTRIBUTE_FormatTest, wsValue, 1019 XFA_ATTRIBUTEENUM_Warning); 1020 } 1021 FX_BOOL CXFA_Validate::SetNullTest(CFX_WideString wsValue) { 1022 return SetTestValue(XFA_ATTRIBUTE_NullTest, wsValue, 1023 XFA_ATTRIBUTEENUM_Disabled); 1024 } 1025 int32_t CXFA_Validate::GetNullTest() { 1026 return m_pNode->GetEnum(XFA_ATTRIBUTE_NullTest); 1027 } 1028 int32_t CXFA_Validate::GetScriptTest() { 1029 return m_pNode->GetEnum(XFA_ATTRIBUTE_ScriptTest); 1030 } 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 } 1049 void CXFA_Validate::SetFormatMessageText(CFX_WideString wsMessage) { 1050 SetMessageText(wsMessage, FX_WSTRC(L"formatTest")); 1051 } 1052 void CXFA_Validate::GetFormatMessageText(CFX_WideString& wsMessage) { 1053 GetMessageText(wsMessage, FX_WSTRC(L"formatTest")); 1054 } 1055 void CXFA_Validate::SetNullMessageText(CFX_WideString wsMessage) { 1056 SetMessageText(wsMessage, FX_WSTRC(L"nullTest")); 1057 } 1058 void CXFA_Validate::GetNullMessageText(CFX_WideString& wsMessage) { 1059 GetMessageText(wsMessage, FX_WSTRC(L"nullTest")); 1060 } 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 } 1083 void CXFA_Validate::GetScriptMessageText(CFX_WideString& wsMessage) { 1084 GetMessageText(wsMessage, FX_WSTRC(L"scriptTest")); 1085 } 1086 void CXFA_Validate::SetScriptMessageText(CFX_WideString wsMessage) { 1087 SetMessageText(wsMessage, FX_WSTRC(L"scriptTest")); 1088 } 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 } 1094 CXFA_Script CXFA_Validate::GetScript() { 1095 return m_pNode->GetChild(0, XFA_ELEMENT_Script); 1096 } 1097 CXFA_Variables::CXFA_Variables(CXFA_Node* pNode) : CXFA_Data(pNode) {} 1098 int32_t CXFA_Variables::CountScripts() { 1099 return m_pNode->CountChildren(XFA_ELEMENT_Script); 1100 } 1101 CXFA_Script CXFA_Variables::GetScript(int32_t nIndex) { 1102 return m_pNode->GetChild(nIndex, XFA_ELEMENT_Script); 1103 } 1104 CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {} 1105 int32_t CXFA_Bind::GetMatch() { 1106 return m_pNode->GetEnum(XFA_ATTRIBUTE_Match); 1107 } 1108 void CXFA_Bind::GetRef(CFX_WideStringC& wsRef) { 1109 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef); 1110 } 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 } 1116 FX_BOOL CXFA_Bind::SetMatch(int32_t iMatch) { 1117 return m_pNode->SetEnum(XFA_ATTRIBUTE_Match, (XFA_ATTRIBUTEENUM)iMatch); 1118 } 1119 FX_BOOL CXFA_Bind::SetRef(const CFX_WideString& wsRef) { 1120 return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef); 1121 } 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 } 1128 CXFA_Assist::CXFA_Assist(CXFA_Node* pNode) : CXFA_Data(pNode) {} 1129 CXFA_ToolTip CXFA_Assist::GetToolTip() { 1130 return m_pNode->GetChild(0, XFA_ELEMENT_ToolTip); 1131 } 1132 CXFA_ToolTip::CXFA_ToolTip(CXFA_Node* pNode) : CXFA_Data(pNode) {} 1133 FX_BOOL CXFA_ToolTip::GetTip(CFX_WideString& wsTip) { 1134 return m_pNode->TryContent(wsTip); 1135 } 1136 FX_BOOL CXFA_ToolTip::SetTip(const CFX_WideString& wsTip) { 1137 return m_pNode->SetContent(wsTip, wsTip); 1138 } 1139 CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {} 1140 void CXFA_BindItems::GetConnection(CFX_WideStringC& wsConnection) { 1141 m_pNode->TryCData(XFA_ATTRIBUTE_Connection, wsConnection); 1142 } 1143 void CXFA_BindItems::GetLabelRef(CFX_WideStringC& wsLabelRef) { 1144 m_pNode->TryCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef); 1145 } 1146 void CXFA_BindItems::GetValueRef(CFX_WideStringC& wsValueRef) { 1147 m_pNode->TryCData(XFA_ATTRIBUTE_ValueRef, wsValueRef); 1148 } 1149 void CXFA_BindItems::GetRef(CFX_WideStringC& wsRef) { 1150 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef); 1151 } 1152 FX_BOOL CXFA_BindItems::SetConnection(const CFX_WideString& wsConnection) { 1153 return m_pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection); 1154 } 1155 FX_BOOL CXFA_BindItems::SetLabelRef(const CFX_WideString& wsLabelRef) { 1156 return m_pNode->SetCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef); 1157 } 1158 FX_BOOL CXFA_BindItems::SetValueRef(const CFX_WideString& wsValueRef) { 1159 return m_pNode->SetCData(XFA_ATTRIBUTE_ValueRef, wsValueRef); 1160 } 1161 FX_BOOL CXFA_BindItems::SetRef(const CFX_WideString& wsRef) { 1162 return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef); 1163 } 1164 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 } 1170 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 } 1176 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 } 1182 int32_t CXFA_Box::CountCorners() const { 1183 if (!m_pNode) { 1184 return 0; 1185 } 1186 return m_pNode->CountChildren(XFA_ELEMENT_Corner); 1187 } 1188 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 } 1195 int32_t CXFA_Box::CountEdges() const { 1196 if (!m_pNode) { 1197 return 0; 1198 } 1199 return m_pNode->CountChildren(XFA_ELEMENT_Edge); 1200 } 1201 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 } 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 } 1246 void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const { 1247 XFA_BOX_GetStrokes(m_pNode, strokes, FALSE); 1248 } 1249 FX_BOOL CXFA_Box::IsCircular() const { 1250 if (!m_pNode) { 1251 return FALSE; 1252 } 1253 return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular); 1254 } 1255 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 } 1267 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 } 1279 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 } 1286 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 } 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 } 1311 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 } 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 } 1346 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 } 1360 int32_t CXFA_Stroke::GetPresence() const { 1361 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence) 1362 : XFA_ATTRIBUTEENUM_Invisible; 1363 } 1364 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 } 1370 int32_t CXFA_Stroke::GetStrokeType() const { 1371 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Stroke) 1372 : XFA_ATTRIBUTEENUM_Solid; 1373 } 1374 FX_FLOAT CXFA_Stroke::GetThickness() const { 1375 return GetMSThickness().ToUnit(XFA_UNIT_Pt); 1376 } 1377 CXFA_Measurement CXFA_Stroke::GetMSThickness() const { 1378 return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Thickness) 1379 : XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT_Edge, 1380 XFA_ATTRIBUTE_Thickness, 1381 XFA_XDPPACKET_Form); 1382 } 1383 void CXFA_Stroke::SetThickness(FX_FLOAT fThickness) { 1384 if (!m_pNode) { 1385 return; 1386 } 1387 CXFA_Measurement thickness(fThickness, XFA_UNIT_Pt); 1388 m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, thickness); 1389 } 1390 void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) { 1391 if (!m_pNode) { 1392 return; 1393 } 1394 m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness); 1395 } 1396 FX_ARGB CXFA_Stroke::GetColor() const { 1397 if (!m_pNode) { 1398 return 0xFF000000; 1399 } 1400 CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color); 1401 if (!pNode) { 1402 return 0xFF000000; 1403 } 1404 CFX_WideStringC wsColor; 1405 pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor); 1406 return XFA_WStringToColor(wsColor); 1407 } 1408 void CXFA_Stroke::SetColor(FX_ARGB argb) { 1409 if (!m_pNode) { 1410 return; 1411 } 1412 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color); 1413 CFX_WideString wsColor; 1414 int a, r, g, b; 1415 ArgbDecode(argb, a, r, g, b); 1416 wsColor.Format(L"%d,%d,%d", r, g, b); 1417 pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor); 1418 } 1419 int32_t CXFA_Stroke::GetJoinType() const { 1420 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Join) 1421 : XFA_ATTRIBUTEENUM_Square; 1422 } 1423 FX_BOOL CXFA_Stroke::IsInverted() const { 1424 return m_pNode ? m_pNode->GetBoolean(XFA_ATTRIBUTE_Inverted) : FALSE; 1425 } 1426 FX_FLOAT CXFA_Stroke::GetRadius() const { 1427 return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Radius).ToUnit(XFA_UNIT_Pt) 1428 : 0; 1429 } 1430 FX_BOOL CXFA_Stroke::SameStyles(CXFA_Stroke stroke, FX_DWORD dwFlags) const { 1431 if (m_pNode == (CXFA_Node*)stroke) { 1432 return TRUE; 1433 } 1434 if (FXSYS_fabs(GetThickness() - stroke.GetThickness()) >= 0.01f) { 1435 return FALSE; 1436 } 1437 if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 && 1438 IsVisible() != stroke.IsVisible()) { 1439 return FALSE; 1440 } 1441 if (GetStrokeType() != stroke.GetStrokeType()) { 1442 return FALSE; 1443 } 1444 if (GetColor() != stroke.GetColor()) { 1445 return FALSE; 1446 } 1447 if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 && 1448 FXSYS_fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) { 1449 return FALSE; 1450 } 1451 return TRUE; 1452 } 1453 FX_FLOAT XFA_GetEdgeThickness(const CXFA_StrokeArray& strokes, 1454 FX_BOOL b3DStyle, 1455 int32_t nIndex) { 1456 FX_FLOAT fThickness = 0; 1457 { 1458 if (strokes[nIndex * 2 + 1].GetPresence() == XFA_ATTRIBUTEENUM_Visible) { 1459 if (nIndex == 0) { 1460 fThickness += 2.5f; 1461 } 1462 fThickness += strokes[nIndex * 2 + 1].GetThickness() * (b3DStyle ? 4 : 2); 1463 } 1464 } 1465 return fThickness; 1466 } 1467 CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode) 1468 : CXFA_Data(pNode), 1469 m_bIsNull(TRUE), 1470 m_bPreNull(TRUE), 1471 m_pUiChildNode(NULL), 1472 m_eUIType(XFA_ELEMENT_UNKNOWN) {} 1473 CXFA_Node* CXFA_WidgetData::GetUIChild() { 1474 if (m_eUIType == XFA_ELEMENT_UNKNOWN) { 1475 m_pUiChildNode = XFA_CreateUIChild(m_pNode, m_eUIType); 1476 } 1477 return m_pUiChildNode; 1478 } 1479 XFA_ELEMENT CXFA_WidgetData::GetUIType() { 1480 GetUIChild(); 1481 return m_eUIType; 1482 } 1483 CFX_WideString CXFA_WidgetData::GetRawValue() { 1484 return m_pNode->GetContent(); 1485 } 1486 int32_t CXFA_WidgetData::GetAccess(FX_BOOL bTemplate) { 1487 if (bTemplate) { 1488 CXFA_Node* pNode = m_pNode->GetTemplateNode(); 1489 if (pNode) { 1490 return pNode->GetEnum(XFA_ATTRIBUTE_Access); 1491 } 1492 return XFA_ATTRIBUTEENUM_Open; 1493 } 1494 CXFA_Node* pNode = m_pNode; 1495 while (pNode) { 1496 int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Access); 1497 if (iAcc != XFA_ATTRIBUTEENUM_Open) { 1498 return iAcc; 1499 } 1500 pNode = 1501 pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); 1502 } 1503 return XFA_ATTRIBUTEENUM_Open; 1504 } 1505 FX_BOOL CXFA_WidgetData::GetAccessKey(CFX_WideStringC& wsAccessKey) { 1506 return m_pNode->TryCData(XFA_ATTRIBUTE_AccessKey, wsAccessKey); 1507 } 1508 int32_t CXFA_WidgetData::GetAnchorType() { 1509 return m_pNode->GetEnum(XFA_ATTRIBUTE_AnchorType); 1510 } 1511 int32_t CXFA_WidgetData::GetColSpan() { 1512 return m_pNode->GetInteger(XFA_ATTRIBUTE_ColSpan); 1513 } 1514 int32_t CXFA_WidgetData::GetPresence() { 1515 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); 1516 CXFA_Node* pNode = m_pNode; 1517 while (pNode && pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { 1518 int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Presence); 1519 if (iAcc != XFA_ATTRIBUTEENUM_Visible) { 1520 return iAcc; 1521 } 1522 pNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); 1523 } 1524 return XFA_ATTRIBUTEENUM_Visible; 1525 } 1526 int32_t CXFA_WidgetData::GetRotate() { 1527 CXFA_Measurement ms; 1528 if (!m_pNode->TryMeasure(XFA_ATTRIBUTE_Rotate, ms, FALSE)) { 1529 return 0; 1530 } 1531 int32_t iRotate = FXSYS_round(ms.GetValue()); 1532 iRotate = XFA_MapRotation(iRotate); 1533 return iRotate / 90 * 90; 1534 } 1535 CXFA_Border CXFA_WidgetData::GetBorder(FX_BOOL bModified) { 1536 return CXFA_Border(m_pNode->GetProperty(0, XFA_ELEMENT_Border, bModified)); 1537 } 1538 CXFA_Caption CXFA_WidgetData::GetCaption(FX_BOOL bModified) { 1539 return CXFA_Caption(m_pNode->GetProperty(0, XFA_ELEMENT_Caption, bModified)); 1540 } 1541 CXFA_Font CXFA_WidgetData::GetFont(FX_BOOL bModified) { 1542 return CXFA_Font(m_pNode->GetProperty(0, XFA_ELEMENT_Font, bModified)); 1543 } 1544 CXFA_Margin CXFA_WidgetData::GetMargin(FX_BOOL bModified) { 1545 return CXFA_Margin(m_pNode->GetProperty(0, XFA_ELEMENT_Margin, bModified)); 1546 } 1547 CXFA_Para CXFA_WidgetData::GetPara(FX_BOOL bModified) { 1548 return CXFA_Para(m_pNode->GetProperty(0, XFA_ELEMENT_Para, bModified)); 1549 } 1550 CXFA_Keep CXFA_WidgetData::GetKeep(FX_BOOL bModified) { 1551 return CXFA_Keep(m_pNode->GetProperty(0, XFA_ELEMENT_Keep, bModified), 1552 m_pNode); 1553 } 1554 void CXFA_WidgetData::GetEventList(CXFA_NodeArray& events) { 1555 m_pNode->GetNodeList(events, 0, XFA_ELEMENT_Event); 1556 } 1557 int32_t CXFA_WidgetData::GetEventByActivity(int32_t iActivity, 1558 CXFA_NodeArray& events, 1559 FX_BOOL bIsFormReady) { 1560 CXFA_NodeArray allEvents; 1561 GetEventList(allEvents); 1562 int32_t iCount = allEvents.GetSize(); 1563 for (int32_t i = 0; i < iCount; i++) { 1564 CXFA_Event event(allEvents[i]); 1565 if (event.GetActivity() == iActivity) { 1566 if (iActivity == XFA_ATTRIBUTEENUM_Ready) { 1567 CFX_WideStringC wsRef; 1568 event.GetRef(wsRef); 1569 if (bIsFormReady) { 1570 if (wsRef == CFX_WideStringC(L"$form")) { 1571 events.Add(allEvents[i]); 1572 } 1573 } else { 1574 if (wsRef == CFX_WideStringC(L"$layout")) { 1575 events.Add(allEvents[i]); 1576 } 1577 } 1578 } else { 1579 events.Add(allEvents[i]); 1580 } 1581 } 1582 } 1583 return events.GetSize(); 1584 } 1585 CXFA_Value CXFA_WidgetData::GetDefaultValue(FX_BOOL bModified) { 1586 CXFA_Node* pTemNode = m_pNode->GetTemplateNode(); 1587 return pTemNode ? pTemNode->GetProperty(0, XFA_ELEMENT_Value, bModified) 1588 : NULL; 1589 } 1590 CXFA_Value CXFA_WidgetData::GetFormValue(FX_BOOL bModified) { 1591 return m_pNode->GetProperty(0, XFA_ELEMENT_Value, bModified); 1592 } 1593 CXFA_Calculate CXFA_WidgetData::GetCalculate(FX_BOOL bModified) { 1594 return m_pNode->GetProperty(0, XFA_ELEMENT_Calculate, bModified); 1595 } 1596 CXFA_Validate CXFA_WidgetData::GetValidate(FX_BOOL bModified) { 1597 return m_pNode->GetProperty(0, XFA_ELEMENT_Validate, bModified); 1598 } 1599 CXFA_Variables CXFA_WidgetData::GetVariables(FX_BOOL bModified) { 1600 return m_pNode->GetProperty(0, XFA_ELEMENT_Variables, bModified); 1601 } 1602 CXFA_Bind CXFA_WidgetData::GetBind(FX_BOOL bModified) { 1603 return m_pNode->GetProperty(0, XFA_ELEMENT_Bind, bModified); 1604 } 1605 CXFA_Assist CXFA_WidgetData::GetAssist(FX_BOOL bModified) { 1606 return m_pNode->GetProperty(0, XFA_ELEMENT_Assist, bModified); 1607 } 1608 void CXFA_WidgetData::GetRelevant(CFX_WideStringC& wsRelevant) { 1609 m_pNode->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant); 1610 } 1611 FX_BOOL CXFA_WidgetData::GetWidth(FX_FLOAT& fWidth) { 1612 return TryMeasure(XFA_ATTRIBUTE_W, fWidth); 1613 } 1614 FX_BOOL CXFA_WidgetData::GetHeight(FX_FLOAT& fHeight) { 1615 return TryMeasure(XFA_ATTRIBUTE_H, fHeight); 1616 } 1617 FX_BOOL CXFA_WidgetData::GetMinWidth(FX_FLOAT& fMinWidth) { 1618 return TryMeasure(XFA_ATTRIBUTE_MinW, fMinWidth); 1619 } 1620 FX_BOOL CXFA_WidgetData::GetMinHeight(FX_FLOAT& fMinHeight) { 1621 return TryMeasure(XFA_ATTRIBUTE_MinH, fMinHeight); 1622 } 1623 FX_BOOL CXFA_WidgetData::GetMaxWidth(FX_FLOAT& fMaxWidth) { 1624 return TryMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth); 1625 } 1626 FX_BOOL CXFA_WidgetData::GetMaxHeight(FX_FLOAT& fMaxHeight) { 1627 return TryMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight); 1628 } 1629 CXFA_BindItems CXFA_WidgetData::GetBindItems() { 1630 return m_pNode->GetChild(0, XFA_ELEMENT_BindItems); 1631 } 1632 FX_BOOL CXFA_WidgetData::SetAccess(int32_t iAccess, FX_BOOL bNotify) { 1633 return m_pNode->SetEnum(XFA_ATTRIBUTE_Access, (XFA_ATTRIBUTEENUM)iAccess, 1634 bNotify); 1635 } 1636 FX_BOOL CXFA_WidgetData::SetAccessKey(const CFX_WideString& wsAccessKey) { 1637 return m_pNode->SetCData(XFA_ATTRIBUTE_AccessKey, wsAccessKey); 1638 } 1639 FX_BOOL CXFA_WidgetData::SetAnchorType(int32_t iType) { 1640 return m_pNode->SetEnum(XFA_ATTRIBUTE_AnchorType, (XFA_ATTRIBUTEENUM)iType); 1641 } 1642 FX_BOOL CXFA_WidgetData::SetColSpan(int32_t iColSpan) { 1643 return m_pNode->SetInteger(XFA_ATTRIBUTE_ColSpan, 1644 (XFA_ATTRIBUTEENUM)iColSpan); 1645 } 1646 FX_BOOL CXFA_WidgetData::SetPresence(int32_t iPresence) { 1647 return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); 1648 } 1649 FX_BOOL CXFA_WidgetData::SetRotate(int32_t iRotate) { 1650 iRotate = XFA_MapRotation(iRotate); 1651 CXFA_Measurement ms((FX_FLOAT)iRotate, XFA_UNIT_Angle); 1652 return m_pNode->SetMeasure(XFA_ATTRIBUTE_Rotate, ms); 1653 } 1654 FX_BOOL CXFA_WidgetData::SetRelevant(const CFX_WideString& wsRelevant) { 1655 return m_pNode->SetCData(XFA_ATTRIBUTE_Relevant, wsRelevant); 1656 } 1657 FX_BOOL CXFA_WidgetData::SetStatus(FX_DWORD dwStatus) { 1658 return FALSE; 1659 } 1660 FX_BOOL CXFA_WidgetData::SetWidth(FX_FLOAT fWidth) { 1661 return SetMeasure(XFA_ATTRIBUTE_W, fWidth); 1662 } 1663 FX_BOOL CXFA_WidgetData::SetHeight(FX_FLOAT fHeight) { 1664 return SetMeasure(XFA_ATTRIBUTE_H, fHeight); 1665 } 1666 FX_BOOL CXFA_WidgetData::SetMinWidth(FX_FLOAT fMinWidth) { 1667 return SetMeasure(XFA_ATTRIBUTE_MinW, fMinWidth); 1668 } 1669 FX_BOOL CXFA_WidgetData::SetMinHeight(FX_FLOAT fMinHeight) { 1670 return SetMeasure(XFA_ATTRIBUTE_MinH, fMinHeight); 1671 } 1672 FX_BOOL CXFA_WidgetData::SetMaxWidth(FX_FLOAT fMaxWidth) { 1673 return SetMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth); 1674 } 1675 FX_BOOL CXFA_WidgetData::SetMaxHeight(FX_FLOAT fMaxHeight) { 1676 return SetMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight); 1677 } 1678 FX_BOOL CXFA_WidgetData::SetPos(FX_FLOAT x, FX_FLOAT y) { 1679 return SetMeasure(XFA_ATTRIBUTE_X, x) && SetMeasure(XFA_ATTRIBUTE_Y, y); 1680 } 1681 FX_BOOL CXFA_WidgetData::SetName(const CFX_WideString& wsName) { 1682 return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); 1683 } 1684 FX_BOOL CXFA_WidgetData::SetButtonHighlight(int32_t iButtonHighlight) { 1685 CXFA_Node* pUiChildNode = GetUIChild(); 1686 return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Highlight, 1687 (XFA_ATTRIBUTEENUM)iButtonHighlight); 1688 } 1689 FX_BOOL CXFA_WidgetData::SetButtonRollover(const CFX_WideString& wsRollover, 1690 FX_BOOL bRichText) { 1691 return FALSE; 1692 } 1693 FX_BOOL CXFA_WidgetData::SetButtonDown(const CFX_WideString& wsDown, 1694 FX_BOOL bRichText) { 1695 return FALSE; 1696 } 1697 FX_BOOL CXFA_WidgetData::SetCheckButtonShape(int32_t iCheckButtonShape) { 1698 CXFA_Node* pUiChildNode = GetUIChild(); 1699 return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Shape, 1700 (XFA_ATTRIBUTEENUM)iCheckButtonShape); 1701 } 1702 FX_BOOL CXFA_WidgetData::SetCheckButtonMark(int32_t iCheckButtonMark) { 1703 CXFA_Node* pUiChildNode = GetUIChild(); 1704 return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Mark, 1705 (XFA_ATTRIBUTEENUM)iCheckButtonMark); 1706 } 1707 FX_BOOL CXFA_WidgetData::SetCheckButtonSize(FX_FLOAT fCheckButtonMark) { 1708 CXFA_Node* pUiChildNode = GetUIChild(); 1709 if (pUiChildNode) { 1710 CXFA_Measurement ms(fCheckButtonMark, XFA_UNIT_Pt); 1711 return pUiChildNode->SetMeasure(XFA_ATTRIBUTE_Size, ms); 1712 } 1713 return FALSE; 1714 } 1715 CXFA_Border CXFA_WidgetData::GetUIBorder(FX_BOOL bModified) { 1716 CXFA_Node* pUIChild = GetUIChild(); 1717 return pUIChild ? pUIChild->GetProperty(0, XFA_ELEMENT_Border, bModified) 1718 : NULL; 1719 } 1720 CXFA_Margin CXFA_WidgetData::GetUIMargin(FX_BOOL bModified) { 1721 CXFA_Node* pUIChild = GetUIChild(); 1722 return pUIChild ? pUIChild->GetProperty(0, XFA_ELEMENT_Margin, bModified) 1723 : NULL; 1724 } 1725 void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) { 1726 rtUIMargin.Reset(); 1727 CXFA_Margin mgUI = GetUIMargin(); 1728 if (!mgUI) { 1729 return; 1730 } 1731 CXFA_Border border = GetUIBorder(); 1732 if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { 1733 return; 1734 } 1735 FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; 1736 FX_BOOL bLeft = mgUI.GetLeftInset(fLeftInset); 1737 FX_BOOL bTop = mgUI.GetTopInset(fTopInset); 1738 FX_BOOL bRight = mgUI.GetRightInset(fRightInset); 1739 FX_BOOL bBottom = mgUI.GetBottomInset(fBottomInset); 1740 if (border) { 1741 FX_BOOL bVisible = FALSE; 1742 FX_FLOAT fThickness = 0; 1743 border.Get3DStyle(bVisible, fThickness); 1744 if (!bLeft || !bTop || !bRight || !bBottom) { 1745 CXFA_StrokeArray strokes; 1746 border.GetStrokes(strokes); 1747 if (!bTop) { 1748 fTopInset = XFA_GetEdgeThickness(strokes, bVisible, 0); 1749 } 1750 if (!bRight) { 1751 fRightInset = XFA_GetEdgeThickness(strokes, bVisible, 1); 1752 } 1753 if (!bBottom) { 1754 fBottomInset = XFA_GetEdgeThickness(strokes, bVisible, 2); 1755 } 1756 if (!bLeft) { 1757 fLeftInset = XFA_GetEdgeThickness(strokes, bVisible, 3); 1758 } 1759 } 1760 } 1761 rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset); 1762 } 1763 int32_t CXFA_WidgetData::GetButtonHighlight() { 1764 CXFA_Node* pUIChild = GetUIChild(); 1765 if (pUIChild) { 1766 return pUIChild->GetEnum(XFA_ATTRIBUTE_Highlight); 1767 } 1768 return XFA_GetAttributeDefaultValue_Enum( 1769 XFA_ELEMENT_Button, XFA_ATTRIBUTE_Highlight, XFA_XDPPACKET_Form); 1770 } 1771 FX_BOOL CXFA_WidgetData::GetButtonRollover(CFX_WideString& wsRollover, 1772 FX_BOOL& bRichText) { 1773 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { 1774 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 1775 while (pText) { 1776 CFX_WideStringC wsName; 1777 pText->TryCData(XFA_ATTRIBUTE_Name, wsName); 1778 if (wsName == FX_WSTRC(L"rollover")) { 1779 pText->TryContent(wsRollover); 1780 bRichText = pText->GetClassID() == XFA_ELEMENT_ExData; 1781 return !wsRollover.IsEmpty(); 1782 } 1783 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); 1784 } 1785 } 1786 return FALSE; 1787 } 1788 FX_BOOL CXFA_WidgetData::GetButtonDown(CFX_WideString& wsDown, 1789 FX_BOOL& bRichText) { 1790 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { 1791 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 1792 while (pText) { 1793 CFX_WideStringC wsName; 1794 pText->TryCData(XFA_ATTRIBUTE_Name, wsName); 1795 if (wsName == FX_WSTRC(L"down")) { 1796 pText->TryContent(wsDown); 1797 bRichText = pText->GetClassID() == XFA_ELEMENT_ExData; 1798 return !wsDown.IsEmpty(); 1799 } 1800 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); 1801 } 1802 } 1803 return FALSE; 1804 } 1805 int32_t CXFA_WidgetData::GetCheckButtonShape() { 1806 CXFA_Node* pUIChild = GetUIChild(); 1807 if (pUIChild) { 1808 return pUIChild->GetEnum(XFA_ATTRIBUTE_Shape); 1809 } 1810 return XFA_GetAttributeDefaultValue_Enum( 1811 XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Shape, XFA_XDPPACKET_Form); 1812 } 1813 int32_t CXFA_WidgetData::GetCheckButtonMark() { 1814 CXFA_Node* pUIChild = GetUIChild(); 1815 if (pUIChild) { 1816 return pUIChild->GetEnum(XFA_ATTRIBUTE_Mark); 1817 } 1818 return XFA_GetAttributeDefaultValue_Enum( 1819 XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Mark, XFA_XDPPACKET_Form); 1820 } 1821 FX_BOOL CXFA_WidgetData::IsRadioButton() { 1822 if (CXFA_Node* pParent = m_pNode->GetNodeItem(XFA_NODEITEM_Parent)) { 1823 return pParent->GetClassID() == XFA_ELEMENT_ExclGroup; 1824 } 1825 return FALSE; 1826 } 1827 FX_FLOAT CXFA_WidgetData::GetCheckButtonSize() { 1828 CXFA_Node* pUIChild = GetUIChild(); 1829 if (pUIChild) { 1830 return pUIChild->GetMeasure(XFA_ATTRIBUTE_Size).ToUnit(XFA_UNIT_Pt); 1831 } 1832 return XFA_GetAttributeDefaultValue_Measure( 1833 XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Size, XFA_XDPPACKET_Form) 1834 .ToUnit(XFA_UNIT_Pt); 1835 } 1836 FX_BOOL CXFA_WidgetData::IsAllowNeutral() { 1837 CXFA_Node* pUIChild = GetUIChild(); 1838 if (pUIChild) { 1839 return pUIChild->GetBoolean(XFA_ATTRIBUTE_AllowNeutral); 1840 } 1841 return XFA_GetAttributeDefaultValue_Boolean( 1842 XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_AllowNeutral, XFA_XDPPACKET_Form); 1843 } 1844 XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() { 1845 CFX_WideString wsValue = GetRawValue(); 1846 if (wsValue.IsEmpty()) { 1847 return XFA_CHECKSTATE_Off; 1848 } 1849 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { 1850 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 1851 int32_t i = 0; 1852 while (pText) { 1853 CFX_WideString wsContent; 1854 if (pText->TryContent(wsContent) && (wsContent == wsValue)) { 1855 return (XFA_CHECKSTATE)i; 1856 } 1857 i++; 1858 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); 1859 } 1860 } 1861 return XFA_CHECKSTATE_Off; 1862 } 1863 void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, 1864 FX_BOOL bNotify) { 1865 if (CXFA_WidgetData exclGroup = GetExclGroupNode()) { 1866 CFX_WideString wsValue; 1867 if (eCheckState != XFA_CHECKSTATE_Off) { 1868 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { 1869 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 1870 if (pText) { 1871 pText->TryContent(wsValue); 1872 } 1873 } 1874 } 1875 CXFA_Node* pChild = 1876 ((CXFA_Node*)exclGroup)->GetNodeItem(XFA_NODEITEM_FirstChild); 1877 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1878 if (pChild->GetClassID() != XFA_ELEMENT_Field) { 1879 continue; 1880 } 1881 CXFA_Node* pItem = pChild->GetChild(0, XFA_ELEMENT_Items); 1882 if (!pItem) { 1883 continue; 1884 } 1885 CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); 1886 if (!pItemchild) { 1887 continue; 1888 } 1889 CFX_WideString text = pItemchild->GetContent(); 1890 CFX_WideString wsChildValue = text; 1891 if (wsValue != text) { 1892 pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); 1893 if (pItemchild) { 1894 wsChildValue = pItemchild->GetContent(); 1895 } else { 1896 wsChildValue.Empty(); 1897 } 1898 } 1899 CXFA_WidgetData ch(pChild); 1900 ch.SyncValue(wsChildValue, bNotify); 1901 } 1902 exclGroup.SyncValue(wsValue, bNotify); 1903 } else { 1904 CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items); 1905 if (!pItems) { 1906 return; 1907 } 1908 int32_t i = -1; 1909 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 1910 CFX_WideString wsContent; 1911 while (pText) { 1912 i++; 1913 if (i == eCheckState) { 1914 pText->TryContent(wsContent); 1915 break; 1916 } 1917 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); 1918 } 1919 SyncValue(wsContent, bNotify); 1920 } 1921 } 1922 CXFA_Node* CXFA_WidgetData::GetExclGroupNode() { 1923 CXFA_Node* pExcl = (CXFA_Node*)m_pNode->GetNodeItem(XFA_NODEITEM_Parent); 1924 if (!pExcl || pExcl->GetClassID() != XFA_ELEMENT_ExclGroup) { 1925 return NULL; 1926 } 1927 return pExcl; 1928 } 1929 CXFA_Node* CXFA_WidgetData::GetSelectedMember() { 1930 CXFA_Node* pSelectedMember = NULL; 1931 CFX_WideString wsState = GetRawValue(); 1932 if (wsState.IsEmpty()) { 1933 return pSelectedMember; 1934 } 1935 for (CXFA_Node* pNode = 1936 (CXFA_Node*)m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1937 pNode != NULL; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1938 CXFA_WidgetData widgetData(pNode); 1939 if (widgetData.GetCheckState() == XFA_CHECKSTATE_On) { 1940 pSelectedMember = pNode; 1941 break; 1942 } 1943 } 1944 return pSelectedMember; 1945 } 1946 CXFA_Node* CXFA_WidgetData::SetSelectedMember(const CFX_WideStringC& wsName, 1947 FX_BOOL bNotify) { 1948 CXFA_Node* pSelectedMember = NULL; 1949 FX_DWORD nameHash = 1950 FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength()); 1951 for (CXFA_Node* pNode = 1952 (CXFA_Node*)m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1953 pNode != NULL; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1954 if (pNode->GetNameHash() == nameHash) { 1955 CXFA_WidgetData widgetData(pNode); 1956 widgetData.SetCheckState(XFA_CHECKSTATE_On, bNotify); 1957 pSelectedMember = pNode; 1958 break; 1959 } 1960 } 1961 return pSelectedMember; 1962 } 1963 void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue, 1964 FX_BOOL bNotify, 1965 FX_BOOL bScriptModify, 1966 FX_BOOL bSyncData) { 1967 CFX_WideString wsExclGroup; 1968 for (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pNode; 1969 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1970 if (pNode->GetClassID() != XFA_ELEMENT_Field) { 1971 continue; 1972 } 1973 CXFA_Node* pItem = pNode->GetChild(0, XFA_ELEMENT_Items); 1974 if (!pItem) { 1975 continue; 1976 } 1977 CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); 1978 if (!pItemchild) { 1979 continue; 1980 } 1981 CFX_WideString wsChildValue = pItemchild->GetContent(); 1982 if (wsValue != wsChildValue) { 1983 pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); 1984 if (pItemchild) { 1985 wsChildValue = pItemchild->GetContent(); 1986 } else { 1987 wsChildValue.Empty(); 1988 } 1989 } else { 1990 wsExclGroup = wsValue; 1991 } 1992 pNode->SetContent(wsChildValue, wsChildValue, bNotify, bScriptModify, 1993 FALSE); 1994 } 1995 if (m_pNode) { 1996 m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify, 1997 bSyncData); 1998 } 1999 } 2000 CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() { 2001 CXFA_Node* pExcl = GetNode(); 2002 if (!pExcl) { 2003 return NULL; 2004 } 2005 CXFA_Node* pNode = pExcl->GetNodeItem(XFA_NODEITEM_FirstChild); 2006 while (pNode) { 2007 if (pNode->GetClassID() == XFA_ELEMENT_Field) { 2008 return pNode; 2009 } 2010 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); 2011 } 2012 return NULL; 2013 } 2014 CXFA_Node* CXFA_WidgetData::GetExclGroupNextMember(CXFA_Node* pNode) { 2015 if (!pNode) { 2016 return NULL; 2017 } 2018 CXFA_Node* pNodeField = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); 2019 while (pNodeField) { 2020 if (pNodeField->GetClassID() == XFA_ELEMENT_Field) { 2021 return pNodeField; 2022 } 2023 pNodeField = pNodeField->GetNodeItem(XFA_NODEITEM_NextSibling); 2024 } 2025 return NULL; 2026 } 2027 int32_t CXFA_WidgetData::GetChoiceListCommitOn() { 2028 CXFA_Node* pUIChild = GetUIChild(); 2029 if (pUIChild) { 2030 return pUIChild->GetEnum(XFA_ATTRIBUTE_CommitOn); 2031 } 2032 return XFA_GetAttributeDefaultValue_Enum( 2033 XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_CommitOn, XFA_XDPPACKET_Form); 2034 } 2035 FX_BOOL CXFA_WidgetData::IsChoiceListAllowTextEntry() { 2036 CXFA_Node* pUIChild = GetUIChild(); 2037 if (pUIChild) { 2038 return pUIChild->GetBoolean(XFA_ATTRIBUTE_TextEntry); 2039 } 2040 return XFA_GetAttributeDefaultValue_Boolean( 2041 XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_TextEntry, XFA_XDPPACKET_Form); 2042 } 2043 int32_t CXFA_WidgetData::GetChoiceListOpen() { 2044 CXFA_Node* pUIChild = GetUIChild(); 2045 if (pUIChild) { 2046 return pUIChild->GetEnum(XFA_ATTRIBUTE_Open); 2047 } 2048 return XFA_GetAttributeDefaultValue_Enum( 2049 XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_Open, XFA_XDPPACKET_Form); 2050 } 2051 FX_BOOL CXFA_WidgetData::IsListBox() { 2052 int32_t iOpenMode = GetChoiceListOpen(); 2053 return (iOpenMode == XFA_ATTRIBUTEENUM_Always || 2054 iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect); 2055 } 2056 int32_t CXFA_WidgetData::CountChoiceListItems(FX_BOOL bSaveValue) { 2057 CXFA_NodeArray pItems; 2058 CXFA_Node* pItem = NULL; 2059 int32_t iCount = 0; 2060 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 2061 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2062 if (pNode->GetClassID() != XFA_ELEMENT_Items) { 2063 continue; 2064 } 2065 iCount++; 2066 pItems.Add(pNode); 2067 if (iCount == 2) { 2068 break; 2069 } 2070 } 2071 if (iCount == 0) { 2072 return 0; 2073 } 2074 pItem = pItems[0]; 2075 if (iCount > 1) { 2076 FX_BOOL bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save); 2077 FX_BOOL bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save); 2078 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) { 2079 pItem = pItems[1]; 2080 } 2081 } 2082 pItems.RemoveAll(); 2083 return pItem->CountChildren(XFA_ELEMENT_UNKNOWN); 2084 } 2085 FX_BOOL CXFA_WidgetData::GetChoiceListItem(CFX_WideString& wsText, 2086 int32_t nIndex, 2087 FX_BOOL bSaveValue) { 2088 wsText.Empty(); 2089 CXFA_NodeArray pItemsArray; 2090 CXFA_Node* pItems = NULL; 2091 int32_t iCount = 0; 2092 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 2093 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2094 if (pNode->GetClassID() != XFA_ELEMENT_Items) { 2095 continue; 2096 } 2097 iCount++; 2098 pItemsArray.Add(pNode); 2099 if (iCount == 2) { 2100 break; 2101 } 2102 } 2103 if (iCount == 0) { 2104 return FALSE; 2105 } 2106 pItems = pItemsArray[0]; 2107 if (iCount > 1) { 2108 FX_BOOL bItemOneHasSave = pItemsArray[0]->GetBoolean(XFA_ATTRIBUTE_Save); 2109 FX_BOOL bItemTwoHasSave = pItemsArray[1]->GetBoolean(XFA_ATTRIBUTE_Save); 2110 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) { 2111 pItems = pItemsArray[1]; 2112 } 2113 } 2114 if (pItems) { 2115 CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_ELEMENT_UNKNOWN); 2116 if (pItem != NULL) { 2117 pItem->TryContent(wsText); 2118 return TRUE; 2119 } 2120 } 2121 return FALSE; 2122 } 2123 void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray, 2124 FX_BOOL bSaveValue) { 2125 CXFA_NodeArray pItems; 2126 CXFA_Node* pItem = NULL; 2127 int32_t iCount = 0; 2128 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 2129 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2130 if (pNode->GetClassID() != XFA_ELEMENT_Items) { 2131 continue; 2132 } 2133 iCount++; 2134 pItems.Add(pNode); 2135 if (iCount == 2) { 2136 break; 2137 } 2138 } 2139 if (iCount == 0) { 2140 return; 2141 } 2142 pItem = pItems[0]; 2143 if (iCount > 1) { 2144 FX_BOOL bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save); 2145 FX_BOOL bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save); 2146 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) { 2147 pItem = pItems[1]; 2148 } 2149 } 2150 pItems.RemoveAll(); 2151 pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); 2152 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2153 pNode->TryContent(wsTextArray.Add()); 2154 } 2155 } 2156 int32_t CXFA_WidgetData::CountSelectedItems() { 2157 CFX_WideStringArray wsValueArray; 2158 GetSelectedItemsValue(wsValueArray); 2159 if (IsListBox() || !IsChoiceListAllowTextEntry()) { 2160 return wsValueArray.GetSize(); 2161 } 2162 int32_t iSelected = 0; 2163 CFX_WideStringArray wsSaveTextArray; 2164 GetChoiceListItems(wsSaveTextArray, TRUE); 2165 int32_t iValues = wsValueArray.GetSize(); 2166 for (int32_t i = 0; i < iValues; i++) { 2167 int32_t iSaves = wsSaveTextArray.GetSize(); 2168 for (int32_t j = 0; j < iSaves; j++) { 2169 if (wsValueArray[i] == wsSaveTextArray[j]) { 2170 iSelected++; 2171 break; 2172 } 2173 } 2174 } 2175 return iSelected; 2176 } 2177 int32_t CXFA_WidgetData::GetSelectedItem(int32_t nIndex) { 2178 CFX_WideStringArray wsValueArray; 2179 GetSelectedItemsValue(wsValueArray); 2180 CFX_WideStringArray wsSaveTextArray; 2181 GetChoiceListItems(wsSaveTextArray, TRUE); 2182 int32_t iSaves = wsSaveTextArray.GetSize(); 2183 for (int32_t j = 0; j < iSaves; j++) { 2184 if (wsValueArray[nIndex] == wsSaveTextArray[j]) { 2185 return j; 2186 } 2187 } 2188 return -1; 2189 } 2190 void CXFA_WidgetData::GetSelectedItems(CFX_Int32Array& iSelArray) { 2191 CFX_WideStringArray wsValueArray; 2192 GetSelectedItemsValue(wsValueArray); 2193 int32_t iValues = wsValueArray.GetSize(); 2194 if (iValues < 1) { 2195 return; 2196 } 2197 CFX_WideStringArray wsSaveTextArray; 2198 GetChoiceListItems(wsSaveTextArray, TRUE); 2199 int32_t iSaves = wsSaveTextArray.GetSize(); 2200 for (int32_t i = 0; i < iValues; i++) { 2201 for (int32_t j = 0; j < iSaves; j++) { 2202 if (wsValueArray[i] == wsSaveTextArray[j]) { 2203 iSelArray.Add(j); 2204 break; 2205 } 2206 } 2207 } 2208 } 2209 void CXFA_WidgetData::GetSelectedItemsValue( 2210 CFX_WideStringArray& wsSelTextArray) { 2211 CFX_WideString wsValue = GetRawValue(); 2212 if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { 2213 if (!wsValue.IsEmpty()) { 2214 int32_t iStart = 0; 2215 int32_t iLength = wsValue.GetLength(); 2216 int32_t iEnd = wsValue.Find(L'\n', iStart); 2217 iEnd = (iEnd == -1) ? iLength : iEnd; 2218 while (iEnd >= iStart) { 2219 wsSelTextArray.Add(wsValue.Mid(iStart, iEnd - iStart)); 2220 iStart = iEnd + 1; 2221 if (iStart >= iLength) { 2222 break; 2223 } 2224 iEnd = wsValue.Find(L'\n', iStart); 2225 if (iEnd < 0) { 2226 wsSelTextArray.Add(wsValue.Mid(iStart, iLength - iStart)); 2227 } 2228 } 2229 } 2230 } else { 2231 wsSelTextArray.Add(wsValue); 2232 } 2233 } 2234 FX_BOOL CXFA_WidgetData::GetItemState(int32_t nIndex) { 2235 if (nIndex < 0) { 2236 return FALSE; 2237 } 2238 CFX_WideStringArray wsSaveTextArray; 2239 GetChoiceListItems(wsSaveTextArray, TRUE); 2240 if (wsSaveTextArray.GetSize() <= nIndex) { 2241 return FALSE; 2242 } 2243 CFX_WideStringArray wsValueArray; 2244 GetSelectedItemsValue(wsValueArray); 2245 int32_t iValues = wsValueArray.GetSize(); 2246 for (int32_t j = 0; j < iValues; j++) { 2247 if (wsValueArray[j] == wsSaveTextArray[nIndex]) { 2248 return TRUE; 2249 } 2250 } 2251 return FALSE; 2252 } 2253 void CXFA_WidgetData::SetItemState(int32_t nIndex, 2254 FX_BOOL bSelected, 2255 FX_BOOL bNotify, 2256 FX_BOOL bScriptModify, 2257 FX_BOOL bSyncData) { 2258 if (nIndex < 0) { 2259 return; 2260 } 2261 CFX_WideStringArray wsSaveTextArray; 2262 GetChoiceListItems(wsSaveTextArray, TRUE); 2263 if (wsSaveTextArray.GetSize() <= nIndex) { 2264 return; 2265 } 2266 int32_t iSel = -1; 2267 CFX_WideStringArray wsValueArray; 2268 GetSelectedItemsValue(wsValueArray); 2269 int32_t iValues = wsValueArray.GetSize(); 2270 for (int32_t j = 0; j < iValues; j++) { 2271 if (wsValueArray[j] == wsSaveTextArray[nIndex]) { 2272 iSel = j; 2273 break; 2274 } 2275 } 2276 if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { 2277 if (bSelected) { 2278 if (iSel < 0) { 2279 CFX_WideString wsValue = GetRawValue(); 2280 if (!wsValue.IsEmpty()) { 2281 wsValue += L"\n"; 2282 } 2283 wsValue += wsSaveTextArray[nIndex]; 2284 m_pNode->SetContent(wsValue, wsValue, bNotify, bScriptModify, 2285 bSyncData); 2286 } 2287 } else if (iSel >= 0) { 2288 CFX_Int32Array iSelArray; 2289 GetSelectedItems(iSelArray); 2290 for (int32_t i = 0; i < iSelArray.GetSize(); i++) { 2291 if (iSelArray[i] == nIndex) { 2292 iSelArray.RemoveAt(i); 2293 break; 2294 } 2295 } 2296 SetSelectdItems(iSelArray, bNotify, bScriptModify, bSyncData); 2297 } 2298 } else { 2299 if (bSelected) { 2300 if (iSel < 0) { 2301 CFX_WideString wsSaveText = wsSaveTextArray[nIndex]; 2302 CFX_WideString wsFormatText(wsSaveText); 2303 GetFormatDataValue(wsSaveText, wsFormatText); 2304 m_pNode->SetContent(wsSaveText, wsFormatText, bNotify, bScriptModify, 2305 bSyncData); 2306 } 2307 } else if (iSel >= 0) { 2308 m_pNode->SetContent(CFX_WideString(), CFX_WideString(), bNotify, 2309 bScriptModify, bSyncData); 2310 } 2311 } 2312 } 2313 void CXFA_WidgetData::SetSelectdItems(CFX_Int32Array& iSelArray, 2314 FX_BOOL bNotify, 2315 FX_BOOL bScriptModify, 2316 FX_BOOL bSyncData) { 2317 CFX_WideString wsValue; 2318 int32_t iSize = iSelArray.GetSize(); 2319 if (iSize >= 1) { 2320 CFX_WideStringArray wsSaveTextArray; 2321 GetChoiceListItems(wsSaveTextArray, TRUE); 2322 CFX_WideString wsItemValue; 2323 for (int32_t i = 0; i < iSize; i++) { 2324 wsItemValue = (iSize == 1) 2325 ? wsSaveTextArray[iSelArray[i]] 2326 : wsSaveTextArray[iSelArray[i]] + FX_WSTRC(L"\n"); 2327 wsValue += wsItemValue; 2328 } 2329 } 2330 CFX_WideString wsFormat(wsValue); 2331 if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect) { 2332 GetFormatDataValue(wsValue, wsFormat); 2333 } 2334 m_pNode->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData); 2335 } 2336 void CXFA_WidgetData::ClearAllSelections() { 2337 CXFA_Node* pBind = m_pNode->GetBindData(); 2338 if (pBind && GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { 2339 while (CXFA_Node* pChildNode = 2340 pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { 2341 pBind->RemoveChild(pChildNode); 2342 } 2343 } else { 2344 SyncValue(CFX_WideString(), FALSE); 2345 } 2346 } 2347 void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel, 2348 const CFX_WideString& wsValue, 2349 int32_t nIndex, 2350 FX_BOOL bNotify) { 2351 CFX_WideString wsNewValue(wsValue); 2352 if (wsNewValue.IsEmpty()) { 2353 wsNewValue = wsLabel; 2354 } 2355 CXFA_NodeArray listitems; 2356 int32_t iCount = 0; 2357 CXFA_Node* pItemNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 2358 for (; pItemNode; 2359 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2360 if (pItemNode->GetClassID() != XFA_ELEMENT_Items) { 2361 continue; 2362 } 2363 listitems.Add(pItemNode); 2364 iCount++; 2365 } 2366 if (iCount < 1) { 2367 CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); 2368 m_pNode->InsertChild(-1, pItems); 2369 InsertListTextItem(pItems, wsLabel, nIndex); 2370 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); 2371 m_pNode->InsertChild(-1, pSaveItems); 2372 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); 2373 InsertListTextItem(pSaveItems, wsNewValue, nIndex); 2374 } else if (iCount > 1) { 2375 for (int32_t i = 0; i < 2; i++) { 2376 CXFA_Node* pNode = listitems[i]; 2377 FX_BOOL bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save); 2378 if (bHasSave) { 2379 InsertListTextItem(pNode, wsNewValue, nIndex); 2380 } else { 2381 InsertListTextItem(pNode, wsLabel, nIndex); 2382 } 2383 } 2384 } else { 2385 CXFA_Node* pNode = listitems[0]; 2386 pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE); 2387 pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible); 2388 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); 2389 m_pNode->InsertChild(-1, pSaveItems); 2390 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); 2391 pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden); 2392 listitems.RemoveAll(); 2393 CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 2394 int32_t i = 0; 2395 while (pListNode) { 2396 CFX_WideString wsOldValue; 2397 pListNode->TryContent(wsOldValue); 2398 InsertListTextItem(pSaveItems, wsOldValue, i); 2399 i++; 2400 pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); 2401 } 2402 InsertListTextItem(pNode, wsLabel, nIndex); 2403 InsertListTextItem(pSaveItems, wsNewValue, nIndex); 2404 } 2405 if (!bNotify) { 2406 return; 2407 } 2408 m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent( 2409 this, XFA_WIDGETEVENT_ListItemAdded, (void*)(const FX_WCHAR*)wsLabel, 2410 (void*)(const FX_WCHAR*)wsValue, (void*)(uintptr_t)nIndex); 2411 } 2412 void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue, 2413 CFX_WideString& wsLabel) { 2414 int32_t iCount = 0; 2415 CXFA_NodeArray listitems; 2416 CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 2417 for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2418 if (pItems->GetClassID() != XFA_ELEMENT_Items) { 2419 continue; 2420 } 2421 iCount++; 2422 listitems.Add(pItems); 2423 } 2424 if (iCount <= 1) { 2425 wsLabel = wsValue; 2426 } else { 2427 CXFA_Node* pLabelItems = listitems[0]; 2428 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); 2429 CXFA_Node* pSaveItems = NULL; 2430 if (bSave) { 2431 pSaveItems = pLabelItems; 2432 pLabelItems = listitems[1]; 2433 } else { 2434 pSaveItems = listitems[1]; 2435 } 2436 iCount = 0; 2437 int32_t iSearch = -1; 2438 CFX_WideString wsContent; 2439 CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild); 2440 for (; pChildItem; 2441 pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2442 pChildItem->TryContent(wsContent); 2443 if (wsContent == wsValue) { 2444 iSearch = iCount; 2445 break; 2446 } 2447 iCount++; 2448 } 2449 if (iSearch < 0) { 2450 return; 2451 } 2452 if (CXFA_Node* pText = 2453 pLabelItems->GetChild(iSearch, XFA_ELEMENT_UNKNOWN)) { 2454 pText->TryContent(wsLabel); 2455 } 2456 } 2457 } 2458 void CXFA_WidgetData::GetItemValue(const CFX_WideStringC& wsLabel, 2459 CFX_WideString& wsValue) { 2460 int32_t iCount = 0; 2461 CXFA_NodeArray listitems; 2462 CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 2463 for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2464 if (pItems->GetClassID() != XFA_ELEMENT_Items) { 2465 continue; 2466 } 2467 iCount++; 2468 listitems.Add(pItems); 2469 } 2470 if (iCount <= 1) { 2471 wsValue = wsLabel; 2472 } else { 2473 CXFA_Node* pLabelItems = listitems[0]; 2474 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); 2475 CXFA_Node* pSaveItems = NULL; 2476 if (bSave) { 2477 pSaveItems = pLabelItems; 2478 pLabelItems = listitems[1]; 2479 } else { 2480 pSaveItems = listitems[1]; 2481 } 2482 iCount = 0; 2483 int32_t iSearch = -1; 2484 CFX_WideString wsContent; 2485 CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild); 2486 for (; pChildItem; 2487 pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2488 pChildItem->TryContent(wsContent); 2489 if (wsContent == wsLabel) { 2490 iSearch = iCount; 2491 break; 2492 } 2493 iCount++; 2494 } 2495 if (iSearch < 0) { 2496 return; 2497 } 2498 if (CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_ELEMENT_UNKNOWN)) { 2499 pText->TryContent(wsValue); 2500 } 2501 } 2502 } 2503 FX_BOOL CXFA_WidgetData::DeleteItem(int32_t nIndex, 2504 FX_BOOL bNotify, 2505 FX_BOOL bScriptModify, 2506 FX_BOOL bSyncData) { 2507 FX_BOOL bSetValue = FALSE; 2508 CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 2509 for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) { 2510 if (pItems->GetClassID() != XFA_ELEMENT_Items) { 2511 continue; 2512 } 2513 if (nIndex < 0) { 2514 while (CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild)) { 2515 pItems->RemoveChild(pNode); 2516 } 2517 } else { 2518 if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) { 2519 SetItemState(nIndex, FALSE, TRUE, bScriptModify, bSyncData); 2520 bSetValue = TRUE; 2521 } 2522 int32_t i = 0; 2523 CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 2524 while (pNode) { 2525 if (i == nIndex) { 2526 pItems->RemoveChild(pNode); 2527 break; 2528 } 2529 i++; 2530 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); 2531 } 2532 } 2533 } 2534 if (!bNotify) { 2535 return TRUE; 2536 } 2537 m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent( 2538 this, XFA_WIDGETEVENT_ListItemRemoved, (void*)(uintptr_t)nIndex); 2539 return TRUE; 2540 } 2541 int32_t CXFA_WidgetData::GetHorizontalScrollPolicy() { 2542 CXFA_Node* pUIChild = GetUIChild(); 2543 if (pUIChild) { 2544 return pUIChild->GetEnum(XFA_ATTRIBUTE_HScrollPolicy); 2545 } 2546 return XFA_ATTRIBUTEENUM_Auto; 2547 } 2548 int32_t CXFA_WidgetData::GetNumberOfCells() { 2549 CXFA_Node* pUIChild = GetUIChild(); 2550 if (!pUIChild) { 2551 return -1; 2552 } 2553 if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_ELEMENT_Comb)) { 2554 return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells); 2555 } 2556 return -1; 2557 } 2558 FX_BOOL CXFA_WidgetData::IsDateTimeEditUsePicker() { 2559 return TRUE; 2560 } 2561 CFX_WideString CXFA_WidgetData::GetBarcodeType() { 2562 CXFA_Node* pUIChild = GetUIChild(); 2563 return pUIChild ? pUIChild->GetCData(XFA_ATTRIBUTE_Type) : NULL; 2564 } 2565 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { 2566 CXFA_Node* pUIChild = GetUIChild(); 2567 CFX_WideString wsCharEncoding; 2568 if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) { 2569 if (wsCharEncoding.CompareNoCase(L"UTF-16")) { 2570 val = CHAR_ENCODING_UNICODE; 2571 return TRUE; 2572 } else if (wsCharEncoding.CompareNoCase(L"UTF-8")) { 2573 val = CHAR_ENCODING_UTF8; 2574 return TRUE; 2575 } 2576 } 2577 return FALSE; 2578 } 2579 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(int32_t& val) { 2580 CXFA_Node* pUIChild = GetUIChild(); 2581 XFA_ATTRIBUTEENUM eChecksum; 2582 if (pUIChild->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) { 2583 switch (eChecksum) { 2584 case XFA_ATTRIBUTEENUM_None: 2585 val = 0; 2586 return TRUE; 2587 case XFA_ATTRIBUTEENUM_Auto: 2588 val = 1; 2589 return TRUE; 2590 case XFA_ATTRIBUTEENUM_1mod10: 2591 break; 2592 case XFA_ATTRIBUTEENUM_1mod10_1mod11: 2593 break; 2594 case XFA_ATTRIBUTEENUM_2mod10: 2595 break; 2596 default: 2597 break; 2598 } 2599 } 2600 return FALSE; 2601 } 2602 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t& val) { 2603 CXFA_Node* pUIChild = GetUIChild(); 2604 CFX_WideString wsDataLength; 2605 if (pUIChild->TryCData(XFA_ATTRIBUTE_DataLength, wsDataLength)) { 2606 val = FXSYS_wtoi(wsDataLength); 2607 return TRUE; 2608 } 2609 return FALSE; 2610 } 2611 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_StartChar(FX_CHAR& val) { 2612 CXFA_Node* pUIChild = GetUIChild(); 2613 CFX_WideStringC wsStartEndChar; 2614 if (pUIChild->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) { 2615 if (wsStartEndChar.GetLength()) { 2616 val = (FX_CHAR)wsStartEndChar.GetAt(0); 2617 return TRUE; 2618 } 2619 } 2620 return FALSE; 2621 } 2622 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_EndChar(FX_CHAR& val) { 2623 CXFA_Node* pUIChild = GetUIChild(); 2624 CFX_WideStringC wsStartEndChar; 2625 if (pUIChild->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) { 2626 if (wsStartEndChar.GetLength()) { 2627 val = (FX_CHAR)wsStartEndChar.GetAt(0); 2628 return TRUE; 2629 } 2630 } 2631 return FALSE; 2632 } 2633 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ECLevel(int32_t& val) { 2634 CXFA_Node* pUIChild = GetUIChild(); 2635 CFX_WideString wsECLevel; 2636 if (pUIChild->TryCData(XFA_ATTRIBUTE_ErrorCorrectionLevel, wsECLevel)) { 2637 val = FXSYS_wtoi(wsECLevel); 2638 return TRUE; 2639 } 2640 return FALSE; 2641 } 2642 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t& val) { 2643 CXFA_Node* pUIChild = GetUIChild(); 2644 CXFA_Measurement mModuleWidthHeight; 2645 if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleWidth, mModuleWidthHeight)) { 2646 val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); 2647 return TRUE; 2648 } 2649 return FALSE; 2650 } 2651 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t& val) { 2652 CXFA_Node* pUIChild = GetUIChild(); 2653 CXFA_Measurement mModuleWidthHeight; 2654 if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleHeight, mModuleWidthHeight)) { 2655 val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); 2656 return TRUE; 2657 } 2658 return FALSE; 2659 } 2660 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(FX_BOOL& val) { 2661 CXFA_Node* pUIChild = GetUIChild(); 2662 FX_BOOL bPrintCheckDigit; 2663 if (pUIChild->TryBoolean(XFA_ATTRIBUTE_PrintCheckDigit, bPrintCheckDigit)) { 2664 val = bPrintCheckDigit; 2665 return TRUE; 2666 } 2667 return FALSE; 2668 } 2669 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t& val) { 2670 CXFA_Node* pUIChild = GetUIChild(); 2671 XFA_ATTRIBUTEENUM eTextLocation; 2672 if (pUIChild->TryEnum(XFA_ATTRIBUTE_TextLocation, eTextLocation)) { 2673 switch (eTextLocation) { 2674 case XFA_ATTRIBUTEENUM_None: 2675 val = BC_TEXT_LOC_NONE; 2676 return TRUE; 2677 case XFA_ATTRIBUTEENUM_Above: 2678 val = BC_TEXT_LOC_ABOVE; 2679 return TRUE; 2680 case XFA_ATTRIBUTEENUM_Below: 2681 val = BC_TEXT_LOC_BELOW; 2682 return TRUE; 2683 case XFA_ATTRIBUTEENUM_AboveEmbedded: 2684 val = BC_TEXT_LOC_ABOVEEMBED; 2685 return TRUE; 2686 case XFA_ATTRIBUTEENUM_BelowEmbedded: 2687 val = BC_TEXT_LOC_BELOWEMBED; 2688 return TRUE; 2689 default: 2690 break; 2691 } 2692 } 2693 return FALSE; 2694 } 2695 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Truncate(FX_BOOL& val) { 2696 CXFA_Node* pUIChild = GetUIChild(); 2697 FX_BOOL bTruncate; 2698 if (pUIChild->TryBoolean(XFA_ATTRIBUTE_Truncate, bTruncate)) { 2699 val = bTruncate; 2700 return TRUE; 2701 } 2702 return FALSE; 2703 } 2704 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val) { 2705 CXFA_Node* pUIChild = GetUIChild(); 2706 CFX_WideString wsWideNarrowRatio; 2707 if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) { 2708 FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':'); 2709 FX_FLOAT fRatio = 0; 2710 if (ptPos >= 0) { 2711 fRatio = (FX_FLOAT)FXSYS_wtoi(wsWideNarrowRatio); 2712 } else { 2713 int32_t fA, fB; 2714 fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos)); 2715 fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1)); 2716 if (fB) { 2717 fRatio = (FX_FLOAT)fA / fB; 2718 } 2719 } 2720 val = fRatio; 2721 return TRUE; 2722 } 2723 return FALSE; 2724 } 2725 void CXFA_WidgetData::GetPasswordChar(CFX_WideString& wsPassWord) { 2726 CXFA_Node* pUIChild = GetUIChild(); 2727 if (pUIChild) { 2728 pUIChild->TryCData(XFA_ATTRIBUTE_PasswordChar, wsPassWord); 2729 } else { 2730 wsPassWord = XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT_PasswordEdit, 2731 XFA_ATTRIBUTE_PasswordChar, 2732 XFA_XDPPACKET_Form); 2733 } 2734 } 2735 FX_BOOL CXFA_WidgetData::IsAllowRichText() { 2736 CXFA_Node* pUIChild = GetUIChild(); 2737 FX_BOOL bValue = FALSE; 2738 if (pUIChild && 2739 pUIChild->TryBoolean(XFA_ATTRIBUTE_AllowRichText, bValue, FALSE)) { 2740 return bValue; 2741 } 2742 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { 2743 if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { 2744 return pChild->GetClassID() == XFA_ELEMENT_ExData; 2745 } 2746 } 2747 return FALSE; 2748 } 2749 FX_BOOL CXFA_WidgetData::IsMultiLine() { 2750 CXFA_Node* pUIChild = GetUIChild(); 2751 if (pUIChild) { 2752 return pUIChild->GetBoolean(XFA_ATTRIBUTE_MultiLine); 2753 } 2754 return XFA_GetAttributeDefaultValue_Boolean( 2755 XFA_ELEMENT_TextEdit, XFA_ATTRIBUTE_MultiLine, XFA_XDPPACKET_Form); 2756 } 2757 int32_t CXFA_WidgetData::GetVerticalScrollPolicy() { 2758 CXFA_Node* pUIChild = GetUIChild(); 2759 if (pUIChild) { 2760 return pUIChild->GetEnum(XFA_ATTRIBUTE_VScrollPolicy); 2761 } 2762 return XFA_GetAttributeDefaultValue_Enum( 2763 XFA_ELEMENT_TextEdit, XFA_ATTRIBUTE_VScrollPolicy, XFA_XDPPACKET_Form); 2764 } 2765 int32_t CXFA_WidgetData::GetMaxChars(XFA_ELEMENT& eType) { 2766 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { 2767 if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { 2768 switch (pChild->GetClassID()) { 2769 case XFA_ELEMENT_Text: 2770 eType = XFA_ELEMENT_Text; 2771 return pChild->GetInteger(XFA_ATTRIBUTE_MaxChars); 2772 case XFA_ELEMENT_ExData: { 2773 eType = XFA_ELEMENT_ExData; 2774 int32_t iMax = pChild->GetInteger(XFA_ATTRIBUTE_MaxLength); 2775 return iMax < 0 ? 0 : iMax; 2776 } 2777 default: 2778 break; 2779 } 2780 } 2781 } 2782 return 0; 2783 } 2784 FX_BOOL CXFA_WidgetData::GetFracDigits(int32_t& iFracDigits) { 2785 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { 2786 if (CXFA_Node* pChild = pNode->GetChild(0, XFA_ELEMENT_Decimal)) { 2787 return pChild->TryInteger(XFA_ATTRIBUTE_FracDigits, iFracDigits); 2788 } 2789 } 2790 iFracDigits = -1; 2791 return FALSE; 2792 } 2793 FX_BOOL CXFA_WidgetData::GetLeadDigits(int32_t& iLeadDigits) { 2794 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { 2795 if (CXFA_Node* pChild = pNode->GetChild(0, XFA_ELEMENT_Decimal)) { 2796 return pChild->TryInteger(XFA_ATTRIBUTE_LeadDigits, iLeadDigits); 2797 } 2798 } 2799 iLeadDigits = -1; 2800 return FALSE; 2801 } 2802 CFX_WideString XFA_NumericLimit(const CFX_WideString& wsValue, 2803 int32_t iLead, 2804 int32_t iTread) { 2805 if ((iLead == -1) && (iTread == -1)) { 2806 return wsValue; 2807 } 2808 CFX_WideString wsRet; 2809 int32_t iLead_ = 0, iTread_ = -1; 2810 int32_t iCount = wsValue.GetLength(); 2811 if (iCount == 0) { 2812 return wsValue; 2813 } 2814 int32_t i = 0; 2815 if (wsValue[i] == L'-') { 2816 wsRet += L'-'; 2817 i++; 2818 } 2819 for (; i < iCount; i++) { 2820 FX_WCHAR wc = wsValue[i]; 2821 if (XFA_IsDigit(wc)) { 2822 if (iLead >= 0) { 2823 iLead_++; 2824 if (iLead_ > iLead) { 2825 return L"0"; 2826 } 2827 } else if (iTread_ >= 0) { 2828 iTread_++; 2829 if (iTread_ > iTread) { 2830 if (iTread != -1) { 2831 CFX_Decimal wsDeci = CFX_Decimal(wsValue); 2832 wsDeci.SetScale(iTread); 2833 wsRet = wsDeci; 2834 } 2835 return wsRet; 2836 } 2837 } 2838 } else if (wc == L'.') { 2839 iTread_ = 0; 2840 iLead = -1; 2841 } 2842 wsRet += wc; 2843 } 2844 return wsRet; 2845 } 2846 FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue, 2847 XFA_VALUEPICTURE eValueType) { 2848 if (wsValue.IsEmpty()) { 2849 SyncValue(wsValue, TRUE); 2850 return TRUE; 2851 } 2852 this->m_bPreNull = this->m_bIsNull; 2853 this->m_bIsNull = FALSE; 2854 CFX_WideString wsNewText(wsValue); 2855 CFX_WideString wsPicture; 2856 GetPictureContent(wsPicture, eValueType); 2857 FX_BOOL bValidate = TRUE; 2858 FX_BOOL bSyncData = FALSE; 2859 CXFA_Node* pNode = GetUIChild(); 2860 if (!pNode) { 2861 return TRUE; 2862 } 2863 XFA_ELEMENT uiType = pNode->GetClassID(); 2864 if (!wsPicture.IsEmpty()) { 2865 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); 2866 IFX_Locale* pLocale = GetLocal(); 2867 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); 2868 bValidate = 2869 widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture); 2870 if (bValidate) { 2871 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText, 2872 wsPicture, pLocale, pLocalMgr); 2873 wsNewText = widgetValue.GetValue(); 2874 if (uiType == XFA_ELEMENT_NumericEdit) { 2875 int32_t iLeadDigits = 0; 2876 int32_t iFracDigits = 0; 2877 GetLeadDigits(iLeadDigits); 2878 GetFracDigits(iFracDigits); 2879 wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits); 2880 } 2881 bSyncData = TRUE; 2882 } 2883 } else { 2884 if (uiType == XFA_ELEMENT_NumericEdit) { 2885 if (wsNewText != FX_WSTRC(L"0")) { 2886 int32_t iLeadDigits = 0; 2887 int32_t iFracDigits = 0; 2888 GetLeadDigits(iLeadDigits); 2889 GetFracDigits(iFracDigits); 2890 wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits); 2891 } 2892 bSyncData = TRUE; 2893 } 2894 } 2895 if (uiType != XFA_ELEMENT_NumericEdit || bSyncData) { 2896 SyncValue(wsNewText, TRUE); 2897 } 2898 return bValidate; 2899 } 2900 FX_BOOL CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture, 2901 XFA_VALUEPICTURE ePicture) { 2902 if (ePicture == XFA_VALUEPICTURE_Raw) { 2903 return FALSE; 2904 } 2905 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); 2906 switch (ePicture) { 2907 case XFA_VALUEPICTURE_Display: { 2908 if (CXFA_Node* pFormat = m_pNode->GetChild(0, XFA_ELEMENT_Format)) { 2909 if (CXFA_Node* pPicture = pFormat->GetChild(0, XFA_ELEMENT_Picture)) { 2910 if (pPicture->TryContent(wsPicture)) { 2911 return TRUE; 2912 } 2913 } 2914 } 2915 CFX_WideString wsDataPicture, wsTimePicture; 2916 IFX_Locale* pLocale = GetLocal(); 2917 if (!pLocale) { 2918 return FALSE; 2919 } 2920 FX_DWORD dwType = widgetValue.GetType(); 2921 switch (dwType) { 2922 case XFA_VT_DATE: 2923 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, 2924 wsPicture); 2925 break; 2926 case XFA_VT_TIME: 2927 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, 2928 wsPicture); 2929 break; 2930 case XFA_VT_DATETIME: 2931 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, 2932 wsDataPicture); 2933 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, 2934 wsTimePicture); 2935 wsPicture = wsDataPicture + FX_WSTRC(L"T") + wsTimePicture; 2936 break; 2937 case XFA_VT_DECIMAL: 2938 case XFA_VT_FLOAT: 2939 break; 2940 default: 2941 break; 2942 } 2943 } 2944 return TRUE; 2945 case XFA_VALUEPICTURE_Edit: { 2946 CXFA_Node* pUI = m_pNode->GetChild(0, XFA_ELEMENT_Ui); 2947 if (pUI) { 2948 if (CXFA_Node* pPicture = pUI->GetChild(0, XFA_ELEMENT_Picture)) { 2949 if (pPicture->TryContent(wsPicture)) { 2950 return TRUE; 2951 } 2952 } 2953 } 2954 { 2955 CFX_WideString wsDataPicture, wsTimePicture; 2956 IFX_Locale* pLocale = GetLocal(); 2957 if (!pLocale) { 2958 return FALSE; 2959 } 2960 FX_DWORD dwType = widgetValue.GetType(); 2961 switch (dwType) { 2962 case XFA_VT_DATE: 2963 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, 2964 wsPicture); 2965 break; 2966 case XFA_VT_TIME: 2967 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, 2968 wsPicture); 2969 break; 2970 case XFA_VT_DATETIME: 2971 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, 2972 wsDataPicture); 2973 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, 2974 wsTimePicture); 2975 wsPicture = wsDataPicture + L"T" + wsTimePicture; 2976 break; 2977 default: 2978 break; 2979 } 2980 } 2981 } 2982 return TRUE; 2983 case XFA_VALUEPICTURE_DataBind: { 2984 if (CXFA_Bind bind = GetBind()) { 2985 bind.GetPicture(wsPicture); 2986 return TRUE; 2987 } 2988 } break; 2989 default: 2990 break; 2991 } 2992 return FALSE; 2993 } 2994 IFX_Locale* CXFA_WidgetData::GetLocal() { 2995 IFX_Locale* pLocale = NULL; 2996 if (!m_pNode) { 2997 return pLocale; 2998 } 2999 FX_BOOL bLocale = FALSE; 3000 CFX_WideString wsLocaleName; 3001 bLocale = m_pNode->GetLocaleName(wsLocaleName); 3002 if (bLocale) { 3003 if (wsLocaleName.Equal(FX_WSTRC(L"ambient"))) { 3004 pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); 3005 } else { 3006 pLocale = 3007 m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName); 3008 } 3009 } 3010 return pLocale; 3011 } 3012 static FX_BOOL XFA_SplitDateTime(const CFX_WideString& wsDateTime, 3013 CFX_WideString& wsDate, 3014 CFX_WideString& wsTime) { 3015 wsDate = L""; 3016 wsTime = L""; 3017 if (wsDateTime.IsEmpty()) { 3018 return FALSE; 3019 } 3020 int nSplitIndex = -1; 3021 nSplitIndex = wsDateTime.Find('T'); 3022 if (nSplitIndex < 0) { 3023 nSplitIndex = wsDateTime.Find(' '); 3024 } 3025 if (nSplitIndex < 0) { 3026 return FALSE; 3027 } 3028 wsDate = wsDateTime.Left(nSplitIndex); 3029 if (!wsDate.IsEmpty()) { 3030 int32_t iCount = wsDate.GetLength(); 3031 int32_t i = 0; 3032 for (i = 0; i < iCount; i++) { 3033 if (wsDate[i] >= '0' && wsDate[i] <= '9') { 3034 break; 3035 } 3036 } 3037 if (i == iCount) { 3038 return FALSE; 3039 } 3040 } 3041 wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); 3042 if (!wsTime.IsEmpty()) { 3043 int32_t iCount = wsTime.GetLength(); 3044 int32_t i = 0; 3045 for (i = 0; i < iCount; i++) { 3046 if (wsTime[i] >= '0' && wsTime[i] <= '9') { 3047 break; 3048 } 3049 } 3050 if (i == iCount) { 3051 return FALSE; 3052 } 3053 } 3054 return TRUE; 3055 } 3056 #ifndef XFA_PARSE_HAS_LINEIDENTIFIER 3057 FX_BOOL CXFA_FieldNode_IsRichTextEdit(CXFA_Node* pFieldNode, 3058 IFDE_XMLNode*& pXMLNode) { 3059 FX_BOOL bRichTextEdit = FALSE; 3060 pXMLNode = NULL; 3061 if (pFieldNode->GetClassID() == XFA_ELEMENT_Field) { 3062 CXFA_Node* pValue = pFieldNode->GetChild(0, XFA_ELEMENT_Value); 3063 if (!pValue) { 3064 return bRichTextEdit; 3065 } 3066 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); 3067 if (!pChildValue) { 3068 return bRichTextEdit; 3069 } 3070 if (pChildValue->GetClassID() == XFA_ELEMENT_ExData) { 3071 CFX_WideString wsContentType; 3072 pChildValue->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, 3073 FALSE); 3074 bRichTextEdit = wsContentType.Equal(FX_WSTRC(L"text/html")); 3075 if (bRichTextEdit) { 3076 FX_BOOL bXMLInData = FALSE; 3077 CXFA_Node* pDataNode = pFieldNode->GetBindData(); 3078 if (pDataNode) { 3079 IFDE_XMLNode* pBindXML = pDataNode->GetXMLMappingNode(); 3080 FXSYS_assert(pBindXML); 3081 IFDE_XMLNode* pValueXML = 3082 pBindXML->GetNodeItem(IFDE_XMLNode::FirstChild); 3083 if (pValueXML && pValueXML->GetType() == FDE_XMLNODE_Element) { 3084 pXMLNode = pValueXML; 3085 bXMLInData = TRUE; 3086 } 3087 } 3088 if (!bXMLInData) { 3089 pXMLNode = pChildValue->GetXMLMappingNode(); 3090 } 3091 } 3092 } 3093 } 3094 return bRichTextEdit; 3095 } 3096 #endif 3097 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, 3098 XFA_VALUEPICTURE eValueType) { 3099 #ifdef XFA_PARSE_HAS_LINEIDENTIFIER 3100 wsValue = m_pNode->GetContent(); 3101 #else 3102 IFDE_XMLNode* pXMLNode = NULL; 3103 FX_BOOL bRichTextEdit = CXFA_FieldNode_IsRichTextEdit(m_pNode, pXMLNode); 3104 if (bRichTextEdit) { 3105 XFA_GetPlainTextFromRichText(pXMLNode, wsValue); 3106 } else { 3107 wsValue = m_pNode->GetContent(); 3108 } 3109 #endif 3110 if (eValueType == XFA_VALUEPICTURE_Display) { 3111 GetItemLabel(wsValue, wsValue); 3112 } 3113 CFX_WideString wsPicture; 3114 GetPictureContent(wsPicture, eValueType); 3115 CXFA_Node* pNode = GetUIChild(); 3116 if (!pNode) { 3117 return TRUE; 3118 } 3119 XFA_ELEMENT uiType = GetUIChild()->GetClassID(); 3120 switch (uiType) { 3121 case XFA_ELEMENT_ChoiceList: { 3122 if (eValueType == XFA_VALUEPICTURE_Display) { 3123 int32_t iSelItemIndex = GetSelectedItem(0); 3124 if (iSelItemIndex >= 0) { 3125 GetChoiceListItem(wsValue, iSelItemIndex); 3126 wsPicture.Empty(); 3127 } 3128 } 3129 } break; 3130 case XFA_ELEMENT_NumericEdit: 3131 if (eValueType != XFA_VALUEPICTURE_Raw && wsPicture.IsEmpty()) { 3132 IFX_Locale* pLocale = GetLocal(); 3133 if (eValueType == XFA_VALUEPICTURE_Display && pLocale) { 3134 CFX_WideString wsOutput; 3135 NormalizeNumStr(wsValue, wsOutput); 3136 FormatNumStr(wsOutput, pLocale, wsOutput); 3137 wsValue = wsOutput; 3138 } 3139 } 3140 break; 3141 default: 3142 break; 3143 } 3144 if (wsPicture.IsEmpty()) { 3145 return TRUE; 3146 } 3147 if (IFX_Locale* pLocale = GetLocal()) { 3148 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); 3149 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); 3150 switch (widgetValue.GetType()) { 3151 case XFA_VT_DATE: { 3152 CFX_WideString wsDate, wsTime; 3153 if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { 3154 CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); 3155 if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) { 3156 return TRUE; 3157 } 3158 } 3159 break; 3160 } 3161 case XFA_VT_TIME: { 3162 CFX_WideString wsDate, wsTime; 3163 if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { 3164 CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); 3165 if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) { 3166 return TRUE; 3167 } 3168 } 3169 break; 3170 } 3171 default: 3172 break; 3173 } 3174 widgetValue.FormatPatterns(wsValue, wsPicture, pLocale, eValueType); 3175 } 3176 return TRUE; 3177 } 3178 FX_BOOL CXFA_WidgetData::GetNormalizeDataValue( 3179 const CFX_WideStringC& wsValue, 3180 CFX_WideString& wsNormalizeValue) { 3181 wsNormalizeValue = wsValue; 3182 if (wsValue.IsEmpty()) { 3183 return TRUE; 3184 } 3185 CFX_WideString wsPicture; 3186 GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); 3187 if (wsPicture.IsEmpty()) { 3188 return TRUE; 3189 } 3190 FXSYS_assert(GetNode()); 3191 CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); 3192 IFX_Locale* pLocale = GetLocal(); 3193 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); 3194 if (widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture)) { 3195 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNormalizeValue, 3196 wsPicture, pLocale, pLocalMgr); 3197 wsNormalizeValue = widgetValue.GetValue(); 3198 return TRUE; 3199 } 3200 return FALSE; 3201 } 3202 FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideStringC& wsValue, 3203 CFX_WideString& wsFormatedValue) { 3204 wsFormatedValue = wsValue; 3205 if (wsValue.IsEmpty()) { 3206 return TRUE; 3207 } 3208 CFX_WideString wsPicture; 3209 GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); 3210 if (wsPicture.IsEmpty()) { 3211 return TRUE; 3212 } 3213 if (IFX_Locale* pLocale = GetLocal()) { 3214 FXSYS_assert(GetNode()); 3215 CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_ELEMENT_Value); 3216 if (!pNodeValue) { 3217 return FALSE; 3218 } 3219 CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); 3220 if (!pValueChild) { 3221 return FALSE; 3222 } 3223 int32_t iVTType = XFA_VT_NULL; 3224 XFA_ELEMENT eType = pValueChild->GetClassID(); 3225 switch (eType) { 3226 case XFA_ELEMENT_Decimal: 3227 iVTType = XFA_VT_DECIMAL; 3228 break; 3229 case XFA_ELEMENT_Float: 3230 iVTType = XFA_VT_FLOAT; 3231 break; 3232 case XFA_ELEMENT_Date: 3233 iVTType = XFA_VT_DATE; 3234 break; 3235 case XFA_ELEMENT_Time: 3236 iVTType = XFA_VT_TIME; 3237 break; 3238 case XFA_ELEMENT_DateTime: 3239 iVTType = XFA_VT_DATETIME; 3240 break; 3241 case XFA_ELEMENT_Boolean: 3242 iVTType = XFA_VT_BOOLEAN; 3243 break; 3244 case XFA_ELEMENT_Integer: 3245 iVTType = XFA_VT_INTEGER; 3246 break; 3247 case XFA_ELEMENT_Text: 3248 iVTType = XFA_VT_TEXT; 3249 break; 3250 default: 3251 iVTType = XFA_VT_NULL; 3252 break; 3253 } 3254 CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); 3255 CXFA_LocaleValue widgetValue(iVTType, wsValue, pLocalMgr); 3256 switch (widgetValue.GetType()) { 3257 case XFA_VT_DATE: { 3258 CFX_WideString wsDate, wsTime; 3259 if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { 3260 CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); 3261 if (date.FormatPatterns(wsFormatedValue, wsPicture, pLocale, 3262 XFA_VALUEPICTURE_DataBind)) { 3263 return TRUE; 3264 } 3265 } 3266 break; 3267 } 3268 case XFA_VT_TIME: { 3269 CFX_WideString wsDate, wsTime; 3270 if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { 3271 CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); 3272 if (time.FormatPatterns(wsFormatedValue, wsPicture, pLocale, 3273 XFA_VALUEPICTURE_DataBind)) { 3274 return TRUE; 3275 } 3276 } 3277 break; 3278 } 3279 default: 3280 break; 3281 } 3282 widgetValue.FormatPatterns(wsFormatedValue, wsPicture, pLocale, 3283 XFA_VALUEPICTURE_DataBind); 3284 } 3285 return FALSE; 3286 } 3287 void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue, 3288 CFX_WideString& wsOutput) { 3289 if (wsValue.IsEmpty()) { 3290 return; 3291 } 3292 wsOutput = wsValue; 3293 wsOutput.TrimLeft('0'); 3294 int32_t dot_index = wsOutput.Find('.'); 3295 int32_t iFracDigits = 0; 3296 if (!wsOutput.IsEmpty() && dot_index >= 0 && 3297 (!GetFracDigits(iFracDigits) || iFracDigits != -1)) { 3298 wsOutput.TrimRight(L"0"); 3299 wsOutput.TrimRight(L"."); 3300 } 3301 if (wsOutput.IsEmpty() || wsOutput[0] == '.') { 3302 wsOutput.Insert(0, '0'); 3303 } 3304 } 3305 void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue, 3306 IFX_Locale* pLocale, 3307 CFX_WideString& wsOutput) { 3308 if (wsValue.IsEmpty()) { 3309 return; 3310 } 3311 CFX_WideString wsSrcNum = wsValue; 3312 CFX_WideString wsGroupSymbol; 3313 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); 3314 FX_BOOL bNeg = FALSE; 3315 if (wsSrcNum[0] == '-') { 3316 bNeg = TRUE; 3317 wsSrcNum.Delete(0, 1); 3318 } 3319 int32_t len = wsSrcNum.GetLength(); 3320 int32_t dot_index = wsSrcNum.Find('.'); 3321 if (dot_index == -1) { 3322 dot_index = len; 3323 } 3324 int32_t cc = dot_index - 1; 3325 if (cc >= 0) { 3326 int nPos = dot_index % 3; 3327 wsOutput.Empty(); 3328 for (int32_t i = 0; i < dot_index; i++) { 3329 if (i % 3 == nPos && i != 0) { 3330 wsOutput += wsGroupSymbol; 3331 } 3332 wsOutput += wsSrcNum[i]; 3333 } 3334 if (dot_index < len) { 3335 CFX_WideString wsSymbol; 3336 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); 3337 wsOutput += wsSymbol; 3338 wsOutput += wsSrcNum.Right(len - dot_index - 1); 3339 } 3340 if (bNeg) { 3341 CFX_WideString wsMinusymbol; 3342 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); 3343 wsOutput = wsMinusymbol + wsOutput; 3344 } 3345 } 3346 } 3347 void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue, 3348 FX_BOOL bNotify) { 3349 if (!m_pNode) { 3350 return; 3351 } 3352 CFX_WideString wsFormatValue(wsValue); 3353 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); 3354 if (pContainerWidgetData) { 3355 pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue); 3356 } 3357 m_pNode->SetContent(wsValue, wsFormatValue, bNotify); 3358 } 3359 void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems, 3360 const CFX_WideStringC& wsText, 3361 int32_t nIndex) { 3362 CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text); 3363 pItems->InsertChild(nIndex, pText); 3364 pText->SetContent(wsText, wsText, FALSE, FALSE, FALSE); 3365 } 3366 CXFA_Filter CXFA_WidgetData::GetFilter(FX_BOOL bModified) { 3367 if (!m_pUiChildNode) { 3368 return CXFA_Filter(NULL); 3369 } 3370 return m_pUiChildNode->GetProperty(0, XFA_ELEMENT_Filter, bModified); 3371 } 3372 CXFA_Manifest CXFA_WidgetData::GetManifest(FX_BOOL bModified) { 3373 if (!m_pUiChildNode) { 3374 return CXFA_Manifest(NULL); 3375 } 3376 return m_pUiChildNode->GetProperty(0, XFA_ELEMENT_Manifest, bModified); 3377 } 3378 CXFA_Occur::CXFA_Occur(CXFA_Node* pNode) : CXFA_Data(pNode) {} 3379 int32_t CXFA_Occur::GetMax() { 3380 int32_t iMax = 1; 3381 if (m_pNode) { 3382 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, TRUE)) { 3383 iMax = GetMin(); 3384 } 3385 } 3386 return iMax; 3387 } 3388 int32_t CXFA_Occur::GetMin() { 3389 int32_t iMin = 1; 3390 if (m_pNode) { 3391 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, TRUE) || iMin < 0) { 3392 iMin = 1; 3393 } 3394 } 3395 return iMin; 3396 } 3397 int32_t CXFA_Occur::GetInitial() { 3398 int32_t iInit = 1; 3399 if (m_pNode) { 3400 int32_t iMin = GetMin(); 3401 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, TRUE) || 3402 iInit < iMin) { 3403 iInit = iMin; 3404 } 3405 } 3406 return iInit; 3407 } 3408 FX_BOOL CXFA_Occur::GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit) { 3409 if (!m_pNode) { 3410 return FALSE; 3411 } 3412 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE) || iMin < 0) { 3413 iMin = 1; 3414 } 3415 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { 3416 if (iMin == 0) { 3417 iMax = 1; 3418 } else { 3419 iMax = iMin; 3420 } 3421 } 3422 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, FALSE) || 3423 iInit < iMin) { 3424 iInit = iMin; 3425 } 3426 return TRUE; 3427 } 3428 void CXFA_Occur::SetMax(int32_t iMax) { 3429 iMax = (iMax != -1 && iMax < 1) ? 1 : iMax; 3430 m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); 3431 int32_t iMin = GetMin(); 3432 if (iMax != -1 && iMax < iMin) { 3433 iMin = iMax; 3434 m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE); 3435 } 3436 } 3437 void CXFA_Occur::SetMin(int32_t iMin) { 3438 iMin = (iMin < 0) ? 1 : iMin; 3439 m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE); 3440 int32_t iMax = GetMax(); 3441 if (iMax > 0 && iMax < iMin) { 3442 iMax = iMin; 3443 m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); 3444 } 3445 } 3446 XFA_ATTRIBUTEENUM XFA_GetEnumTypeAttribute( 3447 CXFA_Node* pNode, 3448 XFA_ATTRIBUTE attributeValue = XFA_ATTRIBUTE_Type, 3449 XFA_ATTRIBUTEENUM eDefaultValue = XFA_ATTRIBUTEENUM_Optional) { 3450 XFA_ATTRIBUTEENUM eType = eDefaultValue; 3451 if (pNode) { 3452 if (!pNode->TryEnum(attributeValue, eType, TRUE)) { 3453 eType = eDefaultValue; 3454 } 3455 } 3456 return eType; 3457 } 3458 CFX_WideString CXFA_Filter::GetFilterString(XFA_ATTRIBUTE eAttribute) { 3459 CFX_WideString wsStringValue; 3460 if (m_pNode) { 3461 m_pNode->GetAttribute(eAttribute, wsStringValue, FALSE); 3462 } 3463 return wsStringValue; 3464 } 3465 XFA_ATTRIBUTEENUM CXFA_Filter::GetAppearanceFilterType() { 3466 if (!m_pNode) { 3467 return XFA_ATTRIBUTEENUM_Optional; 3468 } 3469 CXFA_Node* pAppearanceFilterNode = 3470 m_pNode->GetProperty(0, XFA_ELEMENT_AppearanceFilter); 3471 return XFA_GetEnumTypeAttribute(pAppearanceFilterNode); 3472 } 3473 CFX_WideString CXFA_Filter::GetAppearanceFilterContent() { 3474 CFX_WideString wsContent; 3475 if (m_pNode) { 3476 CXFA_Node* pAppearanceFilterNode = 3477 m_pNode->GetProperty(0, XFA_ELEMENT_AppearanceFilter); 3478 pAppearanceFilterNode->TryContent(wsContent); 3479 } 3480 return wsContent; 3481 } 3482 XFA_ATTRIBUTEENUM CXFA_Filter::GetCertificatesCredentialServerPolicy() { 3483 if (!m_pNode) { 3484 return XFA_ATTRIBUTEENUM_Optional; 3485 } 3486 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); 3487 return XFA_GetEnumTypeAttribute(pCertsNode, 3488 XFA_ATTRIBUTE_CredentialServerPolicy); 3489 } 3490 CFX_WideString CXFA_Filter::GetCertificatesURL() { 3491 CFX_WideString wsURL; 3492 if (m_pNode) { 3493 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); 3494 pCertsNode->GetAttribute(XFA_ATTRIBUTE_Url, wsURL, FALSE); 3495 } 3496 return wsURL; 3497 } 3498 CFX_WideString CXFA_Filter::GetCertificatesURLPolicy() { 3499 CFX_WideString wsURLPolicy; 3500 if (m_pNode) { 3501 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); 3502 pCertsNode->GetAttribute(XFA_ATTRIBUTE_UrlPolicy, wsURLPolicy, FALSE); 3503 } 3504 return wsURLPolicy; 3505 } 3506 CXFA_WrapCertificate CXFA_Filter::GetCertificatesEncryption(FX_BOOL bModified) { 3507 if (!m_pNode) { 3508 return CXFA_WrapCertificate(NULL); 3509 } 3510 CXFA_Node* pCertsNode = 3511 m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); 3512 return CXFA_WrapCertificate( 3513 pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Encryption, bModified) 3514 : NULL); 3515 } 3516 CXFA_WrapCertificate CXFA_Filter::GetCertificatesIssuers(FX_BOOL bModified) { 3517 if (!m_pNode) { 3518 return CXFA_WrapCertificate(NULL); 3519 } 3520 CXFA_Node* pCertsNode = 3521 m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); 3522 return CXFA_WrapCertificate( 3523 pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Issuers, bModified) 3524 : NULL); 3525 } 3526 CFX_WideString CXFA_Filter::GetCertificatesKeyUsageString( 3527 XFA_ATTRIBUTE eAttribute) { 3528 if (!m_pNode) { 3529 return FX_WSTRC(L""); 3530 } 3531 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); 3532 CXFA_Node* pKeyUsageNode = pCertsNode->GetProperty(0, XFA_ELEMENT_KeyUsage); 3533 CFX_WideString wsAttributeValue; 3534 pKeyUsageNode->GetAttribute(eAttribute, wsAttributeValue, FALSE); 3535 return wsAttributeValue; 3536 } 3537 CXFA_Oids CXFA_Filter::GetCertificatesOids() { 3538 if (!m_pNode) { 3539 return CXFA_Oids(NULL); 3540 } 3541 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); 3542 return CXFA_Oids(pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Oids) 3543 : NULL); 3544 } 3545 CXFA_WrapCertificate CXFA_Filter::GetCertificatesSigning(FX_BOOL bModified) { 3546 if (!m_pNode) { 3547 return CXFA_WrapCertificate(NULL); 3548 } 3549 CXFA_Node* pCertsNode = 3550 m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); 3551 return CXFA_WrapCertificate( 3552 pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Signing, bModified) 3553 : NULL); 3554 } 3555 CXFA_DigestMethods CXFA_Filter::GetDigestMethods(FX_BOOL bModified) { 3556 return CXFA_DigestMethods( 3557 m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_DigestMethods, bModified) 3558 : NULL); 3559 } 3560 CXFA_Encodings CXFA_Filter::GetEncodings(FX_BOOL bModified) { 3561 return CXFA_Encodings( 3562 m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_Encodings, bModified) 3563 : NULL); 3564 } 3565 CXFA_EncryptionMethods CXFA_Filter::GetEncryptionMethods(FX_BOOL bModified) { 3566 return CXFA_EncryptionMethods( 3567 m_pNode 3568 ? m_pNode->GetProperty(0, XFA_ELEMENT_EncryptionMethods, bModified) 3569 : NULL); 3570 } 3571 XFA_ATTRIBUTEENUM CXFA_Filter::GetHandlerType() { 3572 if (!m_pNode) { 3573 return XFA_ATTRIBUTEENUM_Optional; 3574 } 3575 CXFA_Node* pHandlerNode = m_pNode->GetProperty(0, XFA_ELEMENT_Handler); 3576 return XFA_GetEnumTypeAttribute(pHandlerNode); 3577 } 3578 CFX_WideString CXFA_Filter::GetHandlerContent() { 3579 CFX_WideString wsContent; 3580 if (m_pNode) { 3581 CXFA_Node* pHandlerNode = m_pNode->GetProperty(0, XFA_ELEMENT_Handler); 3582 pHandlerNode->TryContent(wsContent); 3583 } 3584 return wsContent; 3585 } 3586 XFA_ATTRIBUTEENUM CXFA_Filter::GetlockDocumentType() { 3587 if (!m_pNode) { 3588 return XFA_ATTRIBUTEENUM_Optional; 3589 } 3590 CXFA_Node* pLockDocNode = m_pNode->GetProperty(0, XFA_ELEMENT_LockDocument); 3591 return XFA_GetEnumTypeAttribute(pLockDocNode); 3592 } 3593 CFX_WideString CXFA_Filter::GetlockDocumentContent() { 3594 CFX_WideString wsContent = FX_WSTRC(L"auto"); 3595 if (m_pNode) { 3596 CXFA_Node* pLockDocNode = m_pNode->GetProperty(0, XFA_ELEMENT_LockDocument); 3597 pLockDocNode->TryContent(wsContent); 3598 } 3599 return wsContent; 3600 } 3601 int32_t CXFA_Filter::GetMDPPermissions() { 3602 int32_t iPermissions = 2; 3603 if (m_pNode) { 3604 CXFA_Node* pMDPNode = m_pNode->GetProperty(0, XFA_ELEMENT_Mdp); 3605 if (!pMDPNode->TryInteger(XFA_ATTRIBUTE_Permissions, iPermissions, TRUE)) { 3606 iPermissions = 2; 3607 } 3608 } 3609 return iPermissions; 3610 } 3611 XFA_ATTRIBUTEENUM CXFA_Filter::GetMDPSignatureType() { 3612 if (!m_pNode) { 3613 return XFA_ATTRIBUTEENUM_Filter; 3614 } 3615 CXFA_Node* pMDPNode = m_pNode->GetProperty(0, XFA_ELEMENT_Mdp); 3616 return XFA_GetEnumTypeAttribute(pMDPNode, XFA_ATTRIBUTE_SignatureType, 3617 XFA_ATTRIBUTEENUM_Filter); 3618 } 3619 CXFA_Reasons CXFA_Filter::GetReasons(FX_BOOL bModified) { 3620 return CXFA_Reasons(m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_Reasons) 3621 : NULL); 3622 } 3623 CFX_WideString CXFA_Filter::GetTimeStampServer() { 3624 CFX_WideString wsServerURI; 3625 if (m_pNode) { 3626 CXFA_Node* pTimeStampNode = m_pNode->GetProperty(0, XFA_ELEMENT_TimeStamp); 3627 pTimeStampNode->GetAttribute(XFA_ATTRIBUTE_Server, wsServerURI, FALSE); 3628 } 3629 return wsServerURI; 3630 } 3631 XFA_ATTRIBUTEENUM CXFA_Filter::GetTimeStampType() { 3632 if (!m_pNode) { 3633 return XFA_ATTRIBUTEENUM_Optional; 3634 } 3635 CXFA_Node* pTimeStampNode = m_pNode->GetProperty(0, XFA_ELEMENT_TimeStamp); 3636 return XFA_GetEnumTypeAttribute(pTimeStampNode); 3637 } 3638 CFX_WideString CXFA_Certificate::GetCertificateName() { 3639 CFX_WideString wsName; 3640 if (m_pNode) { 3641 m_pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); 3642 } 3643 return wsName; 3644 } 3645 CFX_WideString CXFA_Certificate::GetCertificateContent() { 3646 CFX_WideString wsContent; 3647 if (m_pNode) { 3648 m_pNode->TryContent(wsContent); 3649 } 3650 return wsContent; 3651 } 3652 XFA_ATTRIBUTEENUM CXFA_WrapCertificate::GetType() { 3653 return XFA_GetEnumTypeAttribute(m_pNode); 3654 } 3655 int32_t CXFA_WrapCertificate::CountCertificates() { 3656 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Certificate) : 0; 3657 } 3658 CXFA_Certificate CXFA_WrapCertificate::GetCertificate(int32_t nIndex) { 3659 return CXFA_Certificate( 3660 (nIndex > -1 && m_pNode) 3661 ? m_pNode->GetChild(nIndex, XFA_ELEMENT_Certificate) 3662 : NULL); 3663 } 3664 XFA_ATTRIBUTEENUM CXFA_Oids::GetOidsType() { 3665 return XFA_GetEnumTypeAttribute(m_pNode); 3666 } 3667 int32_t CXFA_Oids::CountOids() { 3668 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Oid) : 0; 3669 } 3670 CFX_WideString CXFA_Oids::GetOidContent(int32_t nIndex) { 3671 if (nIndex <= -1 || !m_pNode) { 3672 return FX_WSTRC(L""); 3673 } 3674 CXFA_Node* pOidNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Oid); 3675 if (!pOidNode) { 3676 return FX_WSTRC(L""); 3677 } 3678 CFX_WideString wsContent; 3679 pOidNode->TryContent(wsContent); 3680 return wsContent; 3681 } 3682 XFA_ATTRIBUTEENUM CXFA_SubjectDNs::GetSubjectDNsType() { 3683 return XFA_GetEnumTypeAttribute(m_pNode); 3684 } 3685 int32_t CXFA_SubjectDNs::CountSubjectDNs() { 3686 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_SubjectDN) : 0; 3687 } 3688 CFX_WideString CXFA_SubjectDNs::GetSubjectDNString(int32_t nIndex, 3689 XFA_ATTRIBUTE eAttribute) { 3690 if (nIndex <= -1 || !m_pNode) { 3691 return FX_WSTRC(L""); 3692 } 3693 CXFA_Node* pSubjectDNNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_SubjectDN); 3694 if (!pSubjectDNNode) { 3695 return FX_WSTRC(L""); 3696 } 3697 CFX_WideString wsAttributeValue; 3698 pSubjectDNNode->GetAttribute(eAttribute, wsAttributeValue, FALSE); 3699 return wsAttributeValue; 3700 } 3701 CFX_WideString CXFA_SubjectDNs::GetSubjectDNContent(int32_t nIndex) { 3702 if (nIndex <= -1 || !m_pNode) { 3703 return FX_WSTRC(L""); 3704 } 3705 CXFA_Node* pSubjectDNNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_SubjectDN); 3706 if (!pSubjectDNNode) { 3707 return FX_WSTRC(L""); 3708 } 3709 CFX_WideString wsContent; 3710 pSubjectDNNode->TryContent(wsContent); 3711 return wsContent; 3712 } 3713 XFA_ATTRIBUTEENUM CXFA_DigestMethods::GetDigestMethodsType() { 3714 return XFA_GetEnumTypeAttribute(m_pNode); 3715 } 3716 int32_t CXFA_DigestMethods::CountDigestMethods() { 3717 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_DigestMethod) : 0; 3718 } 3719 CFX_WideString CXFA_DigestMethods::GetDigestMethodContent(int32_t nIndex) { 3720 if (nIndex <= -1 || !m_pNode) { 3721 return FX_WSTRC(L""); 3722 } 3723 CXFA_Node* pDigestMethodNode = 3724 m_pNode->GetChild(nIndex, XFA_ELEMENT_DigestMethod); 3725 if (!pDigestMethodNode) { 3726 return FX_WSTRC(L""); 3727 } 3728 CFX_WideString wsContent; 3729 pDigestMethodNode->TryContent(wsContent); 3730 return wsContent; 3731 } 3732 XFA_ATTRIBUTEENUM CXFA_Encodings::GetEncodingsType() { 3733 return XFA_GetEnumTypeAttribute(m_pNode); 3734 } 3735 int32_t CXFA_Encodings::CountEncodings() { 3736 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Encoding) : 0; 3737 } 3738 CFX_WideString CXFA_Encodings::GetEncodingContent(int32_t nIndex) { 3739 if (nIndex <= -1 || !m_pNode) { 3740 return FX_WSTRC(L""); 3741 } 3742 CXFA_Node* pEncodingNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Encoding); 3743 if (!pEncodingNode) { 3744 return FX_WSTRC(L""); 3745 } 3746 CFX_WideString wsContent; 3747 pEncodingNode->TryContent(wsContent); 3748 return wsContent; 3749 } 3750 XFA_ATTRIBUTEENUM CXFA_EncryptionMethods::GetEncryptionMethodsType() { 3751 return XFA_GetEnumTypeAttribute(m_pNode); 3752 } 3753 int32_t CXFA_EncryptionMethods::CountEncryptionMethods() { 3754 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_EncryptionMethod) : 0; 3755 } 3756 CFX_WideString CXFA_EncryptionMethods::GetEncryptionMethodContent( 3757 int32_t nIndex) { 3758 if (nIndex <= -1 || !m_pNode) { 3759 return FX_WSTRC(L""); 3760 } 3761 CXFA_Node* pEncryMethodNode = 3762 m_pNode->GetChild(nIndex, XFA_ELEMENT_EncryptionMethod); 3763 if (!pEncryMethodNode) { 3764 return FX_WSTRC(L""); 3765 } 3766 CFX_WideString wsContent; 3767 pEncryMethodNode->TryContent(wsContent); 3768 return wsContent; 3769 } 3770 XFA_ATTRIBUTEENUM CXFA_Reasons::GetReasonsType() { 3771 return XFA_GetEnumTypeAttribute(m_pNode); 3772 } 3773 int32_t CXFA_Reasons::CountReasons() { 3774 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Reason) : 0; 3775 } 3776 CFX_WideString CXFA_Reasons::GetReasonContent(int32_t nIndex) { 3777 if (nIndex <= -1 || !m_pNode) { 3778 return FX_WSTRC(L""); 3779 } 3780 CXFA_Node* pReasonNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Reason); 3781 if (!pReasonNode) { 3782 return FX_WSTRC(L""); 3783 } 3784 CFX_WideString wsContent; 3785 pReasonNode->TryContent(wsContent); 3786 return wsContent; 3787 } 3788 XFA_ATTRIBUTEENUM CXFA_Manifest::GetAction() { 3789 return XFA_GetEnumTypeAttribute(m_pNode, XFA_ATTRIBUTE_Action, 3790 XFA_ATTRIBUTEENUM_Include); 3791 } 3792 int32_t CXFA_Manifest::CountReives() { 3793 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Ref) : 0; 3794 } 3795 CFX_WideString CXFA_Manifest::GetRefContent(int32_t nIndex) { 3796 if (nIndex <= -1 || !m_pNode) { 3797 return FX_WSTRC(L""); 3798 } 3799 CXFA_Node* pRefNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Ref); 3800 if (!pRefNode) { 3801 return FX_WSTRC(L""); 3802 } 3803 CFX_WideString wsContent; 3804 pRefNode->TryContent(wsContent); 3805 return wsContent; 3806 } 3807