OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/parser/xfa_basic_imp.h" | 7 #include "xfa/fxfa/parser/xfa_basic_imp.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fgas/crt/fgas_algorithm.h" | 10 #include "xfa/fgas/crt/fgas_algorithm.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement, | 180 CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement, |
181 XFA_ATTRIBUTE eAttribute, | 181 XFA_ATTRIBUTE eAttribute, |
182 uint32_t dwPacket) { | 182 uint32_t dwPacket) { |
183 void* pValue; | 183 void* pValue; |
184 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, | 184 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, |
185 XFA_ATTRIBUTETYPE_Measure, dwPacket)) { | 185 XFA_ATTRIBUTETYPE_Measure, dwPacket)) { |
186 return *(CXFA_Measurement*)pValue; | 186 return *(CXFA_Measurement*)pValue; |
187 } | 187 } |
188 return CXFA_Measurement(); | 188 return CXFA_Measurement(); |
189 } | 189 } |
190 int32_t XFA_GetElementCount() { | 190 int32_t XFA_GetObjectByCount() { |
dsinclair
2016/03/29 20:45:25
nit: Don't think we want a By here?
Tom Sepez
2016/03/29 20:58:13
Reverted this entire file.
| |
191 return g_iXFAElementCount; | 191 return g_iXFAElementCount; |
192 } | 192 } |
193 const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) { | 193 const XFA_ELEMENTINFO* XFA_GetObjectByByName(const CFX_WideStringC& wsName) { |
dsinclair
2016/03/29 20:45:25
nit: GetObjectByName
| |
194 int32_t iLength = wsName.GetLength(); | 194 int32_t iLength = wsName.GetLength(); |
195 if (iLength == 0) { | 195 if (iLength == 0) { |
196 return NULL; | 196 return NULL; |
197 } | 197 } |
198 uint32_t uHash = FX_HashCode_String_GetW(wsName.GetPtr(), iLength); | 198 uint32_t uHash = FX_HashCode_String_GetW(wsName.GetPtr(), iLength); |
199 int32_t iStart = 0, iEnd = g_iXFAElementCount - 1; | 199 int32_t iStart = 0, iEnd = g_iXFAElementCount - 1; |
200 do { | 200 do { |
201 int32_t iMid = (iStart + iEnd) / 2; | 201 int32_t iMid = (iStart + iEnd) / 2; |
202 const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid; | 202 const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid; |
203 if (uHash == pInfo->uHash) { | 203 if (uHash == pInfo->uHash) { |
204 return pInfo; | 204 return pInfo; |
205 } else if (uHash < pInfo->uHash) { | 205 } else if (uHash < pInfo->uHash) { |
206 iEnd = iMid - 1; | 206 iEnd = iMid - 1; |
207 } else { | 207 } else { |
208 iStart = iMid + 1; | 208 iStart = iMid + 1; |
209 } | 209 } |
210 } while (iStart <= iEnd); | 210 } while (iStart <= iEnd); |
211 return NULL; | 211 return NULL; |
212 } | 212 } |
213 const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_ELEMENT eName) { | 213 const XFA_ELEMENTINFO* XFA_GetObjectByByID(XFA_ELEMENT eName) { |
dsinclair
2016/03/29 20:45:25
nit: ByBy
| |
214 return (eName < g_iXFAElementCount) ? (g_XFAElementData + eName) : NULL; | 214 return (eName < g_iXFAElementCount) ? (g_XFAElementData + eName) : NULL; |
215 } | 215 } |
216 const uint16_t* XFA_GetElementChildren(XFA_ELEMENT eElement, int32_t& iCount) { | 216 const uint16_t* XFA_GetObjectByChildren(XFA_ELEMENT eElement, int32_t& iCount) { |
dsinclair
2016/03/29 20:45:25
nit: Do we want By here?
| |
217 if (eElement >= g_iXFAElementCount) { | 217 if (eElement >= g_iXFAElementCount) { |
218 return NULL; | 218 return NULL; |
219 } | 219 } |
220 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementChildrenIndex + eElement; | 220 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementChildrenIndex + eElement; |
221 iCount = pElement->wCount; | 221 iCount = pElement->wCount; |
222 return g_XFAElementChildrenData + pElement->wStart; | 222 return g_XFAElementChildrenData + pElement->wStart; |
223 } | 223 } |
224 const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) { | 224 const uint8_t* XFA_GetObjectByAttributes(XFA_ELEMENT eElement, |
dsinclair
2016/03/29 20:45:25
ditto
| |
225 int32_t& iCount) { | |
225 if (eElement >= g_iXFAElementCount) { | 226 if (eElement >= g_iXFAElementCount) { |
226 return NULL; | 227 return NULL; |
227 } | 228 } |
228 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement; | 229 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement; |
229 iCount = pElement->wCount; | 230 iCount = pElement->wCount; |
230 return g_XFAElementAttributeData + pElement->wStart; | 231 return g_XFAElementAttributeData + pElement->wStart; |
231 } | 232 } |
232 const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement, | 233 const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement, |
233 XFA_ATTRIBUTE eAttribute, | 234 XFA_ATTRIBUTE eAttribute, |
234 uint32_t dwPacket) { | 235 uint32_t dwPacket) { |
235 int32_t iCount = 0; | 236 int32_t iCount = 0; |
236 const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount); | 237 const uint8_t* pAttr = XFA_GetObjectByAttributes(eElement, iCount); |
237 if (pAttr == NULL || iCount < 1) { | 238 if (pAttr == NULL || iCount < 1) { |
238 return NULL; | 239 return NULL; |
239 } | 240 } |
240 CFX_DSPATemplate<uint8_t> search; | 241 CFX_DSPATemplate<uint8_t> search; |
241 int32_t index = search.Lookup(eAttribute, pAttr, iCount); | 242 int32_t index = search.Lookup(eAttribute, pAttr, iCount); |
242 if (index < 0) { | 243 if (index < 0) { |
243 return NULL; | 244 return NULL; |
244 } | 245 } |
245 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); | 246 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); |
246 ASSERT(pInfo); | 247 ASSERT(pInfo); |
247 if (dwPacket == XFA_XDPPACKET_UNKNOWN) | 248 if (dwPacket == XFA_XDPPACKET_UNKNOWN) |
248 return pInfo; | 249 return pInfo; |
249 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; | 250 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; |
250 } | 251 } |
251 const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement, | 252 const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement, |
252 XFA_ELEMENT eChild, | 253 XFA_ELEMENT eChild, |
253 uint32_t dwPacket) { | 254 uint32_t dwPacket) { |
254 int32_t iCount = 0; | 255 int32_t iCount = 0; |
255 const uint16_t* pChild = XFA_GetElementChildren(eElement, iCount); | 256 const uint16_t* pChild = XFA_GetObjectByChildren(eElement, iCount); |
256 if (pChild == NULL || iCount < 1) { | 257 if (pChild == NULL || iCount < 1) { |
257 return NULL; | 258 return NULL; |
258 } | 259 } |
259 CFX_DSPATemplate<uint16_t> search; | 260 CFX_DSPATemplate<uint16_t> search; |
260 int32_t index = search.Lookup(eChild, pChild, iCount); | 261 int32_t index = search.Lookup(eChild, pChild, iCount); |
261 if (index < 0) { | 262 if (index < 0) { |
262 return NULL; | 263 return NULL; |
263 } | 264 } |
264 const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eChild); | 265 const XFA_ELEMENTINFO* pInfo = XFA_GetObjectByByID(eChild); |
265 ASSERT(pInfo); | 266 ASSERT(pInfo); |
266 if (dwPacket == XFA_XDPPACKET_UNKNOWN) | 267 if (dwPacket == XFA_XDPPACKET_UNKNOWN) |
267 return pInfo; | 268 return pInfo; |
268 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; | 269 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; |
269 } | 270 } |
270 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement, | 271 const XFA_PROPERTY* XFA_GetObjectByProperties(XFA_ELEMENT eElement, |
271 int32_t& iCount) { | 272 int32_t& iCount) { |
272 if (eElement >= g_iXFAElementCount) { | 273 if (eElement >= g_iXFAElementCount) { |
273 return NULL; | 274 return NULL; |
274 } | 275 } |
275 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement; | 276 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement; |
276 iCount = pElement->wCount; | 277 iCount = pElement->wCount; |
277 return g_XFAElementPropertyData + pElement->wStart; | 278 return g_XFAElementPropertyData + pElement->wStart; |
278 } | 279 } |
279 const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement, | 280 const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement, |
280 XFA_ELEMENT eProperty, | 281 XFA_ELEMENT eProperty, |
281 uint32_t dwPacket) { | 282 uint32_t dwPacket) { |
282 int32_t iCount = 0; | 283 int32_t iCount = 0; |
283 const XFA_PROPERTY* pProperty = XFA_GetElementProperties(eElement, iCount); | 284 const XFA_PROPERTY* pProperty = XFA_GetObjectByProperties(eElement, iCount); |
284 if (pProperty == NULL || iCount < 1) { | 285 if (pProperty == NULL || iCount < 1) { |
285 return NULL; | 286 return NULL; |
286 } | 287 } |
287 int32_t iStart = 0, iEnd = iCount - 1, iMid; | 288 int32_t iStart = 0, iEnd = iCount - 1, iMid; |
288 do { | 289 do { |
289 iMid = (iStart + iEnd) / 2; | 290 iMid = (iStart + iEnd) / 2; |
290 XFA_ELEMENT eName = (XFA_ELEMENT)pProperty[iMid].eName; | 291 XFA_ELEMENT eName = (XFA_ELEMENT)pProperty[iMid].eName; |
291 if (eProperty == eName) { | 292 if (eProperty == eName) { |
292 break; | 293 break; |
293 } else if (eProperty < eName) { | 294 } else if (eProperty < eName) { |
294 iEnd = iMid - 1; | 295 iEnd = iMid - 1; |
295 } else { | 296 } else { |
296 iStart = iMid + 1; | 297 iStart = iMid + 1; |
297 } | 298 } |
298 } while (iStart <= iEnd); | 299 } while (iStart <= iEnd); |
299 if (iStart > iEnd) { | 300 if (iStart > iEnd) { |
300 return NULL; | 301 return NULL; |
301 } | 302 } |
302 const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eProperty); | 303 const XFA_ELEMENTINFO* pInfo = XFA_GetObjectByByID(eProperty); |
303 ASSERT(pInfo); | 304 ASSERT(pInfo); |
304 if (dwPacket == XFA_XDPPACKET_UNKNOWN) | 305 if (dwPacket == XFA_XDPPACKET_UNKNOWN) |
305 return pProperty + iMid; | 306 return pProperty + iMid; |
306 return (dwPacket & pInfo->dwPackets) ? (pProperty + iMid) : NULL; | 307 return (dwPacket & pInfo->dwPackets) ? (pProperty + iMid) : NULL; |
307 } | 308 } |
308 const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement, | 309 const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement, |
309 XFA_ATTRIBUTE eAttribute, | 310 XFA_ATTRIBUTE eAttribute, |
310 XFA_ATTRIBUTETYPE eType) { | 311 XFA_ATTRIBUTETYPE eType) { |
311 int32_t iStart = 0, iEnd = g_iXFANotsureCount - 1; | 312 int32_t iStart = 0, iEnd = g_iXFANotsureCount - 1; |
312 do { | 313 do { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 m_iPosition += iMaxLength; | 604 m_iPosition += iMaxLength; |
604 bEOS = IsEOF(); | 605 bEOS = IsEOF(); |
605 return iMaxLength; | 606 return iMaxLength; |
606 } | 607 } |
607 uint16_t CXFA_WideTextRead::GetCodePage() const { | 608 uint16_t CXFA_WideTextRead::GetCodePage() const { |
608 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; | 609 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; |
609 } | 610 } |
610 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) { | 611 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) { |
611 return GetCodePage(); | 612 return GetCodePage(); |
612 } | 613 } |
OLD | NEW |