Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2061)

Side by Side Diff: xfa/fxfa/parser/xfa_basic_imp.cpp

Issue 2031873003: Get rid of NULLs in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_fpdfsdk
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/xfa_basic_imp.h ('k') | xfa/fxfa/parser/xfa_document_datadescription_imp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_codepage.h" 10 #include "xfa/fgas/crt/fgas_codepage.h"
(...skipping 18 matching lines...) Expand all
29 int32_t iMid = (iStart + iEnd) / 2; 29 int32_t iMid = (iStart + iEnd) / 2;
30 const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid; 30 const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid;
31 if (uHash == pInfo->uHash) { 31 if (uHash == pInfo->uHash) {
32 return pInfo; 32 return pInfo;
33 } else if (uHash < pInfo->uHash) { 33 } else if (uHash < pInfo->uHash) {
34 iEnd = iMid - 1; 34 iEnd = iMid - 1;
35 } else { 35 } else {
36 iStart = iMid + 1; 36 iStart = iMid + 1;
37 } 37 }
38 } while (iStart <= iEnd); 38 } while (iStart <= iEnd);
39 return NULL; 39 return nullptr;
40 } 40 }
41 41
42 const XFA_PACKETINFO* XFA_GetPacketByID(uint32_t dwPacket) { 42 const XFA_PACKETINFO* XFA_GetPacketByID(uint32_t dwPacket) {
43 int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; 43 int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1;
44 do { 44 do {
45 int32_t iMid = (iStart + iEnd) / 2; 45 int32_t iMid = (iStart + iEnd) / 2;
46 uint32_t dwFind = (g_XFAPacketData + iMid)->eName; 46 uint32_t dwFind = (g_XFAPacketData + iMid)->eName;
47 if (dwPacket == dwFind) { 47 if (dwPacket == dwFind) {
48 return g_XFAPacketData + iMid; 48 return g_XFAPacketData + iMid;
49 } else if (dwPacket < dwFind) { 49 } else if (dwPacket < dwFind) {
50 iEnd = iMid - 1; 50 iEnd = iMid - 1;
51 } else { 51 } else {
52 iStart = iMid + 1; 52 iStart = iMid + 1;
53 } 53 }
54 } while (iStart <= iEnd); 54 } while (iStart <= iEnd);
55 return NULL; 55 return nullptr;
56 } 56 }
57 57
58 const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) { 58 const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) {
59 return g_XFAPacketData + ePacket; 59 return g_XFAPacketData + ePacket;
60 } 60 }
61 61
62 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName( 62 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName(
63 const CFX_WideStringC& wsName) { 63 const CFX_WideStringC& wsName) {
64 if (wsName.IsEmpty()) 64 if (wsName.IsEmpty())
65 return nullptr; 65 return nullptr;
66 66
67 uint32_t uHash = FX_HashCode_GetW(wsName, false); 67 uint32_t uHash = FX_HashCode_GetW(wsName, false);
68 int32_t iStart = 0; 68 int32_t iStart = 0;
69 int32_t iEnd = g_iXFAEnumCount - 1; 69 int32_t iEnd = g_iXFAEnumCount - 1;
70 do { 70 do {
71 int32_t iMid = (iStart + iEnd) / 2; 71 int32_t iMid = (iStart + iEnd) / 2;
72 const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid; 72 const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid;
73 if (uHash == pInfo->uHash) { 73 if (uHash == pInfo->uHash) {
74 return pInfo; 74 return pInfo;
75 } else if (uHash < pInfo->uHash) { 75 } else if (uHash < pInfo->uHash) {
76 iEnd = iMid - 1; 76 iEnd = iMid - 1;
77 } else { 77 } else {
78 iStart = iMid + 1; 78 iStart = iMid + 1;
79 } 79 }
80 } while (iStart <= iEnd); 80 } while (iStart <= iEnd);
81 return NULL; 81 return nullptr;
82 } 82 }
83 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) { 83 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) {
84 return g_XFAEnumData + eName; 84 return g_XFAEnumData + eName;
85 } 85 }
86 86
87 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) { 87 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) {
88 if (wsName.IsEmpty()) 88 if (wsName.IsEmpty())
89 return nullptr; 89 return nullptr;
90 90
91 uint32_t uHash = FX_HashCode_GetW(wsName, false); 91 uint32_t uHash = FX_HashCode_GetW(wsName, false);
92 int32_t iStart = 0; 92 int32_t iStart = 0;
93 int32_t iEnd = g_iXFAAttributeCount - 1; 93 int32_t iEnd = g_iXFAAttributeCount - 1;
94 do { 94 do {
95 int32_t iMid = (iStart + iEnd) / 2; 95 int32_t iMid = (iStart + iEnd) / 2;
96 const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid; 96 const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid;
97 if (uHash == pInfo->uHash) { 97 if (uHash == pInfo->uHash) {
98 return pInfo; 98 return pInfo;
99 } else if (uHash < pInfo->uHash) { 99 } else if (uHash < pInfo->uHash) {
100 iEnd = iMid - 1; 100 iEnd = iMid - 1;
101 } else { 101 } else {
102 iStart = iMid + 1; 102 iStart = iMid + 1;
103 } 103 }
104 } while (iStart <= iEnd); 104 } while (iStart <= iEnd);
105 return nullptr; 105 return nullptr;
106 } 106 }
107 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) { 107 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) {
108 return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName) : NULL; 108 return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName)
109 : nullptr;
109 } 110 }
110 FX_BOOL XFA_GetAttributeDefaultValue(void*& pValue, 111 FX_BOOL XFA_GetAttributeDefaultValue(void*& pValue,
111 XFA_ELEMENT eElement, 112 XFA_ELEMENT eElement,
112 XFA_ATTRIBUTE eAttribute, 113 XFA_ATTRIBUTE eAttribute,
113 XFA_ATTRIBUTETYPE eType, 114 XFA_ATTRIBUTETYPE eType,
114 uint32_t dwPacket) { 115 uint32_t dwPacket) {
115 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); 116 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute);
116 if (pInfo == NULL) { 117 if (!pInfo)
117 return FALSE; 118 return FALSE;
118 } 119
119 if (dwPacket && (dwPacket & pInfo->dwPackets) == 0) { 120 if (dwPacket && (dwPacket & pInfo->dwPackets) == 0) {
120 return FALSE; 121 return FALSE;
121 } 122 }
122 if (pInfo->eType == eType) { 123 if (pInfo->eType == eType) {
123 pValue = pInfo->pDefValue; 124 pValue = pInfo->pDefValue;
124 return TRUE; 125 return TRUE;
125 } else if (pInfo->eType == XFA_ATTRIBUTETYPE_NOTSURE) { 126 } else if (pInfo->eType == XFA_ATTRIBUTETYPE_NOTSURE) {
126 const XFA_NOTSUREATTRIBUTE* pAttr = 127 const XFA_NOTSUREATTRIBUTE* pAttr =
127 XFA_GetNotsureAttribute(eElement, eAttribute, eType); 128 XFA_GetNotsureAttribute(eElement, eAttribute, eType);
128 if (pAttr) { 129 if (pAttr) {
(...skipping 14 matching lines...) Expand all
143 return XFA_ATTRIBUTEENUM_Unknown; 144 return XFA_ATTRIBUTEENUM_Unknown;
144 } 145 }
145 CFX_WideStringC XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT eElement, 146 CFX_WideStringC XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT eElement,
146 XFA_ATTRIBUTE eAttribute, 147 XFA_ATTRIBUTE eAttribute,
147 uint32_t dwPacket) { 148 uint32_t dwPacket) {
148 void* pValue; 149 void* pValue;
149 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 150 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
150 XFA_ATTRIBUTETYPE_Cdata, dwPacket)) { 151 XFA_ATTRIBUTETYPE_Cdata, dwPacket)) {
151 return (const FX_WCHAR*)pValue; 152 return (const FX_WCHAR*)pValue;
152 } 153 }
153 return NULL; 154 return nullptr;
154 } 155 }
155 FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement, 156 FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement,
156 XFA_ATTRIBUTE eAttribute, 157 XFA_ATTRIBUTE eAttribute,
157 uint32_t dwPacket) { 158 uint32_t dwPacket) {
158 void* pValue; 159 void* pValue;
159 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 160 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
160 XFA_ATTRIBUTETYPE_Boolean, dwPacket)) { 161 XFA_ATTRIBUTETYPE_Boolean, dwPacket)) {
161 return (FX_BOOL)(uintptr_t)pValue; 162 return (FX_BOOL)(uintptr_t)pValue;
162 } 163 }
163 return FALSE; 164 return FALSE;
(...skipping 21 matching lines...) Expand all
185 int32_t iMid = (iStart + iEnd) / 2; 186 int32_t iMid = (iStart + iEnd) / 2;
186 const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid; 187 const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid;
187 if (uHash == pInfo->uHash) { 188 if (uHash == pInfo->uHash) {
188 return pInfo; 189 return pInfo;
189 } else if (uHash < pInfo->uHash) { 190 } else if (uHash < pInfo->uHash) {
190 iEnd = iMid - 1; 191 iEnd = iMid - 1;
191 } else { 192 } else {
192 iStart = iMid + 1; 193 iStart = iMid + 1;
193 } 194 }
194 } while (iStart <= iEnd); 195 } while (iStart <= iEnd);
195 return NULL; 196 return nullptr;
196 } 197 }
197 const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_ELEMENT eName) { 198 const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_ELEMENT eName) {
198 return (eName < g_iXFAElementCount) ? (g_XFAElementData + eName) : NULL; 199 return (eName < g_iXFAElementCount) ? (g_XFAElementData + eName) : nullptr;
199 } 200 }
200 const uint16_t* XFA_GetElementChildren(XFA_ELEMENT eElement, int32_t& iCount) { 201 const uint16_t* XFA_GetElementChildren(XFA_ELEMENT eElement, int32_t& iCount) {
201 if (eElement >= g_iXFAElementCount) { 202 if (eElement >= g_iXFAElementCount) {
202 return NULL; 203 return nullptr;
203 } 204 }
204 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementChildrenIndex + eElement; 205 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementChildrenIndex + eElement;
205 iCount = pElement->wCount; 206 iCount = pElement->wCount;
206 return g_XFAElementChildrenData + pElement->wStart; 207 return g_XFAElementChildrenData + pElement->wStart;
207 } 208 }
208 const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) { 209 const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) {
209 if (eElement >= g_iXFAElementCount) { 210 if (eElement >= g_iXFAElementCount) {
210 return NULL; 211 return nullptr;
211 } 212 }
212 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement; 213 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement;
213 iCount = pElement->wCount; 214 iCount = pElement->wCount;
214 return g_XFAElementAttributeData + pElement->wStart; 215 return g_XFAElementAttributeData + pElement->wStart;
215 } 216 }
216 217
217 const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement, 218 const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement,
218 XFA_ATTRIBUTE eAttribute, 219 XFA_ATTRIBUTE eAttribute,
219 uint32_t dwPacket) { 220 uint32_t dwPacket) {
220 int32_t iCount = 0; 221 int32_t iCount = 0;
221 const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount); 222 const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount);
222 if (!pAttr || iCount < 1) 223 if (!pAttr || iCount < 1)
223 return nullptr; 224 return nullptr;
224 225
225 if (!std::binary_search(pAttr, pAttr + iCount, eAttribute)) 226 if (!std::binary_search(pAttr, pAttr + iCount, eAttribute))
226 return nullptr; 227 return nullptr;
227 228
228 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); 229 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute);
229 ASSERT(pInfo); 230 ASSERT(pInfo);
230 if (dwPacket == XFA_XDPPACKET_UNKNOWN) 231 if (dwPacket == XFA_XDPPACKET_UNKNOWN)
231 return pInfo; 232 return pInfo;
232 return (dwPacket & pInfo->dwPackets) ? pInfo : nullptr; 233 return (dwPacket & pInfo->dwPackets) ? pInfo : nullptr;
233 } 234 }
234 235
235 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement, 236 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement,
236 int32_t& iCount) { 237 int32_t& iCount) {
237 if (eElement >= g_iXFAElementCount) { 238 if (eElement >= g_iXFAElementCount) {
238 return NULL; 239 return nullptr;
239 } 240 }
240 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement; 241 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement;
241 iCount = pElement->wCount; 242 iCount = pElement->wCount;
242 return g_XFAElementPropertyData + pElement->wStart; 243 return g_XFAElementPropertyData + pElement->wStart;
243 } 244 }
244 const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement, 245 const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement,
245 XFA_ELEMENT eProperty, 246 XFA_ELEMENT eProperty,
246 uint32_t dwPacket) { 247 uint32_t dwPacket) {
247 int32_t iCount = 0; 248 int32_t iCount = 0;
248 const XFA_PROPERTY* pProperty = XFA_GetElementProperties(eElement, iCount); 249 const XFA_PROPERTY* pProperty = XFA_GetElementProperties(eElement, iCount);
249 if (pProperty == NULL || iCount < 1) { 250 if (!pProperty || iCount < 1)
250 return NULL; 251 return nullptr;
251 } 252
252 int32_t iStart = 0, iEnd = iCount - 1, iMid; 253 int32_t iStart = 0, iEnd = iCount - 1, iMid;
253 do { 254 do {
254 iMid = (iStart + iEnd) / 2; 255 iMid = (iStart + iEnd) / 2;
255 XFA_ELEMENT eName = (XFA_ELEMENT)pProperty[iMid].eName; 256 XFA_ELEMENT eName = (XFA_ELEMENT)pProperty[iMid].eName;
256 if (eProperty == eName) { 257 if (eProperty == eName) {
257 break; 258 break;
258 } else if (eProperty < eName) { 259 } else if (eProperty < eName) {
259 iEnd = iMid - 1; 260 iEnd = iMid - 1;
260 } else { 261 } else {
261 iStart = iMid + 1; 262 iStart = iMid + 1;
262 } 263 }
263 } while (iStart <= iEnd); 264 } while (iStart <= iEnd);
264 if (iStart > iEnd) { 265 if (iStart > iEnd) {
265 return NULL; 266 return nullptr;
266 } 267 }
267 const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eProperty); 268 const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eProperty);
268 ASSERT(pInfo); 269 ASSERT(pInfo);
269 if (dwPacket == XFA_XDPPACKET_UNKNOWN) 270 if (dwPacket == XFA_XDPPACKET_UNKNOWN)
270 return pProperty + iMid; 271 return pProperty + iMid;
271 return (dwPacket & pInfo->dwPackets) ? (pProperty + iMid) : NULL; 272 return (dwPacket & pInfo->dwPackets) ? (pProperty + iMid) : nullptr;
272 } 273 }
273 const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement, 274 const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement,
274 XFA_ATTRIBUTE eAttribute, 275 XFA_ATTRIBUTE eAttribute,
275 XFA_ATTRIBUTETYPE eType) { 276 XFA_ATTRIBUTETYPE eType) {
276 int32_t iStart = 0, iEnd = g_iXFANotsureCount - 1; 277 int32_t iStart = 0, iEnd = g_iXFANotsureCount - 1;
277 do { 278 do {
278 int32_t iMid = (iStart + iEnd) / 2; 279 int32_t iMid = (iStart + iEnd) / 2;
279 const XFA_NOTSUREATTRIBUTE* pAttr = g_XFANotsureAttributes + iMid; 280 const XFA_NOTSUREATTRIBUTE* pAttr = g_XFANotsureAttributes + iMid;
280 if (eElement == pAttr->eElement) { 281 if (eElement == pAttr->eElement) {
281 if (pAttr->eAttribute == eAttribute) { 282 if (pAttr->eAttribute == eAttribute) {
282 if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { 283 if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) {
283 return pAttr; 284 return pAttr;
284 } 285 }
285 return NULL; 286 return nullptr;
286 } else { 287 } else {
287 int32_t iBefore = iMid - 1; 288 int32_t iBefore = iMid - 1;
288 if (iBefore >= 0) { 289 if (iBefore >= 0) {
289 pAttr = g_XFANotsureAttributes + iBefore; 290 pAttr = g_XFANotsureAttributes + iBefore;
290 while (eElement == pAttr->eElement) { 291 while (eElement == pAttr->eElement) {
291 if (pAttr->eAttribute == eAttribute) { 292 if (pAttr->eAttribute == eAttribute) {
292 if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { 293 if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) {
293 return pAttr; 294 return pAttr;
294 } 295 }
295 return NULL; 296 return nullptr;
296 } 297 }
297 iBefore--; 298 iBefore--;
298 if (iBefore < 0) { 299 if (iBefore < 0) {
299 break; 300 break;
300 } 301 }
301 pAttr = g_XFANotsureAttributes + iBefore; 302 pAttr = g_XFANotsureAttributes + iBefore;
302 } 303 }
303 } 304 }
304 int32_t iAfter = iMid + 1; 305 int32_t iAfter = iMid + 1;
305 if (iAfter <= g_iXFANotsureCount - 1) { 306 if (iAfter <= g_iXFANotsureCount - 1) {
306 pAttr = g_XFANotsureAttributes + iAfter; 307 pAttr = g_XFANotsureAttributes + iAfter;
307 while (eElement == pAttr->eElement) { 308 while (eElement == pAttr->eElement) {
308 if (pAttr->eAttribute == eAttribute) { 309 if (pAttr->eAttribute == eAttribute) {
309 if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { 310 if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) {
310 return pAttr; 311 return pAttr;
311 } 312 }
312 return NULL; 313 return nullptr;
313 } 314 }
314 iAfter++; 315 iAfter++;
315 if (iAfter > g_iXFANotsureCount - 1) { 316 if (iAfter > g_iXFANotsureCount - 1) {
316 break; 317 break;
317 } 318 }
318 pAttr = g_XFANotsureAttributes + iAfter; 319 pAttr = g_XFANotsureAttributes + iAfter;
319 } 320 }
320 } 321 }
321 return NULL; 322 return nullptr;
322 } 323 }
323 } else if (eElement < pAttr->eElement) { 324 } else if (eElement < pAttr->eElement) {
324 iEnd = iMid - 1; 325 iEnd = iMid - 1;
325 } else { 326 } else {
326 iStart = iMid + 1; 327 iStart = iMid + 1;
327 } 328 }
328 } while (iStart <= iEnd); 329 } while (iStart <= iEnd);
329 return NULL; 330 return nullptr;
330 } 331 }
331 332
332 const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement, 333 const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement,
333 const CFX_WideStringC& wsMethodName) { 334 const CFX_WideStringC& wsMethodName) {
334 if (wsMethodName.IsEmpty()) 335 if (wsMethodName.IsEmpty())
335 return nullptr; 336 return nullptr;
336 337
337 int32_t iElementIndex = eElement; 338 int32_t iElementIndex = eElement;
338 while (iElementIndex != -1) { 339 while (iElementIndex != -1) {
339 const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex; 340 const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex;
(...skipping 11 matching lines...) Expand all
351 if (uHash == pInfo->uHash) { 352 if (uHash == pInfo->uHash) {
352 return pInfo; 353 return pInfo;
353 } else if (uHash < pInfo->uHash) { 354 } else if (uHash < pInfo->uHash) {
354 iEnd = iMid - 1; 355 iEnd = iMid - 1;
355 } else { 356 } else {
356 iStart = iMid + 1; 357 iStart = iMid + 1;
357 } 358 }
358 } while (iStart <= iEnd); 359 } while (iStart <= iEnd);
359 iElementIndex = scriptIndex->wParentIndex; 360 iElementIndex = scriptIndex->wParentIndex;
360 } 361 }
361 return NULL; 362 return nullptr;
362 } 363 }
363 const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName( 364 const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(
364 XFA_ELEMENT eElement, 365 XFA_ELEMENT eElement,
365 const CFX_WideStringC& wsAttributeName) { 366 const CFX_WideStringC& wsAttributeName) {
366 if (wsAttributeName.IsEmpty()) 367 if (wsAttributeName.IsEmpty())
367 return nullptr; 368 return nullptr;
368 369
369 int32_t iElementIndex = eElement; 370 int32_t iElementIndex = eElement;
370 while (iElementIndex != -1) { 371 while (iElementIndex != -1) {
371 const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex; 372 const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex;
(...skipping 10 matching lines...) Expand all
382 if (uHash == pInfo->uHash) { 383 if (uHash == pInfo->uHash) {
383 return pInfo; 384 return pInfo;
384 } else if (uHash < pInfo->uHash) { 385 } else if (uHash < pInfo->uHash) {
385 iEnd = iMid - 1; 386 iEnd = iMid - 1;
386 } else { 387 } else {
387 iStart = iMid + 1; 388 iStart = iMid + 1;
388 } 389 }
389 } while (iStart <= iEnd); 390 } while (iStart <= iEnd);
390 iElementIndex = scriptIndex->wParentIndex; 391 iElementIndex = scriptIndex->wParentIndex;
391 } 392 }
392 return NULL; 393 return nullptr;
393 } 394 }
394 void CXFA_Measurement::Set(const CFX_WideStringC& wsMeasure) { 395 void CXFA_Measurement::Set(const CFX_WideStringC& wsMeasure) {
395 if (wsMeasure.IsEmpty()) { 396 if (wsMeasure.IsEmpty()) {
396 m_fValue = 0; 397 m_fValue = 0;
397 m_eUnit = XFA_UNIT_Unknown; 398 m_eUnit = XFA_UNIT_Unknown;
398 return; 399 return;
399 } 400 }
400 int32_t iUsedLen = 0; 401 int32_t iUsedLen = 0;
401 int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0; 402 int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0;
402 FX_FLOAT fValue = FX_wcstof(wsMeasure.c_str() + iOffset, 403 FX_FLOAT fValue = FX_wcstof(wsMeasure.c_str() + iOffset,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 m_iPosition += iMaxLength; 565 m_iPosition += iMaxLength;
565 bEOS = IsEOF(); 566 bEOS = IsEOF();
566 return iMaxLength; 567 return iMaxLength;
567 } 568 }
568 uint16_t CXFA_WideTextRead::GetCodePage() const { 569 uint16_t CXFA_WideTextRead::GetCodePage() const {
569 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; 570 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE;
570 } 571 }
571 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) { 572 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) {
572 return GetCodePage(); 573 return GetCodePage();
573 } 574 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_basic_imp.h ('k') | xfa/fxfa/parser/xfa_document_datadescription_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698