| 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 #ifndef XFA_FXFA_PARSER_XFA_UTILS_H_ | 7 #ifndef XFA_FXFA_PARSER_XFA_UTILS_H_ |
| 8 #define XFA_FXFA_PARSER_XFA_UTILS_H_ | 8 #define XFA_FXFA_PARSER_XFA_UTILS_H_ |
| 9 | 9 |
| 10 #include "xfa/fde/xml/fde_xml.h" | 10 #include "xfa/fde/xml/fde_xml.h" |
| 11 #include "xfa/fgas/crt/fgas_stream.h" | 11 #include "xfa/fgas/crt/fgas_stream.h" |
| 12 #include "xfa/fgas/crt/fgas_utils.h" | 12 #include "xfa/fgas/crt/fgas_utils.h" |
| 13 #include "xfa/fxfa/include/fxfa_basic.h" | 13 #include "xfa/fxfa/include/fxfa_basic.h" |
| 14 | 14 |
| 15 class CFDE_XMLElement; | 15 class CFDE_XMLElement; |
| 16 class CFDE_XMLNode; | 16 class CFDE_XMLNode; |
| 17 class CXFA_LocaleValue; | 17 class CXFA_LocaleValue; |
| 18 class CXFA_Node; | 18 class CXFA_Node; |
| 19 class CXFA_WidgetData; | 19 class CXFA_WidgetData; |
| 20 | 20 |
| 21 FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( | 21 FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( |
| 22 CFDE_XMLElement* pNode, | 22 CFDE_XMLElement* pNode, |
| 23 const CFX_WideStringC& wsQualifier, | 23 const CFX_WideStringC& wsQualifier, |
| 24 CFX_WideString& wsNamespaceURI); | 24 CFX_WideString& wsNamespaceURI); |
| 25 | 25 |
| 26 template <class NodeType, class TraverseStrategy> | 26 template <class NodeType, class TraverseStrategy> |
| 27 class CXFA_NodeIteratorTemplate { | 27 class CXFA_NodeIteratorTemplate { |
| 28 public: | 28 public: |
| 29 CXFA_NodeIteratorTemplate(NodeType* pRootNode = nullptr) | 29 CXFA_NodeIteratorTemplate(NodeType* pRootNode = nullptr) |
| 30 : m_pRoot(pRootNode) { | 30 : m_pRoot(pRootNode), m_NodeStack(100) { |
| 31 if (pRootNode) { | 31 if (pRootNode) { |
| 32 m_NodeStack.Push(pRootNode); | 32 m_NodeStack.Push(pRootNode); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 FX_BOOL Init(NodeType* pRootNode) { | 35 FX_BOOL Init(NodeType* pRootNode) { |
| 36 if (!pRootNode) { | 36 if (!pRootNode) { |
| 37 return FALSE; | 37 return FALSE; |
| 38 } | 38 } |
| 39 m_pRoot = pRootNode; | 39 m_pRoot = pRootNode; |
| 40 m_NodeStack.RemoveAll(); | 40 m_NodeStack.RemoveAll(FALSE); |
| 41 m_NodeStack.Push(pRootNode); | 41 m_NodeStack.Push(pRootNode); |
| 42 return TRUE; | 42 return TRUE; |
| 43 } | 43 } |
| 44 void Clear() { m_NodeStack.RemoveAll(); } | 44 void Clear() { m_NodeStack.RemoveAll(FALSE); } |
| 45 void Reset() { | 45 void Reset() { |
| 46 Clear(); | 46 Clear(); |
| 47 if (m_pRoot) { | 47 if (m_pRoot) { |
| 48 m_NodeStack.Push(m_pRoot); | 48 m_NodeStack.Push(m_pRoot); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 FX_BOOL SetCurrent(NodeType* pCurNode) { | 51 FX_BOOL SetCurrent(NodeType* pCurNode) { |
| 52 m_NodeStack.RemoveAll(); | 52 m_NodeStack.RemoveAll(FALSE); |
| 53 if (pCurNode) { | 53 if (pCurNode) { |
| 54 CFX_StackTemplate<NodeType*> revStack; | 54 CFX_StackTemplate<NodeType*> revStack(100); |
| 55 NodeType* pNode; | 55 NodeType* pNode; |
| 56 for (pNode = pCurNode; pNode && pNode != m_pRoot; | 56 for (pNode = pCurNode; pNode && pNode != m_pRoot; |
| 57 pNode = TraverseStrategy::GetParent(pNode)) { | 57 pNode = TraverseStrategy::GetParent(pNode)) { |
| 58 revStack.Push(pNode); | 58 revStack.Push(pNode); |
| 59 } | 59 } |
| 60 if (!pNode) { | 60 if (!pNode) { |
| 61 return FALSE; | 61 return FALSE; |
| 62 } | 62 } |
| 63 revStack.Push(m_pRoot); | 63 revStack.Push(m_pRoot); |
| 64 while (revStack.GetSize()) { | 64 while (revStack.GetSize()) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 87 } | 87 } |
| 88 NodeType *pPrevItem = pParentFirstChildItem, *pPrevItemNext = nullptr; | 88 NodeType *pPrevItem = pParentFirstChildItem, *pPrevItemNext = nullptr; |
| 89 for (; pPrevItem; pPrevItem = pPrevItemNext) { | 89 for (; pPrevItem; pPrevItem = pPrevItemNext) { |
| 90 pPrevItemNext = TraverseStrategy::GetNextSibling(pPrevItem); | 90 pPrevItemNext = TraverseStrategy::GetNextSibling(pPrevItem); |
| 91 if (!pPrevItemNext || pPrevItemNext == pCurItem) { | 91 if (!pPrevItemNext || pPrevItemNext == pCurItem) { |
| 92 break; | 92 break; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 m_NodeStack.Push(pPrevItem); | 95 m_NodeStack.Push(pPrevItem); |
| 96 } else { | 96 } else { |
| 97 m_NodeStack.RemoveAll(); | 97 m_NodeStack.RemoveAll(FALSE); |
| 98 if (m_pRoot) { | 98 if (m_pRoot) { |
| 99 m_NodeStack.Push(m_pRoot); | 99 m_NodeStack.Push(m_pRoot); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 if (m_NodeStack.GetSize() > 0) { | 102 if (m_NodeStack.GetSize() > 0) { |
| 103 NodeType* pChildItem = *m_NodeStack.GetTopElement(); | 103 NodeType* pChildItem = *m_NodeStack.GetTopElement(); |
| 104 while ((pChildItem = TraverseStrategy::GetFirstChild(pChildItem)) != | 104 while ((pChildItem = TraverseStrategy::GetFirstChild(pChildItem)) != |
| 105 nullptr) { | 105 nullptr) { |
| 106 while (NodeType* pNextItem = | 106 while (NodeType* pNextItem = |
| 107 TraverseStrategy::GetNextSibling(pChildItem)) { | 107 TraverseStrategy::GetNextSibling(pChildItem)) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode); | 172 FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode); |
| 173 IFX_Stream* XFA_CreateWideTextRead(const CFX_WideString& wsBuffer); | 173 IFX_Stream* XFA_CreateWideTextRead(const CFX_WideString& wsBuffer); |
| 174 | 174 |
| 175 void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode); | 175 void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode); |
| 176 void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, | 176 void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, |
| 177 IFX_Stream* pStream, | 177 IFX_Stream* pStream, |
| 178 const FX_CHAR* pChecksum = nullptr, | 178 const FX_CHAR* pChecksum = nullptr, |
| 179 FX_BOOL bSaveXML = FALSE); | 179 FX_BOOL bSaveXML = FALSE); |
| 180 | 180 |
| 181 #endif // XFA_FXFA_PARSER_XFA_UTILS_H_ | 181 #endif // XFA_FXFA_PARSER_XFA_UTILS_H_ |
| OLD | NEW |