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

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

Issue 1899103002: XFA unused function cleanup (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
« no previous file with comments | « xfa/fxfa/parser/xfa_basic_data.cpp ('k') | xfa/fxfa/parser/xfa_docdata.h » ('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_algorithm.h" 10 #include "xfa/fgas/crt/fgas_algorithm.h"
11 #include "xfa/fgas/crt/fgas_codepage.h" 11 #include "xfa/fgas/crt/fgas_codepage.h"
12 #include "xfa/fgas/crt/fgas_system.h" 12 #include "xfa/fgas/crt/fgas_system.h"
13 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" 13 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
14 #include "xfa/fxfa/parser/xfa_basic_data.h" 14 #include "xfa/fxfa/parser/xfa_basic_data.h"
15 #include "xfa/fxfa/parser/xfa_docdata.h"
16 #include "xfa/fxfa/parser/xfa_doclayout.h" 15 #include "xfa/fxfa/parser/xfa_doclayout.h"
17 #include "xfa/fxfa/parser/xfa_document.h" 16 #include "xfa/fxfa/parser/xfa_document.h"
18 #include "xfa/fxfa/parser/xfa_localemgr.h" 17 #include "xfa/fxfa/parser/xfa_localemgr.h"
19 #include "xfa/fxfa/parser/xfa_object.h" 18 #include "xfa/fxfa/parser/xfa_object.h"
20 #include "xfa/fxfa/parser/xfa_parser.h" 19 #include "xfa/fxfa/parser/xfa_parser.h"
21 #include "xfa/fxfa/parser/xfa_script.h" 20 #include "xfa/fxfa/parser/xfa_script.h"
22 #include "xfa/fxfa/parser/xfa_utils.h" 21 #include "xfa/fxfa/parser/xfa_utils.h"
23 22
24 const XFA_PACKETINFO* XFA_GetPacketByName(const CFX_WideStringC& wsName) { 23 const XFA_PACKETINFO* XFA_GetPacketByName(const CFX_WideStringC& wsName) {
25 int32_t iLength = wsName.GetLength(); 24 int32_t iLength = wsName.GetLength();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 iEnd = iMid - 1; 78 iEnd = iMid - 1;
80 } else { 79 } else {
81 iStart = iMid + 1; 80 iStart = iMid + 1;
82 } 81 }
83 } while (iStart <= iEnd); 82 } while (iStart <= iEnd);
84 return NULL; 83 return NULL;
85 } 84 }
86 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) { 85 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) {
87 return g_XFAEnumData + eName; 86 return g_XFAEnumData + eName;
88 } 87 }
89 int32_t XFA_GetAttributeCount() { 88
90 return g_iXFAAttributeCount;
91 }
92 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) { 89 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) {
93 int32_t iLength = wsName.GetLength(); 90 int32_t iLength = wsName.GetLength();
94 if (iLength == 0) { 91 if (iLength == 0) {
95 return NULL; 92 return NULL;
96 } 93 }
97 uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength); 94 uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength);
98 int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1; 95 int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1;
99 do { 96 do {
100 int32_t iMid = (iStart + iEnd) / 2; 97 int32_t iMid = (iStart + iEnd) / 2;
101 const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid; 98 const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement, 157 FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement,
161 XFA_ATTRIBUTE eAttribute, 158 XFA_ATTRIBUTE eAttribute,
162 uint32_t dwPacket) { 159 uint32_t dwPacket) {
163 void* pValue; 160 void* pValue;
164 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 161 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
165 XFA_ATTRIBUTETYPE_Boolean, dwPacket)) { 162 XFA_ATTRIBUTETYPE_Boolean, dwPacket)) {
166 return (FX_BOOL)(uintptr_t)pValue; 163 return (FX_BOOL)(uintptr_t)pValue;
167 } 164 }
168 return FALSE; 165 return FALSE;
169 } 166 }
170 int32_t XFA_GetAttributeDefaultValue_Integer(XFA_ELEMENT eElement, 167
171 XFA_ATTRIBUTE eAttribute,
172 uint32_t dwPacket) {
173 void* pValue;
174 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
175 XFA_ATTRIBUTETYPE_Integer, dwPacket)) {
176 return (int32_t)(uintptr_t)pValue;
177 }
178 return 0;
179 }
180 CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement, 168 CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement,
181 XFA_ATTRIBUTE eAttribute, 169 XFA_ATTRIBUTE eAttribute,
182 uint32_t dwPacket) { 170 uint32_t dwPacket) {
183 void* pValue; 171 void* pValue;
184 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 172 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
185 XFA_ATTRIBUTETYPE_Measure, dwPacket)) { 173 XFA_ATTRIBUTETYPE_Measure, dwPacket)) {
186 return *(CXFA_Measurement*)pValue; 174 return *(CXFA_Measurement*)pValue;
187 } 175 }
188 return CXFA_Measurement(); 176 return CXFA_Measurement();
189 } 177 }
190 int32_t XFA_GetElementCount() { 178
191 return g_iXFAElementCount;
192 }
193 const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) { 179 const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) {
194 int32_t iLength = wsName.GetLength(); 180 int32_t iLength = wsName.GetLength();
195 if (iLength == 0) { 181 if (iLength == 0) {
196 return NULL; 182 return NULL;
197 } 183 }
198 uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength); 184 uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength);
199 int32_t iStart = 0, iEnd = g_iXFAElementCount - 1; 185 int32_t iStart = 0, iEnd = g_iXFAElementCount - 1;
200 do { 186 do {
201 int32_t iMid = (iStart + iEnd) / 2; 187 int32_t iMid = (iStart + iEnd) / 2;
202 const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid; 188 const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 int32_t index = search.Lookup(eAttribute, pAttr, iCount); 227 int32_t index = search.Lookup(eAttribute, pAttr, iCount);
242 if (index < 0) { 228 if (index < 0) {
243 return NULL; 229 return NULL;
244 } 230 }
245 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); 231 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute);
246 ASSERT(pInfo); 232 ASSERT(pInfo);
247 if (dwPacket == XFA_XDPPACKET_UNKNOWN) 233 if (dwPacket == XFA_XDPPACKET_UNKNOWN)
248 return pInfo; 234 return pInfo;
249 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; 235 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL;
250 } 236 }
251 const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement, 237
252 XFA_ELEMENT eChild,
253 uint32_t dwPacket) {
254 int32_t iCount = 0;
255 const uint16_t* pChild = XFA_GetElementChildren(eElement, iCount);
256 if (pChild == NULL || iCount < 1) {
257 return NULL;
258 }
259 CFX_DSPATemplate<uint16_t> search;
260 int32_t index = search.Lookup(eChild, pChild, iCount);
261 if (index < 0) {
262 return NULL;
263 }
264 const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eChild);
265 ASSERT(pInfo);
266 if (dwPacket == XFA_XDPPACKET_UNKNOWN)
267 return pInfo;
268 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL;
269 }
270 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement, 238 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement,
271 int32_t& iCount) { 239 int32_t& iCount) {
272 if (eElement >= g_iXFAElementCount) { 240 if (eElement >= g_iXFAElementCount) {
273 return NULL; 241 return NULL;
274 } 242 }
275 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement; 243 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement;
276 iCount = pElement->wCount; 244 iCount = pElement->wCount;
277 return g_XFAElementPropertyData + pElement->wStart; 245 return g_XFAElementPropertyData + pElement->wStart;
278 } 246 }
279 const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement, 247 const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return NULL; 324 return NULL;
357 } 325 }
358 } else if (eElement < pAttr->eElement) { 326 } else if (eElement < pAttr->eElement) {
359 iEnd = iMid - 1; 327 iEnd = iMid - 1;
360 } else { 328 } else {
361 iStart = iMid + 1; 329 iStart = iMid + 1;
362 } 330 }
363 } while (iStart <= iEnd); 331 } while (iStart <= iEnd);
364 return NULL; 332 return NULL;
365 } 333 }
366 int32_t XFA_GetMethodCount() { 334
367 return g_iSomMethodCount;
368 }
369 const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement, 335 const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement,
370 const CFX_WideStringC& wsMethodName) { 336 const CFX_WideStringC& wsMethodName) {
371 int32_t iLength = wsMethodName.GetLength(); 337 int32_t iLength = wsMethodName.GetLength();
372 if (iLength == 0) { 338 if (iLength == 0) {
373 return NULL; 339 return NULL;
374 } 340 }
375 int32_t iElementIndex = eElement; 341 int32_t iElementIndex = eElement;
376 while (iElementIndex != -1) { 342 while (iElementIndex != -1) {
377 XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; 343 XFA_SCRIPTHIERARCHY const* scriptIndex = g_XFAScriptIndex + iElementIndex;
Lei Zhang 2016/04/19 04:25:51 XFA_SCRIPTHIERARCHY* const ?
dsinclair 2016/04/19 12:53:10 Nak. cannot initialize a variable of type 'XFA_S
Lei Zhang 2016/04/19 17:45:19 Oh, umm, const XFA_SCRIPTHIERARCHY* then?
378 int32_t icount = scriptIndex->wMethodCount; 344 int32_t icount = scriptIndex->wMethodCount;
379 if (icount == 0) { 345 if (icount == 0) {
380 iElementIndex = scriptIndex->wParentIndex; 346 iElementIndex = scriptIndex->wParentIndex;
381 continue; 347 continue;
382 } 348 }
383 uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.c_str(), iLength); 349 uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.c_str(), iLength);
384 int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1; 350 int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1;
385 do { 351 do {
386 int32_t iMid = (iStart + iEnd) / 2; 352 int32_t iMid = (iStart + iEnd) / 2;
387 const XFA_METHODINFO* pInfo = g_SomMethodData + iMid; 353 const XFA_METHODINFO* pInfo = g_SomMethodData + iMid;
(...skipping 11 matching lines...) Expand all
399 } 365 }
400 const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName( 366 const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(
401 XFA_ELEMENT eElement, 367 XFA_ELEMENT eElement,
402 const CFX_WideStringC& wsAttributeName) { 368 const CFX_WideStringC& wsAttributeName) {
403 int32_t iLength = wsAttributeName.GetLength(); 369 int32_t iLength = wsAttributeName.GetLength();
404 if (iLength == 0) { 370 if (iLength == 0) {
405 return NULL; 371 return NULL;
406 } 372 }
407 int32_t iElementIndex = eElement; 373 int32_t iElementIndex = eElement;
408 while (iElementIndex != -1) { 374 while (iElementIndex != -1) {
409 XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; 375 XFA_SCRIPTHIERARCHY const* scriptIndex = g_XFAScriptIndex + iElementIndex;
410 int32_t icount = scriptIndex->wAttributeCount; 376 int32_t icount = scriptIndex->wAttributeCount;
411 if (icount == 0) { 377 if (icount == 0) {
412 iElementIndex = scriptIndex->wParentIndex; 378 iElementIndex = scriptIndex->wParentIndex;
413 continue; 379 continue;
414 } 380 }
415 uint32_t uHash = FX_HashCode_String_GetW(wsAttributeName.c_str(), iLength); 381 uint32_t uHash = FX_HashCode_String_GetW(wsAttributeName.c_str(), iLength);
416 int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1; 382 int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1;
417 do { 383 do {
418 int32_t iMid = (iStart + iEnd) / 2; 384 int32_t iMid = (iStart + iEnd) / 2;
419 const XFA_SCRIPTATTRIBUTEINFO* pInfo = g_SomAttributeData + iMid; 385 const XFA_SCRIPTATTRIBUTEINFO* pInfo = g_SomAttributeData + iMid;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 m_iPosition += iMaxLength; 569 m_iPosition += iMaxLength;
604 bEOS = IsEOF(); 570 bEOS = IsEOF();
605 return iMaxLength; 571 return iMaxLength;
606 } 572 }
607 uint16_t CXFA_WideTextRead::GetCodePage() const { 573 uint16_t CXFA_WideTextRead::GetCodePage() const {
608 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; 574 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE;
609 } 575 }
610 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) { 576 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) {
611 return GetCodePage(); 577 return GetCodePage();
612 } 578 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_basic_data.cpp ('k') | xfa/fxfa/parser/xfa_docdata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698