| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 size_t CXML_DataStmAcc::GetBlockSize() { | 163 size_t CXML_DataStmAcc::GetBlockSize() { |
| 164 return m_dwSize; | 164 return m_dwSize; |
| 165 } | 165 } |
| 166 | 166 |
| 167 FX_FILESIZE CXML_DataStmAcc::GetBlockOffset() { | 167 FX_FILESIZE CXML_DataStmAcc::GetBlockOffset() { |
| 168 return m_nStart; | 168 return m_nStart; |
| 169 } | 169 } |
| 170 | 170 |
| 171 CXML_Parser::CXML_Parser() | 171 CXML_Parser::CXML_Parser() |
| 172 : m_pDataAcc(nullptr), | 172 : m_pDataAcc(nullptr), |
| 173 m_bOwnedStream(FALSE), | 173 m_bOwnedStream(false), |
| 174 m_nOffset(0), | 174 m_nOffset(0), |
| 175 m_bSaveSpaceChars(FALSE), | 175 m_bSaveSpaceChars(false), |
| 176 m_pBuffer(nullptr), | 176 m_pBuffer(nullptr), |
| 177 m_dwBufferSize(0), | 177 m_dwBufferSize(0), |
| 178 m_nBufferOffset(0), | 178 m_nBufferOffset(0), |
| 179 m_dwIndex(0) {} | 179 m_dwIndex(0) {} |
| 180 | 180 |
| 181 CXML_Parser::~CXML_Parser() { | 181 CXML_Parser::~CXML_Parser() { |
| 182 if (m_bOwnedStream) { | 182 if (m_bOwnedStream) { |
| 183 m_pDataAcc->Release(); | 183 m_pDataAcc->Release(); |
| 184 } | 184 } |
| 185 } | 185 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 419 } |
| 420 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 420 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
| 421 if (ch == mark || m_dwIndex < m_dwBufferSize || IsEOF()) { | 421 if (ch == mark || m_dwIndex < m_dwBufferSize || IsEOF()) { |
| 422 break; | 422 break; |
| 423 } | 423 } |
| 424 } while (ReadNextBlock()); | 424 } while (ReadNextBlock()); |
| 425 value = decoder.GetResult(); | 425 value = decoder.GetResult(); |
| 426 } | 426 } |
| 427 void CXML_Parser::GetTagName(CFX_ByteString& space, | 427 void CXML_Parser::GetTagName(CFX_ByteString& space, |
| 428 CFX_ByteString& name, | 428 CFX_ByteString& name, |
| 429 FX_BOOL& bEndTag, | 429 bool& bEndTag, |
| 430 FX_BOOL bStartTag) { | 430 bool bStartTag) { |
| 431 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 431 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
| 432 if (IsEOF()) { | 432 if (IsEOF()) { |
| 433 return; | 433 return; |
| 434 } | 434 } |
| 435 bEndTag = FALSE; | 435 bEndTag = false; |
| 436 uint8_t ch; | 436 uint8_t ch; |
| 437 int32_t iState = bStartTag ? 1 : 0; | 437 int32_t iState = bStartTag ? 1 : 0; |
| 438 do { | 438 do { |
| 439 while (m_dwIndex < m_dwBufferSize) { | 439 while (m_dwIndex < m_dwBufferSize) { |
| 440 ch = m_pBuffer[m_dwIndex]; | 440 ch = m_pBuffer[m_dwIndex]; |
| 441 switch (iState) { | 441 switch (iState) { |
| 442 case 0: | 442 case 0: |
| 443 m_dwIndex++; | 443 m_dwIndex++; |
| 444 if (ch != '<') { | 444 if (ch != '<') { |
| 445 break; | 445 break; |
| 446 } | 446 } |
| 447 iState = 1; | 447 iState = 1; |
| 448 break; | 448 break; |
| 449 case 1: | 449 case 1: |
| 450 if (ch == '?') { | 450 if (ch == '?') { |
| 451 m_dwIndex++; | 451 m_dwIndex++; |
| 452 SkipLiterals("?>"); | 452 SkipLiterals("?>"); |
| 453 iState = 0; | 453 iState = 0; |
| 454 break; | 454 break; |
| 455 } else if (ch == '!') { | 455 } else if (ch == '!') { |
| 456 m_dwIndex++; | 456 m_dwIndex++; |
| 457 SkipLiterals("-->"); | 457 SkipLiterals("-->"); |
| 458 iState = 0; | 458 iState = 0; |
| 459 break; | 459 break; |
| 460 } | 460 } |
| 461 if (ch == '/') { | 461 if (ch == '/') { |
| 462 m_dwIndex++; | 462 m_dwIndex++; |
| 463 GetName(space, name); | 463 GetName(space, name); |
| 464 bEndTag = TRUE; | 464 bEndTag = true; |
| 465 } else { | 465 } else { |
| 466 GetName(space, name); | 466 GetName(space, name); |
| 467 bEndTag = FALSE; | 467 bEndTag = false; |
| 468 } | 468 } |
| 469 return; | 469 return; |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 472 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
| 473 if (m_dwIndex < m_dwBufferSize || IsEOF()) { | 473 if (m_dwIndex < m_dwBufferSize || IsEOF()) { |
| 474 break; | 474 break; |
| 475 } | 475 } |
| 476 } while (ReadNextBlock()); | 476 } while (ReadNextBlock()); |
| 477 } | 477 } |
| 478 CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, | 478 CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, bool bStartTag) { |
| 479 FX_BOOL bStartTag) { | |
| 480 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 479 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
| 481 if (IsEOF()) { | 480 if (IsEOF()) { |
| 482 return nullptr; | 481 return nullptr; |
| 483 } | 482 } |
| 484 CFX_ByteString tag_name, tag_space; | 483 CFX_ByteString tag_name, tag_space; |
| 485 FX_BOOL bEndTag; | 484 bool bEndTag; |
| 486 GetTagName(tag_space, tag_name, bEndTag, bStartTag); | 485 GetTagName(tag_space, tag_name, bEndTag, bStartTag); |
| 487 if (tag_name.IsEmpty() || bEndTag) { | 486 if (tag_name.IsEmpty() || bEndTag) { |
| 488 return nullptr; | 487 return nullptr; |
| 489 } | 488 } |
| 490 CXML_Element* pElement = new CXML_Element; | 489 CXML_Element* pElement = new CXML_Element; |
| 491 pElement->m_pParent = pParent; | 490 pElement->m_pParent = pParent; |
| 492 pElement->SetTag(tag_space.AsStringC(), tag_name.AsStringC()); | 491 pElement->SetTag(tag_space.AsStringC(), tag_name.AsStringC()); |
| 493 do { | 492 do { |
| 494 CFX_ByteString attr_space, attr_name; | 493 CFX_ByteString attr_space, attr_name; |
| 495 while (m_dwIndex < m_dwBufferSize) { | 494 while (m_dwIndex < m_dwBufferSize) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 535 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
| 537 delete pElement; | 536 delete pElement; |
| 538 return nullptr; | 537 return nullptr; |
| 539 } | 538 } |
| 540 SkipWhiteSpaces(); | 539 SkipWhiteSpaces(); |
| 541 if (IsEOF()) { | 540 if (IsEOF()) { |
| 542 return pElement; | 541 return pElement; |
| 543 } | 542 } |
| 544 CFX_UTF8Decoder decoder; | 543 CFX_UTF8Decoder decoder; |
| 545 CFX_WideTextBuf content; | 544 CFX_WideTextBuf content; |
| 546 FX_BOOL bCDATA = FALSE; | 545 bool bCDATA = false; |
| 547 int32_t iState = 0; | 546 int32_t iState = 0; |
| 548 do { | 547 do { |
| 549 while (m_dwIndex < m_dwBufferSize) { | 548 while (m_dwIndex < m_dwBufferSize) { |
| 550 ch = m_pBuffer[m_dwIndex++]; | 549 ch = m_pBuffer[m_dwIndex++]; |
| 551 switch (iState) { | 550 switch (iState) { |
| 552 case 0: | 551 case 0: |
| 553 if (ch == '<') { | 552 if (ch == '<') { |
| 554 iState = 1; | 553 iState = 1; |
| 555 } else if (ch == '&') { | 554 } else if (ch == '&') { |
| 556 decoder.ClearStatus(); | 555 decoder.ClearStatus(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 574 iState = 10; | 573 iState = 10; |
| 575 } else { | 574 } else { |
| 576 content << decoder.GetResult(); | 575 content << decoder.GetResult(); |
| 577 CFX_WideString dataStr = content.MakeString(); | 576 CFX_WideString dataStr = content.MakeString(); |
| 578 if (!bCDATA && !m_bSaveSpaceChars) { | 577 if (!bCDATA && !m_bSaveSpaceChars) { |
| 579 dataStr.TrimRight(L" \t\r\n"); | 578 dataStr.TrimRight(L" \t\r\n"); |
| 580 } | 579 } |
| 581 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); | 580 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); |
| 582 content.Clear(); | 581 content.Clear(); |
| 583 decoder.Clear(); | 582 decoder.Clear(); |
| 584 bCDATA = FALSE; | 583 bCDATA = false; |
| 585 iState = 0; | 584 iState = 0; |
| 586 m_dwIndex--; | 585 m_dwIndex--; |
| 587 CXML_Element* pSubElement = ParseElement(pElement, TRUE); | 586 CXML_Element* pSubElement = ParseElement(pElement, true); |
| 588 if (!pSubElement) { | 587 if (!pSubElement) { |
| 589 break; | 588 break; |
| 590 } | 589 } |
| 591 pSubElement->m_pParent = pElement; | 590 pSubElement->m_pParent = pElement; |
| 592 pElement->m_Children.push_back( | 591 pElement->m_Children.push_back( |
| 593 {CXML_Element::Element, pSubElement}); | 592 {CXML_Element::Element, pSubElement}); |
| 594 SkipWhiteSpaces(); | 593 SkipWhiteSpaces(); |
| 595 } | 594 } |
| 596 break; | 595 break; |
| 597 case 2: | 596 case 2: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 618 } | 617 } |
| 619 } while (ReadNextBlock()); | 618 } while (ReadNextBlock()); |
| 620 content << decoder.GetResult(); | 619 content << decoder.GetResult(); |
| 621 CFX_WideString dataStr = content.MakeString(); | 620 CFX_WideString dataStr = content.MakeString(); |
| 622 if (!m_bSaveSpaceChars) { | 621 if (!m_bSaveSpaceChars) { |
| 623 dataStr.TrimRight(L" \t\r\n"); | 622 dataStr.TrimRight(L" \t\r\n"); |
| 624 } | 623 } |
| 625 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); | 624 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); |
| 626 content.Clear(); | 625 content.Clear(); |
| 627 decoder.Clear(); | 626 decoder.Clear(); |
| 628 bCDATA = FALSE; | 627 bCDATA = false; |
| 629 return pElement; | 628 return pElement; |
| 630 } | 629 } |
| 631 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, | 630 void CXML_Parser::InsertContentSegment(bool bCDATA, |
| 632 const CFX_WideStringC& content, | 631 const CFX_WideStringC& content, |
| 633 CXML_Element* pElement) { | 632 CXML_Element* pElement) { |
| 634 if (content.IsEmpty()) { | 633 if (content.IsEmpty()) { |
| 635 return; | 634 return; |
| 636 } | 635 } |
| 637 CXML_Content* pContent = new CXML_Content; | 636 CXML_Content* pContent = new CXML_Content; |
| 638 pContent->Set(bCDATA, content); | 637 pContent->Set(bCDATA, content); |
| 639 pElement->m_Children.push_back({CXML_Element::Content, pContent}); | 638 pElement->m_Children.push_back({CXML_Element::Content, pContent}); |
| 640 } | 639 } |
| 641 static CXML_Element* XML_ContinueParse(CXML_Parser& parser, | 640 static CXML_Element* XML_ContinueParse(CXML_Parser& parser, |
| 642 FX_BOOL bSaveSpaceChars, | 641 bool bSaveSpaceChars, |
| 643 FX_FILESIZE* pParsedSize) { | 642 FX_FILESIZE* pParsedSize) { |
| 644 parser.m_bSaveSpaceChars = bSaveSpaceChars; | 643 parser.m_bSaveSpaceChars = bSaveSpaceChars; |
| 645 CXML_Element* pElement = parser.ParseElement(nullptr, FALSE); | 644 CXML_Element* pElement = parser.ParseElement(nullptr, false); |
| 646 if (pParsedSize) { | 645 if (pParsedSize) { |
| 647 *pParsedSize = parser.m_nOffset; | 646 *pParsedSize = parser.m_nOffset; |
| 648 } | 647 } |
| 649 return pElement; | 648 return pElement; |
| 650 } | 649 } |
| 651 CXML_Element* CXML_Element::Parse(const void* pBuffer, | 650 CXML_Element* CXML_Element::Parse(const void* pBuffer, |
| 652 size_t size, | 651 size_t size, |
| 653 FX_BOOL bSaveSpaceChars, | 652 bool bSaveSpaceChars, |
| 654 FX_FILESIZE* pParsedSize) { | 653 FX_FILESIZE* pParsedSize) { |
| 655 CXML_Parser parser; | 654 CXML_Parser parser; |
| 656 if (!parser.Init((uint8_t*)pBuffer, size)) { | 655 if (!parser.Init((uint8_t*)pBuffer, size)) { |
| 657 return nullptr; | 656 return nullptr; |
| 658 } | 657 } |
| 659 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); | 658 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); |
| 660 } | 659 } |
| 661 CXML_Element* CXML_Element::Parse(IFX_SeekableReadStream* pFile, | 660 CXML_Element* CXML_Element::Parse(IFX_SeekableReadStream* pFile, |
| 662 FX_BOOL bSaveSpaceChars, | 661 bool bSaveSpaceChars, |
| 663 FX_FILESIZE* pParsedSize) { | 662 FX_FILESIZE* pParsedSize) { |
| 664 CXML_Parser parser; | 663 CXML_Parser parser; |
| 665 if (!parser.Init(pFile)) { | 664 if (!parser.Init(pFile)) { |
| 666 return nullptr; | 665 return nullptr; |
| 667 } | 666 } |
| 668 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); | 667 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); |
| 669 } | 668 } |
| 670 CXML_Element* CXML_Element::Parse(IFX_BufferRead* pBuffer, | 669 CXML_Element* CXML_Element::Parse(IFX_BufferRead* pBuffer, |
| 671 FX_BOOL bSaveSpaceChars, | 670 bool bSaveSpaceChars, |
| 672 FX_FILESIZE* pParsedSize) { | 671 FX_FILESIZE* pParsedSize) { |
| 673 CXML_Parser parser; | 672 CXML_Parser parser; |
| 674 if (!parser.Init(pBuffer)) { | 673 if (!parser.Init(pBuffer)) { |
| 675 return nullptr; | 674 return nullptr; |
| 676 } | 675 } |
| 677 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); | 676 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); |
| 678 } | 677 } |
| 679 CXML_Element::CXML_Element() : m_QSpaceName(), m_TagName(), m_AttrMap() {} | 678 CXML_Element::CXML_Element() : m_QSpaceName(), m_TagName(), m_AttrMap() {} |
| 680 CXML_Element::CXML_Element(const CFX_ByteStringC& qSpace, | 679 CXML_Element::CXML_Element(const CFX_ByteStringC& qSpace, |
| 681 const CFX_ByteStringC& tagName) | 680 const CFX_ByteStringC& tagName) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 698 if (record.type == Content) { | 697 if (record.type == Content) { |
| 699 delete static_cast<CXML_Content*>(record.child); | 698 delete static_cast<CXML_Content*>(record.child); |
| 700 } else if (record.type == Element) { | 699 } else if (record.type == Element) { |
| 701 CXML_Element* child = static_cast<CXML_Element*>(record.child); | 700 CXML_Element* child = static_cast<CXML_Element*>(record.child); |
| 702 child->RemoveChildren(); | 701 child->RemoveChildren(); |
| 703 delete child; | 702 delete child; |
| 704 } | 703 } |
| 705 } | 704 } |
| 706 m_Children.clear(); | 705 m_Children.clear(); |
| 707 } | 706 } |
| 708 CFX_ByteString CXML_Element::GetTagName(FX_BOOL bQualified) const { | 707 CFX_ByteString CXML_Element::GetTagName(bool bQualified) const { |
| 709 if (!bQualified || m_QSpaceName.IsEmpty()) { | 708 if (!bQualified || m_QSpaceName.IsEmpty()) { |
| 710 return m_TagName; | 709 return m_TagName; |
| 711 } | 710 } |
| 712 CFX_ByteString bsTag = m_QSpaceName; | 711 CFX_ByteString bsTag = m_QSpaceName; |
| 713 bsTag += ":"; | 712 bsTag += ":"; |
| 714 bsTag += m_TagName; | 713 bsTag += m_TagName; |
| 715 return bsTag; | 714 return bsTag; |
| 716 } | 715 } |
| 717 | 716 |
| 718 CFX_ByteString CXML_Element::GetNamespace(FX_BOOL bQualified) const { | 717 CFX_ByteString CXML_Element::GetNamespace(bool bQualified) const { |
| 719 return bQualified ? m_QSpaceName : GetNamespaceURI(m_QSpaceName); | 718 return bQualified ? m_QSpaceName : GetNamespaceURI(m_QSpaceName); |
| 720 } | 719 } |
| 721 | 720 |
| 722 CFX_ByteString CXML_Element::GetNamespaceURI( | 721 CFX_ByteString CXML_Element::GetNamespaceURI( |
| 723 const CFX_ByteString& qName) const { | 722 const CFX_ByteString& qName) const { |
| 724 const CFX_WideString* pwsSpace; | 723 const CFX_WideString* pwsSpace; |
| 725 const CXML_Element* pElement = this; | 724 const CXML_Element* pElement = this; |
| 726 do { | 725 do { |
| 727 if (qName.IsEmpty()) { | 726 if (qName.IsEmpty()) { |
| 728 pwsSpace = pElement->m_AttrMap.Lookup("", "xmlns"); | 727 pwsSpace = pElement->m_AttrMap.Lookup("", "xmlns"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 741 CFX_ByteString& name, | 740 CFX_ByteString& name, |
| 742 CFX_WideString& value) const { | 741 CFX_WideString& value) const { |
| 743 if (index < 0 || index >= m_AttrMap.GetSize()) { | 742 if (index < 0 || index >= m_AttrMap.GetSize()) { |
| 744 return; | 743 return; |
| 745 } | 744 } |
| 746 CXML_AttrItem& item = m_AttrMap.GetAt(index); | 745 CXML_AttrItem& item = m_AttrMap.GetAt(index); |
| 747 space = item.m_QSpaceName; | 746 space = item.m_QSpaceName; |
| 748 name = item.m_AttrName; | 747 name = item.m_AttrName; |
| 749 value = item.m_Value; | 748 value = item.m_Value; |
| 750 } | 749 } |
| 751 FX_BOOL CXML_Element::HasAttr(const CFX_ByteStringC& name) const { | 750 bool CXML_Element::HasAttr(const CFX_ByteStringC& name) const { |
| 752 CFX_ByteStringC bsSpace; | 751 CFX_ByteStringC bsSpace; |
| 753 CFX_ByteStringC bsName; | 752 CFX_ByteStringC bsName; |
| 754 FX_XML_SplitQualifiedName(name, bsSpace, bsName); | 753 FX_XML_SplitQualifiedName(name, bsSpace, bsName); |
| 755 return !!m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName)); | 754 return !!m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName)); |
| 756 } | 755 } |
| 757 FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& name, | 756 bool CXML_Element::GetAttrValue(const CFX_ByteStringC& name, |
| 758 CFX_WideString& attribute) const { | 757 CFX_WideString& attribute) const { |
| 759 CFX_ByteStringC bsSpace; | 758 CFX_ByteStringC bsSpace; |
| 760 CFX_ByteStringC bsName; | 759 CFX_ByteStringC bsName; |
| 761 FX_XML_SplitQualifiedName(name, bsSpace, bsName); | 760 FX_XML_SplitQualifiedName(name, bsSpace, bsName); |
| 762 return GetAttrValue(bsSpace, bsName, attribute); | 761 return GetAttrValue(bsSpace, bsName, attribute); |
| 763 } | 762 } |
| 764 FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& space, | 763 bool CXML_Element::GetAttrValue(const CFX_ByteStringC& space, |
| 765 const CFX_ByteStringC& name, | 764 const CFX_ByteStringC& name, |
| 766 CFX_WideString& attribute) const { | 765 CFX_WideString& attribute) const { |
| 767 const CFX_WideString* pValue = | 766 const CFX_WideString* pValue = |
| 768 m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); | 767 m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); |
| 769 if (pValue) { | 768 if (pValue) { |
| 770 attribute = *pValue; | 769 attribute = *pValue; |
| 771 return TRUE; | 770 return true; |
| 772 } | 771 } |
| 773 return FALSE; | 772 return false; |
| 774 } | 773 } |
| 775 FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& name, | 774 bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& name, |
| 776 int& attribute) const { | 775 int& attribute) const { |
| 777 CFX_ByteStringC bsSpace; | 776 CFX_ByteStringC bsSpace; |
| 778 CFX_ByteStringC bsName; | 777 CFX_ByteStringC bsName; |
| 779 FX_XML_SplitQualifiedName(name, bsSpace, bsName); | 778 FX_XML_SplitQualifiedName(name, bsSpace, bsName); |
| 780 const CFX_WideString* pwsValue = | 779 const CFX_WideString* pwsValue = |
| 781 m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName)); | 780 m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName)); |
| 782 if (pwsValue) { | 781 if (pwsValue) { |
| 783 attribute = pwsValue->GetInteger(); | 782 attribute = pwsValue->GetInteger(); |
| 784 return TRUE; | 783 return true; |
| 785 } | 784 } |
| 786 return FALSE; | 785 return false; |
| 787 } | 786 } |
| 788 FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& space, | 787 bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& space, |
| 789 const CFX_ByteStringC& name, | 788 const CFX_ByteStringC& name, |
| 790 int& attribute) const { | 789 int& attribute) const { |
| 791 const CFX_WideString* pwsValue = | 790 const CFX_WideString* pwsValue = |
| 792 m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); | 791 m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); |
| 793 if (pwsValue) { | 792 if (pwsValue) { |
| 794 attribute = pwsValue->GetInteger(); | 793 attribute = pwsValue->GetInteger(); |
| 795 return TRUE; | 794 return true; |
| 796 } | 795 } |
| 797 return FALSE; | 796 return false; |
| 798 } | 797 } |
| 799 FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& name, | 798 bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& name, |
| 800 FX_FLOAT& attribute) const { | 799 FX_FLOAT& attribute) const { |
| 801 CFX_ByteStringC bsSpace, bsName; | 800 CFX_ByteStringC bsSpace, bsName; |
| 802 FX_XML_SplitQualifiedName(name, bsSpace, bsName); | 801 FX_XML_SplitQualifiedName(name, bsSpace, bsName); |
| 803 return GetAttrFloat(bsSpace, bsName, attribute); | 802 return GetAttrFloat(bsSpace, bsName, attribute); |
| 804 } | 803 } |
| 805 FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, | 804 bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, |
| 806 const CFX_ByteStringC& name, | 805 const CFX_ByteStringC& name, |
| 807 FX_FLOAT& attribute) const { | 806 FX_FLOAT& attribute) const { |
| 808 const CFX_WideString* pValue = | 807 const CFX_WideString* pValue = |
| 809 m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); | 808 m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); |
| 810 if (pValue) { | 809 if (pValue) { |
| 811 attribute = pValue->GetFloat(); | 810 attribute = pValue->GetFloat(); |
| 812 return TRUE; | 811 return true; |
| 813 } | 812 } |
| 814 return FALSE; | 813 return false; |
| 815 } | 814 } |
| 816 CXML_Element::ChildType CXML_Element::GetChildType(uint32_t index) const { | 815 CXML_Element::ChildType CXML_Element::GetChildType(uint32_t index) const { |
| 817 return index < m_Children.size() ? m_Children[index].type : Invalid; | 816 return index < m_Children.size() ? m_Children[index].type : Invalid; |
| 818 } | 817 } |
| 819 CFX_WideString CXML_Element::GetContent(uint32_t index) const { | 818 CFX_WideString CXML_Element::GetContent(uint32_t index) const { |
| 820 if (index < m_Children.size() && m_Children[index].type == Content) { | 819 if (index < m_Children.size() && m_Children[index].type == Content) { |
| 821 CXML_Content* pContent = | 820 CXML_Content* pContent = |
| 822 static_cast<CXML_Content*>(m_Children[index].child); | 821 static_cast<CXML_Content*>(m_Children[index].child); |
| 823 if (pContent) | 822 if (pContent) |
| 824 return pContent->m_Content; | 823 return pContent->m_Content; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 m_pMap->push_back({space, name, CFX_WideString(value)}); | 913 m_pMap->push_back({space, name, CFX_WideString(value)}); |
| 915 } | 914 } |
| 916 | 915 |
| 917 int CXML_AttrMap::GetSize() const { | 916 int CXML_AttrMap::GetSize() const { |
| 918 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; | 917 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; |
| 919 } | 918 } |
| 920 | 919 |
| 921 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { | 920 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { |
| 922 return (*m_pMap)[index]; | 921 return (*m_pMap)[index]; |
| 923 } | 922 } |
| OLD | NEW |