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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if (m_dwIndex < m_dwBufferSize || IsEOF()) { | 172 if (m_dwIndex < m_dwBufferSize || IsEOF()) { |
173 break; | 173 break; |
174 } | 174 } |
175 } while (ReadNextBlock()); | 175 } while (ReadNextBlock()); |
176 while (!m_pDataAcc->IsEOF()) { | 176 while (!m_pDataAcc->IsEOF()) { |
177 ReadNextBlock(); | 177 ReadNextBlock(); |
178 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwBufferSize; | 178 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwBufferSize; |
179 } | 179 } |
180 m_dwIndex = m_dwBufferSize; | 180 m_dwIndex = m_dwBufferSize; |
181 } | 181 } |
182 FX_DWORD CXML_Parser::GetCharRef() { | 182 uint32_t CXML_Parser::GetCharRef() { |
183 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 183 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
184 if (IsEOF()) { | 184 if (IsEOF()) { |
185 return 0; | 185 return 0; |
186 } | 186 } |
187 uint8_t ch; | 187 uint8_t ch; |
188 int32_t iState = 0; | 188 int32_t iState = 0; |
189 CFX_ByteTextBuf buf; | 189 CFX_ByteTextBuf buf; |
190 FX_DWORD code = 0; | 190 uint32_t code = 0; |
191 do { | 191 do { |
192 while (m_dwIndex < m_dwBufferSize) { | 192 while (m_dwIndex < m_dwBufferSize) { |
193 ch = m_pBuffer[m_dwIndex]; | 193 ch = m_pBuffer[m_dwIndex]; |
194 switch (iState) { | 194 switch (iState) { |
195 case 0: | 195 case 0: |
196 if (ch == '#') { | 196 if (ch == '#') { |
197 m_dwIndex++; | 197 m_dwIndex++; |
198 iState = 2; | 198 iState = 2; |
199 break; | 199 break; |
200 } | 200 } |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, | 682 FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, |
683 const CFX_ByteStringC& name, | 683 const CFX_ByteStringC& name, |
684 FX_FLOAT& attribute) const { | 684 FX_FLOAT& attribute) const { |
685 const CFX_WideString* pValue = m_AttrMap.Lookup(space, name); | 685 const CFX_WideString* pValue = m_AttrMap.Lookup(space, name); |
686 if (pValue) { | 686 if (pValue) { |
687 attribute = pValue->GetFloat(); | 687 attribute = pValue->GetFloat(); |
688 return TRUE; | 688 return TRUE; |
689 } | 689 } |
690 return FALSE; | 690 return FALSE; |
691 } | 691 } |
692 CXML_Element::ChildType CXML_Element::GetChildType(FX_DWORD index) const { | 692 CXML_Element::ChildType CXML_Element::GetChildType(uint32_t index) const { |
693 return index < m_Children.size() ? m_Children[index].type : Invalid; | 693 return index < m_Children.size() ? m_Children[index].type : Invalid; |
694 } | 694 } |
695 CFX_WideString CXML_Element::GetContent(FX_DWORD index) const { | 695 CFX_WideString CXML_Element::GetContent(uint32_t index) const { |
696 if (index < m_Children.size() && m_Children[index].type == Content) { | 696 if (index < m_Children.size() && m_Children[index].type == Content) { |
697 CXML_Content* pContent = | 697 CXML_Content* pContent = |
698 static_cast<CXML_Content*>(m_Children[index].child); | 698 static_cast<CXML_Content*>(m_Children[index].child); |
699 if (pContent) | 699 if (pContent) |
700 return pContent->m_Content; | 700 return pContent->m_Content; |
701 } | 701 } |
702 return CFX_WideString(); | 702 return CFX_WideString(); |
703 } | 703 } |
704 CXML_Element* CXML_Element::GetElement(FX_DWORD index) const { | 704 CXML_Element* CXML_Element::GetElement(uint32_t index) const { |
705 if (index < m_Children.size() && m_Children[index].type == Element) { | 705 if (index < m_Children.size() && m_Children[index].type == Element) { |
706 return static_cast<CXML_Element*>(m_Children[index].child); | 706 return static_cast<CXML_Element*>(m_Children[index].child); |
707 } | 707 } |
708 return nullptr; | 708 return nullptr; |
709 } | 709 } |
710 FX_DWORD CXML_Element::CountElements(const CFX_ByteStringC& space, | 710 uint32_t CXML_Element::CountElements(const CFX_ByteStringC& space, |
711 const CFX_ByteStringC& tag) const { | 711 const CFX_ByteStringC& tag) const { |
712 int count = 0; | 712 int count = 0; |
713 for (const ChildRecord& record : m_Children) { | 713 for (const ChildRecord& record : m_Children) { |
714 if (record.type != Element) | 714 if (record.type != Element) |
715 continue; | 715 continue; |
716 | 716 |
717 CXML_Element* pKid = static_cast<CXML_Element*>(record.child); | 717 CXML_Element* pKid = static_cast<CXML_Element*>(record.child); |
718 if ((space.IsEmpty() || pKid->m_QSpaceName == space) && | 718 if ((space.IsEmpty() || pKid->m_QSpaceName == space) && |
719 pKid->m_TagName == tag) { | 719 pKid->m_TagName == tag) { |
720 count++; | 720 count++; |
(...skipping 13 matching lines...) Expand all Loading... |
734 | 734 |
735 CXML_Element* pKid = static_cast<CXML_Element*>(record.child); | 735 CXML_Element* pKid = static_cast<CXML_Element*>(record.child); |
736 if ((space.IsEmpty() || pKid->m_QSpaceName == space) && | 736 if ((space.IsEmpty() || pKid->m_QSpaceName == space) && |
737 pKid->m_TagName == tag) { | 737 pKid->m_TagName == tag) { |
738 if (index-- == 0) | 738 if (index-- == 0) |
739 return pKid; | 739 return pKid; |
740 } | 740 } |
741 } | 741 } |
742 return nullptr; | 742 return nullptr; |
743 } | 743 } |
744 FX_DWORD CXML_Element::FindElement(CXML_Element* pChild) const { | 744 uint32_t CXML_Element::FindElement(CXML_Element* pChild) const { |
745 int index = 0; | 745 int index = 0; |
746 for (const ChildRecord& record : m_Children) { | 746 for (const ChildRecord& record : m_Children) { |
747 if (record.type == Element && | 747 if (record.type == Element && |
748 static_cast<CXML_Element*>(record.child) == pChild) { | 748 static_cast<CXML_Element*>(record.child) == pChild) { |
749 return index; | 749 return index; |
750 } | 750 } |
751 ++index; | 751 ++index; |
752 } | 752 } |
753 return (FX_DWORD)-1; | 753 return (uint32_t)-1; |
754 } | 754 } |
755 | 755 |
756 bool CXML_AttrItem::Matches(const CFX_ByteStringC& space, | 756 bool CXML_AttrItem::Matches(const CFX_ByteStringC& space, |
757 const CFX_ByteStringC& name) const { | 757 const CFX_ByteStringC& name) const { |
758 return (space.IsEmpty() || m_QSpaceName == space) && m_AttrName == name; | 758 return (space.IsEmpty() || m_QSpaceName == space) && m_AttrName == name; |
759 } | 759 } |
760 | 760 |
761 const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space, | 761 const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space, |
762 const CFX_ByteStringC& name) const { | 762 const CFX_ByteStringC& name) const { |
763 if (!m_pMap) | 763 if (!m_pMap) |
(...skipping 22 matching lines...) Expand all Loading... |
786 m_pMap->push_back({space, name, value}); | 786 m_pMap->push_back({space, name, value}); |
787 } | 787 } |
788 | 788 |
789 int CXML_AttrMap::GetSize() const { | 789 int CXML_AttrMap::GetSize() const { |
790 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; | 790 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; |
791 } | 791 } |
792 | 792 |
793 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { | 793 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { |
794 return (*m_pMap)[index]; | 794 return (*m_pMap)[index]; |
795 } | 795 } |
OLD | NEW |