| OLD | NEW |
| (Empty) |
| 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 "core/include/fxcrt/fx_ext.h" | |
| 8 #include "xfa/include/fxbarcode/BC_BarCode.h" | |
| 9 #include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" | |
| 10 #include "xfa/src/fxfa/parser/xfa_docdata.h" | |
| 11 #include "xfa/src/fxfa/parser/xfa_doclayout.h" | |
| 12 #include "xfa/src/fxfa/parser/xfa_document.h" | |
| 13 #include "xfa/src/fxfa/parser/xfa_localemgr.h" | |
| 14 #include "xfa/src/fxfa/parser/xfa_localevalue.h" | |
| 15 #include "xfa/src/fxfa/parser/xfa_object.h" | |
| 16 #include "xfa/src/fxfa/parser/xfa_parser.h" | |
| 17 #include "xfa/src/fxfa/parser/xfa_script.h" | |
| 18 #include "xfa/src/fxfa/parser/xfa_utils.h" | |
| 19 | |
| 20 static FX_ARGB XFA_WStringToColor(const CFX_WideStringC& wsValue) { | |
| 21 uint8_t r = 0, g = 0, b = 0; | |
| 22 if (wsValue.GetLength() == 0) { | |
| 23 return 0xff000000; | |
| 24 } | |
| 25 int cc = 0; | |
| 26 const FX_WCHAR* str = wsValue.GetPtr(); | |
| 27 int len = wsValue.GetLength(); | |
| 28 while (XFA_IsSpace(str[cc]) && cc < len) { | |
| 29 cc++; | |
| 30 } | |
| 31 if (cc >= len) { | |
| 32 return 0xff000000; | |
| 33 } | |
| 34 while (cc < len) { | |
| 35 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) { | |
| 36 break; | |
| 37 } | |
| 38 r = r * 10 + str[cc] - '0'; | |
| 39 cc++; | |
| 40 } | |
| 41 if (cc < len && str[cc] == ',') { | |
| 42 cc++; | |
| 43 while (XFA_IsSpace(str[cc]) && cc < len) { | |
| 44 cc++; | |
| 45 } | |
| 46 while (cc < len) { | |
| 47 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) { | |
| 48 break; | |
| 49 } | |
| 50 g = g * 10 + str[cc] - '0'; | |
| 51 cc++; | |
| 52 } | |
| 53 if (cc < len && str[cc] == ',') { | |
| 54 cc++; | |
| 55 while (XFA_IsSpace(str[cc]) && cc < len) { | |
| 56 cc++; | |
| 57 } | |
| 58 while (cc < len) { | |
| 59 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) { | |
| 60 break; | |
| 61 } | |
| 62 b = b * 10 + str[cc] - '0'; | |
| 63 cc++; | |
| 64 } | |
| 65 } | |
| 66 } | |
| 67 return (0xff << 24) | (r << 16) | (g << 8) | b; | |
| 68 } | |
| 69 XFA_ELEMENT CXFA_Data::GetClassID() const { | |
| 70 return m_pNode ? m_pNode->GetClassID() : XFA_ELEMENT_UNKNOWN; | |
| 71 } | |
| 72 FX_BOOL CXFA_Data::TryMeasure(XFA_ATTRIBUTE eAttr, | |
| 73 FX_FLOAT& fValue, | |
| 74 FX_BOOL bUseDefault) const { | |
| 75 CXFA_Measurement ms; | |
| 76 if (m_pNode->TryMeasure(eAttr, ms, bUseDefault)) { | |
| 77 fValue = ms.ToUnit(XFA_UNIT_Pt); | |
| 78 return TRUE; | |
| 79 } | |
| 80 return FALSE; | |
| 81 } | |
| 82 FX_BOOL CXFA_Data::SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue) { | |
| 83 CXFA_Measurement ms(fValue, XFA_UNIT_Pt); | |
| 84 return m_pNode->SetMeasure(eAttr, ms); | |
| 85 } | |
| 86 CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 87 CXFA_Fill::~CXFA_Fill() {} | |
| 88 int32_t CXFA_Fill::GetPresence() { | |
| 89 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); | |
| 90 } | |
| 91 void CXFA_Fill::SetColor(FX_ARGB color) { | |
| 92 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color); | |
| 93 CFX_WideString wsColor; | |
| 94 int a, r, g, b; | |
| 95 ArgbDecode(color, a, r, g, b); | |
| 96 wsColor.Format(L"%d,%d,%d", r, g, b); | |
| 97 pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor); | |
| 98 } | |
| 99 FX_ARGB CXFA_Fill::GetColor(FX_BOOL bText) { | |
| 100 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color)) { | |
| 101 CFX_WideStringC wsColor; | |
| 102 if (pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE)) { | |
| 103 return XFA_WStringToColor(wsColor); | |
| 104 } | |
| 105 } | |
| 106 if (bText) { | |
| 107 return 0xFF000000; | |
| 108 } | |
| 109 return 0xFFFFFFFF; | |
| 110 } | |
| 111 int32_t CXFA_Fill::GetFillType() { | |
| 112 CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 113 while (pChild) { | |
| 114 int32_t eType = pChild->GetClassID(); | |
| 115 if (eType != XFA_ELEMENT_Color && eType != XFA_ELEMENT_Extras) { | |
| 116 return eType; | |
| 117 } | |
| 118 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 119 } | |
| 120 return XFA_ELEMENT_Solid; | |
| 121 } | |
| 122 int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) { | |
| 123 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Pattern); | |
| 124 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) { | |
| 125 CFX_WideStringC wsColor; | |
| 126 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE); | |
| 127 foreColor = XFA_WStringToColor(wsColor); | |
| 128 } else { | |
| 129 foreColor = 0xFF000000; | |
| 130 } | |
| 131 return pNode->GetEnum(XFA_ATTRIBUTE_Type); | |
| 132 } | |
| 133 int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) { | |
| 134 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Stipple); | |
| 135 int32_t eAttr = 50; | |
| 136 pNode->TryInteger(XFA_ATTRIBUTE_Rate, eAttr); | |
| 137 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) { | |
| 138 CFX_WideStringC wsColor; | |
| 139 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE); | |
| 140 stippleColor = XFA_WStringToColor(wsColor); | |
| 141 } else { | |
| 142 stippleColor = 0xFF000000; | |
| 143 } | |
| 144 return eAttr; | |
| 145 } | |
| 146 int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) { | |
| 147 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Linear); | |
| 148 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight; | |
| 149 pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr); | |
| 150 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) { | |
| 151 CFX_WideStringC wsColor; | |
| 152 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE); | |
| 153 endColor = XFA_WStringToColor(wsColor); | |
| 154 } else { | |
| 155 endColor = 0xFF000000; | |
| 156 } | |
| 157 return eAttr; | |
| 158 } | |
| 159 int32_t CXFA_Fill::GetRadial(FX_ARGB& endColor) { | |
| 160 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Radial); | |
| 161 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge; | |
| 162 pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr); | |
| 163 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) { | |
| 164 CFX_WideStringC wsColor; | |
| 165 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE); | |
| 166 endColor = XFA_WStringToColor(wsColor); | |
| 167 } else { | |
| 168 endColor = 0xFF000000; | |
| 169 } | |
| 170 return eAttr; | |
| 171 } | |
| 172 FX_BOOL CXFA_Fill::SetPresence(int32_t iPresence) { | |
| 173 return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); | |
| 174 } | |
| 175 FX_BOOL CXFA_Fill::SetFillType(int32_t iType) { | |
| 176 return FALSE; | |
| 177 } | |
| 178 FX_BOOL CXFA_Fill::SetPattern(int32_t iPattern, FX_ARGB foreColor) { | |
| 179 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Pattern); | |
| 180 CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); | |
| 181 CFX_WideString wsColor; | |
| 182 int a, r, g, b; | |
| 183 ArgbDecode(foreColor, a, r, g, b); | |
| 184 wsColor.Format(L"%d,%d,%d", r, g, b); | |
| 185 pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); | |
| 186 return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iPattern); | |
| 187 } | |
| 188 FX_BOOL CXFA_Fill::SetStipple(int32_t iStipple, FX_ARGB stippleColor) { | |
| 189 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Stipple); | |
| 190 CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); | |
| 191 CFX_WideString wsColor; | |
| 192 int a, r, g, b; | |
| 193 ArgbDecode(stippleColor, a, r, g, b); | |
| 194 wsColor.Format(L"%d,%d,%d", r, g, b); | |
| 195 pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); | |
| 196 return pNode->SetEnum(XFA_ATTRIBUTE_Rate, (XFA_ATTRIBUTEENUM)iStipple); | |
| 197 } | |
| 198 FX_BOOL CXFA_Fill::SetLinear(int32_t iLinear, FX_ARGB endColor) { | |
| 199 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Linear); | |
| 200 CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); | |
| 201 CFX_WideString wsColor; | |
| 202 int a, r, g, b; | |
| 203 ArgbDecode(endColor, a, r, g, b); | |
| 204 wsColor.Format(L"%d,%d,%d", r, g, b); | |
| 205 pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); | |
| 206 return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iLinear); | |
| 207 } | |
| 208 FX_BOOL CXFA_Fill::SetRadial(int32_t iRadial, FX_ARGB endColor) { | |
| 209 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Radial); | |
| 210 CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); | |
| 211 CFX_WideString wsColor; | |
| 212 int a, r, g, b; | |
| 213 ArgbDecode(endColor, a, r, g, b); | |
| 214 wsColor.Format(L"%d,%d,%d", r, g, b); | |
| 215 pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); | |
| 216 return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iRadial); | |
| 217 } | |
| 218 CXFA_Margin::CXFA_Margin(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 219 FX_BOOL CXFA_Margin::GetLeftInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const { | |
| 220 fInset = fDefInset; | |
| 221 return TryMeasure(XFA_ATTRIBUTE_LeftInset, fInset); | |
| 222 } | |
| 223 FX_BOOL CXFA_Margin::GetTopInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const { | |
| 224 fInset = fDefInset; | |
| 225 return TryMeasure(XFA_ATTRIBUTE_TopInset, fInset); | |
| 226 } | |
| 227 FX_BOOL CXFA_Margin::GetRightInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const { | |
| 228 fInset = fDefInset; | |
| 229 return TryMeasure(XFA_ATTRIBUTE_RightInset, fInset); | |
| 230 } | |
| 231 FX_BOOL CXFA_Margin::GetBottomInset(FX_FLOAT& fInset, | |
| 232 FX_FLOAT fDefInset) const { | |
| 233 fInset = fDefInset; | |
| 234 return TryMeasure(XFA_ATTRIBUTE_BottomInset, fInset); | |
| 235 } | |
| 236 FX_BOOL CXFA_Margin::SetLeftInset(FX_FLOAT fInset) { | |
| 237 return SetMeasure(XFA_ATTRIBUTE_LeftInset, fInset); | |
| 238 } | |
| 239 FX_BOOL CXFA_Margin::SetTopInset(FX_FLOAT fInset) { | |
| 240 return SetMeasure(XFA_ATTRIBUTE_TopInset, fInset); | |
| 241 } | |
| 242 FX_BOOL CXFA_Margin::SetRightInset(FX_FLOAT fInset) { | |
| 243 return SetMeasure(XFA_ATTRIBUTE_RightInset, fInset); | |
| 244 } | |
| 245 FX_BOOL CXFA_Margin::SetBottomInset(FX_FLOAT fInset) { | |
| 246 return SetMeasure(XFA_ATTRIBUTE_BottomInset, fInset); | |
| 247 } | |
| 248 CXFA_Font::CXFA_Font(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 249 FX_FLOAT CXFA_Font::GetBaselineShift() { | |
| 250 return m_pNode->GetMeasure(XFA_ATTRIBUTE_BaselineShift).ToUnit(XFA_UNIT_Pt); | |
| 251 } | |
| 252 FX_FLOAT CXFA_Font::GetHorizontalScale() { | |
| 253 CFX_WideString wsValue; | |
| 254 m_pNode->TryCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue); | |
| 255 int32_t iScale = FXSYS_wtoi((const FX_WCHAR*)wsValue); | |
| 256 return iScale > 0 ? (FX_FLOAT)iScale : 100.0f; | |
| 257 } | |
| 258 FX_FLOAT CXFA_Font::GetVerticalScale() { | |
| 259 CFX_WideString wsValue; | |
| 260 m_pNode->TryCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue); | |
| 261 int32_t iScale = FXSYS_wtoi((const FX_WCHAR*)wsValue); | |
| 262 return iScale > 0 ? (FX_FLOAT)iScale : 100.0f; | |
| 263 } | |
| 264 FX_FLOAT CXFA_Font::GetLetterSpacing() { | |
| 265 CFX_WideStringC wsValue; | |
| 266 if (!m_pNode->TryCData(XFA_ATTRIBUTE_LetterSpacing, wsValue)) { | |
| 267 return 0; | |
| 268 } | |
| 269 CXFA_Measurement ms(wsValue); | |
| 270 if (ms.GetUnit() == XFA_UNIT_Em) { | |
| 271 return ms.GetValue() * GetFontSize(); | |
| 272 } | |
| 273 return ms.ToUnit(XFA_UNIT_Pt); | |
| 274 } | |
| 275 int32_t CXFA_Font::GetLineThrough() { | |
| 276 int32_t iValue = 0; | |
| 277 m_pNode->TryInteger(XFA_ATTRIBUTE_LineThrough, iValue); | |
| 278 return iValue; | |
| 279 } | |
| 280 int32_t CXFA_Font::GetLineThroughPeriod() { | |
| 281 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All; | |
| 282 m_pNode->TryEnum(XFA_ATTRIBUTE_LineThroughPeriod, eAttr); | |
| 283 return eAttr; | |
| 284 } | |
| 285 int32_t CXFA_Font::GetOverline() { | |
| 286 int32_t iValue = 0; | |
| 287 m_pNode->TryInteger(XFA_ATTRIBUTE_Overline, iValue); | |
| 288 return iValue; | |
| 289 } | |
| 290 int32_t CXFA_Font::GetOverlinePeriod() { | |
| 291 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All; | |
| 292 m_pNode->TryEnum(XFA_ATTRIBUTE_OverlinePeriod, eAttr); | |
| 293 return eAttr; | |
| 294 } | |
| 295 int32_t CXFA_Font::GetUnderline() { | |
| 296 int32_t iValue = 0; | |
| 297 m_pNode->TryInteger(XFA_ATTRIBUTE_Underline, iValue); | |
| 298 return iValue; | |
| 299 } | |
| 300 int32_t CXFA_Font::GetUnderlinePeriod() { | |
| 301 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All; | |
| 302 m_pNode->TryEnum(XFA_ATTRIBUTE_UnderlinePeriod, eAttr); | |
| 303 return eAttr; | |
| 304 } | |
| 305 FX_FLOAT CXFA_Font::GetFontSize() { | |
| 306 CXFA_Measurement ms; | |
| 307 m_pNode->TryMeasure(XFA_ATTRIBUTE_Size, ms); | |
| 308 return ms.ToUnit(XFA_UNIT_Pt); | |
| 309 } | |
| 310 void CXFA_Font::GetTypeface(CFX_WideStringC& wsTypeFace) { | |
| 311 m_pNode->TryCData(XFA_ATTRIBUTE_Typeface, wsTypeFace); | |
| 312 } | |
| 313 FX_BOOL CXFA_Font::IsBold() { | |
| 314 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal; | |
| 315 m_pNode->TryEnum(XFA_ATTRIBUTE_Weight, eAttr); | |
| 316 return eAttr == XFA_ATTRIBUTEENUM_Bold; | |
| 317 } | |
| 318 FX_BOOL CXFA_Font::IsItalic() { | |
| 319 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal; | |
| 320 m_pNode->TryEnum(XFA_ATTRIBUTE_Posture, eAttr); | |
| 321 return eAttr == XFA_ATTRIBUTEENUM_Italic; | |
| 322 } | |
| 323 FX_BOOL CXFA_Font::IsUseKerning() { | |
| 324 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; | |
| 325 m_pNode->TryEnum(XFA_ATTRIBUTE_KerningMode, eAttr); | |
| 326 return eAttr == XFA_ATTRIBUTEENUM_Pair; | |
| 327 } | |
| 328 void CXFA_Font::SetColor(FX_ARGB color) { | |
| 329 CXFA_Fill fill(m_pNode->GetProperty(0, XFA_ELEMENT_Fill)); | |
| 330 fill.SetColor(color); | |
| 331 } | |
| 332 FX_ARGB CXFA_Font::GetColor() { | |
| 333 CXFA_Fill fill(m_pNode->GetChild(0, XFA_ELEMENT_Fill)); | |
| 334 return fill ? fill.GetColor(TRUE) : 0xFF000000; | |
| 335 } | |
| 336 FX_BOOL CXFA_Font::SetBaselineShift(FX_FLOAT fBaselineShift) { | |
| 337 CXFA_Measurement ms(fBaselineShift, XFA_UNIT_Pt); | |
| 338 return m_pNode->SetMeasure(XFA_ATTRIBUTE_BaselineShift, ms); | |
| 339 } | |
| 340 FX_BOOL CXFA_Font::SetHorizontalScale(FX_FLOAT fHorizontalScale) { | |
| 341 CFX_WideString wsValue; | |
| 342 wsValue.Format(L"%d", (int32_t)fHorizontalScale); | |
| 343 return m_pNode->SetCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue); | |
| 344 } | |
| 345 FX_BOOL CXFA_Font::SetVerticalScale(FX_FLOAT fVerticalScale) { | |
| 346 CFX_WideString wsValue; | |
| 347 wsValue.Format(L"%d", (int32_t)fVerticalScale); | |
| 348 return m_pNode->SetCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue); | |
| 349 } | |
| 350 FX_BOOL CXFA_Font::SetLetterSpacing(FX_FLOAT fLetterSpacing, XFA_UNIT eUnit) { | |
| 351 return FALSE; | |
| 352 } | |
| 353 FX_BOOL CXFA_Font::SetLineThrough(int32_t iLineThrough) { | |
| 354 return m_pNode->SetInteger(XFA_ATTRIBUTE_LineThrough, iLineThrough); | |
| 355 } | |
| 356 FX_BOOL CXFA_Font::SetLineThroughPeriod(int32_t iLineThroughPeriod) { | |
| 357 return m_pNode->SetEnum(XFA_ATTRIBUTE_LineThroughPeriod, | |
| 358 (XFA_ATTRIBUTEENUM)iLineThroughPeriod); | |
| 359 } | |
| 360 FX_BOOL CXFA_Font::SetOverline(int32_t iOverline) { | |
| 361 return m_pNode->SetInteger(XFA_ATTRIBUTE_Overline, iOverline); | |
| 362 } | |
| 363 FX_BOOL CXFA_Font::SetOverlinePeriod(int32_t iOverlinePeriod) { | |
| 364 return m_pNode->SetEnum(XFA_ATTRIBUTE_OverlinePeriod, | |
| 365 (XFA_ATTRIBUTEENUM)iOverlinePeriod); | |
| 366 } | |
| 367 FX_BOOL CXFA_Font::SetUnderline(int32_t iUnderline) { | |
| 368 return m_pNode->SetInteger(XFA_ATTRIBUTE_Underline, iUnderline); | |
| 369 } | |
| 370 FX_BOOL CXFA_Font::SetUnderlinePeriod(int32_t iUnderlinePeriod) { | |
| 371 return m_pNode->SetEnum(XFA_ATTRIBUTE_UnderlinePeriod, | |
| 372 (XFA_ATTRIBUTEENUM)iUnderlinePeriod); | |
| 373 } | |
| 374 CXFA_Caption::CXFA_Caption(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 375 int32_t CXFA_Caption::GetPresence() { | |
| 376 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Visible; | |
| 377 m_pNode->TryEnum(XFA_ATTRIBUTE_Presence, eAttr); | |
| 378 return eAttr; | |
| 379 } | |
| 380 int32_t CXFA_Caption::GetPlacementType() { | |
| 381 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left; | |
| 382 m_pNode->TryEnum(XFA_ATTRIBUTE_Placement, eAttr); | |
| 383 return eAttr; | |
| 384 } | |
| 385 FX_FLOAT CXFA_Caption::GetReserve() { | |
| 386 CXFA_Measurement ms; | |
| 387 m_pNode->TryMeasure(XFA_ATTRIBUTE_Reserve, ms); | |
| 388 return ms.ToUnit(XFA_UNIT_Pt); | |
| 389 } | |
| 390 CXFA_Margin CXFA_Caption::GetMargin() { | |
| 391 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin) : NULL); | |
| 392 } | |
| 393 CXFA_Font CXFA_Caption::GetFont() { | |
| 394 return CXFA_Font(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Font) : NULL); | |
| 395 } | |
| 396 CXFA_Value CXFA_Caption::GetValue() { | |
| 397 return CXFA_Value(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Value) : NULL); | |
| 398 } | |
| 399 CXFA_Para CXFA_Caption::GetPara() { | |
| 400 return CXFA_Para(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Para) : NULL); | |
| 401 } | |
| 402 FX_BOOL CXFA_Caption::SetPresence(int32_t iPresence) { | |
| 403 return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); | |
| 404 } | |
| 405 FX_BOOL CXFA_Caption::SetPlacementType(int32_t iType) { | |
| 406 return m_pNode->SetEnum(XFA_ATTRIBUTE_Placement, (XFA_ATTRIBUTEENUM)iType); | |
| 407 } | |
| 408 FX_BOOL CXFA_Caption::SetReserve(FX_FLOAT fReserve) { | |
| 409 CXFA_Measurement ms(fReserve, XFA_UNIT_Pt); | |
| 410 return m_pNode->SetMeasure(XFA_ATTRIBUTE_Reserve, ms); | |
| 411 } | |
| 412 CXFA_Para::CXFA_Para(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 413 int32_t CXFA_Para::GetHorizontalAlign() { | |
| 414 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left; | |
| 415 m_pNode->TryEnum(XFA_ATTRIBUTE_HAlign, eAttr); | |
| 416 return eAttr; | |
| 417 } | |
| 418 int32_t CXFA_Para::GetVerticalAlign() { | |
| 419 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Top; | |
| 420 m_pNode->TryEnum(XFA_ATTRIBUTE_VAlign, eAttr); | |
| 421 return eAttr; | |
| 422 } | |
| 423 FX_FLOAT CXFA_Para::GetLineHeight() { | |
| 424 CXFA_Measurement ms; | |
| 425 m_pNode->TryMeasure(XFA_ATTRIBUTE_LineHeight, ms); | |
| 426 return ms.ToUnit(XFA_UNIT_Pt); | |
| 427 } | |
| 428 FX_FLOAT CXFA_Para::GetMarginLeft() { | |
| 429 CXFA_Measurement ms; | |
| 430 m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginLeft, ms); | |
| 431 return ms.ToUnit(XFA_UNIT_Pt); | |
| 432 } | |
| 433 FX_FLOAT CXFA_Para::GetMarginRight() { | |
| 434 CXFA_Measurement ms; | |
| 435 m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginRight, ms); | |
| 436 return ms.ToUnit(XFA_UNIT_Pt); | |
| 437 } | |
| 438 int32_t CXFA_Para::GetOrphans() { | |
| 439 int32_t iValue = 0; | |
| 440 m_pNode->TryInteger(XFA_ATTRIBUTE_Orphans, iValue); | |
| 441 return iValue; | |
| 442 } | |
| 443 FX_FLOAT CXFA_Para::GetRadixOffset() { | |
| 444 CXFA_Measurement ms; | |
| 445 m_pNode->TryMeasure(XFA_ATTRIBUTE_RadixOffset, ms); | |
| 446 return ms.ToUnit(XFA_UNIT_Pt); | |
| 447 } | |
| 448 FX_FLOAT CXFA_Para::GetSpaceAbove() { | |
| 449 CXFA_Measurement ms; | |
| 450 m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceAbove, ms); | |
| 451 return ms.ToUnit(XFA_UNIT_Pt); | |
| 452 } | |
| 453 FX_FLOAT CXFA_Para::GetSpaceBelow() { | |
| 454 CXFA_Measurement ms; | |
| 455 m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceBelow, ms); | |
| 456 return ms.ToUnit(XFA_UNIT_Pt); | |
| 457 } | |
| 458 FX_FLOAT CXFA_Para::GetTextIndent() { | |
| 459 CXFA_Measurement ms; | |
| 460 m_pNode->TryMeasure(XFA_ATTRIBUTE_TextIndent, ms); | |
| 461 return ms.ToUnit(XFA_UNIT_Pt); | |
| 462 } | |
| 463 int32_t CXFA_Para::GetWidows() { | |
| 464 int32_t iValue = 0; | |
| 465 m_pNode->TryInteger(XFA_ATTRIBUTE_Widows, iValue); | |
| 466 return iValue; | |
| 467 } | |
| 468 FX_BOOL CXFA_Para::SetHorizontalAlign(int32_t iHorizontalAlign) { | |
| 469 return m_pNode->SetEnum(XFA_ATTRIBUTE_HAlign, | |
| 470 (XFA_ATTRIBUTEENUM)iHorizontalAlign); | |
| 471 } | |
| 472 FX_BOOL CXFA_Para::SetVerticalAlign(int32_t iVerticalAlign) { | |
| 473 return m_pNode->SetEnum(XFA_ATTRIBUTE_VAlign, | |
| 474 (XFA_ATTRIBUTEENUM)iVerticalAlign); | |
| 475 } | |
| 476 FX_BOOL CXFA_Para::SetLineHeight(FX_FLOAT fLineHeight) { | |
| 477 CXFA_Measurement ms; | |
| 478 return m_pNode->SetMeasure(XFA_ATTRIBUTE_LineHeight, ms); | |
| 479 } | |
| 480 FX_BOOL CXFA_Para::SetMarginLeft(FX_FLOAT fMarginLeft) { | |
| 481 CXFA_Measurement ms(fMarginLeft, XFA_UNIT_Pt); | |
| 482 return m_pNode->SetMeasure(XFA_ATTRIBUTE_MarginLeft, ms); | |
| 483 } | |
| 484 FX_BOOL CXFA_Para::SetMarginRight(FX_FLOAT fMarginRight) { | |
| 485 CXFA_Measurement ms(fMarginRight, XFA_UNIT_Pt); | |
| 486 return m_pNode->SetMeasure(XFA_ATTRIBUTE_MarginRight, ms); | |
| 487 } | |
| 488 FX_BOOL CXFA_Para::SetOrphans(int32_t iOrphans) { | |
| 489 return m_pNode->SetInteger(XFA_ATTRIBUTE_Orphans, iOrphans); | |
| 490 } | |
| 491 FX_BOOL CXFA_Para::SetRadixOffset(FX_FLOAT fRadixOffset) { | |
| 492 CXFA_Measurement ms(fRadixOffset, XFA_UNIT_Pt); | |
| 493 return m_pNode->SetMeasure(XFA_ATTRIBUTE_RadixOffset, ms); | |
| 494 } | |
| 495 FX_BOOL CXFA_Para::SetSpaceAbove(FX_FLOAT fSpaceAbove) { | |
| 496 CXFA_Measurement ms(fSpaceAbove, XFA_UNIT_Pt); | |
| 497 return m_pNode->SetMeasure(XFA_ATTRIBUTE_SpaceAbove, ms); | |
| 498 } | |
| 499 FX_BOOL CXFA_Para::SetSpaceBelow(FX_FLOAT fSpaceBelow) { | |
| 500 CXFA_Measurement ms(fSpaceBelow, XFA_UNIT_Pt); | |
| 501 return m_pNode->SetMeasure(XFA_ATTRIBUTE_SpaceBelow, ms); | |
| 502 } | |
| 503 FX_BOOL CXFA_Para::SetTextIndent(FX_FLOAT fTextIndent) { | |
| 504 CXFA_Measurement ms(fTextIndent, XFA_UNIT_Pt); | |
| 505 return m_pNode->SetMeasure(XFA_ATTRIBUTE_TextIndent, ms); | |
| 506 } | |
| 507 FX_BOOL CXFA_Para::SetWidows(int32_t iWidows) { | |
| 508 return m_pNode->SetInteger(XFA_ATTRIBUTE_Widows, iWidows); | |
| 509 } | |
| 510 CXFA_Keep::CXFA_Keep(CXFA_Node* pNode, CXFA_Node* pParent) | |
| 511 : CXFA_Data(pNode), m_pParent(pParent) {} | |
| 512 int32_t CXFA_Keep::GetIntact() { | |
| 513 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; | |
| 514 switch (m_pParent->GetClassID()) { | |
| 515 case XFA_ELEMENT_Subform: { | |
| 516 XFA_ATTRIBUTEENUM eAttrSubForm; | |
| 517 m_pParent->TryEnum(XFA_ATTRIBUTE_Layout, eAttrSubForm); | |
| 518 if (eAttrSubForm == XFA_ATTRIBUTEENUM_Position || | |
| 519 eAttrSubForm == XFA_ATTRIBUTEENUM_Row) { | |
| 520 eAttr = XFA_ATTRIBUTEENUM_ContentArea; | |
| 521 } | |
| 522 } break; | |
| 523 case XFA_ELEMENT_Draw: | |
| 524 eAttr = XFA_ATTRIBUTEENUM_ContentArea; | |
| 525 break; | |
| 526 default: | |
| 527 break; | |
| 528 } | |
| 529 m_pNode->TryEnum(XFA_ATTRIBUTE_Intact, eAttr, FALSE); | |
| 530 return eAttr; | |
| 531 } | |
| 532 int32_t CXFA_Keep::GetNext() { | |
| 533 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; | |
| 534 m_pNode->TryEnum(XFA_ATTRIBUTE_Next, eAttr); | |
| 535 return eAttr; | |
| 536 } | |
| 537 int32_t CXFA_Keep::GetPrevious() { | |
| 538 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; | |
| 539 m_pNode->TryEnum(XFA_ATTRIBUTE_Previous, eAttr); | |
| 540 return eAttr; | |
| 541 } | |
| 542 FX_BOOL CXFA_Keep::SetIntact(int32_t iIntact) { | |
| 543 return m_pNode->SetEnum(XFA_ATTRIBUTE_Intact, (XFA_ATTRIBUTEENUM)iIntact); | |
| 544 } | |
| 545 FX_BOOL CXFA_Keep::SetNext(int32_t iNext) { | |
| 546 return m_pNode->SetEnum(XFA_ATTRIBUTE_Next, (XFA_ATTRIBUTEENUM)iNext); | |
| 547 } | |
| 548 FX_BOOL CXFA_Keep::SetPrevious(int32_t iPrevious) { | |
| 549 return m_pNode->SetEnum(XFA_ATTRIBUTE_Previous, (XFA_ATTRIBUTEENUM)iPrevious); | |
| 550 } | |
| 551 CXFA_Event::CXFA_Event(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 552 int32_t CXFA_Event::GetActivity() { | |
| 553 return m_pNode->GetEnum(XFA_ATTRIBUTE_Activity); | |
| 554 } | |
| 555 int32_t CXFA_Event::GetEventType() { | |
| 556 CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 557 while (pChild) { | |
| 558 int32_t eType = pChild->GetClassID(); | |
| 559 if (eType != XFA_ELEMENT_Extras) { | |
| 560 return eType; | |
| 561 } | |
| 562 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 563 } | |
| 564 return XFA_ELEMENT_UNKNOWN; | |
| 565 } | |
| 566 void CXFA_Event::GetRef(CFX_WideStringC& wsRef) { | |
| 567 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef); | |
| 568 } | |
| 569 int32_t CXFA_Event::GetExecuteRunAt() { | |
| 570 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); | |
| 571 return pNode->GetEnum(XFA_ATTRIBUTE_RunAt); | |
| 572 } | |
| 573 int32_t CXFA_Event::GetExecuteType() { | |
| 574 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); | |
| 575 return pNode->GetEnum(XFA_ATTRIBUTE_ExecuteType); | |
| 576 } | |
| 577 void CXFA_Event::GetExecuteConnection(CFX_WideString& wsConnection) { | |
| 578 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); | |
| 579 CFX_WideStringC cData; | |
| 580 pNode->TryCData(XFA_ATTRIBUTE_Connection, cData); | |
| 581 wsConnection = cData; | |
| 582 } | |
| 583 CXFA_Script CXFA_Event::GetScript() { | |
| 584 return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script)); | |
| 585 } | |
| 586 CXFA_Submit CXFA_Event::GetSubmit() { | |
| 587 return CXFA_Submit(m_pNode->GetChild(0, XFA_ELEMENT_Submit)); | |
| 588 } | |
| 589 int32_t CXFA_Event::GetSignDataOperation() { | |
| 590 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData); | |
| 591 return pNode->GetEnum(XFA_ATTRIBUTE_Operation); | |
| 592 } | |
| 593 void CXFA_Event::GetSignDataTarget(CFX_WideString& wsTarget) { | |
| 594 if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData)) { | |
| 595 CFX_WideStringC wsCData; | |
| 596 pNode->TryCData(XFA_ATTRIBUTE_Target, wsCData); | |
| 597 wsTarget = wsCData; | |
| 598 } | |
| 599 } | |
| 600 FX_BOOL CXFA_Event::SetActivity(int32_t iActivity) { | |
| 601 return m_pNode->SetEnum(XFA_ATTRIBUTE_Activity, (XFA_ATTRIBUTEENUM)iActivity); | |
| 602 } | |
| 603 FX_BOOL CXFA_Event::SetEventType(int32_t iEventType) { | |
| 604 return FALSE; | |
| 605 } | |
| 606 FX_BOOL CXFA_Event::SetExecuteRunAt(int32_t iExecuteRunAt) { | |
| 607 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); | |
| 608 return pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iExecuteRunAt); | |
| 609 } | |
| 610 FX_BOOL CXFA_Event::SetExecuteType(int32_t iExecuteType) { | |
| 611 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); | |
| 612 return pNode->SetEnum(XFA_ATTRIBUTE_ExecuteType, | |
| 613 (XFA_ATTRIBUTEENUM)iExecuteType); | |
| 614 } | |
| 615 FX_BOOL CXFA_Event::SetExecuteConnection(const CFX_WideString& wsConnection) { | |
| 616 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); | |
| 617 return pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection); | |
| 618 } | |
| 619 FX_BOOL CXFA_Event::SetSignDataOperation(int32_t iOperation) { | |
| 620 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData); | |
| 621 return pNode->SetEnum(XFA_ATTRIBUTE_Operation, (XFA_ATTRIBUTEENUM)iOperation); | |
| 622 } | |
| 623 FX_BOOL CXFA_Event::SetSignDataTarget(const CFX_WideString& wsTarget) { | |
| 624 if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData)) { | |
| 625 return pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget); | |
| 626 } | |
| 627 return FALSE; | |
| 628 } | |
| 629 CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 630 void CXFA_Script::GetBinding(CFX_WideString& wsBinding) { | |
| 631 CFX_WideStringC cData; | |
| 632 m_pNode->TryCData(XFA_ATTRIBUTE_Binding, cData); | |
| 633 wsBinding = cData; | |
| 634 } | |
| 635 XFA_SCRIPTTYPE CXFA_Script::GetContentType() { | |
| 636 CFX_WideStringC cData; | |
| 637 if (m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, cData, FALSE)) { | |
| 638 if (cData == FX_WSTRC(L"application/x-javascript")) { | |
| 639 return XFA_SCRIPTTYPE_Javascript; | |
| 640 } else if (cData == FX_WSTRC(L"application/x-formcalc")) { | |
| 641 return XFA_SCRIPTTYPE_Formcalc; | |
| 642 } else { | |
| 643 return XFA_SCRIPTTYPE_Unkown; | |
| 644 } | |
| 645 } | |
| 646 return XFA_SCRIPTTYPE_Formcalc; | |
| 647 } | |
| 648 int32_t CXFA_Script::GetRunAt() { | |
| 649 return m_pNode->GetEnum(XFA_ATTRIBUTE_RunAt); | |
| 650 } | |
| 651 void CXFA_Script::GetExpression(CFX_WideString& wsExpression) { | |
| 652 m_pNode->TryContent(wsExpression); | |
| 653 } | |
| 654 FX_BOOL CXFA_Script::SetBinding(const CFX_WideString& wsBinding) { | |
| 655 return m_pNode->SetCData(XFA_ATTRIBUTE_Binding, wsBinding); | |
| 656 } | |
| 657 FX_BOOL CXFA_Script::SetContentType(XFA_SCRIPTTYPE eType) { | |
| 658 CFX_WideString wsType; | |
| 659 switch (eType) { | |
| 660 case XFA_SCRIPTTYPE_Javascript: | |
| 661 wsType = L"application/x-javascript"; | |
| 662 break; | |
| 663 case XFA_SCRIPTTYPE_Formcalc: | |
| 664 wsType = L"application/x-formcalc"; | |
| 665 break; | |
| 666 default: | |
| 667 break; | |
| 668 } | |
| 669 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsType); | |
| 670 } | |
| 671 FX_BOOL CXFA_Script::SetRunAt(int32_t iRunAt) { | |
| 672 return m_pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iRunAt); | |
| 673 } | |
| 674 FX_BOOL CXFA_Script::SetExpression(const CFX_WideString& wsExpression) { | |
| 675 return m_pNode->SetContent(wsExpression, wsExpression); | |
| 676 } | |
| 677 CXFA_Submit::CXFA_Submit(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 678 FX_BOOL CXFA_Submit::IsSubmitEmbedPDF() { | |
| 679 return m_pNode->GetBoolean(XFA_ATTRIBUTE_EmbedPDF); | |
| 680 } | |
| 681 int32_t CXFA_Submit::GetSubmitFormat() { | |
| 682 return m_pNode->GetEnum(XFA_ATTRIBUTE_Format); | |
| 683 } | |
| 684 void CXFA_Submit::GetSubmitTarget(CFX_WideStringC& wsTarget) { | |
| 685 m_pNode->TryCData(XFA_ATTRIBUTE_Target, wsTarget); | |
| 686 } | |
| 687 XFA_TEXTENCODING CXFA_Submit::GetSubmitTextEncoding() { | |
| 688 CFX_WideStringC wsCData; | |
| 689 if (!m_pNode->TryCData(XFA_ATTRIBUTE_TextEncoding, wsCData)) { | |
| 690 return XFA_TEXTENCODING_None; | |
| 691 } | |
| 692 CFX_WideString wsValue(wsCData); | |
| 693 if (wsValue == L"Big-Five") { | |
| 694 return XFA_TEXTENCODING_Big5; | |
| 695 } else if (wsValue == L"fontSpecific") { | |
| 696 return XFA_TEXTENCODING_FontSpecific; | |
| 697 } else if (wsValue == L"GBK") { | |
| 698 return XFA_TEXTENCODING_GBK; | |
| 699 } else if (wsValue == L"GB-18030") { | |
| 700 return XFA_TEXTENCODING_GB18030; | |
| 701 } else if (wsValue == L"GB-2312") { | |
| 702 return XFA_TEXTENCODING_GB2312; | |
| 703 } else if (wsValue == L"ISO-8859-NN") { | |
| 704 return XFA_TEXTENCODING_ISO8859NN; | |
| 705 } else if (wsValue == L"KSC-5601") { | |
| 706 return XFA_TEXTENCODING_KSC5601; | |
| 707 } else if (wsValue == L"Shift-JIS") { | |
| 708 return XFA_TEXTENCODING_ShiftJIS; | |
| 709 } else if (wsValue == L"UCS-2") { | |
| 710 return XFA_TEXTENCODING_UCS2; | |
| 711 } else if (wsValue == L"UTF-16") { | |
| 712 return XFA_TEXTENCODING_UTF16; | |
| 713 } else if (wsValue == L"UTF-8") { | |
| 714 return XFA_TEXTENCODING_UTF8; | |
| 715 } | |
| 716 return XFA_TEXTENCODING_None; | |
| 717 } | |
| 718 void CXFA_Submit::GetSubmitXDPContent(CFX_WideStringC& wsContent) { | |
| 719 m_pNode->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent); | |
| 720 } | |
| 721 FX_BOOL CXFA_Submit::SetSubmitFormat(int32_t iSubmitFormat) { | |
| 722 return m_pNode->SetEnum(XFA_ATTRIBUTE_Format, | |
| 723 (XFA_ATTRIBUTEENUM)iSubmitFormat); | |
| 724 } | |
| 725 FX_BOOL CXFA_Submit::SetSubmitTarget(const CFX_WideString& wsTarget) { | |
| 726 return m_pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget); | |
| 727 } | |
| 728 FX_BOOL CXFA_Submit::SetSubmitTextEncoding(XFA_TEXTENCODING eTextEncoding) { | |
| 729 CFX_WideString wsValue; | |
| 730 switch (eTextEncoding) { | |
| 731 case XFA_TEXTENCODING_Big5: | |
| 732 wsValue = L"Big-Five"; | |
| 733 break; | |
| 734 case XFA_TEXTENCODING_FontSpecific: | |
| 735 wsValue = L"fontSpecific"; | |
| 736 break; | |
| 737 case XFA_TEXTENCODING_GBK: | |
| 738 wsValue = L"GBK"; | |
| 739 break; | |
| 740 case XFA_TEXTENCODING_GB18030: | |
| 741 wsValue = L"GB-18030"; | |
| 742 break; | |
| 743 case XFA_TEXTENCODING_GB2312: | |
| 744 wsValue = L"GB-2312"; | |
| 745 break; | |
| 746 case XFA_TEXTENCODING_ISO8859NN: | |
| 747 wsValue = L"ISO-8859-NN"; | |
| 748 break; | |
| 749 case XFA_TEXTENCODING_KSC5601: | |
| 750 wsValue = L"KSC-5601"; | |
| 751 break; | |
| 752 case XFA_TEXTENCODING_ShiftJIS: | |
| 753 wsValue = L"Shift-JIS"; | |
| 754 break; | |
| 755 case XFA_TEXTENCODING_UCS2: | |
| 756 wsValue = L"UCS-2"; | |
| 757 break; | |
| 758 case XFA_TEXTENCODING_UTF16: | |
| 759 wsValue = L"UTF-16"; | |
| 760 break; | |
| 761 case XFA_TEXTENCODING_UTF8: | |
| 762 wsValue = L"UTF-8"; | |
| 763 break; | |
| 764 default: | |
| 765 break; | |
| 766 } | |
| 767 return m_pNode->SetCData(XFA_ATTRIBUTE_TextEncoding, wsValue); | |
| 768 } | |
| 769 FX_BOOL CXFA_Submit::SetSubmitXDPContent(const CFX_WideString& wsContent) { | |
| 770 return m_pNode->SetCData(XFA_ATTRIBUTE_XdpContent, wsContent); | |
| 771 } | |
| 772 XFA_ELEMENT CXFA_Value::GetChildValueClassID() { | |
| 773 if (!m_pNode) { | |
| 774 return XFA_ELEMENT_UNKNOWN; | |
| 775 } | |
| 776 if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { | |
| 777 return pNode->GetClassID(); | |
| 778 } | |
| 779 return XFA_ELEMENT_UNKNOWN; | |
| 780 } | |
| 781 FX_BOOL CXFA_Value::GetChildValueContent(CFX_WideString& wsContent) { | |
| 782 if (!m_pNode) { | |
| 783 return FALSE; | |
| 784 } | |
| 785 if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { | |
| 786 return pNode->TryContent(wsContent); | |
| 787 } | |
| 788 return FALSE; | |
| 789 } | |
| 790 CXFA_Arc CXFA_Value::GetArc() { | |
| 791 return CXFA_Arc(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) | |
| 792 : nullptr); | |
| 793 } | |
| 794 CXFA_Line CXFA_Value::GetLine() { | |
| 795 return CXFA_Line(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) | |
| 796 : nullptr); | |
| 797 } | |
| 798 CXFA_Rectangle CXFA_Value::GetRectangle() { | |
| 799 return CXFA_Rectangle(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) | |
| 800 : nullptr); | |
| 801 } | |
| 802 CXFA_Text CXFA_Value::GetText() { | |
| 803 return CXFA_Text(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) | |
| 804 : nullptr); | |
| 805 } | |
| 806 CXFA_ExData CXFA_Value::GetExData() { | |
| 807 return CXFA_ExData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) | |
| 808 : nullptr); | |
| 809 } | |
| 810 CXFA_Image CXFA_Value::GetImage() { | |
| 811 return CXFA_Image( | |
| 812 m_pNode ? (m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) : nullptr, | |
| 813 TRUE); | |
| 814 } | |
| 815 FX_BOOL CXFA_Value::SetChildValueContent(const CFX_WideString& wsContent, | |
| 816 FX_BOOL bNotify, | |
| 817 XFA_ELEMENT iType) { | |
| 818 if (!m_pNode) { | |
| 819 return FALSE; | |
| 820 } | |
| 821 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 822 if (!pNode) { | |
| 823 if (iType == XFA_ELEMENT_UNKNOWN) { | |
| 824 return FALSE; | |
| 825 } | |
| 826 pNode = m_pNode->GetProperty(0, iType); | |
| 827 } | |
| 828 CFX_WideString wsFormatContent(wsContent); | |
| 829 CXFA_WidgetData* pContainerWidgetData = pNode->GetContainerWidgetData(); | |
| 830 if (pContainerWidgetData) { | |
| 831 pContainerWidgetData->GetFormatDataValue(wsContent, wsFormatContent); | |
| 832 } | |
| 833 return pNode->SetContent(wsContent, wsFormatContent, bNotify); | |
| 834 } | |
| 835 int32_t CXFA_Line::GetHand() { | |
| 836 return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand); | |
| 837 } | |
| 838 FX_BOOL CXFA_Line::GetSlop() { | |
| 839 XFA_ATTRIBUTEENUM eSlop = m_pNode->GetEnum(XFA_ATTRIBUTE_Slope); | |
| 840 return eSlop == XFA_ATTRIBUTEENUM_Slash; | |
| 841 } | |
| 842 CXFA_Edge CXFA_Line::GetEdge() { | |
| 843 return CXFA_Edge(m_pNode->GetChild(0, XFA_ELEMENT_Edge)); | |
| 844 } | |
| 845 FX_BOOL CXFA_Line::SetHand(int32_t iHand) { | |
| 846 return m_pNode->SetEnum(XFA_ATTRIBUTE_Hand, (XFA_ATTRIBUTEENUM)iHand); | |
| 847 } | |
| 848 FX_BOOL CXFA_Line::SetSlop(int32_t iSlop) { | |
| 849 return m_pNode->SetEnum(XFA_ATTRIBUTE_Slope, (XFA_ATTRIBUTEENUM)iSlop); | |
| 850 } | |
| 851 CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 852 void CXFA_Text::GetName(CFX_WideStringC& wsName) { | |
| 853 m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); | |
| 854 } | |
| 855 int32_t CXFA_Text::GetMaxChars() { | |
| 856 return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxChars); | |
| 857 } | |
| 858 void CXFA_Text::GetRid(CFX_WideStringC& wsRid) { | |
| 859 m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid); | |
| 860 } | |
| 861 void CXFA_Text::GetContent(CFX_WideString& wsText) { | |
| 862 m_pNode->TryContent(wsText); | |
| 863 } | |
| 864 void CXFA_Text::SetContent(CFX_WideString wsText, FX_BOOL bNotify) { | |
| 865 CFX_WideString wsFormatValue(wsText); | |
| 866 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); | |
| 867 if (pContainerWidgetData) { | |
| 868 pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); | |
| 869 } | |
| 870 m_pNode->SetContent(wsText, wsFormatValue, bNotify); | |
| 871 } | |
| 872 FX_BOOL CXFA_Text::SetName(const CFX_WideString& wsName) { | |
| 873 return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); | |
| 874 } | |
| 875 FX_BOOL CXFA_Text::SetMaxChars(int32_t iMaxChars) { | |
| 876 return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxChars, iMaxChars); | |
| 877 } | |
| 878 FX_BOOL CXFA_Text::SetRid(const CFX_WideString& wsRid) { | |
| 879 return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid); | |
| 880 } | |
| 881 CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 882 void CXFA_ExData::GetContentType(CFX_WideStringC& wsContentType) { | |
| 883 m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType); | |
| 884 } | |
| 885 void CXFA_ExData::GetHref(CFX_WideStringC& wsHref) { | |
| 886 m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref); | |
| 887 } | |
| 888 int32_t CXFA_ExData::GetMaxLength() { | |
| 889 return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxLength); | |
| 890 } | |
| 891 void CXFA_ExData::GetRid(CFX_WideStringC& wsRid) { | |
| 892 m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid); | |
| 893 } | |
| 894 int32_t CXFA_ExData::GetTransferEncoding() { | |
| 895 return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding); | |
| 896 } | |
| 897 void CXFA_ExData::GetContent(CFX_WideString& wsText) { | |
| 898 m_pNode->TryContent(wsText); | |
| 899 } | |
| 900 FX_BOOL CXFA_ExData::SetContentType(const CFX_WideString& wsContentType) { | |
| 901 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); | |
| 902 } | |
| 903 FX_BOOL CXFA_ExData::SetHref(const CFX_WideString& wsHref) { | |
| 904 return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref); | |
| 905 } | |
| 906 FX_BOOL CXFA_ExData::SetMaxLength(int32_t iMaxLength) { | |
| 907 return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxLength, iMaxLength); | |
| 908 } | |
| 909 FX_BOOL CXFA_ExData::SetRid(const CFX_WideString& wsRid) { | |
| 910 return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid); | |
| 911 } | |
| 912 FX_BOOL CXFA_ExData::SetTransferEncoding(int32_t iTransferEncoding) { | |
| 913 return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding, | |
| 914 (XFA_ATTRIBUTEENUM)iTransferEncoding); | |
| 915 } | |
| 916 FX_BOOL CXFA_ExData::SetContent(const CFX_WideString& wsText, | |
| 917 FX_BOOL bNotify, | |
| 918 FX_BOOL bScriptModify, | |
| 919 FX_BOOL bSyncData) { | |
| 920 CFX_WideString wsFormatValue(wsText); | |
| 921 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); | |
| 922 if (pContainerWidgetData) { | |
| 923 pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); | |
| 924 } | |
| 925 return m_pNode->SetContent(wsText, wsFormatValue, bNotify, bScriptModify, | |
| 926 bSyncData); | |
| 927 } | |
| 928 CXFA_Image::CXFA_Image(CXFA_Node* pNode, FX_BOOL bDefValue) | |
| 929 : CXFA_Data(pNode), m_bDefValue(bDefValue) {} | |
| 930 int32_t CXFA_Image::GetAspect() { | |
| 931 return m_pNode->GetEnum(XFA_ATTRIBUTE_Aspect); | |
| 932 } | |
| 933 FX_BOOL CXFA_Image::GetContentType(CFX_WideString& wsContentType) { | |
| 934 return m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType); | |
| 935 } | |
| 936 FX_BOOL CXFA_Image::GetHref(CFX_WideString& wsHref) { | |
| 937 if (m_bDefValue) { | |
| 938 return m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref); | |
| 939 } | |
| 940 return m_pNode->GetAttribute(FX_WSTRC(L"href"), wsHref); | |
| 941 } | |
| 942 int32_t CXFA_Image::GetTransferEncoding() { | |
| 943 if (m_bDefValue) { | |
| 944 return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding); | |
| 945 } | |
| 946 return XFA_ATTRIBUTEENUM_Base64; | |
| 947 } | |
| 948 FX_BOOL CXFA_Image::GetContent(CFX_WideString& wsText) { | |
| 949 return m_pNode->TryContent(wsText); | |
| 950 } | |
| 951 FX_BOOL CXFA_Image::SetAspect(int32_t iAspect) { | |
| 952 return m_pNode->SetEnum(XFA_ATTRIBUTE_Aspect, (XFA_ATTRIBUTEENUM)iAspect); | |
| 953 } | |
| 954 FX_BOOL CXFA_Image::SetContentType(const CFX_WideString& wsContentType) { | |
| 955 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); | |
| 956 } | |
| 957 FX_BOOL CXFA_Image::SetHref(const CFX_WideString& wsHref) { | |
| 958 if (m_bDefValue) { | |
| 959 return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref); | |
| 960 } | |
| 961 return m_pNode->SetAttribute(XFA_ATTRIBUTE_Href, wsHref); | |
| 962 } | |
| 963 FX_BOOL CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) { | |
| 964 if (m_bDefValue) { | |
| 965 return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding, | |
| 966 (XFA_ATTRIBUTEENUM)iTransferEncoding); | |
| 967 } | |
| 968 return TRUE; | |
| 969 } | |
| 970 FX_BOOL CXFA_Image::SetContent(const CFX_WideString& wsText) { | |
| 971 CFX_WideString wsFormatValue(wsText); | |
| 972 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); | |
| 973 if (pContainerWidgetData) { | |
| 974 pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); | |
| 975 } | |
| 976 return m_pNode->SetContent(wsText, wsFormatValue); | |
| 977 } | |
| 978 CXFA_Calculate::CXFA_Calculate(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 979 int32_t CXFA_Calculate::GetOverride() { | |
| 980 XFA_ATTRIBUTEENUM eAtt = XFA_ATTRIBUTEENUM_Error; | |
| 981 m_pNode->TryEnum(XFA_ATTRIBUTE_Override, eAtt, FALSE); | |
| 982 return eAtt; | |
| 983 } | |
| 984 CXFA_Script CXFA_Calculate::GetScript() { | |
| 985 return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script)); | |
| 986 } | |
| 987 void CXFA_Calculate::GetMessageText(CFX_WideString& wsMessage) { | |
| 988 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Message)) { | |
| 989 CXFA_Text text(pNode->GetChild(0, XFA_ELEMENT_Text)); | |
| 990 if (text) { | |
| 991 text.GetContent(wsMessage); | |
| 992 } | |
| 993 } | |
| 994 } | |
| 995 FX_BOOL CXFA_Calculate::SetOverride(int32_t iOverride) { | |
| 996 return m_pNode->SetEnum(XFA_ATTRIBUTE_Override, (XFA_ATTRIBUTEENUM)iOverride); | |
| 997 } | |
| 998 FX_BOOL CXFA_Calculate::SetMessageText(const CFX_WideString& wsMessage) { | |
| 999 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Message)) { | |
| 1000 CXFA_Node* pChildNode = pNode->GetProperty(0, XFA_ELEMENT_Text); | |
| 1001 return pChildNode->SetContent(wsMessage, wsMessage); | |
| 1002 } | |
| 1003 return FALSE; | |
| 1004 } | |
| 1005 CXFA_Validate::CXFA_Validate(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 1006 int32_t CXFA_Validate::GetFormatTest() { | |
| 1007 return m_pNode->GetEnum(XFA_ATTRIBUTE_FormatTest); | |
| 1008 } | |
| 1009 FX_BOOL CXFA_Validate::SetTestValue(int32_t iType, | |
| 1010 CFX_WideString& wsValue, | |
| 1011 XFA_ATTRIBUTEENUM eName) { | |
| 1012 const XFA_ATTRIBUTEENUMINFO* pInfo = XFA_GetAttributeEnumByName(wsValue); | |
| 1013 if (pInfo) { | |
| 1014 eName = pInfo->eName; | |
| 1015 } | |
| 1016 m_pNode->SetEnum((XFA_ATTRIBUTE)iType, eName, FALSE); | |
| 1017 return TRUE; | |
| 1018 } | |
| 1019 FX_BOOL CXFA_Validate::SetFormatTest(CFX_WideString wsValue) { | |
| 1020 return SetTestValue(XFA_ATTRIBUTE_FormatTest, wsValue, | |
| 1021 XFA_ATTRIBUTEENUM_Warning); | |
| 1022 } | |
| 1023 FX_BOOL CXFA_Validate::SetNullTest(CFX_WideString wsValue) { | |
| 1024 return SetTestValue(XFA_ATTRIBUTE_NullTest, wsValue, | |
| 1025 XFA_ATTRIBUTEENUM_Disabled); | |
| 1026 } | |
| 1027 int32_t CXFA_Validate::GetNullTest() { | |
| 1028 return m_pNode->GetEnum(XFA_ATTRIBUTE_NullTest); | |
| 1029 } | |
| 1030 int32_t CXFA_Validate::GetScriptTest() { | |
| 1031 return m_pNode->GetEnum(XFA_ATTRIBUTE_ScriptTest); | |
| 1032 } | |
| 1033 void CXFA_Validate::GetMessageText(CFX_WideString& wsMessage, | |
| 1034 const CFX_WideStringC& wsMessageType) { | |
| 1035 if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, FALSE)) { | |
| 1036 CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1037 for (; pItemNode; | |
| 1038 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 1039 if (pItemNode->GetClassID() != XFA_ELEMENT_Text) { | |
| 1040 continue; | |
| 1041 } | |
| 1042 CFX_WideStringC wsName; | |
| 1043 pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName); | |
| 1044 if (wsName.IsEmpty() || wsName == wsMessageType) { | |
| 1045 pItemNode->TryContent(wsMessage); | |
| 1046 return; | |
| 1047 } | |
| 1048 } | |
| 1049 } | |
| 1050 } | |
| 1051 void CXFA_Validate::SetFormatMessageText(CFX_WideString wsMessage) { | |
| 1052 SetMessageText(wsMessage, FX_WSTRC(L"formatTest")); | |
| 1053 } | |
| 1054 void CXFA_Validate::GetFormatMessageText(CFX_WideString& wsMessage) { | |
| 1055 GetMessageText(wsMessage, FX_WSTRC(L"formatTest")); | |
| 1056 } | |
| 1057 void CXFA_Validate::SetNullMessageText(CFX_WideString wsMessage) { | |
| 1058 SetMessageText(wsMessage, FX_WSTRC(L"nullTest")); | |
| 1059 } | |
| 1060 void CXFA_Validate::GetNullMessageText(CFX_WideString& wsMessage) { | |
| 1061 GetMessageText(wsMessage, FX_WSTRC(L"nullTest")); | |
| 1062 } | |
| 1063 void CXFA_Validate::SetMessageText(CFX_WideString& wsMessage, | |
| 1064 const CFX_WideStringC& wsMessageType) { | |
| 1065 if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, TRUE)) { | |
| 1066 CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1067 for (; pItemNode; | |
| 1068 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 1069 if (pItemNode->GetClassID() != XFA_ELEMENT_Text) { | |
| 1070 continue; | |
| 1071 } | |
| 1072 CFX_WideStringC wsName; | |
| 1073 pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName); | |
| 1074 if (wsName.IsEmpty() || wsName == wsMessageType) { | |
| 1075 pItemNode->SetContent(wsMessage, wsMessage, FALSE); | |
| 1076 return; | |
| 1077 } | |
| 1078 } | |
| 1079 CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_ELEMENT_Text); | |
| 1080 pNode->InsertChild(pTextNode); | |
| 1081 pTextNode->SetCData(XFA_ATTRIBUTE_Name, wsMessageType, FALSE); | |
| 1082 pTextNode->SetContent(wsMessage, wsMessage, FALSE); | |
| 1083 } | |
| 1084 } | |
| 1085 void CXFA_Validate::GetScriptMessageText(CFX_WideString& wsMessage) { | |
| 1086 GetMessageText(wsMessage, FX_WSTRC(L"scriptTest")); | |
| 1087 } | |
| 1088 void CXFA_Validate::SetScriptMessageText(CFX_WideString wsMessage) { | |
| 1089 SetMessageText(wsMessage, FX_WSTRC(L"scriptTest")); | |
| 1090 } | |
| 1091 void CXFA_Validate::GetPicture(CFX_WideString& wsPicture) { | |
| 1092 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) { | |
| 1093 pNode->TryContent(wsPicture); | |
| 1094 } | |
| 1095 } | |
| 1096 CXFA_Script CXFA_Validate::GetScript() { | |
| 1097 return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script)); | |
| 1098 } | |
| 1099 CXFA_Variables::CXFA_Variables(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 1100 int32_t CXFA_Variables::CountScripts() { | |
| 1101 return m_pNode->CountChildren(XFA_ELEMENT_Script); | |
| 1102 } | |
| 1103 CXFA_Script CXFA_Variables::GetScript(int32_t nIndex) { | |
| 1104 return CXFA_Script(m_pNode->GetChild(nIndex, XFA_ELEMENT_Script)); | |
| 1105 } | |
| 1106 CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 1107 int32_t CXFA_Bind::GetMatch() { | |
| 1108 return m_pNode->GetEnum(XFA_ATTRIBUTE_Match); | |
| 1109 } | |
| 1110 void CXFA_Bind::GetRef(CFX_WideStringC& wsRef) { | |
| 1111 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef); | |
| 1112 } | |
| 1113 void CXFA_Bind::GetPicture(CFX_WideString& wsPicture) { | |
| 1114 if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) { | |
| 1115 pPicture->TryContent(wsPicture); | |
| 1116 } | |
| 1117 } | |
| 1118 FX_BOOL CXFA_Bind::SetMatch(int32_t iMatch) { | |
| 1119 return m_pNode->SetEnum(XFA_ATTRIBUTE_Match, (XFA_ATTRIBUTEENUM)iMatch); | |
| 1120 } | |
| 1121 FX_BOOL CXFA_Bind::SetRef(const CFX_WideString& wsRef) { | |
| 1122 return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef); | |
| 1123 } | |
| 1124 FX_BOOL CXFA_Bind::SetPicture(const CFX_WideString& wsPicture) { | |
| 1125 if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) { | |
| 1126 return pPicture->SetContent(wsPicture, wsPicture); | |
| 1127 } | |
| 1128 return FALSE; | |
| 1129 } | |
| 1130 CXFA_Assist::CXFA_Assist(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 1131 CXFA_ToolTip CXFA_Assist::GetToolTip() { | |
| 1132 return CXFA_ToolTip(m_pNode->GetChild(0, XFA_ELEMENT_ToolTip)); | |
| 1133 } | |
| 1134 CXFA_ToolTip::CXFA_ToolTip(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 1135 FX_BOOL CXFA_ToolTip::GetTip(CFX_WideString& wsTip) { | |
| 1136 return m_pNode->TryContent(wsTip); | |
| 1137 } | |
| 1138 FX_BOOL CXFA_ToolTip::SetTip(const CFX_WideString& wsTip) { | |
| 1139 return m_pNode->SetContent(wsTip, wsTip); | |
| 1140 } | |
| 1141 CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 1142 void CXFA_BindItems::GetConnection(CFX_WideStringC& wsConnection) { | |
| 1143 m_pNode->TryCData(XFA_ATTRIBUTE_Connection, wsConnection); | |
| 1144 } | |
| 1145 void CXFA_BindItems::GetLabelRef(CFX_WideStringC& wsLabelRef) { | |
| 1146 m_pNode->TryCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef); | |
| 1147 } | |
| 1148 void CXFA_BindItems::GetValueRef(CFX_WideStringC& wsValueRef) { | |
| 1149 m_pNode->TryCData(XFA_ATTRIBUTE_ValueRef, wsValueRef); | |
| 1150 } | |
| 1151 void CXFA_BindItems::GetRef(CFX_WideStringC& wsRef) { | |
| 1152 m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef); | |
| 1153 } | |
| 1154 FX_BOOL CXFA_BindItems::SetConnection(const CFX_WideString& wsConnection) { | |
| 1155 return m_pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection); | |
| 1156 } | |
| 1157 FX_BOOL CXFA_BindItems::SetLabelRef(const CFX_WideString& wsLabelRef) { | |
| 1158 return m_pNode->SetCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef); | |
| 1159 } | |
| 1160 FX_BOOL CXFA_BindItems::SetValueRef(const CFX_WideString& wsValueRef) { | |
| 1161 return m_pNode->SetCData(XFA_ATTRIBUTE_ValueRef, wsValueRef); | |
| 1162 } | |
| 1163 FX_BOOL CXFA_BindItems::SetRef(const CFX_WideString& wsRef) { | |
| 1164 return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef); | |
| 1165 } | |
| 1166 int32_t CXFA_Box::GetBreak() const { | |
| 1167 if (!m_pNode) { | |
| 1168 return XFA_ATTRIBUTEENUM_Close; | |
| 1169 } | |
| 1170 return m_pNode->GetEnum(XFA_ATTRIBUTE_Break); | |
| 1171 } | |
| 1172 int32_t CXFA_Box::GetHand() const { | |
| 1173 if (!m_pNode) { | |
| 1174 return XFA_ATTRIBUTEENUM_Even; | |
| 1175 } | |
| 1176 return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand); | |
| 1177 } | |
| 1178 int32_t CXFA_Box::GetPresence() const { | |
| 1179 if (!m_pNode) { | |
| 1180 return XFA_ATTRIBUTEENUM_Hidden; | |
| 1181 } | |
| 1182 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); | |
| 1183 } | |
| 1184 int32_t CXFA_Box::CountCorners() const { | |
| 1185 if (!m_pNode) { | |
| 1186 return 0; | |
| 1187 } | |
| 1188 return m_pNode->CountChildren(XFA_ELEMENT_Corner); | |
| 1189 } | |
| 1190 CXFA_Corner CXFA_Box::GetCorner(int32_t nIndex) const { | |
| 1191 return CXFA_Corner( | |
| 1192 m_pNode ? m_pNode->GetProperty(nIndex, XFA_ELEMENT_Corner, nIndex == 0) | |
| 1193 : nullptr); | |
| 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 return CXFA_Edge( | |
| 1203 m_pNode ? m_pNode->GetProperty(nIndex, XFA_ELEMENT_Edge, nIndex == 0) | |
| 1204 : nullptr); | |
| 1205 } | |
| 1206 static void XFA_BOX_GetStrokes(CXFA_Node* pNode, | |
| 1207 CXFA_StrokeArray& strokes, | |
| 1208 FX_BOOL bNULL) { | |
| 1209 strokes.RemoveAll(); | |
| 1210 if (!pNode) { | |
| 1211 return; | |
| 1212 } | |
| 1213 strokes.SetSize(8); | |
| 1214 int32_t i, j; | |
| 1215 for (i = 0, j = 0; i < 4; i++) { | |
| 1216 CXFA_Corner corner = | |
| 1217 CXFA_Corner(pNode->GetProperty(i, XFA_ELEMENT_Corner, i == 0)); | |
| 1218 if (corner || i == 0) { | |
| 1219 strokes.SetAt(j, corner); | |
| 1220 } else if (bNULL) { | |
| 1221 strokes.SetAt(j, CXFA_Stroke(nullptr)); | |
| 1222 } else if (i == 1) { | |
| 1223 strokes.SetAt(j, strokes[0]); | |
| 1224 } else if (i == 2) { | |
| 1225 strokes.SetAt(j, strokes[0]); | |
| 1226 } else { | |
| 1227 strokes.SetAt(j, strokes[2]); | |
| 1228 } | |
| 1229 j++; | |
| 1230 CXFA_Edge edge = CXFA_Edge(pNode->GetProperty(i, XFA_ELEMENT_Edge, i == 0)); | |
| 1231 if (edge || i == 0) { | |
| 1232 strokes.SetAt(j, edge); | |
| 1233 } else if (bNULL) { | |
| 1234 strokes.SetAt(j, CXFA_Stroke(nullptr)); | |
| 1235 } else if (i == 1) { | |
| 1236 strokes.SetAt(j, strokes[1]); | |
| 1237 } else if (i == 2) { | |
| 1238 strokes.SetAt(j, strokes[1]); | |
| 1239 } else { | |
| 1240 strokes.SetAt(j, strokes[3]); | |
| 1241 } | |
| 1242 j++; | |
| 1243 } | |
| 1244 } | |
| 1245 void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const { | |
| 1246 XFA_BOX_GetStrokes(m_pNode, strokes, FALSE); | |
| 1247 } | |
| 1248 FX_BOOL CXFA_Box::IsCircular() const { | |
| 1249 if (!m_pNode) { | |
| 1250 return FALSE; | |
| 1251 } | |
| 1252 return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular); | |
| 1253 } | |
| 1254 FX_BOOL CXFA_Box::GetStartAngle(FX_FLOAT& fStartAngle) const { | |
| 1255 fStartAngle = 0; | |
| 1256 if (!m_pNode) { | |
| 1257 return FALSE; | |
| 1258 } | |
| 1259 CXFA_Measurement ms; | |
| 1260 FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, FALSE); | |
| 1261 if (bRet) { | |
| 1262 fStartAngle = ms.GetValue(); | |
| 1263 } | |
| 1264 return bRet; | |
| 1265 } | |
| 1266 FX_BOOL CXFA_Box::GetSweepAngle(FX_FLOAT& fSweepAngle) const { | |
| 1267 fSweepAngle = 360; | |
| 1268 if (!m_pNode) { | |
| 1269 return FALSE; | |
| 1270 } | |
| 1271 CXFA_Measurement ms; | |
| 1272 FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, FALSE); | |
| 1273 if (bRet) { | |
| 1274 fSweepAngle = ms.GetValue(); | |
| 1275 } | |
| 1276 return bRet; | |
| 1277 } | |
| 1278 CXFA_Fill CXFA_Box::GetFill(FX_BOOL bModified) const { | |
| 1279 if (!m_pNode) { | |
| 1280 return CXFA_Fill(nullptr); | |
| 1281 } | |
| 1282 CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_ELEMENT_Fill, bModified); | |
| 1283 return CXFA_Fill(pFillNode); | |
| 1284 } | |
| 1285 CXFA_Margin CXFA_Box::GetMargin() const { | |
| 1286 return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin) | |
| 1287 : nullptr); | |
| 1288 } | |
| 1289 static FX_BOOL XFA_BOX_SameStyles(const CXFA_StrokeArray& strokes) { | |
| 1290 int32_t iCount = strokes.GetSize(); | |
| 1291 if (iCount < 1) { | |
| 1292 return TRUE; | |
| 1293 } | |
| 1294 CXFA_Stroke stroke1 = strokes[0]; | |
| 1295 for (int32_t i = 1; i < iCount; i++) { | |
| 1296 CXFA_Stroke stroke2 = strokes[i]; | |
| 1297 if (!stroke2) { | |
| 1298 continue; | |
| 1299 } | |
| 1300 if (!stroke1) { | |
| 1301 stroke1 = stroke2; | |
| 1302 } else if (!stroke1.SameStyles(stroke2)) { | |
| 1303 return FALSE; | |
| 1304 } | |
| 1305 } | |
| 1306 return TRUE; | |
| 1307 } | |
| 1308 FX_BOOL CXFA_Box::SameStyles() const { | |
| 1309 if (IsArc()) { | |
| 1310 return TRUE; | |
| 1311 } | |
| 1312 CXFA_StrokeArray strokes; | |
| 1313 XFA_BOX_GetStrokes(m_pNode, strokes, TRUE); | |
| 1314 return XFA_BOX_SameStyles(strokes); | |
| 1315 } | |
| 1316 static int32_t XFA_BOX_3DStyle(const CXFA_StrokeArray& strokes, | |
| 1317 CXFA_Stroke& stroke) { | |
| 1318 int32_t iCount = strokes.GetSize(); | |
| 1319 if (iCount < 1) { | |
| 1320 return 0; | |
| 1321 } | |
| 1322 stroke = strokes[0]; | |
| 1323 for (int32_t i = 1; i < iCount; i++) { | |
| 1324 CXFA_Stroke find = strokes[i]; | |
| 1325 if (!find) { | |
| 1326 continue; | |
| 1327 } | |
| 1328 if (!stroke) { | |
| 1329 stroke = find; | |
| 1330 } else if (stroke.GetStrokeType() != find.GetStrokeType()) { | |
| 1331 stroke = find; | |
| 1332 break; | |
| 1333 } | |
| 1334 } | |
| 1335 int32_t iType = stroke.GetStrokeType(); | |
| 1336 if (iType == XFA_ATTRIBUTEENUM_Lowered || iType == XFA_ATTRIBUTEENUM_Raised || | |
| 1337 iType == XFA_ATTRIBUTEENUM_Etched || | |
| 1338 iType == XFA_ATTRIBUTEENUM_Embossed) { | |
| 1339 return iType; | |
| 1340 } | |
| 1341 return 0; | |
| 1342 } | |
| 1343 int32_t CXFA_Box::Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const { | |
| 1344 if (IsArc()) { | |
| 1345 return 0; | |
| 1346 } | |
| 1347 CXFA_StrokeArray strokes; | |
| 1348 XFA_BOX_GetStrokes(m_pNode, strokes, TRUE); | |
| 1349 CXFA_Stroke stroke(NULL); | |
| 1350 int32_t iType = XFA_BOX_3DStyle(strokes, stroke); | |
| 1351 if (iType) { | |
| 1352 bVisible = stroke.IsVisible(); | |
| 1353 fThickness = stroke.GetThickness(); | |
| 1354 } | |
| 1355 return iType; | |
| 1356 } | |
| 1357 int32_t CXFA_Stroke::GetPresence() const { | |
| 1358 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence) | |
| 1359 : XFA_ATTRIBUTEENUM_Invisible; | |
| 1360 } | |
| 1361 int32_t CXFA_Stroke::GetCapType() const { | |
| 1362 if (!m_pNode) { | |
| 1363 return XFA_ATTRIBUTEENUM_Square; | |
| 1364 } | |
| 1365 return m_pNode->GetEnum(XFA_ATTRIBUTE_Cap); | |
| 1366 } | |
| 1367 int32_t CXFA_Stroke::GetStrokeType() const { | |
| 1368 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Stroke) | |
| 1369 : XFA_ATTRIBUTEENUM_Solid; | |
| 1370 } | |
| 1371 FX_FLOAT CXFA_Stroke::GetThickness() const { | |
| 1372 return GetMSThickness().ToUnit(XFA_UNIT_Pt); | |
| 1373 } | |
| 1374 CXFA_Measurement CXFA_Stroke::GetMSThickness() const { | |
| 1375 return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Thickness) | |
| 1376 : XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT_Edge, | |
| 1377 XFA_ATTRIBUTE_Thickness, | |
| 1378 XFA_XDPPACKET_Form); | |
| 1379 } | |
| 1380 void CXFA_Stroke::SetThickness(FX_FLOAT fThickness) { | |
| 1381 if (!m_pNode) { | |
| 1382 return; | |
| 1383 } | |
| 1384 CXFA_Measurement thickness(fThickness, XFA_UNIT_Pt); | |
| 1385 m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, thickness); | |
| 1386 } | |
| 1387 void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) { | |
| 1388 if (!m_pNode) { | |
| 1389 return; | |
| 1390 } | |
| 1391 m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness); | |
| 1392 } | |
| 1393 FX_ARGB CXFA_Stroke::GetColor() const { | |
| 1394 if (!m_pNode) { | |
| 1395 return 0xFF000000; | |
| 1396 } | |
| 1397 CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color); | |
| 1398 if (!pNode) { | |
| 1399 return 0xFF000000; | |
| 1400 } | |
| 1401 CFX_WideStringC wsColor; | |
| 1402 pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor); | |
| 1403 return XFA_WStringToColor(wsColor); | |
| 1404 } | |
| 1405 void CXFA_Stroke::SetColor(FX_ARGB argb) { | |
| 1406 if (!m_pNode) { | |
| 1407 return; | |
| 1408 } | |
| 1409 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color); | |
| 1410 CFX_WideString wsColor; | |
| 1411 int a, r, g, b; | |
| 1412 ArgbDecode(argb, a, r, g, b); | |
| 1413 wsColor.Format(L"%d,%d,%d", r, g, b); | |
| 1414 pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor); | |
| 1415 } | |
| 1416 int32_t CXFA_Stroke::GetJoinType() const { | |
| 1417 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Join) | |
| 1418 : XFA_ATTRIBUTEENUM_Square; | |
| 1419 } | |
| 1420 FX_BOOL CXFA_Stroke::IsInverted() const { | |
| 1421 return m_pNode ? m_pNode->GetBoolean(XFA_ATTRIBUTE_Inverted) : FALSE; | |
| 1422 } | |
| 1423 FX_FLOAT CXFA_Stroke::GetRadius() const { | |
| 1424 return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Radius).ToUnit(XFA_UNIT_Pt) | |
| 1425 : 0; | |
| 1426 } | |
| 1427 FX_BOOL CXFA_Stroke::SameStyles(CXFA_Stroke stroke, FX_DWORD dwFlags) const { | |
| 1428 if (m_pNode == stroke.GetNode()) { | |
| 1429 return TRUE; | |
| 1430 } | |
| 1431 if (FXSYS_fabs(GetThickness() - stroke.GetThickness()) >= 0.01f) { | |
| 1432 return FALSE; | |
| 1433 } | |
| 1434 if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 && | |
| 1435 IsVisible() != stroke.IsVisible()) { | |
| 1436 return FALSE; | |
| 1437 } | |
| 1438 if (GetStrokeType() != stroke.GetStrokeType()) { | |
| 1439 return FALSE; | |
| 1440 } | |
| 1441 if (GetColor() != stroke.GetColor()) { | |
| 1442 return FALSE; | |
| 1443 } | |
| 1444 if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 && | |
| 1445 FXSYS_fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) { | |
| 1446 return FALSE; | |
| 1447 } | |
| 1448 return TRUE; | |
| 1449 } | |
| 1450 FX_FLOAT XFA_GetEdgeThickness(const CXFA_StrokeArray& strokes, | |
| 1451 FX_BOOL b3DStyle, | |
| 1452 int32_t nIndex) { | |
| 1453 FX_FLOAT fThickness = 0; | |
| 1454 { | |
| 1455 if (strokes[nIndex * 2 + 1].GetPresence() == XFA_ATTRIBUTEENUM_Visible) { | |
| 1456 if (nIndex == 0) { | |
| 1457 fThickness += 2.5f; | |
| 1458 } | |
| 1459 fThickness += strokes[nIndex * 2 + 1].GetThickness() * (b3DStyle ? 4 : 2); | |
| 1460 } | |
| 1461 } | |
| 1462 return fThickness; | |
| 1463 } | |
| 1464 CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode) | |
| 1465 : CXFA_Data(pNode), | |
| 1466 m_bIsNull(TRUE), | |
| 1467 m_bPreNull(TRUE), | |
| 1468 m_pUiChildNode(NULL), | |
| 1469 m_eUIType(XFA_ELEMENT_UNKNOWN) {} | |
| 1470 CXFA_Node* CXFA_WidgetData::GetUIChild() { | |
| 1471 if (m_eUIType == XFA_ELEMENT_UNKNOWN) { | |
| 1472 m_pUiChildNode = XFA_CreateUIChild(m_pNode, m_eUIType); | |
| 1473 } | |
| 1474 return m_pUiChildNode; | |
| 1475 } | |
| 1476 XFA_ELEMENT CXFA_WidgetData::GetUIType() { | |
| 1477 GetUIChild(); | |
| 1478 return m_eUIType; | |
| 1479 } | |
| 1480 CFX_WideString CXFA_WidgetData::GetRawValue() { | |
| 1481 return m_pNode->GetContent(); | |
| 1482 } | |
| 1483 int32_t CXFA_WidgetData::GetAccess(FX_BOOL bTemplate) { | |
| 1484 if (bTemplate) { | |
| 1485 CXFA_Node* pNode = m_pNode->GetTemplateNode(); | |
| 1486 if (pNode) { | |
| 1487 return pNode->GetEnum(XFA_ATTRIBUTE_Access); | |
| 1488 } | |
| 1489 return XFA_ATTRIBUTEENUM_Open; | |
| 1490 } | |
| 1491 CXFA_Node* pNode = m_pNode; | |
| 1492 while (pNode) { | |
| 1493 int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Access); | |
| 1494 if (iAcc != XFA_ATTRIBUTEENUM_Open) { | |
| 1495 return iAcc; | |
| 1496 } | |
| 1497 pNode = | |
| 1498 pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); | |
| 1499 } | |
| 1500 return XFA_ATTRIBUTEENUM_Open; | |
| 1501 } | |
| 1502 FX_BOOL CXFA_WidgetData::GetAccessKey(CFX_WideStringC& wsAccessKey) { | |
| 1503 return m_pNode->TryCData(XFA_ATTRIBUTE_AccessKey, wsAccessKey); | |
| 1504 } | |
| 1505 int32_t CXFA_WidgetData::GetAnchorType() { | |
| 1506 return m_pNode->GetEnum(XFA_ATTRIBUTE_AnchorType); | |
| 1507 } | |
| 1508 int32_t CXFA_WidgetData::GetColSpan() { | |
| 1509 return m_pNode->GetInteger(XFA_ATTRIBUTE_ColSpan); | |
| 1510 } | |
| 1511 int32_t CXFA_WidgetData::GetPresence() { | |
| 1512 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); | |
| 1513 CXFA_Node* pNode = m_pNode; | |
| 1514 while (pNode && pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { | |
| 1515 int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Presence); | |
| 1516 if (iAcc != XFA_ATTRIBUTEENUM_Visible) { | |
| 1517 return iAcc; | |
| 1518 } | |
| 1519 pNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); | |
| 1520 } | |
| 1521 return XFA_ATTRIBUTEENUM_Visible; | |
| 1522 } | |
| 1523 int32_t CXFA_WidgetData::GetRotate() { | |
| 1524 CXFA_Measurement ms; | |
| 1525 if (!m_pNode->TryMeasure(XFA_ATTRIBUTE_Rotate, ms, FALSE)) { | |
| 1526 return 0; | |
| 1527 } | |
| 1528 int32_t iRotate = FXSYS_round(ms.GetValue()); | |
| 1529 iRotate = XFA_MapRotation(iRotate); | |
| 1530 return iRotate / 90 * 90; | |
| 1531 } | |
| 1532 CXFA_Border CXFA_WidgetData::GetBorder(FX_BOOL bModified) { | |
| 1533 return CXFA_Border(m_pNode->GetProperty(0, XFA_ELEMENT_Border, bModified)); | |
| 1534 } | |
| 1535 CXFA_Caption CXFA_WidgetData::GetCaption(FX_BOOL bModified) { | |
| 1536 return CXFA_Caption(m_pNode->GetProperty(0, XFA_ELEMENT_Caption, bModified)); | |
| 1537 } | |
| 1538 CXFA_Font CXFA_WidgetData::GetFont(FX_BOOL bModified) { | |
| 1539 return CXFA_Font(m_pNode->GetProperty(0, XFA_ELEMENT_Font, bModified)); | |
| 1540 } | |
| 1541 CXFA_Margin CXFA_WidgetData::GetMargin(FX_BOOL bModified) { | |
| 1542 return CXFA_Margin(m_pNode->GetProperty(0, XFA_ELEMENT_Margin, bModified)); | |
| 1543 } | |
| 1544 CXFA_Para CXFA_WidgetData::GetPara(FX_BOOL bModified) { | |
| 1545 return CXFA_Para(m_pNode->GetProperty(0, XFA_ELEMENT_Para, bModified)); | |
| 1546 } | |
| 1547 CXFA_Keep CXFA_WidgetData::GetKeep(FX_BOOL bModified) { | |
| 1548 return CXFA_Keep(m_pNode->GetProperty(0, XFA_ELEMENT_Keep, bModified), | |
| 1549 m_pNode); | |
| 1550 } | |
| 1551 void CXFA_WidgetData::GetEventList(CXFA_NodeArray& events) { | |
| 1552 m_pNode->GetNodeList(events, 0, XFA_ELEMENT_Event); | |
| 1553 } | |
| 1554 int32_t CXFA_WidgetData::GetEventByActivity(int32_t iActivity, | |
| 1555 CXFA_NodeArray& events, | |
| 1556 FX_BOOL bIsFormReady) { | |
| 1557 CXFA_NodeArray allEvents; | |
| 1558 GetEventList(allEvents); | |
| 1559 int32_t iCount = allEvents.GetSize(); | |
| 1560 for (int32_t i = 0; i < iCount; i++) { | |
| 1561 CXFA_Event event(allEvents[i]); | |
| 1562 if (event.GetActivity() == iActivity) { | |
| 1563 if (iActivity == XFA_ATTRIBUTEENUM_Ready) { | |
| 1564 CFX_WideStringC wsRef; | |
| 1565 event.GetRef(wsRef); | |
| 1566 if (bIsFormReady) { | |
| 1567 if (wsRef == CFX_WideStringC(L"$form")) { | |
| 1568 events.Add(allEvents[i]); | |
| 1569 } | |
| 1570 } else { | |
| 1571 if (wsRef == CFX_WideStringC(L"$layout")) { | |
| 1572 events.Add(allEvents[i]); | |
| 1573 } | |
| 1574 } | |
| 1575 } else { | |
| 1576 events.Add(allEvents[i]); | |
| 1577 } | |
| 1578 } | |
| 1579 } | |
| 1580 return events.GetSize(); | |
| 1581 } | |
| 1582 CXFA_Value CXFA_WidgetData::GetDefaultValue(FX_BOOL bModified) { | |
| 1583 CXFA_Node* pTemNode = m_pNode->GetTemplateNode(); | |
| 1584 return CXFA_Value(pTemNode | |
| 1585 ? pTemNode->GetProperty(0, XFA_ELEMENT_Value, bModified) | |
| 1586 : nullptr); | |
| 1587 } | |
| 1588 CXFA_Value CXFA_WidgetData::GetFormValue(FX_BOOL bModified) { | |
| 1589 return CXFA_Value(m_pNode->GetProperty(0, XFA_ELEMENT_Value, bModified)); | |
| 1590 } | |
| 1591 CXFA_Calculate CXFA_WidgetData::GetCalculate(FX_BOOL bModified) { | |
| 1592 return CXFA_Calculate( | |
| 1593 m_pNode->GetProperty(0, XFA_ELEMENT_Calculate, bModified)); | |
| 1594 } | |
| 1595 CXFA_Validate CXFA_WidgetData::GetValidate(FX_BOOL bModified) { | |
| 1596 return CXFA_Validate( | |
| 1597 m_pNode->GetProperty(0, XFA_ELEMENT_Validate, bModified)); | |
| 1598 } | |
| 1599 CXFA_Variables CXFA_WidgetData::GetVariables(FX_BOOL bModified) { | |
| 1600 return CXFA_Variables( | |
| 1601 m_pNode->GetProperty(0, XFA_ELEMENT_Variables, bModified)); | |
| 1602 } | |
| 1603 CXFA_Bind CXFA_WidgetData::GetBind(FX_BOOL bModified) { | |
| 1604 return CXFA_Bind(m_pNode->GetProperty(0, XFA_ELEMENT_Bind, bModified)); | |
| 1605 } | |
| 1606 CXFA_Assist CXFA_WidgetData::GetAssist(FX_BOOL bModified) { | |
| 1607 return CXFA_Assist(m_pNode->GetProperty(0, XFA_ELEMENT_Assist, bModified)); | |
| 1608 } | |
| 1609 void CXFA_WidgetData::GetRelevant(CFX_WideStringC& wsRelevant) { | |
| 1610 m_pNode->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant); | |
| 1611 } | |
| 1612 FX_BOOL CXFA_WidgetData::GetWidth(FX_FLOAT& fWidth) { | |
| 1613 return TryMeasure(XFA_ATTRIBUTE_W, fWidth); | |
| 1614 } | |
| 1615 FX_BOOL CXFA_WidgetData::GetHeight(FX_FLOAT& fHeight) { | |
| 1616 return TryMeasure(XFA_ATTRIBUTE_H, fHeight); | |
| 1617 } | |
| 1618 FX_BOOL CXFA_WidgetData::GetMinWidth(FX_FLOAT& fMinWidth) { | |
| 1619 return TryMeasure(XFA_ATTRIBUTE_MinW, fMinWidth); | |
| 1620 } | |
| 1621 FX_BOOL CXFA_WidgetData::GetMinHeight(FX_FLOAT& fMinHeight) { | |
| 1622 return TryMeasure(XFA_ATTRIBUTE_MinH, fMinHeight); | |
| 1623 } | |
| 1624 FX_BOOL CXFA_WidgetData::GetMaxWidth(FX_FLOAT& fMaxWidth) { | |
| 1625 return TryMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth); | |
| 1626 } | |
| 1627 FX_BOOL CXFA_WidgetData::GetMaxHeight(FX_FLOAT& fMaxHeight) { | |
| 1628 return TryMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight); | |
| 1629 } | |
| 1630 CXFA_BindItems CXFA_WidgetData::GetBindItems() { | |
| 1631 return CXFA_BindItems(m_pNode->GetChild(0, XFA_ELEMENT_BindItems)); | |
| 1632 } | |
| 1633 FX_BOOL CXFA_WidgetData::SetAccess(int32_t iAccess, FX_BOOL bNotify) { | |
| 1634 return m_pNode->SetEnum(XFA_ATTRIBUTE_Access, (XFA_ATTRIBUTEENUM)iAccess, | |
| 1635 bNotify); | |
| 1636 } | |
| 1637 FX_BOOL CXFA_WidgetData::SetAccessKey(const CFX_WideString& wsAccessKey) { | |
| 1638 return m_pNode->SetCData(XFA_ATTRIBUTE_AccessKey, wsAccessKey); | |
| 1639 } | |
| 1640 FX_BOOL CXFA_WidgetData::SetAnchorType(int32_t iType) { | |
| 1641 return m_pNode->SetEnum(XFA_ATTRIBUTE_AnchorType, (XFA_ATTRIBUTEENUM)iType); | |
| 1642 } | |
| 1643 FX_BOOL CXFA_WidgetData::SetColSpan(int32_t iColSpan) { | |
| 1644 return m_pNode->SetInteger(XFA_ATTRIBUTE_ColSpan, | |
| 1645 (XFA_ATTRIBUTEENUM)iColSpan); | |
| 1646 } | |
| 1647 FX_BOOL CXFA_WidgetData::SetPresence(int32_t iPresence) { | |
| 1648 return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); | |
| 1649 } | |
| 1650 FX_BOOL CXFA_WidgetData::SetRotate(int32_t iRotate) { | |
| 1651 iRotate = XFA_MapRotation(iRotate); | |
| 1652 CXFA_Measurement ms((FX_FLOAT)iRotate, XFA_UNIT_Angle); | |
| 1653 return m_pNode->SetMeasure(XFA_ATTRIBUTE_Rotate, ms); | |
| 1654 } | |
| 1655 FX_BOOL CXFA_WidgetData::SetRelevant(const CFX_WideString& wsRelevant) { | |
| 1656 return m_pNode->SetCData(XFA_ATTRIBUTE_Relevant, wsRelevant); | |
| 1657 } | |
| 1658 FX_BOOL CXFA_WidgetData::SetStatus(FX_DWORD dwStatus) { | |
| 1659 return FALSE; | |
| 1660 } | |
| 1661 FX_BOOL CXFA_WidgetData::SetWidth(FX_FLOAT fWidth) { | |
| 1662 return SetMeasure(XFA_ATTRIBUTE_W, fWidth); | |
| 1663 } | |
| 1664 FX_BOOL CXFA_WidgetData::SetHeight(FX_FLOAT fHeight) { | |
| 1665 return SetMeasure(XFA_ATTRIBUTE_H, fHeight); | |
| 1666 } | |
| 1667 FX_BOOL CXFA_WidgetData::SetMinWidth(FX_FLOAT fMinWidth) { | |
| 1668 return SetMeasure(XFA_ATTRIBUTE_MinW, fMinWidth); | |
| 1669 } | |
| 1670 FX_BOOL CXFA_WidgetData::SetMinHeight(FX_FLOAT fMinHeight) { | |
| 1671 return SetMeasure(XFA_ATTRIBUTE_MinH, fMinHeight); | |
| 1672 } | |
| 1673 FX_BOOL CXFA_WidgetData::SetMaxWidth(FX_FLOAT fMaxWidth) { | |
| 1674 return SetMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth); | |
| 1675 } | |
| 1676 FX_BOOL CXFA_WidgetData::SetMaxHeight(FX_FLOAT fMaxHeight) { | |
| 1677 return SetMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight); | |
| 1678 } | |
| 1679 FX_BOOL CXFA_WidgetData::SetPos(FX_FLOAT x, FX_FLOAT y) { | |
| 1680 return SetMeasure(XFA_ATTRIBUTE_X, x) && SetMeasure(XFA_ATTRIBUTE_Y, y); | |
| 1681 } | |
| 1682 FX_BOOL CXFA_WidgetData::SetName(const CFX_WideString& wsName) { | |
| 1683 return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); | |
| 1684 } | |
| 1685 FX_BOOL CXFA_WidgetData::SetButtonHighlight(int32_t iButtonHighlight) { | |
| 1686 CXFA_Node* pUiChildNode = GetUIChild(); | |
| 1687 return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Highlight, | |
| 1688 (XFA_ATTRIBUTEENUM)iButtonHighlight); | |
| 1689 } | |
| 1690 FX_BOOL CXFA_WidgetData::SetButtonRollover(const CFX_WideString& wsRollover, | |
| 1691 FX_BOOL bRichText) { | |
| 1692 return FALSE; | |
| 1693 } | |
| 1694 FX_BOOL CXFA_WidgetData::SetButtonDown(const CFX_WideString& wsDown, | |
| 1695 FX_BOOL bRichText) { | |
| 1696 return FALSE; | |
| 1697 } | |
| 1698 FX_BOOL CXFA_WidgetData::SetCheckButtonShape(int32_t iCheckButtonShape) { | |
| 1699 CXFA_Node* pUiChildNode = GetUIChild(); | |
| 1700 return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Shape, | |
| 1701 (XFA_ATTRIBUTEENUM)iCheckButtonShape); | |
| 1702 } | |
| 1703 FX_BOOL CXFA_WidgetData::SetCheckButtonMark(int32_t iCheckButtonMark) { | |
| 1704 CXFA_Node* pUiChildNode = GetUIChild(); | |
| 1705 return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Mark, | |
| 1706 (XFA_ATTRIBUTEENUM)iCheckButtonMark); | |
| 1707 } | |
| 1708 FX_BOOL CXFA_WidgetData::SetCheckButtonSize(FX_FLOAT fCheckButtonMark) { | |
| 1709 CXFA_Node* pUiChildNode = GetUIChild(); | |
| 1710 if (pUiChildNode) { | |
| 1711 CXFA_Measurement ms(fCheckButtonMark, XFA_UNIT_Pt); | |
| 1712 return pUiChildNode->SetMeasure(XFA_ATTRIBUTE_Size, ms); | |
| 1713 } | |
| 1714 return FALSE; | |
| 1715 } | |
| 1716 CXFA_Border CXFA_WidgetData::GetUIBorder(FX_BOOL bModified) { | |
| 1717 CXFA_Node* pUIChild = GetUIChild(); | |
| 1718 return CXFA_Border( | |
| 1719 pUIChild ? pUIChild->GetProperty(0, XFA_ELEMENT_Border, bModified) | |
| 1720 : nullptr); | |
| 1721 } | |
| 1722 CXFA_Margin CXFA_WidgetData::GetUIMargin(FX_BOOL bModified) { | |
| 1723 CXFA_Node* pUIChild = GetUIChild(); | |
| 1724 return CXFA_Margin( | |
| 1725 pUIChild ? pUIChild->GetProperty(0, XFA_ELEMENT_Margin, bModified) | |
| 1726 : nullptr); | |
| 1727 } | |
| 1728 void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) { | |
| 1729 rtUIMargin.Reset(); | |
| 1730 CXFA_Margin mgUI = GetUIMargin(); | |
| 1731 if (!mgUI) { | |
| 1732 return; | |
| 1733 } | |
| 1734 CXFA_Border border = GetUIBorder(); | |
| 1735 if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { | |
| 1736 return; | |
| 1737 } | |
| 1738 FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; | |
| 1739 FX_BOOL bLeft = mgUI.GetLeftInset(fLeftInset); | |
| 1740 FX_BOOL bTop = mgUI.GetTopInset(fTopInset); | |
| 1741 FX_BOOL bRight = mgUI.GetRightInset(fRightInset); | |
| 1742 FX_BOOL bBottom = mgUI.GetBottomInset(fBottomInset); | |
| 1743 if (border) { | |
| 1744 FX_BOOL bVisible = FALSE; | |
| 1745 FX_FLOAT fThickness = 0; | |
| 1746 border.Get3DStyle(bVisible, fThickness); | |
| 1747 if (!bLeft || !bTop || !bRight || !bBottom) { | |
| 1748 CXFA_StrokeArray strokes; | |
| 1749 border.GetStrokes(strokes); | |
| 1750 if (!bTop) { | |
| 1751 fTopInset = XFA_GetEdgeThickness(strokes, bVisible, 0); | |
| 1752 } | |
| 1753 if (!bRight) { | |
| 1754 fRightInset = XFA_GetEdgeThickness(strokes, bVisible, 1); | |
| 1755 } | |
| 1756 if (!bBottom) { | |
| 1757 fBottomInset = XFA_GetEdgeThickness(strokes, bVisible, 2); | |
| 1758 } | |
| 1759 if (!bLeft) { | |
| 1760 fLeftInset = XFA_GetEdgeThickness(strokes, bVisible, 3); | |
| 1761 } | |
| 1762 } | |
| 1763 } | |
| 1764 rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset); | |
| 1765 } | |
| 1766 int32_t CXFA_WidgetData::GetButtonHighlight() { | |
| 1767 CXFA_Node* pUIChild = GetUIChild(); | |
| 1768 if (pUIChild) { | |
| 1769 return pUIChild->GetEnum(XFA_ATTRIBUTE_Highlight); | |
| 1770 } | |
| 1771 return XFA_GetAttributeDefaultValue_Enum( | |
| 1772 XFA_ELEMENT_Button, XFA_ATTRIBUTE_Highlight, XFA_XDPPACKET_Form); | |
| 1773 } | |
| 1774 FX_BOOL CXFA_WidgetData::GetButtonRollover(CFX_WideString& wsRollover, | |
| 1775 FX_BOOL& bRichText) { | |
| 1776 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { | |
| 1777 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1778 while (pText) { | |
| 1779 CFX_WideStringC wsName; | |
| 1780 pText->TryCData(XFA_ATTRIBUTE_Name, wsName); | |
| 1781 if (wsName == FX_WSTRC(L"rollover")) { | |
| 1782 pText->TryContent(wsRollover); | |
| 1783 bRichText = pText->GetClassID() == XFA_ELEMENT_ExData; | |
| 1784 return !wsRollover.IsEmpty(); | |
| 1785 } | |
| 1786 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 1787 } | |
| 1788 } | |
| 1789 return FALSE; | |
| 1790 } | |
| 1791 FX_BOOL CXFA_WidgetData::GetButtonDown(CFX_WideString& wsDown, | |
| 1792 FX_BOOL& bRichText) { | |
| 1793 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { | |
| 1794 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1795 while (pText) { | |
| 1796 CFX_WideStringC wsName; | |
| 1797 pText->TryCData(XFA_ATTRIBUTE_Name, wsName); | |
| 1798 if (wsName == FX_WSTRC(L"down")) { | |
| 1799 pText->TryContent(wsDown); | |
| 1800 bRichText = pText->GetClassID() == XFA_ELEMENT_ExData; | |
| 1801 return !wsDown.IsEmpty(); | |
| 1802 } | |
| 1803 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 1804 } | |
| 1805 } | |
| 1806 return FALSE; | |
| 1807 } | |
| 1808 int32_t CXFA_WidgetData::GetCheckButtonShape() { | |
| 1809 CXFA_Node* pUIChild = GetUIChild(); | |
| 1810 if (pUIChild) { | |
| 1811 return pUIChild->GetEnum(XFA_ATTRIBUTE_Shape); | |
| 1812 } | |
| 1813 return XFA_GetAttributeDefaultValue_Enum( | |
| 1814 XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Shape, XFA_XDPPACKET_Form); | |
| 1815 } | |
| 1816 int32_t CXFA_WidgetData::GetCheckButtonMark() { | |
| 1817 CXFA_Node* pUIChild = GetUIChild(); | |
| 1818 if (pUIChild) { | |
| 1819 return pUIChild->GetEnum(XFA_ATTRIBUTE_Mark); | |
| 1820 } | |
| 1821 return XFA_GetAttributeDefaultValue_Enum( | |
| 1822 XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Mark, XFA_XDPPACKET_Form); | |
| 1823 } | |
| 1824 FX_BOOL CXFA_WidgetData::IsRadioButton() { | |
| 1825 if (CXFA_Node* pParent = m_pNode->GetNodeItem(XFA_NODEITEM_Parent)) { | |
| 1826 return pParent->GetClassID() == XFA_ELEMENT_ExclGroup; | |
| 1827 } | |
| 1828 return FALSE; | |
| 1829 } | |
| 1830 FX_FLOAT CXFA_WidgetData::GetCheckButtonSize() { | |
| 1831 CXFA_Node* pUIChild = GetUIChild(); | |
| 1832 if (pUIChild) { | |
| 1833 return pUIChild->GetMeasure(XFA_ATTRIBUTE_Size).ToUnit(XFA_UNIT_Pt); | |
| 1834 } | |
| 1835 return XFA_GetAttributeDefaultValue_Measure( | |
| 1836 XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Size, XFA_XDPPACKET_Form) | |
| 1837 .ToUnit(XFA_UNIT_Pt); | |
| 1838 } | |
| 1839 FX_BOOL CXFA_WidgetData::IsAllowNeutral() { | |
| 1840 CXFA_Node* pUIChild = GetUIChild(); | |
| 1841 if (pUIChild) { | |
| 1842 return pUIChild->GetBoolean(XFA_ATTRIBUTE_AllowNeutral); | |
| 1843 } | |
| 1844 return XFA_GetAttributeDefaultValue_Boolean( | |
| 1845 XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_AllowNeutral, XFA_XDPPACKET_Form); | |
| 1846 } | |
| 1847 XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() { | |
| 1848 CFX_WideString wsValue = GetRawValue(); | |
| 1849 if (wsValue.IsEmpty()) { | |
| 1850 return XFA_CHECKSTATE_Off; | |
| 1851 } | |
| 1852 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { | |
| 1853 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1854 int32_t i = 0; | |
| 1855 while (pText) { | |
| 1856 CFX_WideString wsContent; | |
| 1857 if (pText->TryContent(wsContent) && (wsContent == wsValue)) { | |
| 1858 return (XFA_CHECKSTATE)i; | |
| 1859 } | |
| 1860 i++; | |
| 1861 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 1862 } | |
| 1863 } | |
| 1864 return XFA_CHECKSTATE_Off; | |
| 1865 } | |
| 1866 void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, | |
| 1867 FX_BOOL bNotify) { | |
| 1868 CXFA_WidgetData exclGroup(GetExclGroupNode()); | |
| 1869 if (exclGroup) { | |
| 1870 CFX_WideString wsValue; | |
| 1871 if (eCheckState != XFA_CHECKSTATE_Off) { | |
| 1872 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { | |
| 1873 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1874 if (pText) { | |
| 1875 pText->TryContent(wsValue); | |
| 1876 } | |
| 1877 } | |
| 1878 } | |
| 1879 CXFA_Node* pChild = | |
| 1880 exclGroup.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1881 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 1882 if (pChild->GetClassID() != XFA_ELEMENT_Field) { | |
| 1883 continue; | |
| 1884 } | |
| 1885 CXFA_Node* pItem = pChild->GetChild(0, XFA_ELEMENT_Items); | |
| 1886 if (!pItem) { | |
| 1887 continue; | |
| 1888 } | |
| 1889 CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1890 if (!pItemchild) { | |
| 1891 continue; | |
| 1892 } | |
| 1893 CFX_WideString text = pItemchild->GetContent(); | |
| 1894 CFX_WideString wsChildValue = text; | |
| 1895 if (wsValue != text) { | |
| 1896 pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 1897 if (pItemchild) { | |
| 1898 wsChildValue = pItemchild->GetContent(); | |
| 1899 } else { | |
| 1900 wsChildValue.Empty(); | |
| 1901 } | |
| 1902 } | |
| 1903 CXFA_WidgetData ch(pChild); | |
| 1904 ch.SyncValue(wsChildValue, bNotify); | |
| 1905 } | |
| 1906 exclGroup.SyncValue(wsValue, bNotify); | |
| 1907 } else { | |
| 1908 CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items); | |
| 1909 if (!pItems) { | |
| 1910 return; | |
| 1911 } | |
| 1912 int32_t i = -1; | |
| 1913 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1914 CFX_WideString wsContent; | |
| 1915 while (pText) { | |
| 1916 i++; | |
| 1917 if (i == eCheckState) { | |
| 1918 pText->TryContent(wsContent); | |
| 1919 break; | |
| 1920 } | |
| 1921 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 1922 } | |
| 1923 SyncValue(wsContent, bNotify); | |
| 1924 } | |
| 1925 } | |
| 1926 CXFA_Node* CXFA_WidgetData::GetExclGroupNode() { | |
| 1927 CXFA_Node* pExcl = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_Parent)); | |
| 1928 if (!pExcl || pExcl->GetClassID() != XFA_ELEMENT_ExclGroup) { | |
| 1929 return NULL; | |
| 1930 } | |
| 1931 return pExcl; | |
| 1932 } | |
| 1933 CXFA_Node* CXFA_WidgetData::GetSelectedMember() { | |
| 1934 CXFA_Node* pSelectedMember = NULL; | |
| 1935 CFX_WideString wsState = GetRawValue(); | |
| 1936 if (wsState.IsEmpty()) { | |
| 1937 return pSelectedMember; | |
| 1938 } | |
| 1939 for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); | |
| 1940 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 1941 CXFA_WidgetData widgetData(pNode); | |
| 1942 if (widgetData.GetCheckState() == XFA_CHECKSTATE_On) { | |
| 1943 pSelectedMember = pNode; | |
| 1944 break; | |
| 1945 } | |
| 1946 } | |
| 1947 return pSelectedMember; | |
| 1948 } | |
| 1949 CXFA_Node* CXFA_WidgetData::SetSelectedMember(const CFX_WideStringC& wsName, | |
| 1950 FX_BOOL bNotify) { | |
| 1951 CXFA_Node* pSelectedMember = NULL; | |
| 1952 FX_DWORD nameHash = | |
| 1953 FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength()); | |
| 1954 for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); | |
| 1955 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 1956 if (pNode->GetNameHash() == nameHash) { | |
| 1957 CXFA_WidgetData widgetData(pNode); | |
| 1958 widgetData.SetCheckState(XFA_CHECKSTATE_On, bNotify); | |
| 1959 pSelectedMember = pNode; | |
| 1960 break; | |
| 1961 } | |
| 1962 } | |
| 1963 return pSelectedMember; | |
| 1964 } | |
| 1965 void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue, | |
| 1966 FX_BOOL bNotify, | |
| 1967 FX_BOOL bScriptModify, | |
| 1968 FX_BOOL bSyncData) { | |
| 1969 CFX_WideString wsExclGroup; | |
| 1970 for (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pNode; | |
| 1971 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 1972 if (pNode->GetClassID() != XFA_ELEMENT_Field) { | |
| 1973 continue; | |
| 1974 } | |
| 1975 CXFA_Node* pItem = pNode->GetChild(0, XFA_ELEMENT_Items); | |
| 1976 if (!pItem) { | |
| 1977 continue; | |
| 1978 } | |
| 1979 CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 1980 if (!pItemchild) { | |
| 1981 continue; | |
| 1982 } | |
| 1983 CFX_WideString wsChildValue = pItemchild->GetContent(); | |
| 1984 if (wsValue != wsChildValue) { | |
| 1985 pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 1986 if (pItemchild) { | |
| 1987 wsChildValue = pItemchild->GetContent(); | |
| 1988 } else { | |
| 1989 wsChildValue.Empty(); | |
| 1990 } | |
| 1991 } else { | |
| 1992 wsExclGroup = wsValue; | |
| 1993 } | |
| 1994 pNode->SetContent(wsChildValue, wsChildValue, bNotify, bScriptModify, | |
| 1995 FALSE); | |
| 1996 } | |
| 1997 if (m_pNode) { | |
| 1998 m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify, | |
| 1999 bSyncData); | |
| 2000 } | |
| 2001 } | |
| 2002 CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() { | |
| 2003 CXFA_Node* pExcl = GetNode(); | |
| 2004 if (!pExcl) { | |
| 2005 return NULL; | |
| 2006 } | |
| 2007 CXFA_Node* pNode = pExcl->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2008 while (pNode) { | |
| 2009 if (pNode->GetClassID() == XFA_ELEMENT_Field) { | |
| 2010 return pNode; | |
| 2011 } | |
| 2012 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 2013 } | |
| 2014 return NULL; | |
| 2015 } | |
| 2016 CXFA_Node* CXFA_WidgetData::GetExclGroupNextMember(CXFA_Node* pNode) { | |
| 2017 if (!pNode) { | |
| 2018 return NULL; | |
| 2019 } | |
| 2020 CXFA_Node* pNodeField = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 2021 while (pNodeField) { | |
| 2022 if (pNodeField->GetClassID() == XFA_ELEMENT_Field) { | |
| 2023 return pNodeField; | |
| 2024 } | |
| 2025 pNodeField = pNodeField->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 2026 } | |
| 2027 return NULL; | |
| 2028 } | |
| 2029 int32_t CXFA_WidgetData::GetChoiceListCommitOn() { | |
| 2030 CXFA_Node* pUIChild = GetUIChild(); | |
| 2031 if (pUIChild) { | |
| 2032 return pUIChild->GetEnum(XFA_ATTRIBUTE_CommitOn); | |
| 2033 } | |
| 2034 return XFA_GetAttributeDefaultValue_Enum( | |
| 2035 XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_CommitOn, XFA_XDPPACKET_Form); | |
| 2036 } | |
| 2037 FX_BOOL CXFA_WidgetData::IsChoiceListAllowTextEntry() { | |
| 2038 CXFA_Node* pUIChild = GetUIChild(); | |
| 2039 if (pUIChild) { | |
| 2040 return pUIChild->GetBoolean(XFA_ATTRIBUTE_TextEntry); | |
| 2041 } | |
| 2042 return XFA_GetAttributeDefaultValue_Boolean( | |
| 2043 XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_TextEntry, XFA_XDPPACKET_Form); | |
| 2044 } | |
| 2045 int32_t CXFA_WidgetData::GetChoiceListOpen() { | |
| 2046 CXFA_Node* pUIChild = GetUIChild(); | |
| 2047 if (pUIChild) { | |
| 2048 return pUIChild->GetEnum(XFA_ATTRIBUTE_Open); | |
| 2049 } | |
| 2050 return XFA_GetAttributeDefaultValue_Enum( | |
| 2051 XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_Open, XFA_XDPPACKET_Form); | |
| 2052 } | |
| 2053 FX_BOOL CXFA_WidgetData::IsListBox() { | |
| 2054 int32_t iOpenMode = GetChoiceListOpen(); | |
| 2055 return (iOpenMode == XFA_ATTRIBUTEENUM_Always || | |
| 2056 iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect); | |
| 2057 } | |
| 2058 int32_t CXFA_WidgetData::CountChoiceListItems(FX_BOOL bSaveValue) { | |
| 2059 CXFA_NodeArray pItems; | |
| 2060 CXFA_Node* pItem = NULL; | |
| 2061 int32_t iCount = 0; | |
| 2062 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2063 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2064 if (pNode->GetClassID() != XFA_ELEMENT_Items) { | |
| 2065 continue; | |
| 2066 } | |
| 2067 iCount++; | |
| 2068 pItems.Add(pNode); | |
| 2069 if (iCount == 2) { | |
| 2070 break; | |
| 2071 } | |
| 2072 } | |
| 2073 if (iCount == 0) { | |
| 2074 return 0; | |
| 2075 } | |
| 2076 pItem = pItems[0]; | |
| 2077 if (iCount > 1) { | |
| 2078 FX_BOOL bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2079 FX_BOOL bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2080 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) { | |
| 2081 pItem = pItems[1]; | |
| 2082 } | |
| 2083 } | |
| 2084 pItems.RemoveAll(); | |
| 2085 return pItem->CountChildren(XFA_ELEMENT_UNKNOWN); | |
| 2086 } | |
| 2087 FX_BOOL CXFA_WidgetData::GetChoiceListItem(CFX_WideString& wsText, | |
| 2088 int32_t nIndex, | |
| 2089 FX_BOOL bSaveValue) { | |
| 2090 wsText.Empty(); | |
| 2091 CXFA_NodeArray pItemsArray; | |
| 2092 CXFA_Node* pItems = NULL; | |
| 2093 int32_t iCount = 0; | |
| 2094 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2095 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2096 if (pNode->GetClassID() != XFA_ELEMENT_Items) { | |
| 2097 continue; | |
| 2098 } | |
| 2099 iCount++; | |
| 2100 pItemsArray.Add(pNode); | |
| 2101 if (iCount == 2) { | |
| 2102 break; | |
| 2103 } | |
| 2104 } | |
| 2105 if (iCount == 0) { | |
| 2106 return FALSE; | |
| 2107 } | |
| 2108 pItems = pItemsArray[0]; | |
| 2109 if (iCount > 1) { | |
| 2110 FX_BOOL bItemOneHasSave = pItemsArray[0]->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2111 FX_BOOL bItemTwoHasSave = pItemsArray[1]->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2112 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) { | |
| 2113 pItems = pItemsArray[1]; | |
| 2114 } | |
| 2115 } | |
| 2116 if (pItems) { | |
| 2117 CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_ELEMENT_UNKNOWN); | |
| 2118 if (pItem) { | |
| 2119 pItem->TryContent(wsText); | |
| 2120 return TRUE; | |
| 2121 } | |
| 2122 } | |
| 2123 return FALSE; | |
| 2124 } | |
| 2125 void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray, | |
| 2126 FX_BOOL bSaveValue) { | |
| 2127 CXFA_NodeArray pItems; | |
| 2128 CXFA_Node* pItem = NULL; | |
| 2129 int32_t iCount = 0; | |
| 2130 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2131 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2132 if (pNode->GetClassID() != XFA_ELEMENT_Items) { | |
| 2133 continue; | |
| 2134 } | |
| 2135 iCount++; | |
| 2136 pItems.Add(pNode); | |
| 2137 if (iCount == 2) { | |
| 2138 break; | |
| 2139 } | |
| 2140 } | |
| 2141 if (iCount == 0) { | |
| 2142 return; | |
| 2143 } | |
| 2144 pItem = pItems[0]; | |
| 2145 if (iCount > 1) { | |
| 2146 FX_BOOL bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2147 FX_BOOL bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2148 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) { | |
| 2149 pItem = pItems[1]; | |
| 2150 } | |
| 2151 } | |
| 2152 pItems.RemoveAll(); | |
| 2153 pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2154 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2155 pNode->TryContent(wsTextArray.Add()); | |
| 2156 } | |
| 2157 } | |
| 2158 int32_t CXFA_WidgetData::CountSelectedItems() { | |
| 2159 CFX_WideStringArray wsValueArray; | |
| 2160 GetSelectedItemsValue(wsValueArray); | |
| 2161 if (IsListBox() || !IsChoiceListAllowTextEntry()) { | |
| 2162 return wsValueArray.GetSize(); | |
| 2163 } | |
| 2164 int32_t iSelected = 0; | |
| 2165 CFX_WideStringArray wsSaveTextArray; | |
| 2166 GetChoiceListItems(wsSaveTextArray, TRUE); | |
| 2167 int32_t iValues = wsValueArray.GetSize(); | |
| 2168 for (int32_t i = 0; i < iValues; i++) { | |
| 2169 int32_t iSaves = wsSaveTextArray.GetSize(); | |
| 2170 for (int32_t j = 0; j < iSaves; j++) { | |
| 2171 if (wsValueArray[i] == wsSaveTextArray[j]) { | |
| 2172 iSelected++; | |
| 2173 break; | |
| 2174 } | |
| 2175 } | |
| 2176 } | |
| 2177 return iSelected; | |
| 2178 } | |
| 2179 int32_t CXFA_WidgetData::GetSelectedItem(int32_t nIndex) { | |
| 2180 CFX_WideStringArray wsValueArray; | |
| 2181 GetSelectedItemsValue(wsValueArray); | |
| 2182 CFX_WideStringArray wsSaveTextArray; | |
| 2183 GetChoiceListItems(wsSaveTextArray, TRUE); | |
| 2184 int32_t iSaves = wsSaveTextArray.GetSize(); | |
| 2185 for (int32_t j = 0; j < iSaves; j++) { | |
| 2186 if (wsValueArray[nIndex] == wsSaveTextArray[j]) { | |
| 2187 return j; | |
| 2188 } | |
| 2189 } | |
| 2190 return -1; | |
| 2191 } | |
| 2192 void CXFA_WidgetData::GetSelectedItems(CFX_Int32Array& iSelArray) { | |
| 2193 CFX_WideStringArray wsValueArray; | |
| 2194 GetSelectedItemsValue(wsValueArray); | |
| 2195 int32_t iValues = wsValueArray.GetSize(); | |
| 2196 if (iValues < 1) { | |
| 2197 return; | |
| 2198 } | |
| 2199 CFX_WideStringArray wsSaveTextArray; | |
| 2200 GetChoiceListItems(wsSaveTextArray, TRUE); | |
| 2201 int32_t iSaves = wsSaveTextArray.GetSize(); | |
| 2202 for (int32_t i = 0; i < iValues; i++) { | |
| 2203 for (int32_t j = 0; j < iSaves; j++) { | |
| 2204 if (wsValueArray[i] == wsSaveTextArray[j]) { | |
| 2205 iSelArray.Add(j); | |
| 2206 break; | |
| 2207 } | |
| 2208 } | |
| 2209 } | |
| 2210 } | |
| 2211 void CXFA_WidgetData::GetSelectedItemsValue( | |
| 2212 CFX_WideStringArray& wsSelTextArray) { | |
| 2213 CFX_WideString wsValue = GetRawValue(); | |
| 2214 if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | |
| 2215 if (!wsValue.IsEmpty()) { | |
| 2216 int32_t iStart = 0; | |
| 2217 int32_t iLength = wsValue.GetLength(); | |
| 2218 int32_t iEnd = wsValue.Find(L'\n', iStart); | |
| 2219 iEnd = (iEnd == -1) ? iLength : iEnd; | |
| 2220 while (iEnd >= iStart) { | |
| 2221 wsSelTextArray.Add(wsValue.Mid(iStart, iEnd - iStart)); | |
| 2222 iStart = iEnd + 1; | |
| 2223 if (iStart >= iLength) { | |
| 2224 break; | |
| 2225 } | |
| 2226 iEnd = wsValue.Find(L'\n', iStart); | |
| 2227 if (iEnd < 0) { | |
| 2228 wsSelTextArray.Add(wsValue.Mid(iStart, iLength - iStart)); | |
| 2229 } | |
| 2230 } | |
| 2231 } | |
| 2232 } else { | |
| 2233 wsSelTextArray.Add(wsValue); | |
| 2234 } | |
| 2235 } | |
| 2236 FX_BOOL CXFA_WidgetData::GetItemState(int32_t nIndex) { | |
| 2237 if (nIndex < 0) { | |
| 2238 return FALSE; | |
| 2239 } | |
| 2240 CFX_WideStringArray wsSaveTextArray; | |
| 2241 GetChoiceListItems(wsSaveTextArray, TRUE); | |
| 2242 if (wsSaveTextArray.GetSize() <= nIndex) { | |
| 2243 return FALSE; | |
| 2244 } | |
| 2245 CFX_WideStringArray wsValueArray; | |
| 2246 GetSelectedItemsValue(wsValueArray); | |
| 2247 int32_t iValues = wsValueArray.GetSize(); | |
| 2248 for (int32_t j = 0; j < iValues; j++) { | |
| 2249 if (wsValueArray[j] == wsSaveTextArray[nIndex]) { | |
| 2250 return TRUE; | |
| 2251 } | |
| 2252 } | |
| 2253 return FALSE; | |
| 2254 } | |
| 2255 void CXFA_WidgetData::SetItemState(int32_t nIndex, | |
| 2256 FX_BOOL bSelected, | |
| 2257 FX_BOOL bNotify, | |
| 2258 FX_BOOL bScriptModify, | |
| 2259 FX_BOOL bSyncData) { | |
| 2260 if (nIndex < 0) { | |
| 2261 return; | |
| 2262 } | |
| 2263 CFX_WideStringArray wsSaveTextArray; | |
| 2264 GetChoiceListItems(wsSaveTextArray, TRUE); | |
| 2265 if (wsSaveTextArray.GetSize() <= nIndex) { | |
| 2266 return; | |
| 2267 } | |
| 2268 int32_t iSel = -1; | |
| 2269 CFX_WideStringArray wsValueArray; | |
| 2270 GetSelectedItemsValue(wsValueArray); | |
| 2271 int32_t iValues = wsValueArray.GetSize(); | |
| 2272 for (int32_t j = 0; j < iValues; j++) { | |
| 2273 if (wsValueArray[j] == wsSaveTextArray[nIndex]) { | |
| 2274 iSel = j; | |
| 2275 break; | |
| 2276 } | |
| 2277 } | |
| 2278 if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | |
| 2279 if (bSelected) { | |
| 2280 if (iSel < 0) { | |
| 2281 CFX_WideString wsValue = GetRawValue(); | |
| 2282 if (!wsValue.IsEmpty()) { | |
| 2283 wsValue += L"\n"; | |
| 2284 } | |
| 2285 wsValue += wsSaveTextArray[nIndex]; | |
| 2286 m_pNode->SetContent(wsValue, wsValue, bNotify, bScriptModify, | |
| 2287 bSyncData); | |
| 2288 } | |
| 2289 } else if (iSel >= 0) { | |
| 2290 CFX_Int32Array iSelArray; | |
| 2291 GetSelectedItems(iSelArray); | |
| 2292 for (int32_t i = 0; i < iSelArray.GetSize(); i++) { | |
| 2293 if (iSelArray[i] == nIndex) { | |
| 2294 iSelArray.RemoveAt(i); | |
| 2295 break; | |
| 2296 } | |
| 2297 } | |
| 2298 SetSelectdItems(iSelArray, bNotify, bScriptModify, bSyncData); | |
| 2299 } | |
| 2300 } else { | |
| 2301 if (bSelected) { | |
| 2302 if (iSel < 0) { | |
| 2303 CFX_WideString wsSaveText = wsSaveTextArray[nIndex]; | |
| 2304 CFX_WideString wsFormatText(wsSaveText); | |
| 2305 GetFormatDataValue(wsSaveText, wsFormatText); | |
| 2306 m_pNode->SetContent(wsSaveText, wsFormatText, bNotify, bScriptModify, | |
| 2307 bSyncData); | |
| 2308 } | |
| 2309 } else if (iSel >= 0) { | |
| 2310 m_pNode->SetContent(CFX_WideString(), CFX_WideString(), bNotify, | |
| 2311 bScriptModify, bSyncData); | |
| 2312 } | |
| 2313 } | |
| 2314 } | |
| 2315 void CXFA_WidgetData::SetSelectdItems(CFX_Int32Array& iSelArray, | |
| 2316 FX_BOOL bNotify, | |
| 2317 FX_BOOL bScriptModify, | |
| 2318 FX_BOOL bSyncData) { | |
| 2319 CFX_WideString wsValue; | |
| 2320 int32_t iSize = iSelArray.GetSize(); | |
| 2321 if (iSize >= 1) { | |
| 2322 CFX_WideStringArray wsSaveTextArray; | |
| 2323 GetChoiceListItems(wsSaveTextArray, TRUE); | |
| 2324 CFX_WideString wsItemValue; | |
| 2325 for (int32_t i = 0; i < iSize; i++) { | |
| 2326 wsItemValue = (iSize == 1) | |
| 2327 ? wsSaveTextArray[iSelArray[i]] | |
| 2328 : wsSaveTextArray[iSelArray[i]] + FX_WSTRC(L"\n"); | |
| 2329 wsValue += wsItemValue; | |
| 2330 } | |
| 2331 } | |
| 2332 CFX_WideString wsFormat(wsValue); | |
| 2333 if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect) { | |
| 2334 GetFormatDataValue(wsValue, wsFormat); | |
| 2335 } | |
| 2336 m_pNode->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData); | |
| 2337 } | |
| 2338 void CXFA_WidgetData::ClearAllSelections() { | |
| 2339 CXFA_Node* pBind = m_pNode->GetBindData(); | |
| 2340 if (pBind && GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | |
| 2341 while (CXFA_Node* pChildNode = | |
| 2342 pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { | |
| 2343 pBind->RemoveChild(pChildNode); | |
| 2344 } | |
| 2345 } else { | |
| 2346 SyncValue(CFX_WideString(), FALSE); | |
| 2347 } | |
| 2348 } | |
| 2349 void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel, | |
| 2350 const CFX_WideString& wsValue, | |
| 2351 int32_t nIndex, | |
| 2352 FX_BOOL bNotify) { | |
| 2353 CFX_WideString wsNewValue(wsValue); | |
| 2354 if (wsNewValue.IsEmpty()) { | |
| 2355 wsNewValue = wsLabel; | |
| 2356 } | |
| 2357 CXFA_NodeArray listitems; | |
| 2358 int32_t iCount = 0; | |
| 2359 CXFA_Node* pItemNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2360 for (; pItemNode; | |
| 2361 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2362 if (pItemNode->GetClassID() != XFA_ELEMENT_Items) { | |
| 2363 continue; | |
| 2364 } | |
| 2365 listitems.Add(pItemNode); | |
| 2366 iCount++; | |
| 2367 } | |
| 2368 if (iCount < 1) { | |
| 2369 CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | |
| 2370 m_pNode->InsertChild(-1, pItems); | |
| 2371 InsertListTextItem(pItems, wsLabel, nIndex); | |
| 2372 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | |
| 2373 m_pNode->InsertChild(-1, pSaveItems); | |
| 2374 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); | |
| 2375 InsertListTextItem(pSaveItems, wsNewValue, nIndex); | |
| 2376 } else if (iCount > 1) { | |
| 2377 for (int32_t i = 0; i < 2; i++) { | |
| 2378 CXFA_Node* pNode = listitems[i]; | |
| 2379 FX_BOOL bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2380 if (bHasSave) { | |
| 2381 InsertListTextItem(pNode, wsNewValue, nIndex); | |
| 2382 } else { | |
| 2383 InsertListTextItem(pNode, wsLabel, nIndex); | |
| 2384 } | |
| 2385 } | |
| 2386 } else { | |
| 2387 CXFA_Node* pNode = listitems[0]; | |
| 2388 pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE); | |
| 2389 pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible); | |
| 2390 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | |
| 2391 m_pNode->InsertChild(-1, pSaveItems); | |
| 2392 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); | |
| 2393 pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden); | |
| 2394 listitems.RemoveAll(); | |
| 2395 CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2396 int32_t i = 0; | |
| 2397 while (pListNode) { | |
| 2398 CFX_WideString wsOldValue; | |
| 2399 pListNode->TryContent(wsOldValue); | |
| 2400 InsertListTextItem(pSaveItems, wsOldValue, i); | |
| 2401 i++; | |
| 2402 pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 2403 } | |
| 2404 InsertListTextItem(pNode, wsLabel, nIndex); | |
| 2405 InsertListTextItem(pSaveItems, wsNewValue, nIndex); | |
| 2406 } | |
| 2407 if (!bNotify) { | |
| 2408 return; | |
| 2409 } | |
| 2410 m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent( | |
| 2411 this, XFA_WIDGETEVENT_ListItemAdded, (void*)(const FX_WCHAR*)wsLabel, | |
| 2412 (void*)(const FX_WCHAR*)wsValue, (void*)(uintptr_t)nIndex); | |
| 2413 } | |
| 2414 void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue, | |
| 2415 CFX_WideString& wsLabel) { | |
| 2416 int32_t iCount = 0; | |
| 2417 CXFA_NodeArray listitems; | |
| 2418 CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2419 for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2420 if (pItems->GetClassID() != XFA_ELEMENT_Items) { | |
| 2421 continue; | |
| 2422 } | |
| 2423 iCount++; | |
| 2424 listitems.Add(pItems); | |
| 2425 } | |
| 2426 if (iCount <= 1) { | |
| 2427 wsLabel = wsValue; | |
| 2428 } else { | |
| 2429 CXFA_Node* pLabelItems = listitems[0]; | |
| 2430 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2431 CXFA_Node* pSaveItems = NULL; | |
| 2432 if (bSave) { | |
| 2433 pSaveItems = pLabelItems; | |
| 2434 pLabelItems = listitems[1]; | |
| 2435 } else { | |
| 2436 pSaveItems = listitems[1]; | |
| 2437 } | |
| 2438 iCount = 0; | |
| 2439 int32_t iSearch = -1; | |
| 2440 CFX_WideString wsContent; | |
| 2441 CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2442 for (; pChildItem; | |
| 2443 pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2444 pChildItem->TryContent(wsContent); | |
| 2445 if (wsContent == wsValue) { | |
| 2446 iSearch = iCount; | |
| 2447 break; | |
| 2448 } | |
| 2449 iCount++; | |
| 2450 } | |
| 2451 if (iSearch < 0) { | |
| 2452 return; | |
| 2453 } | |
| 2454 if (CXFA_Node* pText = | |
| 2455 pLabelItems->GetChild(iSearch, XFA_ELEMENT_UNKNOWN)) { | |
| 2456 pText->TryContent(wsLabel); | |
| 2457 } | |
| 2458 } | |
| 2459 } | |
| 2460 void CXFA_WidgetData::GetItemValue(const CFX_WideStringC& wsLabel, | |
| 2461 CFX_WideString& wsValue) { | |
| 2462 int32_t iCount = 0; | |
| 2463 CXFA_NodeArray listitems; | |
| 2464 CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2465 for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2466 if (pItems->GetClassID() != XFA_ELEMENT_Items) { | |
| 2467 continue; | |
| 2468 } | |
| 2469 iCount++; | |
| 2470 listitems.Add(pItems); | |
| 2471 } | |
| 2472 if (iCount <= 1) { | |
| 2473 wsValue = wsLabel; | |
| 2474 } else { | |
| 2475 CXFA_Node* pLabelItems = listitems[0]; | |
| 2476 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); | |
| 2477 CXFA_Node* pSaveItems = NULL; | |
| 2478 if (bSave) { | |
| 2479 pSaveItems = pLabelItems; | |
| 2480 pLabelItems = listitems[1]; | |
| 2481 } else { | |
| 2482 pSaveItems = listitems[1]; | |
| 2483 } | |
| 2484 iCount = 0; | |
| 2485 int32_t iSearch = -1; | |
| 2486 CFX_WideString wsContent; | |
| 2487 CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2488 for (; pChildItem; | |
| 2489 pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2490 pChildItem->TryContent(wsContent); | |
| 2491 if (wsContent == wsLabel) { | |
| 2492 iSearch = iCount; | |
| 2493 break; | |
| 2494 } | |
| 2495 iCount++; | |
| 2496 } | |
| 2497 if (iSearch < 0) { | |
| 2498 return; | |
| 2499 } | |
| 2500 if (CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_ELEMENT_UNKNOWN)) { | |
| 2501 pText->TryContent(wsValue); | |
| 2502 } | |
| 2503 } | |
| 2504 } | |
| 2505 FX_BOOL CXFA_WidgetData::DeleteItem(int32_t nIndex, | |
| 2506 FX_BOOL bNotify, | |
| 2507 FX_BOOL bScriptModify, | |
| 2508 FX_BOOL bSyncData) { | |
| 2509 FX_BOOL bSetValue = FALSE; | |
| 2510 CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2511 for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 2512 if (pItems->GetClassID() != XFA_ELEMENT_Items) { | |
| 2513 continue; | |
| 2514 } | |
| 2515 if (nIndex < 0) { | |
| 2516 while (CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild)) { | |
| 2517 pItems->RemoveChild(pNode); | |
| 2518 } | |
| 2519 } else { | |
| 2520 if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) { | |
| 2521 SetItemState(nIndex, FALSE, TRUE, bScriptModify, bSyncData); | |
| 2522 bSetValue = TRUE; | |
| 2523 } | |
| 2524 int32_t i = 0; | |
| 2525 CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 2526 while (pNode) { | |
| 2527 if (i == nIndex) { | |
| 2528 pItems->RemoveChild(pNode); | |
| 2529 break; | |
| 2530 } | |
| 2531 i++; | |
| 2532 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
| 2533 } | |
| 2534 } | |
| 2535 } | |
| 2536 if (!bNotify) { | |
| 2537 return TRUE; | |
| 2538 } | |
| 2539 m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent( | |
| 2540 this, XFA_WIDGETEVENT_ListItemRemoved, (void*)(uintptr_t)nIndex); | |
| 2541 return TRUE; | |
| 2542 } | |
| 2543 int32_t CXFA_WidgetData::GetHorizontalScrollPolicy() { | |
| 2544 CXFA_Node* pUIChild = GetUIChild(); | |
| 2545 if (pUIChild) { | |
| 2546 return pUIChild->GetEnum(XFA_ATTRIBUTE_HScrollPolicy); | |
| 2547 } | |
| 2548 return XFA_ATTRIBUTEENUM_Auto; | |
| 2549 } | |
| 2550 int32_t CXFA_WidgetData::GetNumberOfCells() { | |
| 2551 CXFA_Node* pUIChild = GetUIChild(); | |
| 2552 if (!pUIChild) { | |
| 2553 return -1; | |
| 2554 } | |
| 2555 if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_ELEMENT_Comb)) { | |
| 2556 return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells); | |
| 2557 } | |
| 2558 return -1; | |
| 2559 } | |
| 2560 FX_BOOL CXFA_WidgetData::IsDateTimeEditUsePicker() { | |
| 2561 return TRUE; | |
| 2562 } | |
| 2563 CFX_WideString CXFA_WidgetData::GetBarcodeType() { | |
| 2564 CXFA_Node* pUIChild = GetUIChild(); | |
| 2565 return pUIChild ? pUIChild->GetCData(XFA_ATTRIBUTE_Type) : NULL; | |
| 2566 } | |
| 2567 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { | |
| 2568 CXFA_Node* pUIChild = GetUIChild(); | |
| 2569 CFX_WideString wsCharEncoding; | |
| 2570 if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) { | |
| 2571 if (wsCharEncoding.CompareNoCase(L"UTF-16")) { | |
| 2572 val = CHAR_ENCODING_UNICODE; | |
| 2573 return TRUE; | |
| 2574 } else if (wsCharEncoding.CompareNoCase(L"UTF-8")) { | |
| 2575 val = CHAR_ENCODING_UTF8; | |
| 2576 return TRUE; | |
| 2577 } | |
| 2578 } | |
| 2579 return FALSE; | |
| 2580 } | |
| 2581 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(int32_t& val) { | |
| 2582 CXFA_Node* pUIChild = GetUIChild(); | |
| 2583 XFA_ATTRIBUTEENUM eChecksum; | |
| 2584 if (pUIChild->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) { | |
| 2585 switch (eChecksum) { | |
| 2586 case XFA_ATTRIBUTEENUM_None: | |
| 2587 val = 0; | |
| 2588 return TRUE; | |
| 2589 case XFA_ATTRIBUTEENUM_Auto: | |
| 2590 val = 1; | |
| 2591 return TRUE; | |
| 2592 case XFA_ATTRIBUTEENUM_1mod10: | |
| 2593 break; | |
| 2594 case XFA_ATTRIBUTEENUM_1mod10_1mod11: | |
| 2595 break; | |
| 2596 case XFA_ATTRIBUTEENUM_2mod10: | |
| 2597 break; | |
| 2598 default: | |
| 2599 break; | |
| 2600 } | |
| 2601 } | |
| 2602 return FALSE; | |
| 2603 } | |
| 2604 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t& val) { | |
| 2605 CXFA_Node* pUIChild = GetUIChild(); | |
| 2606 CFX_WideString wsDataLength; | |
| 2607 if (pUIChild->TryCData(XFA_ATTRIBUTE_DataLength, wsDataLength)) { | |
| 2608 val = FXSYS_wtoi(wsDataLength); | |
| 2609 return TRUE; | |
| 2610 } | |
| 2611 return FALSE; | |
| 2612 } | |
| 2613 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_StartChar(FX_CHAR& val) { | |
| 2614 CXFA_Node* pUIChild = GetUIChild(); | |
| 2615 CFX_WideStringC wsStartEndChar; | |
| 2616 if (pUIChild->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) { | |
| 2617 if (wsStartEndChar.GetLength()) { | |
| 2618 val = (FX_CHAR)wsStartEndChar.GetAt(0); | |
| 2619 return TRUE; | |
| 2620 } | |
| 2621 } | |
| 2622 return FALSE; | |
| 2623 } | |
| 2624 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_EndChar(FX_CHAR& val) { | |
| 2625 CXFA_Node* pUIChild = GetUIChild(); | |
| 2626 CFX_WideStringC wsStartEndChar; | |
| 2627 if (pUIChild->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) { | |
| 2628 if (wsStartEndChar.GetLength()) { | |
| 2629 val = (FX_CHAR)wsStartEndChar.GetAt(0); | |
| 2630 return TRUE; | |
| 2631 } | |
| 2632 } | |
| 2633 return FALSE; | |
| 2634 } | |
| 2635 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ECLevel(int32_t& val) { | |
| 2636 CXFA_Node* pUIChild = GetUIChild(); | |
| 2637 CFX_WideString wsECLevel; | |
| 2638 if (pUIChild->TryCData(XFA_ATTRIBUTE_ErrorCorrectionLevel, wsECLevel)) { | |
| 2639 val = FXSYS_wtoi(wsECLevel); | |
| 2640 return TRUE; | |
| 2641 } | |
| 2642 return FALSE; | |
| 2643 } | |
| 2644 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t& val) { | |
| 2645 CXFA_Node* pUIChild = GetUIChild(); | |
| 2646 CXFA_Measurement mModuleWidthHeight; | |
| 2647 if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleWidth, mModuleWidthHeight)) { | |
| 2648 val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); | |
| 2649 return TRUE; | |
| 2650 } | |
| 2651 return FALSE; | |
| 2652 } | |
| 2653 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t& val) { | |
| 2654 CXFA_Node* pUIChild = GetUIChild(); | |
| 2655 CXFA_Measurement mModuleWidthHeight; | |
| 2656 if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleHeight, mModuleWidthHeight)) { | |
| 2657 val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); | |
| 2658 return TRUE; | |
| 2659 } | |
| 2660 return FALSE; | |
| 2661 } | |
| 2662 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(FX_BOOL& val) { | |
| 2663 CXFA_Node* pUIChild = GetUIChild(); | |
| 2664 FX_BOOL bPrintCheckDigit; | |
| 2665 if (pUIChild->TryBoolean(XFA_ATTRIBUTE_PrintCheckDigit, bPrintCheckDigit)) { | |
| 2666 val = bPrintCheckDigit; | |
| 2667 return TRUE; | |
| 2668 } | |
| 2669 return FALSE; | |
| 2670 } | |
| 2671 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t& val) { | |
| 2672 CXFA_Node* pUIChild = GetUIChild(); | |
| 2673 XFA_ATTRIBUTEENUM eTextLocation; | |
| 2674 if (pUIChild->TryEnum(XFA_ATTRIBUTE_TextLocation, eTextLocation)) { | |
| 2675 switch (eTextLocation) { | |
| 2676 case XFA_ATTRIBUTEENUM_None: | |
| 2677 val = BC_TEXT_LOC_NONE; | |
| 2678 return TRUE; | |
| 2679 case XFA_ATTRIBUTEENUM_Above: | |
| 2680 val = BC_TEXT_LOC_ABOVE; | |
| 2681 return TRUE; | |
| 2682 case XFA_ATTRIBUTEENUM_Below: | |
| 2683 val = BC_TEXT_LOC_BELOW; | |
| 2684 return TRUE; | |
| 2685 case XFA_ATTRIBUTEENUM_AboveEmbedded: | |
| 2686 val = BC_TEXT_LOC_ABOVEEMBED; | |
| 2687 return TRUE; | |
| 2688 case XFA_ATTRIBUTEENUM_BelowEmbedded: | |
| 2689 val = BC_TEXT_LOC_BELOWEMBED; | |
| 2690 return TRUE; | |
| 2691 default: | |
| 2692 break; | |
| 2693 } | |
| 2694 } | |
| 2695 return FALSE; | |
| 2696 } | |
| 2697 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Truncate(FX_BOOL& val) { | |
| 2698 CXFA_Node* pUIChild = GetUIChild(); | |
| 2699 FX_BOOL bTruncate; | |
| 2700 if (pUIChild->TryBoolean(XFA_ATTRIBUTE_Truncate, bTruncate)) { | |
| 2701 val = bTruncate; | |
| 2702 return TRUE; | |
| 2703 } | |
| 2704 return FALSE; | |
| 2705 } | |
| 2706 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val) { | |
| 2707 CXFA_Node* pUIChild = GetUIChild(); | |
| 2708 CFX_WideString wsWideNarrowRatio; | |
| 2709 if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) { | |
| 2710 FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':'); | |
| 2711 FX_FLOAT fRatio = 0; | |
| 2712 if (ptPos >= 0) { | |
| 2713 fRatio = (FX_FLOAT)FXSYS_wtoi(wsWideNarrowRatio); | |
| 2714 } else { | |
| 2715 int32_t fA, fB; | |
| 2716 fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos)); | |
| 2717 fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1)); | |
| 2718 if (fB) { | |
| 2719 fRatio = (FX_FLOAT)fA / fB; | |
| 2720 } | |
| 2721 } | |
| 2722 val = fRatio; | |
| 2723 return TRUE; | |
| 2724 } | |
| 2725 return FALSE; | |
| 2726 } | |
| 2727 void CXFA_WidgetData::GetPasswordChar(CFX_WideString& wsPassWord) { | |
| 2728 CXFA_Node* pUIChild = GetUIChild(); | |
| 2729 if (pUIChild) { | |
| 2730 pUIChild->TryCData(XFA_ATTRIBUTE_PasswordChar, wsPassWord); | |
| 2731 } else { | |
| 2732 wsPassWord = XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT_PasswordEdit, | |
| 2733 XFA_ATTRIBUTE_PasswordChar, | |
| 2734 XFA_XDPPACKET_Form); | |
| 2735 } | |
| 2736 } | |
| 2737 FX_BOOL CXFA_WidgetData::IsAllowRichText() { | |
| 2738 CXFA_Node* pUIChild = GetUIChild(); | |
| 2739 FX_BOOL bValue = FALSE; | |
| 2740 if (pUIChild && | |
| 2741 pUIChild->TryBoolean(XFA_ATTRIBUTE_AllowRichText, bValue, FALSE)) { | |
| 2742 return bValue; | |
| 2743 } | |
| 2744 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { | |
| 2745 if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { | |
| 2746 return pChild->GetClassID() == XFA_ELEMENT_ExData; | |
| 2747 } | |
| 2748 } | |
| 2749 return FALSE; | |
| 2750 } | |
| 2751 FX_BOOL CXFA_WidgetData::IsMultiLine() { | |
| 2752 CXFA_Node* pUIChild = GetUIChild(); | |
| 2753 if (pUIChild) { | |
| 2754 return pUIChild->GetBoolean(XFA_ATTRIBUTE_MultiLine); | |
| 2755 } | |
| 2756 return XFA_GetAttributeDefaultValue_Boolean( | |
| 2757 XFA_ELEMENT_TextEdit, XFA_ATTRIBUTE_MultiLine, XFA_XDPPACKET_Form); | |
| 2758 } | |
| 2759 int32_t CXFA_WidgetData::GetVerticalScrollPolicy() { | |
| 2760 CXFA_Node* pUIChild = GetUIChild(); | |
| 2761 if (pUIChild) { | |
| 2762 return pUIChild->GetEnum(XFA_ATTRIBUTE_VScrollPolicy); | |
| 2763 } | |
| 2764 return XFA_GetAttributeDefaultValue_Enum( | |
| 2765 XFA_ELEMENT_TextEdit, XFA_ATTRIBUTE_VScrollPolicy, XFA_XDPPACKET_Form); | |
| 2766 } | |
| 2767 int32_t CXFA_WidgetData::GetMaxChars(XFA_ELEMENT& eType) { | |
| 2768 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { | |
| 2769 if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { | |
| 2770 switch (pChild->GetClassID()) { | |
| 2771 case XFA_ELEMENT_Text: | |
| 2772 eType = XFA_ELEMENT_Text; | |
| 2773 return pChild->GetInteger(XFA_ATTRIBUTE_MaxChars); | |
| 2774 case XFA_ELEMENT_ExData: { | |
| 2775 eType = XFA_ELEMENT_ExData; | |
| 2776 int32_t iMax = pChild->GetInteger(XFA_ATTRIBUTE_MaxLength); | |
| 2777 return iMax < 0 ? 0 : iMax; | |
| 2778 } | |
| 2779 default: | |
| 2780 break; | |
| 2781 } | |
| 2782 } | |
| 2783 } | |
| 2784 return 0; | |
| 2785 } | |
| 2786 FX_BOOL CXFA_WidgetData::GetFracDigits(int32_t& iFracDigits) { | |
| 2787 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { | |
| 2788 if (CXFA_Node* pChild = pNode->GetChild(0, XFA_ELEMENT_Decimal)) { | |
| 2789 return pChild->TryInteger(XFA_ATTRIBUTE_FracDigits, iFracDigits); | |
| 2790 } | |
| 2791 } | |
| 2792 iFracDigits = -1; | |
| 2793 return FALSE; | |
| 2794 } | |
| 2795 FX_BOOL CXFA_WidgetData::GetLeadDigits(int32_t& iLeadDigits) { | |
| 2796 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { | |
| 2797 if (CXFA_Node* pChild = pNode->GetChild(0, XFA_ELEMENT_Decimal)) { | |
| 2798 return pChild->TryInteger(XFA_ATTRIBUTE_LeadDigits, iLeadDigits); | |
| 2799 } | |
| 2800 } | |
| 2801 iLeadDigits = -1; | |
| 2802 return FALSE; | |
| 2803 } | |
| 2804 CFX_WideString XFA_NumericLimit(const CFX_WideString& wsValue, | |
| 2805 int32_t iLead, | |
| 2806 int32_t iTread) { | |
| 2807 if ((iLead == -1) && (iTread == -1)) { | |
| 2808 return wsValue; | |
| 2809 } | |
| 2810 CFX_WideString wsRet; | |
| 2811 int32_t iLead_ = 0, iTread_ = -1; | |
| 2812 int32_t iCount = wsValue.GetLength(); | |
| 2813 if (iCount == 0) { | |
| 2814 return wsValue; | |
| 2815 } | |
| 2816 int32_t i = 0; | |
| 2817 if (wsValue[i] == L'-') { | |
| 2818 wsRet += L'-'; | |
| 2819 i++; | |
| 2820 } | |
| 2821 for (; i < iCount; i++) { | |
| 2822 FX_WCHAR wc = wsValue[i]; | |
| 2823 if (XFA_IsDigit(wc)) { | |
| 2824 if (iLead >= 0) { | |
| 2825 iLead_++; | |
| 2826 if (iLead_ > iLead) { | |
| 2827 return L"0"; | |
| 2828 } | |
| 2829 } else if (iTread_ >= 0) { | |
| 2830 iTread_++; | |
| 2831 if (iTread_ > iTread) { | |
| 2832 if (iTread != -1) { | |
| 2833 CFX_Decimal wsDeci = CFX_Decimal(wsValue); | |
| 2834 wsDeci.SetScale(iTread); | |
| 2835 wsRet = wsDeci; | |
| 2836 } | |
| 2837 return wsRet; | |
| 2838 } | |
| 2839 } | |
| 2840 } else if (wc == L'.') { | |
| 2841 iTread_ = 0; | |
| 2842 iLead = -1; | |
| 2843 } | |
| 2844 wsRet += wc; | |
| 2845 } | |
| 2846 return wsRet; | |
| 2847 } | |
| 2848 FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue, | |
| 2849 XFA_VALUEPICTURE eValueType) { | |
| 2850 if (wsValue.IsEmpty()) { | |
| 2851 SyncValue(wsValue, TRUE); | |
| 2852 return TRUE; | |
| 2853 } | |
| 2854 m_bPreNull = m_bIsNull; | |
| 2855 m_bIsNull = FALSE; | |
| 2856 CFX_WideString wsNewText(wsValue); | |
| 2857 CFX_WideString wsPicture; | |
| 2858 GetPictureContent(wsPicture, eValueType); | |
| 2859 FX_BOOL bValidate = TRUE; | |
| 2860 FX_BOOL bSyncData = FALSE; | |
| 2861 CXFA_Node* pNode = GetUIChild(); | |
| 2862 if (!pNode) { | |
| 2863 return TRUE; | |
| 2864 } | |
| 2865 XFA_ELEMENT uiType = pNode->GetClassID(); | |
| 2866 if (!wsPicture.IsEmpty()) { | |
| 2867 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); | |
| 2868 IFX_Locale* pLocale = GetLocal(); | |
| 2869 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); | |
| 2870 bValidate = | |
| 2871 widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture); | |
| 2872 if (bValidate) { | |
| 2873 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText, | |
| 2874 wsPicture, pLocale, pLocalMgr); | |
| 2875 wsNewText = widgetValue.GetValue(); | |
| 2876 if (uiType == XFA_ELEMENT_NumericEdit) { | |
| 2877 int32_t iLeadDigits = 0; | |
| 2878 int32_t iFracDigits = 0; | |
| 2879 GetLeadDigits(iLeadDigits); | |
| 2880 GetFracDigits(iFracDigits); | |
| 2881 wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits); | |
| 2882 } | |
| 2883 bSyncData = TRUE; | |
| 2884 } | |
| 2885 } else { | |
| 2886 if (uiType == XFA_ELEMENT_NumericEdit) { | |
| 2887 if (wsNewText != FX_WSTRC(L"0")) { | |
| 2888 int32_t iLeadDigits = 0; | |
| 2889 int32_t iFracDigits = 0; | |
| 2890 GetLeadDigits(iLeadDigits); | |
| 2891 GetFracDigits(iFracDigits); | |
| 2892 wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits); | |
| 2893 } | |
| 2894 bSyncData = TRUE; | |
| 2895 } | |
| 2896 } | |
| 2897 if (uiType != XFA_ELEMENT_NumericEdit || bSyncData) { | |
| 2898 SyncValue(wsNewText, TRUE); | |
| 2899 } | |
| 2900 return bValidate; | |
| 2901 } | |
| 2902 FX_BOOL CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture, | |
| 2903 XFA_VALUEPICTURE ePicture) { | |
| 2904 if (ePicture == XFA_VALUEPICTURE_Raw) { | |
| 2905 return FALSE; | |
| 2906 } | |
| 2907 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); | |
| 2908 switch (ePicture) { | |
| 2909 case XFA_VALUEPICTURE_Display: { | |
| 2910 if (CXFA_Node* pFormat = m_pNode->GetChild(0, XFA_ELEMENT_Format)) { | |
| 2911 if (CXFA_Node* pPicture = pFormat->GetChild(0, XFA_ELEMENT_Picture)) { | |
| 2912 if (pPicture->TryContent(wsPicture)) { | |
| 2913 return TRUE; | |
| 2914 } | |
| 2915 } | |
| 2916 } | |
| 2917 CFX_WideString wsDataPicture, wsTimePicture; | |
| 2918 IFX_Locale* pLocale = GetLocal(); | |
| 2919 if (!pLocale) { | |
| 2920 return FALSE; | |
| 2921 } | |
| 2922 FX_DWORD dwType = widgetValue.GetType(); | |
| 2923 switch (dwType) { | |
| 2924 case XFA_VT_DATE: | |
| 2925 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, | |
| 2926 wsPicture); | |
| 2927 break; | |
| 2928 case XFA_VT_TIME: | |
| 2929 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, | |
| 2930 wsPicture); | |
| 2931 break; | |
| 2932 case XFA_VT_DATETIME: | |
| 2933 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, | |
| 2934 wsDataPicture); | |
| 2935 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, | |
| 2936 wsTimePicture); | |
| 2937 wsPicture = wsDataPicture + FX_WSTRC(L"T") + wsTimePicture; | |
| 2938 break; | |
| 2939 case XFA_VT_DECIMAL: | |
| 2940 case XFA_VT_FLOAT: | |
| 2941 break; | |
| 2942 default: | |
| 2943 break; | |
| 2944 } | |
| 2945 } | |
| 2946 return TRUE; | |
| 2947 case XFA_VALUEPICTURE_Edit: { | |
| 2948 CXFA_Node* pUI = m_pNode->GetChild(0, XFA_ELEMENT_Ui); | |
| 2949 if (pUI) { | |
| 2950 if (CXFA_Node* pPicture = pUI->GetChild(0, XFA_ELEMENT_Picture)) { | |
| 2951 if (pPicture->TryContent(wsPicture)) { | |
| 2952 return TRUE; | |
| 2953 } | |
| 2954 } | |
| 2955 } | |
| 2956 { | |
| 2957 CFX_WideString wsDataPicture, wsTimePicture; | |
| 2958 IFX_Locale* pLocale = GetLocal(); | |
| 2959 if (!pLocale) { | |
| 2960 return FALSE; | |
| 2961 } | |
| 2962 FX_DWORD dwType = widgetValue.GetType(); | |
| 2963 switch (dwType) { | |
| 2964 case XFA_VT_DATE: | |
| 2965 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, | |
| 2966 wsPicture); | |
| 2967 break; | |
| 2968 case XFA_VT_TIME: | |
| 2969 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, | |
| 2970 wsPicture); | |
| 2971 break; | |
| 2972 case XFA_VT_DATETIME: | |
| 2973 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, | |
| 2974 wsDataPicture); | |
| 2975 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, | |
| 2976 wsTimePicture); | |
| 2977 wsPicture = wsDataPicture + L"T" + wsTimePicture; | |
| 2978 break; | |
| 2979 default: | |
| 2980 break; | |
| 2981 } | |
| 2982 } | |
| 2983 } | |
| 2984 return TRUE; | |
| 2985 case XFA_VALUEPICTURE_DataBind: { | |
| 2986 if (CXFA_Bind bind = GetBind()) { | |
| 2987 bind.GetPicture(wsPicture); | |
| 2988 return TRUE; | |
| 2989 } | |
| 2990 } break; | |
| 2991 default: | |
| 2992 break; | |
| 2993 } | |
| 2994 return FALSE; | |
| 2995 } | |
| 2996 IFX_Locale* CXFA_WidgetData::GetLocal() { | |
| 2997 IFX_Locale* pLocale = NULL; | |
| 2998 if (!m_pNode) { | |
| 2999 return pLocale; | |
| 3000 } | |
| 3001 FX_BOOL bLocale = FALSE; | |
| 3002 CFX_WideString wsLocaleName; | |
| 3003 bLocale = m_pNode->GetLocaleName(wsLocaleName); | |
| 3004 if (bLocale) { | |
| 3005 if (wsLocaleName.Equal(FX_WSTRC(L"ambient"))) { | |
| 3006 pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); | |
| 3007 } else { | |
| 3008 pLocale = | |
| 3009 m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName); | |
| 3010 } | |
| 3011 } | |
| 3012 return pLocale; | |
| 3013 } | |
| 3014 static FX_BOOL XFA_SplitDateTime(const CFX_WideString& wsDateTime, | |
| 3015 CFX_WideString& wsDate, | |
| 3016 CFX_WideString& wsTime) { | |
| 3017 wsDate = L""; | |
| 3018 wsTime = L""; | |
| 3019 if (wsDateTime.IsEmpty()) { | |
| 3020 return FALSE; | |
| 3021 } | |
| 3022 int nSplitIndex = -1; | |
| 3023 nSplitIndex = wsDateTime.Find('T'); | |
| 3024 if (nSplitIndex < 0) { | |
| 3025 nSplitIndex = wsDateTime.Find(' '); | |
| 3026 } | |
| 3027 if (nSplitIndex < 0) { | |
| 3028 return FALSE; | |
| 3029 } | |
| 3030 wsDate = wsDateTime.Left(nSplitIndex); | |
| 3031 if (!wsDate.IsEmpty()) { | |
| 3032 int32_t iCount = wsDate.GetLength(); | |
| 3033 int32_t i = 0; | |
| 3034 for (i = 0; i < iCount; i++) { | |
| 3035 if (wsDate[i] >= '0' && wsDate[i] <= '9') { | |
| 3036 break; | |
| 3037 } | |
| 3038 } | |
| 3039 if (i == iCount) { | |
| 3040 return FALSE; | |
| 3041 } | |
| 3042 } | |
| 3043 wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); | |
| 3044 if (!wsTime.IsEmpty()) { | |
| 3045 int32_t iCount = wsTime.GetLength(); | |
| 3046 int32_t i = 0; | |
| 3047 for (i = 0; i < iCount; i++) { | |
| 3048 if (wsTime[i] >= '0' && wsTime[i] <= '9') { | |
| 3049 break; | |
| 3050 } | |
| 3051 } | |
| 3052 if (i == iCount) { | |
| 3053 return FALSE; | |
| 3054 } | |
| 3055 } | |
| 3056 return TRUE; | |
| 3057 } | |
| 3058 | |
| 3059 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, | |
| 3060 XFA_VALUEPICTURE eValueType) { | |
| 3061 wsValue = m_pNode->GetContent(); | |
| 3062 | |
| 3063 if (eValueType == XFA_VALUEPICTURE_Display) | |
| 3064 GetItemLabel(wsValue, wsValue); | |
| 3065 | |
| 3066 CFX_WideString wsPicture; | |
| 3067 GetPictureContent(wsPicture, eValueType); | |
| 3068 CXFA_Node* pNode = GetUIChild(); | |
| 3069 if (!pNode) | |
| 3070 return TRUE; | |
| 3071 | |
| 3072 XFA_ELEMENT uiType = GetUIChild()->GetClassID(); | |
| 3073 switch (uiType) { | |
| 3074 case XFA_ELEMENT_ChoiceList: { | |
| 3075 if (eValueType == XFA_VALUEPICTURE_Display) { | |
| 3076 int32_t iSelItemIndex = GetSelectedItem(0); | |
| 3077 if (iSelItemIndex >= 0) { | |
| 3078 GetChoiceListItem(wsValue, iSelItemIndex); | |
| 3079 wsPicture.Empty(); | |
| 3080 } | |
| 3081 } | |
| 3082 } break; | |
| 3083 case XFA_ELEMENT_NumericEdit: | |
| 3084 if (eValueType != XFA_VALUEPICTURE_Raw && wsPicture.IsEmpty()) { | |
| 3085 IFX_Locale* pLocale = GetLocal(); | |
| 3086 if (eValueType == XFA_VALUEPICTURE_Display && pLocale) { | |
| 3087 CFX_WideString wsOutput; | |
| 3088 NormalizeNumStr(wsValue, wsOutput); | |
| 3089 FormatNumStr(wsOutput, pLocale, wsOutput); | |
| 3090 wsValue = wsOutput; | |
| 3091 } | |
| 3092 } | |
| 3093 break; | |
| 3094 default: | |
| 3095 break; | |
| 3096 } | |
| 3097 if (wsPicture.IsEmpty()) | |
| 3098 return TRUE; | |
| 3099 | |
| 3100 if (IFX_Locale* pLocale = GetLocal()) { | |
| 3101 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); | |
| 3102 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); | |
| 3103 switch (widgetValue.GetType()) { | |
| 3104 case XFA_VT_DATE: { | |
| 3105 CFX_WideString wsDate, wsTime; | |
| 3106 if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { | |
| 3107 CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); | |
| 3108 if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) | |
| 3109 return TRUE; | |
| 3110 } | |
| 3111 break; | |
| 3112 } | |
| 3113 case XFA_VT_TIME: { | |
| 3114 CFX_WideString wsDate, wsTime; | |
| 3115 if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { | |
| 3116 CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); | |
| 3117 if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) | |
| 3118 return TRUE; | |
| 3119 } | |
| 3120 break; | |
| 3121 } | |
| 3122 default: | |
| 3123 break; | |
| 3124 } | |
| 3125 widgetValue.FormatPatterns(wsValue, wsPicture, pLocale, eValueType); | |
| 3126 } | |
| 3127 return TRUE; | |
| 3128 } | |
| 3129 | |
| 3130 FX_BOOL CXFA_WidgetData::GetNormalizeDataValue( | |
| 3131 const CFX_WideStringC& wsValue, | |
| 3132 CFX_WideString& wsNormalizeValue) { | |
| 3133 wsNormalizeValue = wsValue; | |
| 3134 if (wsValue.IsEmpty()) { | |
| 3135 return TRUE; | |
| 3136 } | |
| 3137 CFX_WideString wsPicture; | |
| 3138 GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); | |
| 3139 if (wsPicture.IsEmpty()) { | |
| 3140 return TRUE; | |
| 3141 } | |
| 3142 FXSYS_assert(GetNode()); | |
| 3143 CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); | |
| 3144 IFX_Locale* pLocale = GetLocal(); | |
| 3145 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); | |
| 3146 if (widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture)) { | |
| 3147 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNormalizeValue, | |
| 3148 wsPicture, pLocale, pLocalMgr); | |
| 3149 wsNormalizeValue = widgetValue.GetValue(); | |
| 3150 return TRUE; | |
| 3151 } | |
| 3152 return FALSE; | |
| 3153 } | |
| 3154 FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideStringC& wsValue, | |
| 3155 CFX_WideString& wsFormatedValue) { | |
| 3156 wsFormatedValue = wsValue; | |
| 3157 if (wsValue.IsEmpty()) { | |
| 3158 return TRUE; | |
| 3159 } | |
| 3160 CFX_WideString wsPicture; | |
| 3161 GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); | |
| 3162 if (wsPicture.IsEmpty()) { | |
| 3163 return TRUE; | |
| 3164 } | |
| 3165 if (IFX_Locale* pLocale = GetLocal()) { | |
| 3166 FXSYS_assert(GetNode()); | |
| 3167 CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_ELEMENT_Value); | |
| 3168 if (!pNodeValue) { | |
| 3169 return FALSE; | |
| 3170 } | |
| 3171 CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 3172 if (!pValueChild) { | |
| 3173 return FALSE; | |
| 3174 } | |
| 3175 int32_t iVTType = XFA_VT_NULL; | |
| 3176 XFA_ELEMENT eType = pValueChild->GetClassID(); | |
| 3177 switch (eType) { | |
| 3178 case XFA_ELEMENT_Decimal: | |
| 3179 iVTType = XFA_VT_DECIMAL; | |
| 3180 break; | |
| 3181 case XFA_ELEMENT_Float: | |
| 3182 iVTType = XFA_VT_FLOAT; | |
| 3183 break; | |
| 3184 case XFA_ELEMENT_Date: | |
| 3185 iVTType = XFA_VT_DATE; | |
| 3186 break; | |
| 3187 case XFA_ELEMENT_Time: | |
| 3188 iVTType = XFA_VT_TIME; | |
| 3189 break; | |
| 3190 case XFA_ELEMENT_DateTime: | |
| 3191 iVTType = XFA_VT_DATETIME; | |
| 3192 break; | |
| 3193 case XFA_ELEMENT_Boolean: | |
| 3194 iVTType = XFA_VT_BOOLEAN; | |
| 3195 break; | |
| 3196 case XFA_ELEMENT_Integer: | |
| 3197 iVTType = XFA_VT_INTEGER; | |
| 3198 break; | |
| 3199 case XFA_ELEMENT_Text: | |
| 3200 iVTType = XFA_VT_TEXT; | |
| 3201 break; | |
| 3202 default: | |
| 3203 iVTType = XFA_VT_NULL; | |
| 3204 break; | |
| 3205 } | |
| 3206 CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); | |
| 3207 CXFA_LocaleValue widgetValue(iVTType, wsValue, pLocalMgr); | |
| 3208 switch (widgetValue.GetType()) { | |
| 3209 case XFA_VT_DATE: { | |
| 3210 CFX_WideString wsDate, wsTime; | |
| 3211 if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { | |
| 3212 CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); | |
| 3213 if (date.FormatPatterns(wsFormatedValue, wsPicture, pLocale, | |
| 3214 XFA_VALUEPICTURE_DataBind)) { | |
| 3215 return TRUE; | |
| 3216 } | |
| 3217 } | |
| 3218 break; | |
| 3219 } | |
| 3220 case XFA_VT_TIME: { | |
| 3221 CFX_WideString wsDate, wsTime; | |
| 3222 if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { | |
| 3223 CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); | |
| 3224 if (time.FormatPatterns(wsFormatedValue, wsPicture, pLocale, | |
| 3225 XFA_VALUEPICTURE_DataBind)) { | |
| 3226 return TRUE; | |
| 3227 } | |
| 3228 } | |
| 3229 break; | |
| 3230 } | |
| 3231 default: | |
| 3232 break; | |
| 3233 } | |
| 3234 widgetValue.FormatPatterns(wsFormatedValue, wsPicture, pLocale, | |
| 3235 XFA_VALUEPICTURE_DataBind); | |
| 3236 } | |
| 3237 return FALSE; | |
| 3238 } | |
| 3239 void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue, | |
| 3240 CFX_WideString& wsOutput) { | |
| 3241 if (wsValue.IsEmpty()) { | |
| 3242 return; | |
| 3243 } | |
| 3244 wsOutput = wsValue; | |
| 3245 wsOutput.TrimLeft('0'); | |
| 3246 int32_t dot_index = wsOutput.Find('.'); | |
| 3247 int32_t iFracDigits = 0; | |
| 3248 if (!wsOutput.IsEmpty() && dot_index >= 0 && | |
| 3249 (!GetFracDigits(iFracDigits) || iFracDigits != -1)) { | |
| 3250 wsOutput.TrimRight(L"0"); | |
| 3251 wsOutput.TrimRight(L"."); | |
| 3252 } | |
| 3253 if (wsOutput.IsEmpty() || wsOutput[0] == '.') { | |
| 3254 wsOutput.Insert(0, '0'); | |
| 3255 } | |
| 3256 } | |
| 3257 void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue, | |
| 3258 IFX_Locale* pLocale, | |
| 3259 CFX_WideString& wsOutput) { | |
| 3260 if (wsValue.IsEmpty()) { | |
| 3261 return; | |
| 3262 } | |
| 3263 CFX_WideString wsSrcNum = wsValue; | |
| 3264 CFX_WideString wsGroupSymbol; | |
| 3265 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | |
| 3266 FX_BOOL bNeg = FALSE; | |
| 3267 if (wsSrcNum[0] == '-') { | |
| 3268 bNeg = TRUE; | |
| 3269 wsSrcNum.Delete(0, 1); | |
| 3270 } | |
| 3271 int32_t len = wsSrcNum.GetLength(); | |
| 3272 int32_t dot_index = wsSrcNum.Find('.'); | |
| 3273 if (dot_index == -1) { | |
| 3274 dot_index = len; | |
| 3275 } | |
| 3276 int32_t cc = dot_index - 1; | |
| 3277 if (cc >= 0) { | |
| 3278 int nPos = dot_index % 3; | |
| 3279 wsOutput.Empty(); | |
| 3280 for (int32_t i = 0; i < dot_index; i++) { | |
| 3281 if (i % 3 == nPos && i != 0) { | |
| 3282 wsOutput += wsGroupSymbol; | |
| 3283 } | |
| 3284 wsOutput += wsSrcNum[i]; | |
| 3285 } | |
| 3286 if (dot_index < len) { | |
| 3287 CFX_WideString wsSymbol; | |
| 3288 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); | |
| 3289 wsOutput += wsSymbol; | |
| 3290 wsOutput += wsSrcNum.Right(len - dot_index - 1); | |
| 3291 } | |
| 3292 if (bNeg) { | |
| 3293 CFX_WideString wsMinusymbol; | |
| 3294 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); | |
| 3295 wsOutput = wsMinusymbol + wsOutput; | |
| 3296 } | |
| 3297 } | |
| 3298 } | |
| 3299 void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue, | |
| 3300 FX_BOOL bNotify) { | |
| 3301 if (!m_pNode) { | |
| 3302 return; | |
| 3303 } | |
| 3304 CFX_WideString wsFormatValue(wsValue); | |
| 3305 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); | |
| 3306 if (pContainerWidgetData) { | |
| 3307 pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue); | |
| 3308 } | |
| 3309 m_pNode->SetContent(wsValue, wsFormatValue, bNotify); | |
| 3310 } | |
| 3311 void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems, | |
| 3312 const CFX_WideStringC& wsText, | |
| 3313 int32_t nIndex) { | |
| 3314 CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text); | |
| 3315 pItems->InsertChild(nIndex, pText); | |
| 3316 pText->SetContent(wsText, wsText, FALSE, FALSE, FALSE); | |
| 3317 } | |
| 3318 CXFA_Filter CXFA_WidgetData::GetFilter(FX_BOOL bModified) { | |
| 3319 if (!m_pUiChildNode) { | |
| 3320 return CXFA_Filter(nullptr); | |
| 3321 } | |
| 3322 return CXFA_Filter( | |
| 3323 m_pUiChildNode->GetProperty(0, XFA_ELEMENT_Filter, bModified)); | |
| 3324 } | |
| 3325 CXFA_Manifest CXFA_WidgetData::GetManifest(FX_BOOL bModified) { | |
| 3326 if (!m_pUiChildNode) { | |
| 3327 return CXFA_Manifest(nullptr); | |
| 3328 } | |
| 3329 return CXFA_Manifest( | |
| 3330 m_pUiChildNode->GetProperty(0, XFA_ELEMENT_Manifest, bModified)); | |
| 3331 } | |
| 3332 CXFA_Occur::CXFA_Occur(CXFA_Node* pNode) : CXFA_Data(pNode) {} | |
| 3333 int32_t CXFA_Occur::GetMax() { | |
| 3334 int32_t iMax = 1; | |
| 3335 if (m_pNode) { | |
| 3336 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, TRUE)) { | |
| 3337 iMax = GetMin(); | |
| 3338 } | |
| 3339 } | |
| 3340 return iMax; | |
| 3341 } | |
| 3342 int32_t CXFA_Occur::GetMin() { | |
| 3343 int32_t iMin = 1; | |
| 3344 if (m_pNode) { | |
| 3345 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, TRUE) || iMin < 0) { | |
| 3346 iMin = 1; | |
| 3347 } | |
| 3348 } | |
| 3349 return iMin; | |
| 3350 } | |
| 3351 int32_t CXFA_Occur::GetInitial() { | |
| 3352 int32_t iInit = 1; | |
| 3353 if (m_pNode) { | |
| 3354 int32_t iMin = GetMin(); | |
| 3355 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, TRUE) || | |
| 3356 iInit < iMin) { | |
| 3357 iInit = iMin; | |
| 3358 } | |
| 3359 } | |
| 3360 return iInit; | |
| 3361 } | |
| 3362 FX_BOOL CXFA_Occur::GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit) { | |
| 3363 if (!m_pNode) { | |
| 3364 return FALSE; | |
| 3365 } | |
| 3366 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE) || iMin < 0) { | |
| 3367 iMin = 1; | |
| 3368 } | |
| 3369 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { | |
| 3370 if (iMin == 0) { | |
| 3371 iMax = 1; | |
| 3372 } else { | |
| 3373 iMax = iMin; | |
| 3374 } | |
| 3375 } | |
| 3376 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, FALSE) || | |
| 3377 iInit < iMin) { | |
| 3378 iInit = iMin; | |
| 3379 } | |
| 3380 return TRUE; | |
| 3381 } | |
| 3382 void CXFA_Occur::SetMax(int32_t iMax) { | |
| 3383 iMax = (iMax != -1 && iMax < 1) ? 1 : iMax; | |
| 3384 m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); | |
| 3385 int32_t iMin = GetMin(); | |
| 3386 if (iMax != -1 && iMax < iMin) { | |
| 3387 iMin = iMax; | |
| 3388 m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE); | |
| 3389 } | |
| 3390 } | |
| 3391 void CXFA_Occur::SetMin(int32_t iMin) { | |
| 3392 iMin = (iMin < 0) ? 1 : iMin; | |
| 3393 m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE); | |
| 3394 int32_t iMax = GetMax(); | |
| 3395 if (iMax > 0 && iMax < iMin) { | |
| 3396 iMax = iMin; | |
| 3397 m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); | |
| 3398 } | |
| 3399 } | |
| 3400 XFA_ATTRIBUTEENUM XFA_GetEnumTypeAttribute( | |
| 3401 CXFA_Node* pNode, | |
| 3402 XFA_ATTRIBUTE attributeValue = XFA_ATTRIBUTE_Type, | |
| 3403 XFA_ATTRIBUTEENUM eDefaultValue = XFA_ATTRIBUTEENUM_Optional) { | |
| 3404 XFA_ATTRIBUTEENUM eType = eDefaultValue; | |
| 3405 if (pNode) { | |
| 3406 if (!pNode->TryEnum(attributeValue, eType, TRUE)) { | |
| 3407 eType = eDefaultValue; | |
| 3408 } | |
| 3409 } | |
| 3410 return eType; | |
| 3411 } | |
| 3412 CFX_WideString CXFA_Filter::GetFilterString(XFA_ATTRIBUTE eAttribute) { | |
| 3413 CFX_WideString wsStringValue; | |
| 3414 if (m_pNode) { | |
| 3415 m_pNode->GetAttribute(eAttribute, wsStringValue, FALSE); | |
| 3416 } | |
| 3417 return wsStringValue; | |
| 3418 } | |
| 3419 XFA_ATTRIBUTEENUM CXFA_Filter::GetAppearanceFilterType() { | |
| 3420 if (!m_pNode) { | |
| 3421 return XFA_ATTRIBUTEENUM_Optional; | |
| 3422 } | |
| 3423 CXFA_Node* pAppearanceFilterNode = | |
| 3424 m_pNode->GetProperty(0, XFA_ELEMENT_AppearanceFilter); | |
| 3425 return XFA_GetEnumTypeAttribute(pAppearanceFilterNode); | |
| 3426 } | |
| 3427 CFX_WideString CXFA_Filter::GetAppearanceFilterContent() { | |
| 3428 CFX_WideString wsContent; | |
| 3429 if (m_pNode) { | |
| 3430 CXFA_Node* pAppearanceFilterNode = | |
| 3431 m_pNode->GetProperty(0, XFA_ELEMENT_AppearanceFilter); | |
| 3432 pAppearanceFilterNode->TryContent(wsContent); | |
| 3433 } | |
| 3434 return wsContent; | |
| 3435 } | |
| 3436 XFA_ATTRIBUTEENUM CXFA_Filter::GetCertificatesCredentialServerPolicy() { | |
| 3437 if (!m_pNode) { | |
| 3438 return XFA_ATTRIBUTEENUM_Optional; | |
| 3439 } | |
| 3440 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); | |
| 3441 return XFA_GetEnumTypeAttribute(pCertsNode, | |
| 3442 XFA_ATTRIBUTE_CredentialServerPolicy); | |
| 3443 } | |
| 3444 CFX_WideString CXFA_Filter::GetCertificatesURL() { | |
| 3445 CFX_WideString wsURL; | |
| 3446 if (m_pNode) { | |
| 3447 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); | |
| 3448 pCertsNode->GetAttribute(XFA_ATTRIBUTE_Url, wsURL, FALSE); | |
| 3449 } | |
| 3450 return wsURL; | |
| 3451 } | |
| 3452 CFX_WideString CXFA_Filter::GetCertificatesURLPolicy() { | |
| 3453 CFX_WideString wsURLPolicy; | |
| 3454 if (m_pNode) { | |
| 3455 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); | |
| 3456 pCertsNode->GetAttribute(XFA_ATTRIBUTE_UrlPolicy, wsURLPolicy, FALSE); | |
| 3457 } | |
| 3458 return wsURLPolicy; | |
| 3459 } | |
| 3460 CXFA_WrapCertificate CXFA_Filter::GetCertificatesEncryption(FX_BOOL bModified) { | |
| 3461 if (!m_pNode) { | |
| 3462 return CXFA_WrapCertificate(NULL); | |
| 3463 } | |
| 3464 CXFA_Node* pCertsNode = | |
| 3465 m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); | |
| 3466 return CXFA_WrapCertificate( | |
| 3467 pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Encryption, bModified) | |
| 3468 : NULL); | |
| 3469 } | |
| 3470 CXFA_WrapCertificate CXFA_Filter::GetCertificatesIssuers(FX_BOOL bModified) { | |
| 3471 if (!m_pNode) { | |
| 3472 return CXFA_WrapCertificate(NULL); | |
| 3473 } | |
| 3474 CXFA_Node* pCertsNode = | |
| 3475 m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); | |
| 3476 return CXFA_WrapCertificate( | |
| 3477 pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Issuers, bModified) | |
| 3478 : NULL); | |
| 3479 } | |
| 3480 CFX_WideString CXFA_Filter::GetCertificatesKeyUsageString( | |
| 3481 XFA_ATTRIBUTE eAttribute) { | |
| 3482 if (!m_pNode) { | |
| 3483 return FX_WSTRC(L""); | |
| 3484 } | |
| 3485 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); | |
| 3486 CXFA_Node* pKeyUsageNode = pCertsNode->GetProperty(0, XFA_ELEMENT_KeyUsage); | |
| 3487 CFX_WideString wsAttributeValue; | |
| 3488 pKeyUsageNode->GetAttribute(eAttribute, wsAttributeValue, FALSE); | |
| 3489 return wsAttributeValue; | |
| 3490 } | |
| 3491 CXFA_Oids CXFA_Filter::GetCertificatesOids() { | |
| 3492 if (!m_pNode) { | |
| 3493 return CXFA_Oids(NULL); | |
| 3494 } | |
| 3495 CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); | |
| 3496 return CXFA_Oids(pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Oids) | |
| 3497 : NULL); | |
| 3498 } | |
| 3499 CXFA_WrapCertificate CXFA_Filter::GetCertificatesSigning(FX_BOOL bModified) { | |
| 3500 if (!m_pNode) { | |
| 3501 return CXFA_WrapCertificate(NULL); | |
| 3502 } | |
| 3503 CXFA_Node* pCertsNode = | |
| 3504 m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); | |
| 3505 return CXFA_WrapCertificate( | |
| 3506 pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Signing, bModified) | |
| 3507 : NULL); | |
| 3508 } | |
| 3509 CXFA_DigestMethods CXFA_Filter::GetDigestMethods(FX_BOOL bModified) { | |
| 3510 return CXFA_DigestMethods( | |
| 3511 m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_DigestMethods, bModified) | |
| 3512 : NULL); | |
| 3513 } | |
| 3514 CXFA_Encodings CXFA_Filter::GetEncodings(FX_BOOL bModified) { | |
| 3515 return CXFA_Encodings( | |
| 3516 m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_Encodings, bModified) | |
| 3517 : NULL); | |
| 3518 } | |
| 3519 CXFA_EncryptionMethods CXFA_Filter::GetEncryptionMethods(FX_BOOL bModified) { | |
| 3520 return CXFA_EncryptionMethods( | |
| 3521 m_pNode | |
| 3522 ? m_pNode->GetProperty(0, XFA_ELEMENT_EncryptionMethods, bModified) | |
| 3523 : NULL); | |
| 3524 } | |
| 3525 XFA_ATTRIBUTEENUM CXFA_Filter::GetHandlerType() { | |
| 3526 if (!m_pNode) { | |
| 3527 return XFA_ATTRIBUTEENUM_Optional; | |
| 3528 } | |
| 3529 CXFA_Node* pHandlerNode = m_pNode->GetProperty(0, XFA_ELEMENT_Handler); | |
| 3530 return XFA_GetEnumTypeAttribute(pHandlerNode); | |
| 3531 } | |
| 3532 CFX_WideString CXFA_Filter::GetHandlerContent() { | |
| 3533 CFX_WideString wsContent; | |
| 3534 if (m_pNode) { | |
| 3535 CXFA_Node* pHandlerNode = m_pNode->GetProperty(0, XFA_ELEMENT_Handler); | |
| 3536 pHandlerNode->TryContent(wsContent); | |
| 3537 } | |
| 3538 return wsContent; | |
| 3539 } | |
| 3540 XFA_ATTRIBUTEENUM CXFA_Filter::GetlockDocumentType() { | |
| 3541 if (!m_pNode) { | |
| 3542 return XFA_ATTRIBUTEENUM_Optional; | |
| 3543 } | |
| 3544 CXFA_Node* pLockDocNode = m_pNode->GetProperty(0, XFA_ELEMENT_LockDocument); | |
| 3545 return XFA_GetEnumTypeAttribute(pLockDocNode); | |
| 3546 } | |
| 3547 CFX_WideString CXFA_Filter::GetlockDocumentContent() { | |
| 3548 CFX_WideString wsContent = FX_WSTRC(L"auto"); | |
| 3549 if (m_pNode) { | |
| 3550 CXFA_Node* pLockDocNode = m_pNode->GetProperty(0, XFA_ELEMENT_LockDocument); | |
| 3551 pLockDocNode->TryContent(wsContent); | |
| 3552 } | |
| 3553 return wsContent; | |
| 3554 } | |
| 3555 int32_t CXFA_Filter::GetMDPPermissions() { | |
| 3556 int32_t iPermissions = 2; | |
| 3557 if (m_pNode) { | |
| 3558 CXFA_Node* pMDPNode = m_pNode->GetProperty(0, XFA_ELEMENT_Mdp); | |
| 3559 if (!pMDPNode->TryInteger(XFA_ATTRIBUTE_Permissions, iPermissions, TRUE)) { | |
| 3560 iPermissions = 2; | |
| 3561 } | |
| 3562 } | |
| 3563 return iPermissions; | |
| 3564 } | |
| 3565 XFA_ATTRIBUTEENUM CXFA_Filter::GetMDPSignatureType() { | |
| 3566 if (!m_pNode) { | |
| 3567 return XFA_ATTRIBUTEENUM_Filter; | |
| 3568 } | |
| 3569 CXFA_Node* pMDPNode = m_pNode->GetProperty(0, XFA_ELEMENT_Mdp); | |
| 3570 return XFA_GetEnumTypeAttribute(pMDPNode, XFA_ATTRIBUTE_SignatureType, | |
| 3571 XFA_ATTRIBUTEENUM_Filter); | |
| 3572 } | |
| 3573 CXFA_Reasons CXFA_Filter::GetReasons(FX_BOOL bModified) { | |
| 3574 return CXFA_Reasons(m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_Reasons) | |
| 3575 : NULL); | |
| 3576 } | |
| 3577 CFX_WideString CXFA_Filter::GetTimeStampServer() { | |
| 3578 CFX_WideString wsServerURI; | |
| 3579 if (m_pNode) { | |
| 3580 CXFA_Node* pTimeStampNode = m_pNode->GetProperty(0, XFA_ELEMENT_TimeStamp); | |
| 3581 pTimeStampNode->GetAttribute(XFA_ATTRIBUTE_Server, wsServerURI, FALSE); | |
| 3582 } | |
| 3583 return wsServerURI; | |
| 3584 } | |
| 3585 XFA_ATTRIBUTEENUM CXFA_Filter::GetTimeStampType() { | |
| 3586 if (!m_pNode) { | |
| 3587 return XFA_ATTRIBUTEENUM_Optional; | |
| 3588 } | |
| 3589 CXFA_Node* pTimeStampNode = m_pNode->GetProperty(0, XFA_ELEMENT_TimeStamp); | |
| 3590 return XFA_GetEnumTypeAttribute(pTimeStampNode); | |
| 3591 } | |
| 3592 CFX_WideString CXFA_Certificate::GetCertificateName() { | |
| 3593 CFX_WideString wsName; | |
| 3594 if (m_pNode) { | |
| 3595 m_pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); | |
| 3596 } | |
| 3597 return wsName; | |
| 3598 } | |
| 3599 CFX_WideString CXFA_Certificate::GetCertificateContent() { | |
| 3600 CFX_WideString wsContent; | |
| 3601 if (m_pNode) { | |
| 3602 m_pNode->TryContent(wsContent); | |
| 3603 } | |
| 3604 return wsContent; | |
| 3605 } | |
| 3606 XFA_ATTRIBUTEENUM CXFA_WrapCertificate::GetType() { | |
| 3607 return XFA_GetEnumTypeAttribute(m_pNode); | |
| 3608 } | |
| 3609 int32_t CXFA_WrapCertificate::CountCertificates() { | |
| 3610 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Certificate) : 0; | |
| 3611 } | |
| 3612 CXFA_Certificate CXFA_WrapCertificate::GetCertificate(int32_t nIndex) { | |
| 3613 return CXFA_Certificate( | |
| 3614 (nIndex > -1 && m_pNode) | |
| 3615 ? m_pNode->GetChild(nIndex, XFA_ELEMENT_Certificate) | |
| 3616 : NULL); | |
| 3617 } | |
| 3618 XFA_ATTRIBUTEENUM CXFA_Oids::GetOidsType() { | |
| 3619 return XFA_GetEnumTypeAttribute(m_pNode); | |
| 3620 } | |
| 3621 int32_t CXFA_Oids::CountOids() { | |
| 3622 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Oid) : 0; | |
| 3623 } | |
| 3624 CFX_WideString CXFA_Oids::GetOidContent(int32_t nIndex) { | |
| 3625 if (nIndex <= -1 || !m_pNode) { | |
| 3626 return FX_WSTRC(L""); | |
| 3627 } | |
| 3628 CXFA_Node* pOidNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Oid); | |
| 3629 if (!pOidNode) { | |
| 3630 return FX_WSTRC(L""); | |
| 3631 } | |
| 3632 CFX_WideString wsContent; | |
| 3633 pOidNode->TryContent(wsContent); | |
| 3634 return wsContent; | |
| 3635 } | |
| 3636 XFA_ATTRIBUTEENUM CXFA_SubjectDNs::GetSubjectDNsType() { | |
| 3637 return XFA_GetEnumTypeAttribute(m_pNode); | |
| 3638 } | |
| 3639 int32_t CXFA_SubjectDNs::CountSubjectDNs() { | |
| 3640 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_SubjectDN) : 0; | |
| 3641 } | |
| 3642 CFX_WideString CXFA_SubjectDNs::GetSubjectDNString(int32_t nIndex, | |
| 3643 XFA_ATTRIBUTE eAttribute) { | |
| 3644 if (nIndex <= -1 || !m_pNode) { | |
| 3645 return FX_WSTRC(L""); | |
| 3646 } | |
| 3647 CXFA_Node* pSubjectDNNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_SubjectDN); | |
| 3648 if (!pSubjectDNNode) { | |
| 3649 return FX_WSTRC(L""); | |
| 3650 } | |
| 3651 CFX_WideString wsAttributeValue; | |
| 3652 pSubjectDNNode->GetAttribute(eAttribute, wsAttributeValue, FALSE); | |
| 3653 return wsAttributeValue; | |
| 3654 } | |
| 3655 CFX_WideString CXFA_SubjectDNs::GetSubjectDNContent(int32_t nIndex) { | |
| 3656 if (nIndex <= -1 || !m_pNode) { | |
| 3657 return FX_WSTRC(L""); | |
| 3658 } | |
| 3659 CXFA_Node* pSubjectDNNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_SubjectDN); | |
| 3660 if (!pSubjectDNNode) { | |
| 3661 return FX_WSTRC(L""); | |
| 3662 } | |
| 3663 CFX_WideString wsContent; | |
| 3664 pSubjectDNNode->TryContent(wsContent); | |
| 3665 return wsContent; | |
| 3666 } | |
| 3667 XFA_ATTRIBUTEENUM CXFA_DigestMethods::GetDigestMethodsType() { | |
| 3668 return XFA_GetEnumTypeAttribute(m_pNode); | |
| 3669 } | |
| 3670 int32_t CXFA_DigestMethods::CountDigestMethods() { | |
| 3671 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_DigestMethod) : 0; | |
| 3672 } | |
| 3673 CFX_WideString CXFA_DigestMethods::GetDigestMethodContent(int32_t nIndex) { | |
| 3674 if (nIndex <= -1 || !m_pNode) { | |
| 3675 return FX_WSTRC(L""); | |
| 3676 } | |
| 3677 CXFA_Node* pDigestMethodNode = | |
| 3678 m_pNode->GetChild(nIndex, XFA_ELEMENT_DigestMethod); | |
| 3679 if (!pDigestMethodNode) { | |
| 3680 return FX_WSTRC(L""); | |
| 3681 } | |
| 3682 CFX_WideString wsContent; | |
| 3683 pDigestMethodNode->TryContent(wsContent); | |
| 3684 return wsContent; | |
| 3685 } | |
| 3686 XFA_ATTRIBUTEENUM CXFA_Encodings::GetEncodingsType() { | |
| 3687 return XFA_GetEnumTypeAttribute(m_pNode); | |
| 3688 } | |
| 3689 int32_t CXFA_Encodings::CountEncodings() { | |
| 3690 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Encoding) : 0; | |
| 3691 } | |
| 3692 CFX_WideString CXFA_Encodings::GetEncodingContent(int32_t nIndex) { | |
| 3693 if (nIndex <= -1 || !m_pNode) { | |
| 3694 return FX_WSTRC(L""); | |
| 3695 } | |
| 3696 CXFA_Node* pEncodingNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Encoding); | |
| 3697 if (!pEncodingNode) { | |
| 3698 return FX_WSTRC(L""); | |
| 3699 } | |
| 3700 CFX_WideString wsContent; | |
| 3701 pEncodingNode->TryContent(wsContent); | |
| 3702 return wsContent; | |
| 3703 } | |
| 3704 XFA_ATTRIBUTEENUM CXFA_EncryptionMethods::GetEncryptionMethodsType() { | |
| 3705 return XFA_GetEnumTypeAttribute(m_pNode); | |
| 3706 } | |
| 3707 int32_t CXFA_EncryptionMethods::CountEncryptionMethods() { | |
| 3708 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_EncryptionMethod) : 0; | |
| 3709 } | |
| 3710 CFX_WideString CXFA_EncryptionMethods::GetEncryptionMethodContent( | |
| 3711 int32_t nIndex) { | |
| 3712 if (nIndex <= -1 || !m_pNode) { | |
| 3713 return FX_WSTRC(L""); | |
| 3714 } | |
| 3715 CXFA_Node* pEncryMethodNode = | |
| 3716 m_pNode->GetChild(nIndex, XFA_ELEMENT_EncryptionMethod); | |
| 3717 if (!pEncryMethodNode) { | |
| 3718 return FX_WSTRC(L""); | |
| 3719 } | |
| 3720 CFX_WideString wsContent; | |
| 3721 pEncryMethodNode->TryContent(wsContent); | |
| 3722 return wsContent; | |
| 3723 } | |
| 3724 XFA_ATTRIBUTEENUM CXFA_Reasons::GetReasonsType() { | |
| 3725 return XFA_GetEnumTypeAttribute(m_pNode); | |
| 3726 } | |
| 3727 int32_t CXFA_Reasons::CountReasons() { | |
| 3728 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Reason) : 0; | |
| 3729 } | |
| 3730 CFX_WideString CXFA_Reasons::GetReasonContent(int32_t nIndex) { | |
| 3731 if (nIndex <= -1 || !m_pNode) { | |
| 3732 return FX_WSTRC(L""); | |
| 3733 } | |
| 3734 CXFA_Node* pReasonNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Reason); | |
| 3735 if (!pReasonNode) { | |
| 3736 return FX_WSTRC(L""); | |
| 3737 } | |
| 3738 CFX_WideString wsContent; | |
| 3739 pReasonNode->TryContent(wsContent); | |
| 3740 return wsContent; | |
| 3741 } | |
| 3742 XFA_ATTRIBUTEENUM CXFA_Manifest::GetAction() { | |
| 3743 return XFA_GetEnumTypeAttribute(m_pNode, XFA_ATTRIBUTE_Action, | |
| 3744 XFA_ATTRIBUTEENUM_Include); | |
| 3745 } | |
| 3746 int32_t CXFA_Manifest::CountReives() { | |
| 3747 return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Ref) : 0; | |
| 3748 } | |
| 3749 CFX_WideString CXFA_Manifest::GetRefContent(int32_t nIndex) { | |
| 3750 if (nIndex <= -1 || !m_pNode) { | |
| 3751 return FX_WSTRC(L""); | |
| 3752 } | |
| 3753 CXFA_Node* pRefNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Ref); | |
| 3754 if (!pRefNode) { | |
| 3755 return FX_WSTRC(L""); | |
| 3756 } | |
| 3757 CFX_WideString wsContent; | |
| 3758 pRefNode->TryContent(wsContent); | |
| 3759 return wsContent; | |
| 3760 } | |
| OLD | NEW |