Chromium Code Reviews| Index: xfa/fde/xml/fde_xml_imp.cpp |
| diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp |
| index b71d8b8f4fd87e6e035682e8e039cbdd9eefef18..17feacc1332595a6d191452c6db89a06c39f092e 100644 |
| --- a/xfa/fde/xml/fde_xml_imp.cpp |
| +++ b/xfa/fde/xml/fde_xml_imp.cpp |
| @@ -80,6 +80,14 @@ CFDE_XMLNode::CFDE_XMLNode() |
| m_pPrior(nullptr), |
| m_pNext(nullptr) {} |
| +void CFDE_XMLNode::Release() { |
| + delete this; |
| +} |
| + |
| +FDE_XMLNODETYPE CFDE_XMLNode::GetType() const { |
| + return FDE_XMLNODE_Unknown; |
| +} |
| + |
| CFDE_XMLNode::~CFDE_XMLNode() { |
| DeleteChildren(); |
| } |
| @@ -209,6 +217,7 @@ int32_t CFDE_XMLNode::InsertChildNode(CFDE_XMLNode* pNode, int32_t index) { |
| pFind->m_pNext = pNode; |
| return iCount; |
| } |
| + |
| void CFDE_XMLNode::RemoveChildNode(CFDE_XMLNode* pNode) { |
| ASSERT(m_pChild && pNode); |
| if (m_pChild == pNode) { |
| @@ -375,6 +384,7 @@ CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(CFDE_XMLNode::NodeItem eItem) { |
| CFDE_XMLNode* CFDE_XMLNode::Clone(FX_BOOL bRecursive) { |
| return nullptr; |
| } |
| + |
| void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) { |
| CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; |
| switch (pNode->GetType()) { |
| @@ -484,6 +494,7 @@ void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) { |
| break; |
| } |
| } |
| + |
| void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) { |
| if (!m_pChild) { |
| return; |
| @@ -504,6 +515,13 @@ CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget) |
| : m_wsTarget(wsTarget) { |
| ASSERT(m_wsTarget.GetLength() > 0); |
| } |
| + |
| +void CFDE_XMLInstruction::Release() { |
| + delete this; |
| +} |
|
Lei Zhang
2016/06/17 03:10:05
blank line after
Wei Li
2016/06/17 21:47:44
Done.
|
| +FDE_XMLNODETYPE CFDE_XMLInstruction::GetType() const { |
| + return FDE_XMLNODE_Instruction; |
| +} |
| CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) { |
| CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget); |
| if (!pClone) { |
| @@ -516,6 +534,10 @@ CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) { |
| } |
| return pClone; |
| } |
| + |
| +void CFDE_XMLInstruction::GetTargetName(CFX_WideString& wsTarget) const { |
| + wsTarget = m_wsTarget; |
| +} |
|
Lei Zhang
2016/06/17 03:10:05
blank line after
Wei Li
2016/06/17 21:47:44
Done.
|
| int32_t CFDE_XMLInstruction::CountAttributes() const { |
| return m_Attributes.GetSize() / 2; |
| } |
| @@ -543,6 +565,7 @@ FX_BOOL CFDE_XMLInstruction::HasAttribute(const FX_WCHAR* pwsAttriName) const { |
| } |
| return FALSE; |
| } |
| + |
| void CFDE_XMLInstruction::GetString(const FX_WCHAR* pwsAttriName, |
| CFX_WideString& wsAttriValue, |
| const FX_WCHAR* pwsDefValue) const { |
| @@ -555,6 +578,7 @@ void CFDE_XMLInstruction::GetString(const FX_WCHAR* pwsAttriName, |
| } |
| wsAttriValue = pwsDefValue; |
| } |
| + |
| void CFDE_XMLInstruction::SetString(const CFX_WideString& wsAttriName, |
| const CFX_WideString& wsAttriValue) { |
| ASSERT(wsAttriName.GetLength() > 0); |
| @@ -579,6 +603,7 @@ int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName, |
| } |
| return iDefValue; |
| } |
| + |
| void CFDE_XMLInstruction::SetInteger(const FX_WCHAR* pwsAttriName, |
| int32_t iAttriValue) { |
| CFX_WideString wsValue; |
| @@ -595,12 +620,14 @@ FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName, |
| } |
| return fDefValue; |
| } |
| + |
| void CFDE_XMLInstruction::SetFloat(const FX_WCHAR* pwsAttriName, |
| FX_FLOAT fAttriValue) { |
| CFX_WideString wsValue; |
| wsValue.Format(L"%f", fAttriValue); |
| SetString(pwsAttriName, wsValue); |
| } |
| + |
| void CFDE_XMLInstruction::RemoveAttribute(const FX_WCHAR* pwsAttriName) { |
| int32_t iCount = m_Attributes.GetSize(); |
| for (int32_t i = 0; i < iCount; i += 2) { |
| @@ -622,13 +649,17 @@ FX_BOOL CFDE_XMLInstruction::GetData(int32_t index, |
| wsData = m_TargetData[index]; |
| return TRUE; |
| } |
| + |
| void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) { |
| m_TargetData.Add(wsData); |
| } |
| + |
| void CFDE_XMLInstruction::RemoveData(int32_t index) { |
| m_TargetData.RemoveAt(index); |
| } |
| +CFDE_XMLInstruction::~CFDE_XMLInstruction() {} |
| + |
| CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag) |
| : CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() { |
| ASSERT(m_wsTag.GetLength() > 0); |
| @@ -636,6 +667,15 @@ CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag) |
| CFDE_XMLElement::~CFDE_XMLElement() { |
| m_Attributes.RemoveAll(); |
| } |
| + |
| +void CFDE_XMLElement::Release() { |
| + delete this; |
| +} |
| + |
| +FDE_XMLNODETYPE CFDE_XMLElement::GetType() const { |
| + return FDE_XMLNODE_Element; |
| +} |
| + |
| CFDE_XMLNode* CFDE_XMLElement::Clone(FX_BOOL bRecursive) { |
| CFDE_XMLElement* pClone = new CFDE_XMLElement(m_wsTag); |
| if (!pClone) { |
| @@ -661,9 +701,11 @@ CFDE_XMLNode* CFDE_XMLElement::Clone(FX_BOOL bRecursive) { |
| } |
| return pClone; |
| } |
| + |
| void CFDE_XMLElement::GetTagName(CFX_WideString& wsTag) const { |
| wsTag = m_wsTag; |
| } |
| + |
| void CFDE_XMLElement::GetLocalTagName(CFX_WideString& wsTag) const { |
| FX_STRSIZE iFind = m_wsTag.Find(L':', 0); |
| if (iFind < 0) { |
| @@ -672,6 +714,7 @@ void CFDE_XMLElement::GetLocalTagName(CFX_WideString& wsTag) const { |
| wsTag = m_wsTag.Right(m_wsTag.GetLength() - iFind - 1); |
| } |
| } |
| + |
| void CFDE_XMLElement::GetNamespacePrefix(CFX_WideString& wsPrefix) const { |
| FX_STRSIZE iFind = m_wsTag.Find(L':', 0); |
| if (iFind < 0) { |
| @@ -680,6 +723,7 @@ void CFDE_XMLElement::GetNamespacePrefix(CFX_WideString& wsPrefix) const { |
| wsPrefix = m_wsTag.Left(iFind); |
| } |
| } |
| + |
| void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const { |
| CFX_WideString wsAttri(L"xmlns"), wsPrefix; |
| GetNamespacePrefix(wsPrefix); |
| @@ -702,6 +746,7 @@ void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const { |
| break; |
| } |
| } |
| + |
| int32_t CFDE_XMLElement::CountAttributes() const { |
| return m_Attributes.GetSize() / 2; |
| } |
| @@ -720,6 +765,7 @@ FX_BOOL CFDE_XMLElement::GetAttribute(int32_t index, |
| } |
| return FALSE; |
| } |
| + |
| FX_BOOL CFDE_XMLElement::HasAttribute(const FX_WCHAR* pwsAttriName) const { |
| int32_t iCount = m_Attributes.GetSize(); |
| for (int32_t i = 0; i < iCount; i += 2) { |
| @@ -729,6 +775,7 @@ FX_BOOL CFDE_XMLElement::HasAttribute(const FX_WCHAR* pwsAttriName) const { |
| } |
| return FALSE; |
| } |
| + |
| void CFDE_XMLElement::GetString(const FX_WCHAR* pwsAttriName, |
| CFX_WideString& wsAttriValue, |
| const FX_WCHAR* pwsDefValue) const { |
| @@ -741,6 +788,7 @@ void CFDE_XMLElement::GetString(const FX_WCHAR* pwsAttriName, |
| } |
| wsAttriValue = pwsDefValue; |
| } |
| + |
| void CFDE_XMLElement::SetString(const CFX_WideString& wsAttriName, |
| const CFX_WideString& wsAttriValue) { |
| ASSERT(wsAttriName.GetLength() > 0); |
| @@ -765,12 +813,14 @@ int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName, |
| } |
| return iDefValue; |
| } |
| + |
| void CFDE_XMLElement::SetInteger(const FX_WCHAR* pwsAttriName, |
| int32_t iAttriValue) { |
| CFX_WideString wsValue; |
| wsValue.Format(L"%d", iAttriValue); |
| SetString(pwsAttriName, wsValue); |
| } |
| + |
| FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, |
| FX_FLOAT fDefValue) const { |
| int32_t iCount = m_Attributes.GetSize(); |
| @@ -781,12 +831,14 @@ FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, |
| } |
| return fDefValue; |
| } |
| + |
| void CFDE_XMLElement::SetFloat(const FX_WCHAR* pwsAttriName, |
| FX_FLOAT fAttriValue) { |
| CFX_WideString wsValue; |
| wsValue.Format(L"%f", fAttriValue); |
| SetString(pwsAttriName, wsValue); |
| } |
| + |
| void CFDE_XMLElement::RemoveAttribute(const FX_WCHAR* pwsAttriName) { |
| int32_t iCount = m_Attributes.GetSize(); |
| for (int32_t i = 0; i < iCount; i += 2) { |
| @@ -797,6 +849,7 @@ void CFDE_XMLElement::RemoveAttribute(const FX_WCHAR* pwsAttriName) { |
| } |
| } |
| } |
| + |
| void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const { |
| CFX_WideTextBuf buffer; |
| CFDE_XMLNode* pChild = m_pChild; |
| @@ -815,6 +868,7 @@ void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const { |
| } |
| wsText = buffer.AsStringC(); |
| } |
| + |
| void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { |
| if (wsText.GetLength() < 1) { |
| return; |
| @@ -823,18 +877,52 @@ void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { |
| } |
| CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText) |
| : CFDE_XMLNode(), m_wsText(wsText) {} |
| + |
| +void CFDE_XMLText::Release() { |
| + delete this; |
| +} |
| +FDE_XMLNODETYPE CFDE_XMLText::GetType() const { |
| + return FDE_XMLNODE_Text; |
| +} |
|
Lei Zhang
2016/06/17 03:10:05
blank line after
Wei Li
2016/06/17 21:47:44
Done.
|
| CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) { |
| CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText); |
| return pClone; |
| } |
| +void CFDE_XMLText::GetText(CFX_WideString& wsText) const { |
| + wsText = m_wsText; |
| +} |
| + |
| +void CFDE_XMLText::SetText(const CFX_WideString& wsText) { |
| + m_wsText = wsText; |
| +} |
| + |
| +CFDE_XMLText::~CFDE_XMLText() {} |
| + |
| CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData) |
| : CFDE_XMLDeclaration(), m_wsCharData(wsCData) {} |
| + |
| +void CFDE_XMLCharData::Release() { |
| + delete this; |
| +} |
| +FDE_XMLNODETYPE CFDE_XMLCharData::GetType() const { |
| + return FDE_XMLNODE_CharData; |
| +} |
| CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) { |
| CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData); |
| return pClone; |
| } |
| +void CFDE_XMLCharData::GetCharData(CFX_WideString& wsCharData) const { |
| + wsCharData = m_wsCharData; |
| +} |
| + |
| +void CFDE_XMLCharData::SetCharData(const CFX_WideString& wsCData) { |
| + m_wsCharData = wsCData; |
| +} |
| + |
| +CFDE_XMLCharData::~CFDE_XMLCharData() {} |
| + |
| CFDE_XMLDoc::CFDE_XMLDoc() |
| : m_pRoot(nullptr), m_pSyntaxParser(nullptr), m_pXMLParser(nullptr) { |
| Reset(TRUE); |
| @@ -844,6 +932,7 @@ CFDE_XMLDoc::CFDE_XMLDoc() |
| CFDE_XMLDoc::~CFDE_XMLDoc() { |
| Reset(FALSE); |
| } |
| + |
| void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { |
| m_iStatus = 0; |
| m_pStream = nullptr; |
| @@ -860,6 +949,7 @@ void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { |
| } |
| ReleaseParser(); |
| } |
| + |
| void CFDE_XMLDoc::ReleaseParser() { |
| if (m_pXMLParser) { |
| m_pXMLParser->Release(); |
| @@ -871,6 +961,10 @@ void CFDE_XMLDoc::ReleaseParser() { |
| } |
| } |
| +void CFDE_XMLDoc::Release() { |
| + delete this; |
| +} |
| + |
| FX_BOOL CFDE_XMLDoc::LoadXML(CFDE_XMLParser* pXMLParser) { |
| if (!pXMLParser) |
| return FALSE; |
| @@ -884,9 +978,15 @@ int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { |
| return m_iStatus; |
| return m_iStatus = m_pXMLParser->DoParser(pPause); |
| } |
| + |
| void CFDE_XMLDoc::CloseXML() { |
| ReleaseParser(); |
| } |
| + |
| +CFDE_XMLNode* CFDE_XMLDoc::GetRoot() const { |
| + return m_pRoot; |
| +} |
| + |
| void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) { |
| CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; |
| switch (pNode->GetType()) { |
| @@ -996,6 +1096,7 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) { |
| break; |
| } |
| } |
| + |
| void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) { |
| if (!pXMLStream || pXMLStream == m_pStream) { |
| m_pStream->Seek(FX_STREAMSEEK_Begin, 0); |
| @@ -1028,9 +1129,11 @@ CFDE_BlockBuffer::CFDE_BlockBuffer(int32_t iAllocStep) |
| m_iBufferSize(0), |
| m_iAllocStep(iAllocStep), |
| m_iStartPosition(0) {} |
| + |
| CFDE_BlockBuffer::~CFDE_BlockBuffer() { |
| ClearBuffer(); |
| } |
| + |
| FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) { |
| iIndexInBlock = 0; |
| if (!m_BlockArray.GetSize()) { |
| @@ -1046,6 +1149,7 @@ FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) { |
| iIndexInBlock = iRealIndex % m_iAllocStep; |
| return m_BlockArray[iRealIndex / m_iAllocStep]; |
| } |
| + |
| FX_BOOL CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) { |
| ClearBuffer(); |
| int32_t iNumOfBlock = (iBufferSize - 1) / m_iAllocStep + 1; |
| @@ -1055,6 +1159,7 @@ FX_BOOL CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) { |
| m_iBufferSize = iNumOfBlock * m_iAllocStep; |
| return TRUE; |
| } |
| + |
| void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) { |
| if (iIndex < 0) { |
| return; |
| @@ -1093,6 +1198,7 @@ int32_t CFDE_BlockBuffer::DeleteTextChars(int32_t iCount, FX_BOOL bDirection) { |
| } |
| return m_iDataLength; |
| } |
| + |
| void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData, |
| int32_t iStart, |
| int32_t iLength) const { |
| @@ -1135,6 +1241,7 @@ void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData, |
| } |
| wsTextData.ReleaseBuffer(iLength); |
| } |
| + |
| void CFDE_BlockBuffer::TextDataIndex2BufIndex(const int32_t iIndex, |
| int32_t& iBlockIndex, |
| int32_t& iInnerIndex) const { |
| @@ -1143,6 +1250,7 @@ void CFDE_BlockBuffer::TextDataIndex2BufIndex(const int32_t iIndex, |
| iBlockIndex = iRealIndex / m_iAllocStep; |
| iInnerIndex = iRealIndex % m_iAllocStep; |
| } |
| + |
| void CFDE_BlockBuffer::ClearBuffer() { |
| m_iBufferSize = 0; |
| int32_t iSize = m_BlockArray.GetSize(); |
| @@ -1179,6 +1287,7 @@ CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser() |
| m_CurNode.iNodeNum = -1; |
| m_CurNode.eNodeType = FDE_XMLNODE_Unknown; |
| } |
| + |
| void CFDE_XMLSyntaxParser::Init(IFX_Stream* pStream, |
| int32_t iXMLPlaneSize, |
| int32_t iTextDataSize) { |