| 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" |
| 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" | 15 #include "xfa/fxfa/parser/xfa_docdata.h" |
| 16 #include "xfa/fxfa/parser/xfa_doclayout.h" | 16 #include "xfa/fxfa/parser/xfa_doclayout.h" |
| 17 #include "xfa/fxfa/parser/xfa_document.h" | 17 #include "xfa/fxfa/parser/xfa_document.h" |
| 18 #include "xfa/fxfa/parser/xfa_localemgr.h" | 18 #include "xfa/fxfa/parser/xfa_localemgr.h" |
| 19 #include "xfa/fxfa/parser/xfa_object.h" | 19 #include "xfa/fxfa/parser/xfa_object.h" |
| 20 #include "xfa/fxfa/parser/xfa_parser.h" | 20 #include "xfa/fxfa/parser/xfa_parser.h" |
| 21 #include "xfa/fxfa/parser/xfa_script.h" | 21 #include "xfa/fxfa/parser/xfa_script.h" |
| 22 #include "xfa/fxfa/parser/xfa_utils.h" | 22 #include "xfa/fxfa/parser/xfa_utils.h" |
| 23 | 23 |
| 24 const XFA_PACKETINFO* XFA_GetPacketByName(const CFX_WideStringC& wsName) { | 24 const XFA_PACKETINFO* XFA_GetPacketByName(const CFX_WideStringC& wsName) { |
| 25 int32_t iLength = wsName.GetLength(); | 25 int32_t iLength = wsName.GetLength(); |
| 26 if (iLength == 0) { | 26 if (iLength == 0) { |
| 27 return NULL; | 27 return NULL; |
| 28 } | 28 } |
| 29 uint32_t uHash = FX_HashCode_String_GetW(wsName.GetPtr(), iLength); | 29 uint32_t uHash = FX_HashCode_String_GetW(wsName.raw_str(), iLength); |
| 30 int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; | 30 int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; |
| 31 do { | 31 do { |
| 32 int32_t iMid = (iStart + iEnd) / 2; | 32 int32_t iMid = (iStart + iEnd) / 2; |
| 33 const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid; | 33 const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid; |
| 34 if (uHash == pInfo->uHash) { | 34 if (uHash == pInfo->uHash) { |
| 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; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 61 const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) { | 61 const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) { |
| 62 return g_XFAPacketData + ePacket; | 62 return g_XFAPacketData + ePacket; |
| 63 } | 63 } |
| 64 | 64 |
| 65 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName( | 65 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName( |
| 66 const CFX_WideStringC& wsName) { | 66 const CFX_WideStringC& wsName) { |
| 67 int32_t iLength = wsName.GetLength(); | 67 int32_t iLength = wsName.GetLength(); |
| 68 if (iLength == 0) { | 68 if (iLength == 0) { |
| 69 return NULL; | 69 return NULL; |
| 70 } | 70 } |
| 71 uint32_t uHash = FX_HashCode_String_GetW(wsName.GetPtr(), iLength); | 71 uint32_t uHash = FX_HashCode_String_GetW(wsName.raw_str(), iLength); |
| 72 int32_t iStart = 0, iEnd = g_iXFAEnumCount - 1; | 72 int32_t iStart = 0, iEnd = g_iXFAEnumCount - 1; |
| 73 do { | 73 do { |
| 74 int32_t iMid = (iStart + iEnd) / 2; | 74 int32_t iMid = (iStart + iEnd) / 2; |
| 75 const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid; | 75 const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid; |
| 76 if (uHash == pInfo->uHash) { | 76 if (uHash == pInfo->uHash) { |
| 77 return pInfo; | 77 return pInfo; |
| 78 } else if (uHash < pInfo->uHash) { | 78 } else if (uHash < pInfo->uHash) { |
| 79 iEnd = iMid - 1; | 79 iEnd = iMid - 1; |
| 80 } else { | 80 } else { |
| 81 iStart = iMid + 1; | 81 iStart = iMid + 1; |
| 82 } | 82 } |
| 83 } while (iStart <= iEnd); | 83 } while (iStart <= iEnd); |
| 84 return NULL; | 84 return NULL; |
| 85 } | 85 } |
| 86 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) { | 86 const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) { |
| 87 return g_XFAEnumData + eName; | 87 return g_XFAEnumData + eName; |
| 88 } | 88 } |
| 89 int32_t XFA_GetAttributeCount() { | 89 int32_t XFA_GetAttributeCount() { |
| 90 return g_iXFAAttributeCount; | 90 return g_iXFAAttributeCount; |
| 91 } | 91 } |
| 92 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) { | 92 const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) { |
| 93 int32_t iLength = wsName.GetLength(); | 93 int32_t iLength = wsName.GetLength(); |
| 94 if (iLength == 0) { | 94 if (iLength == 0) { |
| 95 return NULL; | 95 return NULL; |
| 96 } | 96 } |
| 97 uint32_t uHash = FX_HashCode_String_GetW(wsName.GetPtr(), iLength); | 97 uint32_t uHash = FX_HashCode_String_GetW(wsName.raw_str(), iLength); |
| 98 int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1; | 98 int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1; |
| 99 do { | 99 do { |
| 100 int32_t iMid = (iStart + iEnd) / 2; | 100 int32_t iMid = (iStart + iEnd) / 2; |
| 101 const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid; | 101 const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid; |
| 102 if (uHash == pInfo->uHash) { | 102 if (uHash == pInfo->uHash) { |
| 103 return pInfo; | 103 return pInfo; |
| 104 } else if (uHash < pInfo->uHash) { | 104 } else if (uHash < pInfo->uHash) { |
| 105 iEnd = iMid - 1; | 105 iEnd = iMid - 1; |
| 106 } else { | 106 } else { |
| 107 iStart = iMid + 1; | 107 iStart = iMid + 1; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 193 const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) { | 193 const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) { |
| 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.raw_str(), 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; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 return NULL; | 373 return NULL; |
| 374 } | 374 } |
| 375 int32_t iElementIndex = eElement; | 375 int32_t iElementIndex = eElement; |
| 376 while (iElementIndex != -1) { | 376 while (iElementIndex != -1) { |
| 377 XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; | 377 XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; |
| 378 int32_t icount = scriptIndex->wMethodCount; | 378 int32_t icount = scriptIndex->wMethodCount; |
| 379 if (icount == 0) { | 379 if (icount == 0) { |
| 380 iElementIndex = scriptIndex->wParentIndex; | 380 iElementIndex = scriptIndex->wParentIndex; |
| 381 continue; | 381 continue; |
| 382 } | 382 } |
| 383 uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.GetPtr(), iLength); | 383 uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.raw_str(), iLength); |
| 384 int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1; | 384 int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1; |
| 385 do { | 385 do { |
| 386 int32_t iMid = (iStart + iEnd) / 2; | 386 int32_t iMid = (iStart + iEnd) / 2; |
| 387 const XFA_METHODINFO* pInfo = g_SomMethodData + iMid; | 387 const XFA_METHODINFO* pInfo = g_SomMethodData + iMid; |
| 388 if (uHash == pInfo->uHash) { | 388 if (uHash == pInfo->uHash) { |
| 389 return pInfo; | 389 return pInfo; |
| 390 } else if (uHash < pInfo->uHash) { | 390 } else if (uHash < pInfo->uHash) { |
| 391 iEnd = iMid - 1; | 391 iEnd = iMid - 1; |
| 392 } else { | 392 } else { |
| 393 iStart = iMid + 1; | 393 iStart = iMid + 1; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 405 return NULL; | 405 return NULL; |
| 406 } | 406 } |
| 407 int32_t iElementIndex = eElement; | 407 int32_t iElementIndex = eElement; |
| 408 while (iElementIndex != -1) { | 408 while (iElementIndex != -1) { |
| 409 XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; | 409 XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; |
| 410 int32_t icount = scriptIndex->wAttributeCount; | 410 int32_t icount = scriptIndex->wAttributeCount; |
| 411 if (icount == 0) { | 411 if (icount == 0) { |
| 412 iElementIndex = scriptIndex->wParentIndex; | 412 iElementIndex = scriptIndex->wParentIndex; |
| 413 continue; | 413 continue; |
| 414 } | 414 } |
| 415 uint32_t uHash = FX_HashCode_String_GetW(wsAttributeName.GetPtr(), iLength); | 415 uint32_t uHash = |
| 416 FX_HashCode_String_GetW(wsAttributeName.raw_str(), iLength); |
| 416 int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1; | 417 int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1; |
| 417 do { | 418 do { |
| 418 int32_t iMid = (iStart + iEnd) / 2; | 419 int32_t iMid = (iStart + iEnd) / 2; |
| 419 const XFA_SCRIPTATTRIBUTEINFO* pInfo = g_SomAttributeData + iMid; | 420 const XFA_SCRIPTATTRIBUTEINFO* pInfo = g_SomAttributeData + iMid; |
| 420 if (uHash == pInfo->uHash) { | 421 if (uHash == pInfo->uHash) { |
| 421 return pInfo; | 422 return pInfo; |
| 422 } else if (uHash < pInfo->uHash) { | 423 } else if (uHash < pInfo->uHash) { |
| 423 iEnd = iMid - 1; | 424 iEnd = iMid - 1; |
| 424 } else { | 425 } else { |
| 425 iStart = iMid + 1; | 426 iStart = iMid + 1; |
| 426 } | 427 } |
| 427 } while (iStart <= iEnd); | 428 } while (iStart <= iEnd); |
| 428 iElementIndex = scriptIndex->wParentIndex; | 429 iElementIndex = scriptIndex->wParentIndex; |
| 429 } | 430 } |
| 430 return NULL; | 431 return NULL; |
| 431 } | 432 } |
| 432 void CXFA_Measurement::Set(const CFX_WideStringC& wsMeasure) { | 433 void CXFA_Measurement::Set(const CFX_WideStringC& wsMeasure) { |
| 433 if (wsMeasure.IsEmpty()) { | 434 if (wsMeasure.IsEmpty()) { |
| 434 m_fValue = 0; | 435 m_fValue = 0; |
| 435 m_eUnit = XFA_UNIT_Unknown; | 436 m_eUnit = XFA_UNIT_Unknown; |
| 436 return; | 437 return; |
| 437 } | 438 } |
| 438 int32_t iUsedLen = 0; | 439 int32_t iUsedLen = 0; |
| 439 int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0; | 440 int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0; |
| 440 FX_FLOAT fValue = FX_wcstof(wsMeasure.GetPtr() + iOffset, | 441 FX_FLOAT fValue = FX_wcstof(wsMeasure.raw_str() + iOffset, |
| 441 wsMeasure.GetLength() - iOffset, &iUsedLen); | 442 wsMeasure.GetLength() - iOffset, &iUsedLen); |
| 442 XFA_UNIT eUnit = GetUnit(wsMeasure.Mid(iOffset + iUsedLen)); | 443 XFA_UNIT eUnit = GetUnit(wsMeasure.Mid(iOffset + iUsedLen)); |
| 443 Set(fValue, eUnit); | 444 Set(fValue, eUnit); |
| 444 } | 445 } |
| 445 FX_BOOL CXFA_Measurement::ToString(CFX_WideString& wsMeasure) const { | 446 FX_BOOL CXFA_Measurement::ToString(CFX_WideString& wsMeasure) const { |
| 446 switch (GetUnit()) { | 447 switch (GetUnit()) { |
| 447 case XFA_UNIT_Mm: | 448 case XFA_UNIT_Mm: |
| 448 wsMeasure.Format(L"%.8gmm", GetValue()); | 449 wsMeasure.Format(L"%.8gmm", GetValue()); |
| 449 return TRUE; | 450 return TRUE; |
| 450 case XFA_UNIT_Pt: | 451 case XFA_UNIT_Pt: |
| (...skipping 152 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 |