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

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

Issue 1830323006: Remove FX_DWORD from XFA. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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
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_algorithm.h" 10 #include "xfa/fgas/crt/fgas_algorithm.h"
(...skipping 24 matching lines...) Expand all
35 return pInfo; 35 return pInfo;
36 } else if (uHash < pInfo->uHash) { 36 } else if (uHash < pInfo->uHash) {
37 iEnd = iMid - 1; 37 iEnd = iMid - 1;
38 } else { 38 } else {
39 iStart = iMid + 1; 39 iStart = iMid + 1;
40 } 40 }
41 } while (iStart <= iEnd); 41 } while (iStart <= iEnd);
42 return NULL; 42 return NULL;
43 } 43 }
44 44
45 const XFA_PACKETINFO* XFA_GetPacketByID(FX_DWORD dwPacket) { 45 const XFA_PACKETINFO* XFA_GetPacketByID(uint32_t dwPacket) {
46 int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; 46 int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1;
47 do { 47 do {
48 int32_t iMid = (iStart + iEnd) / 2; 48 int32_t iMid = (iStart + iEnd) / 2;
49 FX_DWORD dwFind = (g_XFAPacketData + iMid)->eName; 49 uint32_t dwFind = (g_XFAPacketData + iMid)->eName;
50 if (dwPacket == dwFind) { 50 if (dwPacket == dwFind) {
51 return g_XFAPacketData + iMid; 51 return g_XFAPacketData + iMid;
52 } else if (dwPacket < dwFind) { 52 } else if (dwPacket < dwFind) {
53 iEnd = iMid - 1; 53 iEnd = iMid - 1;
54 } else { 54 } else {
55 iStart = iMid + 1; 55 iStart = iMid + 1;
56 } 56 }
57 } while (iStart <= iEnd); 57 } while (iStart <= iEnd);
58 return NULL; 58 return NULL;
59 } 59 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } while (iStart <= iEnd); 109 } while (iStart <= iEnd);
110 return NULL; 110 return NULL;
111 } 111 }
112 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) { 112 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) {
113 return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName) : NULL; 113 return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName) : NULL;
114 } 114 }
115 FX_BOOL XFA_GetAttributeDefaultValue(void*& pValue, 115 FX_BOOL XFA_GetAttributeDefaultValue(void*& pValue,
116 XFA_ELEMENT eElement, 116 XFA_ELEMENT eElement,
117 XFA_ATTRIBUTE eAttribute, 117 XFA_ATTRIBUTE eAttribute,
118 XFA_ATTRIBUTETYPE eType, 118 XFA_ATTRIBUTETYPE eType,
119 FX_DWORD dwPacket) { 119 uint32_t dwPacket) {
120 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); 120 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute);
121 if (pInfo == NULL) { 121 if (pInfo == NULL) {
122 return FALSE; 122 return FALSE;
123 } 123 }
124 if (dwPacket && (dwPacket & pInfo->dwPackets) == 0) { 124 if (dwPacket && (dwPacket & pInfo->dwPackets) == 0) {
125 return FALSE; 125 return FALSE;
126 } 126 }
127 if (pInfo->eType == eType) { 127 if (pInfo->eType == eType) {
128 pValue = pInfo->pDefValue; 128 pValue = pInfo->pDefValue;
129 return TRUE; 129 return TRUE;
130 } else if (pInfo->eType == XFA_ATTRIBUTETYPE_NOTSURE) { 130 } else if (pInfo->eType == XFA_ATTRIBUTETYPE_NOTSURE) {
131 const XFA_NOTSUREATTRIBUTE* pAttr = 131 const XFA_NOTSUREATTRIBUTE* pAttr =
132 XFA_GetNotsureAttribute(eElement, eAttribute, eType); 132 XFA_GetNotsureAttribute(eElement, eAttribute, eType);
133 if (pAttr) { 133 if (pAttr) {
134 pValue = pAttr->pValue; 134 pValue = pAttr->pValue;
135 return TRUE; 135 return TRUE;
136 } 136 }
137 } 137 }
138 return FALSE; 138 return FALSE;
139 } 139 }
140 XFA_ATTRIBUTEENUM XFA_GetAttributeDefaultValue_Enum(XFA_ELEMENT eElement, 140 XFA_ATTRIBUTEENUM XFA_GetAttributeDefaultValue_Enum(XFA_ELEMENT eElement,
141 XFA_ATTRIBUTE eAttribute, 141 XFA_ATTRIBUTE eAttribute,
142 FX_DWORD dwPacket) { 142 uint32_t dwPacket) {
143 void* pValue; 143 void* pValue;
144 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 144 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
145 XFA_ATTRIBUTETYPE_Enum, dwPacket)) { 145 XFA_ATTRIBUTETYPE_Enum, dwPacket)) {
146 return (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; 146 return (XFA_ATTRIBUTEENUM)(uintptr_t)pValue;
147 } 147 }
148 return XFA_ATTRIBUTEENUM_Unknown; 148 return XFA_ATTRIBUTEENUM_Unknown;
149 } 149 }
150 CFX_WideStringC XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT eElement, 150 CFX_WideStringC XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT eElement,
151 XFA_ATTRIBUTE eAttribute, 151 XFA_ATTRIBUTE eAttribute,
152 FX_DWORD dwPacket) { 152 uint32_t dwPacket) {
153 void* pValue; 153 void* pValue;
154 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 154 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
155 XFA_ATTRIBUTETYPE_Cdata, dwPacket)) { 155 XFA_ATTRIBUTETYPE_Cdata, dwPacket)) {
156 return (const FX_WCHAR*)pValue; 156 return (const FX_WCHAR*)pValue;
157 } 157 }
158 return NULL; 158 return NULL;
159 } 159 }
160 FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement, 160 FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement,
161 XFA_ATTRIBUTE eAttribute, 161 XFA_ATTRIBUTE eAttribute,
162 FX_DWORD dwPacket) { 162 uint32_t dwPacket) {
163 void* pValue; 163 void* pValue;
164 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 164 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
165 XFA_ATTRIBUTETYPE_Boolean, dwPacket)) { 165 XFA_ATTRIBUTETYPE_Boolean, dwPacket)) {
166 return (FX_BOOL)(uintptr_t)pValue; 166 return (FX_BOOL)(uintptr_t)pValue;
167 } 167 }
168 return FALSE; 168 return FALSE;
169 } 169 }
170 int32_t XFA_GetAttributeDefaultValue_Integer(XFA_ELEMENT eElement, 170 int32_t XFA_GetAttributeDefaultValue_Integer(XFA_ELEMENT eElement,
171 XFA_ATTRIBUTE eAttribute, 171 XFA_ATTRIBUTE eAttribute,
172 FX_DWORD dwPacket) { 172 uint32_t dwPacket) {
173 void* pValue; 173 void* pValue;
174 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 174 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
175 XFA_ATTRIBUTETYPE_Integer, dwPacket)) { 175 XFA_ATTRIBUTETYPE_Integer, dwPacket)) {
176 return (int32_t)(uintptr_t)pValue; 176 return (int32_t)(uintptr_t)pValue;
177 } 177 }
178 return 0; 178 return 0;
179 } 179 }
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 FX_DWORD 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_GetElementCount() {
191 return g_iXFAElementCount; 191 return g_iXFAElementCount;
192 } 192 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) { 224 const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) {
225 if (eElement >= g_iXFAElementCount) { 225 if (eElement >= g_iXFAElementCount) {
226 return NULL; 226 return NULL;
227 } 227 }
228 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement; 228 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement;
229 iCount = pElement->wCount; 229 iCount = pElement->wCount;
230 return g_XFAElementAttributeData + pElement->wStart; 230 return g_XFAElementAttributeData + pElement->wStart;
231 } 231 }
232 const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement, 232 const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement,
233 XFA_ATTRIBUTE eAttribute, 233 XFA_ATTRIBUTE eAttribute,
234 FX_DWORD dwPacket) { 234 uint32_t dwPacket) {
235 int32_t iCount = 0; 235 int32_t iCount = 0;
236 const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount); 236 const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount);
237 if (pAttr == NULL || iCount < 1) { 237 if (pAttr == NULL || iCount < 1) {
238 return NULL; 238 return NULL;
239 } 239 }
240 CFX_DSPATemplate<uint8_t> search; 240 CFX_DSPATemplate<uint8_t> search;
241 int32_t index = search.Lookup(eAttribute, pAttr, iCount); 241 int32_t index = search.Lookup(eAttribute, pAttr, iCount);
242 if (index < 0) { 242 if (index < 0) {
243 return NULL; 243 return NULL;
244 } 244 }
245 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); 245 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute);
246 ASSERT(pInfo); 246 ASSERT(pInfo);
247 if (dwPacket == XFA_XDPPACKET_UNKNOWN) 247 if (dwPacket == XFA_XDPPACKET_UNKNOWN)
248 return pInfo; 248 return pInfo;
249 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; 249 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL;
250 } 250 }
251 const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement, 251 const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement,
252 XFA_ELEMENT eChild, 252 XFA_ELEMENT eChild,
253 FX_DWORD dwPacket) { 253 uint32_t dwPacket) {
254 int32_t iCount = 0; 254 int32_t iCount = 0;
255 const uint16_t* pChild = XFA_GetElementChildren(eElement, iCount); 255 const uint16_t* pChild = XFA_GetElementChildren(eElement, iCount);
256 if (pChild == NULL || iCount < 1) { 256 if (pChild == NULL || iCount < 1) {
257 return NULL; 257 return NULL;
258 } 258 }
259 CFX_DSPATemplate<uint16_t> search; 259 CFX_DSPATemplate<uint16_t> search;
260 int32_t index = search.Lookup(eChild, pChild, iCount); 260 int32_t index = search.Lookup(eChild, pChild, iCount);
261 if (index < 0) { 261 if (index < 0) {
262 return NULL; 262 return NULL;
263 } 263 }
264 const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eChild); 264 const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eChild);
265 ASSERT(pInfo); 265 ASSERT(pInfo);
266 if (dwPacket == XFA_XDPPACKET_UNKNOWN) 266 if (dwPacket == XFA_XDPPACKET_UNKNOWN)
267 return pInfo; 267 return pInfo;
268 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; 268 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL;
269 } 269 }
270 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement, 270 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement,
271 int32_t& iCount) { 271 int32_t& iCount) {
272 if (eElement >= g_iXFAElementCount) { 272 if (eElement >= g_iXFAElementCount) {
273 return NULL; 273 return NULL;
274 } 274 }
275 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement; 275 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement;
276 iCount = pElement->wCount; 276 iCount = pElement->wCount;
277 return g_XFAElementPropertyData + pElement->wStart; 277 return g_XFAElementPropertyData + pElement->wStart;
278 } 278 }
279 const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement, 279 const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement,
280 XFA_ELEMENT eProperty, 280 XFA_ELEMENT eProperty,
281 FX_DWORD dwPacket) { 281 uint32_t dwPacket) {
282 int32_t iCount = 0; 282 int32_t iCount = 0;
283 const XFA_PROPERTY* pProperty = XFA_GetElementProperties(eElement, iCount); 283 const XFA_PROPERTY* pProperty = XFA_GetElementProperties(eElement, iCount);
284 if (pProperty == NULL || iCount < 1) { 284 if (pProperty == NULL || iCount < 1) {
285 return NULL; 285 return NULL;
286 } 286 }
287 int32_t iStart = 0, iEnd = iCount - 1, iMid; 287 int32_t iStart = 0, iEnd = iCount - 1, iMid;
288 do { 288 do {
289 iMid = (iStart + iEnd) / 2; 289 iMid = (iStart + iEnd) / 2;
290 XFA_ELEMENT eName = (XFA_ELEMENT)pProperty[iMid].eName; 290 XFA_ELEMENT eName = (XFA_ELEMENT)pProperty[iMid].eName;
291 if (eProperty == eName) { 291 if (eProperty == eName) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 : m_wsBuffer(wsBuffer), m_iPosition(0), m_iRefCount(1) {} 553 : m_wsBuffer(wsBuffer), m_iPosition(0), m_iRefCount(1) {}
554 void CXFA_WideTextRead::Release() { 554 void CXFA_WideTextRead::Release() {
555 if (--m_iRefCount < 1) { 555 if (--m_iRefCount < 1) {
556 delete this; 556 delete this;
557 } 557 }
558 } 558 }
559 IFX_Stream* CXFA_WideTextRead::Retain() { 559 IFX_Stream* CXFA_WideTextRead::Retain() {
560 m_iRefCount++; 560 m_iRefCount++;
561 return this; 561 return this;
562 } 562 }
563 FX_DWORD CXFA_WideTextRead::GetAccessModes() const { 563 uint32_t CXFA_WideTextRead::GetAccessModes() const {
564 return FX_STREAMACCESS_Read | FX_STREAMACCESS_Text; 564 return FX_STREAMACCESS_Read | FX_STREAMACCESS_Text;
565 } 565 }
566 int32_t CXFA_WideTextRead::GetLength() const { 566 int32_t CXFA_WideTextRead::GetLength() const {
567 return m_wsBuffer.GetLength() * sizeof(FX_WCHAR); 567 return m_wsBuffer.GetLength() * sizeof(FX_WCHAR);
568 } 568 }
569 int32_t CXFA_WideTextRead::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { 569 int32_t CXFA_WideTextRead::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) {
570 switch (eSeek) { 570 switch (eSeek) {
571 case FX_STREAMSEEK_Begin: 571 case FX_STREAMSEEK_Begin:
572 m_iPosition = iOffset; 572 m_iPosition = iOffset;
573 break; 573 break;
(...skipping 29 matching lines...) Expand all
603 m_iPosition += iMaxLength; 603 m_iPosition += iMaxLength;
604 bEOS = IsEOF(); 604 bEOS = IsEOF();
605 return iMaxLength; 605 return iMaxLength;
606 } 606 }
607 uint16_t CXFA_WideTextRead::GetCodePage() const { 607 uint16_t CXFA_WideTextRead::GetCodePage() const {
608 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; 608 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE;
609 } 609 }
610 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) { 610 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) {
611 return GetCodePage(); 611 return GetCodePage();
612 } 612 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_simpleexpression.cpp ('k') | xfa/fxfa/parser/xfa_document_datadescription_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698