| 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 "core/fxcrt/xml_int.h" | 7 #include "core/fxcrt/xml_int.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 break; | 391 break; |
| 392 } | 392 } |
| 393 m_dwIndex++; | 393 m_dwIndex++; |
| 394 SkipWhiteSpaces(); | 394 SkipWhiteSpaces(); |
| 395 if (IsEOF()) { | 395 if (IsEOF()) { |
| 396 break; | 396 break; |
| 397 } | 397 } |
| 398 CFX_WideString attr_value; | 398 CFX_WideString attr_value; |
| 399 GetAttrValue(attr_value); | 399 GetAttrValue(attr_value); |
| 400 pElement->m_AttrMap.SetAt(attr_space.AsByteStringC(), | 400 pElement->m_AttrMap.SetAt(attr_space.AsByteStringC(), |
| 401 attr_name.AsByteStringC(), attr_value); | 401 attr_name.AsByteStringC(), |
| 402 attr_value.AsWideStringC()); |
| 402 } | 403 } |
| 403 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 404 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
| 404 if (m_dwIndex < m_dwBufferSize || IsEOF()) { | 405 if (m_dwIndex < m_dwBufferSize || IsEOF()) { |
| 405 break; | 406 break; |
| 406 } | 407 } |
| 407 } while (ReadNextBlock()); | 408 } while (ReadNextBlock()); |
| 408 SkipWhiteSpaces(); | 409 SkipWhiteSpaces(); |
| 409 if (IsEOF()) { | 410 if (IsEOF()) { |
| 410 return pElement; | 411 return pElement; |
| 411 } | 412 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 GetName(space, name); | 455 GetName(space, name); |
| 455 SkipWhiteSpaces(); | 456 SkipWhiteSpaces(); |
| 456 m_dwIndex++; | 457 m_dwIndex++; |
| 457 iState = 10; | 458 iState = 10; |
| 458 } else { | 459 } else { |
| 459 content << decoder.GetResult(); | 460 content << decoder.GetResult(); |
| 460 CFX_WideString dataStr = content.GetWideString(); | 461 CFX_WideString dataStr = content.GetWideString(); |
| 461 if (!bCDATA && !m_bSaveSpaceChars) { | 462 if (!bCDATA && !m_bSaveSpaceChars) { |
| 462 dataStr.TrimRight(L" \t\r\n"); | 463 dataStr.TrimRight(L" \t\r\n"); |
| 463 } | 464 } |
| 464 InsertContentSegment(bCDATA, dataStr, pElement); | 465 InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement); |
| 465 content.Clear(); | 466 content.Clear(); |
| 466 decoder.Clear(); | 467 decoder.Clear(); |
| 467 bCDATA = FALSE; | 468 bCDATA = FALSE; |
| 468 iState = 0; | 469 iState = 0; |
| 469 m_dwIndex--; | 470 m_dwIndex--; |
| 470 CXML_Element* pSubElement = ParseElement(pElement, TRUE); | 471 CXML_Element* pSubElement = ParseElement(pElement, TRUE); |
| 471 if (!pSubElement) { | 472 if (!pSubElement) { |
| 472 break; | 473 break; |
| 473 } | 474 } |
| 474 pSubElement->m_pParent = pElement; | 475 pSubElement->m_pParent = pElement; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 498 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 499 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
| 499 if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) { | 500 if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) { |
| 500 break; | 501 break; |
| 501 } | 502 } |
| 502 } while (ReadNextBlock()); | 503 } while (ReadNextBlock()); |
| 503 content << decoder.GetResult(); | 504 content << decoder.GetResult(); |
| 504 CFX_WideString dataStr = content.GetWideString(); | 505 CFX_WideString dataStr = content.GetWideString(); |
| 505 if (!m_bSaveSpaceChars) { | 506 if (!m_bSaveSpaceChars) { |
| 506 dataStr.TrimRight(L" \t\r\n"); | 507 dataStr.TrimRight(L" \t\r\n"); |
| 507 } | 508 } |
| 508 InsertContentSegment(bCDATA, dataStr, pElement); | 509 InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement); |
| 509 content.Clear(); | 510 content.Clear(); |
| 510 decoder.Clear(); | 511 decoder.Clear(); |
| 511 bCDATA = FALSE; | 512 bCDATA = FALSE; |
| 512 return pElement; | 513 return pElement; |
| 513 } | 514 } |
| 514 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, | 515 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, |
| 515 const CFX_WideStringC& content, | 516 const CFX_WideStringC& content, |
| 516 CXML_Element* pElement) { | 517 CXML_Element* pElement) { |
| 517 if (content.IsEmpty()) { | 518 if (content.IsEmpty()) { |
| 518 return; | 519 return; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 m_pMap->push_back({space, name, value}); | 788 m_pMap->push_back({space, name, value}); |
| 788 } | 789 } |
| 789 | 790 |
| 790 int CXML_AttrMap::GetSize() const { | 791 int CXML_AttrMap::GetSize() const { |
| 791 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; | 792 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; |
| 792 } | 793 } |
| 793 | 794 |
| 794 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { | 795 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { |
| 795 return (*m_pMap)[index]; | 796 return (*m_pMap)[index]; |
| 796 } | 797 } |
| OLD | NEW |