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 "xml_int.h" | 7 #include "xml_int.h" |
8 | 8 |
9 #include "core/include/fxcrt/fx_ext.h" | 9 #include "core/include/fxcrt/fx_ext.h" |
10 #include "core/include/fxcrt/fx_xml.h" | 10 #include "core/include/fxcrt/fx_xml.h" |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 if (!bCDATA && !m_bSaveSpaceChars) { | 456 if (!bCDATA && !m_bSaveSpaceChars) { |
457 dataStr.TrimRight(L" \t\r\n"); | 457 dataStr.TrimRight(L" \t\r\n"); |
458 } | 458 } |
459 InsertContentSegment(bCDATA, dataStr, pElement); | 459 InsertContentSegment(bCDATA, dataStr, pElement); |
460 content.Clear(); | 460 content.Clear(); |
461 decoder.Clear(); | 461 decoder.Clear(); |
462 bCDATA = FALSE; | 462 bCDATA = FALSE; |
463 iState = 0; | 463 iState = 0; |
464 m_dwIndex--; | 464 m_dwIndex--; |
465 CXML_Element* pSubElement = ParseElement(pElement, TRUE); | 465 CXML_Element* pSubElement = ParseElement(pElement, TRUE); |
466 if (pSubElement == NULL) { | 466 if (!pSubElement) { |
467 break; | 467 break; |
468 } | 468 } |
469 pSubElement->m_pParent = pElement; | 469 pSubElement->m_pParent = pElement; |
470 pElement->m_Children.Add((void*)CXML_Element::Element); | 470 pElement->m_Children.Add((void*)CXML_Element::Element); |
471 pElement->m_Children.Add(pSubElement); | 471 pElement->m_Children.Add(pSubElement); |
472 SkipWhiteSpaces(); | 472 SkipWhiteSpaces(); |
473 } | 473 } |
474 break; | 474 break; |
475 case 2: | 475 case 2: |
476 if (ch == '[') { | 476 if (ch == '[') { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 for (int i = 0; i < m_Children.GetSize(); i += 2) { | 760 for (int i = 0; i < m_Children.GetSize(); i += 2) { |
761 if ((ChildType)(uintptr_t)m_Children.GetAt(i) == Element && | 761 if ((ChildType)(uintptr_t)m_Children.GetAt(i) == Element && |
762 (CXML_Element*)m_Children.GetAt(i + 1) == pChild) { | 762 (CXML_Element*)m_Children.GetAt(i + 1) == pChild) { |
763 return (FX_DWORD)(i >> 1); | 763 return (FX_DWORD)(i >> 1); |
764 } | 764 } |
765 } | 765 } |
766 return (FX_DWORD)-1; | 766 return (FX_DWORD)-1; |
767 } | 767 } |
768 const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space, | 768 const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space, |
769 const CFX_ByteStringC& name) const { | 769 const CFX_ByteStringC& name) const { |
770 if (m_pMap == NULL) { | 770 if (!m_pMap) { |
771 return NULL; | 771 return NULL; |
772 } | 772 } |
773 for (int i = 0; i < m_pMap->GetSize(); i++) { | 773 for (int i = 0; i < m_pMap->GetSize(); i++) { |
774 CXML_AttrItem& item = GetAt(i); | 774 CXML_AttrItem& item = GetAt(i); |
775 if ((space.IsEmpty() || item.m_QSpaceName == space) && | 775 if ((space.IsEmpty() || item.m_QSpaceName == space) && |
776 item.m_AttrName == name) { | 776 item.m_AttrName == name) { |
777 return &item.m_Value; | 777 return &item.m_Value; |
778 } | 778 } |
779 } | 779 } |
780 return NULL; | 780 return NULL; |
(...skipping 15 matching lines...) Expand all Loading... |
796 CXML_AttrItem* pItem = (CXML_AttrItem*)m_pMap->AddSpace(); | 796 CXML_AttrItem* pItem = (CXML_AttrItem*)m_pMap->AddSpace(); |
797 if (!pItem) { | 797 if (!pItem) { |
798 return; | 798 return; |
799 } | 799 } |
800 pItem->m_QSpaceName = space; | 800 pItem->m_QSpaceName = space; |
801 pItem->m_AttrName = name; | 801 pItem->m_AttrName = name; |
802 pItem->m_Value = value; | 802 pItem->m_Value = value; |
803 } | 803 } |
804 void CXML_AttrMap::RemoveAt(const CFX_ByteStringC& space, | 804 void CXML_AttrMap::RemoveAt(const CFX_ByteStringC& space, |
805 const CFX_ByteStringC& name) { | 805 const CFX_ByteStringC& name) { |
806 if (m_pMap == NULL) { | 806 if (!m_pMap) { |
807 return; | 807 return; |
808 } | 808 } |
809 for (int i = 0; i < m_pMap->GetSize(); i++) { | 809 for (int i = 0; i < m_pMap->GetSize(); i++) { |
810 CXML_AttrItem& item = GetAt(i); | 810 CXML_AttrItem& item = GetAt(i); |
811 if ((space.IsEmpty() || item.m_QSpaceName == space) && | 811 if ((space.IsEmpty() || item.m_QSpaceName == space) && |
812 item.m_AttrName == name) { | 812 item.m_AttrName == name) { |
813 m_pMap->RemoveAt(i); | 813 m_pMap->RemoveAt(i); |
814 return; | 814 return; |
815 } | 815 } |
816 } | 816 } |
817 } | 817 } |
818 int CXML_AttrMap::GetSize() const { | 818 int CXML_AttrMap::GetSize() const { |
819 return m_pMap == NULL ? 0 : m_pMap->GetSize(); | 819 return m_pMap ? m_pMap->GetSize() : 0; |
820 } | 820 } |
821 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { | 821 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { |
822 return (*m_pMap)[index]; | 822 return (*m_pMap)[index]; |
823 } | 823 } |
824 void CXML_AttrMap::RemoveAll() { | 824 void CXML_AttrMap::RemoveAll() { |
825 if (!m_pMap) { | 825 if (!m_pMap) { |
826 return; | 826 return; |
827 } | 827 } |
828 m_pMap->RemoveAll(); | 828 m_pMap->RemoveAll(); |
829 delete m_pMap; | 829 delete m_pMap; |
830 m_pMap = NULL; | 830 m_pMap = NULL; |
831 } | 831 } |
OLD | NEW |