| 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 "../../include/fxcrt/fx_xml.h" | 7 #include "../../include/fxcrt/fx_xml.h" |
| 8 #include "xml_int.h" | 8 #include "xml_int.h" |
| 9 CXML_Parser::~CXML_Parser() | 9 CXML_Parser::~CXML_Parser() |
| 10 { | 10 { |
| 11 if (m_bOwnedStream) { | 11 if (m_bOwnedStream) { |
| 12 m_pDataAcc->Release(); | 12 m_pDataAcc->Release(); |
| 13 } | 13 } |
| 14 } | 14 } |
| 15 FX_BOOL CXML_Parser::Init(FX_LPBYTE pBuffer, size_t size) | 15 FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) |
| 16 { | 16 { |
| 17 m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); | 17 m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); |
| 18 return Init(TRUE); | 18 return Init(TRUE); |
| 19 } | 19 } |
| 20 FX_BOOL CXML_Parser::Init(IFX_FileRead *pFileRead) | 20 FX_BOOL CXML_Parser::Init(IFX_FileRead *pFileRead) |
| 21 { | 21 { |
| 22 m_pDataAcc = new CXML_DataStmAcc(pFileRead); | 22 m_pDataAcc = new CXML_DataStmAcc(pFileRead); |
| 23 return Init(TRUE); | 23 return Init(TRUE); |
| 24 } | 24 } |
| 25 FX_BOOL CXML_Parser::Init(IFX_BufferRead *pBuffer) | 25 FX_BOOL CXML_Parser::Init(IFX_BufferRead *pBuffer) |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 content.Clear(); | 466 content.Clear(); |
| 467 decoder.Clear(); | 467 decoder.Clear(); |
| 468 bCDATA = FALSE; | 468 bCDATA = FALSE; |
| 469 iState = 0; | 469 iState = 0; |
| 470 m_dwIndex --; | 470 m_dwIndex --; |
| 471 CXML_Element* pSubElement = ParseElement(pElement, TRUE)
; | 471 CXML_Element* pSubElement = ParseElement(pElement, TRUE)
; |
| 472 if (pSubElement == NULL) { | 472 if (pSubElement == NULL) { |
| 473 break; | 473 break; |
| 474 } | 474 } |
| 475 pSubElement->m_pParent = pElement; | 475 pSubElement->m_pParent = pElement; |
| 476 pElement->m_Children.Add((FX_LPVOID)CXML_Element::Elemen
t); | 476 pElement->m_Children.Add((void*)CXML_Element::Element); |
| 477 pElement->m_Children.Add(pSubElement); | 477 pElement->m_Children.Add(pSubElement); |
| 478 SkipWhiteSpaces(); | 478 SkipWhiteSpaces(); |
| 479 } | 479 } |
| 480 break; | 480 break; |
| 481 case 2: | 481 case 2: |
| 482 if (ch == '[') { | 482 if (ch == '[') { |
| 483 SkipLiterals(FX_BSTRC("]]>")); | 483 SkipLiterals(FX_BSTRC("]]>")); |
| 484 } else if (ch == '-') { | 484 } else if (ch == '-') { |
| 485 m_dwIndex ++; | 485 m_dwIndex ++; |
| 486 SkipLiterals(FX_BSTRC("-->")); | 486 SkipLiterals(FX_BSTRC("-->")); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 512 bCDATA = FALSE; | 512 bCDATA = FALSE; |
| 513 return pElement; | 513 return pElement; |
| 514 } | 514 } |
| 515 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, FX_WSTR content, CXML_Ele
ment* pElement) | 515 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, FX_WSTR content, CXML_Ele
ment* pElement) |
| 516 { | 516 { |
| 517 if (content.IsEmpty()) { | 517 if (content.IsEmpty()) { |
| 518 return; | 518 return; |
| 519 } | 519 } |
| 520 CXML_Content* pContent = new CXML_Content; | 520 CXML_Content* pContent = new CXML_Content; |
| 521 pContent->Set(bCDATA, content); | 521 pContent->Set(bCDATA, content); |
| 522 pElement->m_Children.Add((FX_LPVOID)CXML_Element::Content); | 522 pElement->m_Children.Add((void*)CXML_Element::Content); |
| 523 pElement->m_Children.Add(pContent); | 523 pElement->m_Children.Add(pContent); |
| 524 } | 524 } |
| 525 static CXML_Element* XML_ContinueParse(CXML_Parser &parser, FX_BOOL bSaveSpaceCh
ars, FX_FILESIZE* pParsedSize) | 525 static CXML_Element* XML_ContinueParse(CXML_Parser &parser, FX_BOOL bSaveSpaceCh
ars, FX_FILESIZE* pParsedSize) |
| 526 { | 526 { |
| 527 parser.m_bSaveSpaceChars = bSaveSpaceChars; | 527 parser.m_bSaveSpaceChars = bSaveSpaceChars; |
| 528 CXML_Element* pElement = parser.ParseElement(NULL, FALSE); | 528 CXML_Element* pElement = parser.ParseElement(NULL, FALSE); |
| 529 if (pParsedSize) { | 529 if (pParsedSize) { |
| 530 *pParsedSize = parser.m_nOffset; | 530 *pParsedSize = parser.m_nOffset; |
| 531 } | 531 } |
| 532 return pElement; | 532 return pElement; |
| 533 } | 533 } |
| 534 CXML_Element* CXML_Element::Parse(const void* pBuffer, size_t size, FX_BOOL bSav
eSpaceChars, FX_FILESIZE* pParsedSize) | 534 CXML_Element* CXML_Element::Parse(const void* pBuffer, size_t size, FX_BOOL bSav
eSpaceChars, FX_FILESIZE* pParsedSize) |
| 535 { | 535 { |
| 536 CXML_Parser parser; | 536 CXML_Parser parser; |
| 537 if (!parser.Init((FX_LPBYTE)pBuffer, size)) { | 537 if (!parser.Init((uint8_t*)pBuffer, size)) { |
| 538 return NULL; | 538 return NULL; |
| 539 } | 539 } |
| 540 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); | 540 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); |
| 541 } | 541 } |
| 542 CXML_Element* CXML_Element::Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars,
FX_FILESIZE* pParsedSize) | 542 CXML_Element* CXML_Element::Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars,
FX_FILESIZE* pParsedSize) |
| 543 { | 543 { |
| 544 CXML_Parser parser; | 544 CXML_Parser parser; |
| 545 if (!parser.Init(pFile)) { | 545 if (!parser.Init(pFile)) { |
| 546 return NULL; | 546 return NULL; |
| 547 } | 547 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 } | 836 } |
| 837 void CXML_AttrMap::RemoveAll() | 837 void CXML_AttrMap::RemoveAll() |
| 838 { | 838 { |
| 839 if (!m_pMap) { | 839 if (!m_pMap) { |
| 840 return; | 840 return; |
| 841 } | 841 } |
| 842 m_pMap->RemoveAll(); | 842 m_pMap->RemoveAll(); |
| 843 delete m_pMap; | 843 delete m_pMap; |
| 844 m_pMap = NULL; | 844 m_pMap = NULL; |
| 845 } | 845 } |
| OLD | NEW |