| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 return c >= '0' && c <= '9'; | 23 return c >= '0' && c <= '9'; |
| 24 } | 24 } |
| 25 | 25 |
| 26 FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( | 26 FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( |
| 27 CFDE_XMLElement* pNode, | 27 CFDE_XMLElement* pNode, |
| 28 const CFX_WideStringC& wsQualifier, | 28 const CFX_WideStringC& wsQualifier, |
| 29 CFX_WideString& wsNamespaceURI); | 29 CFX_WideString& wsNamespaceURI); |
| 30 template <class NodeType, class TraverseStrategy> | 30 template <class NodeType, class TraverseStrategy> |
| 31 class CXFA_NodeIteratorTemplate { | 31 class CXFA_NodeIteratorTemplate { |
| 32 public: | 32 public: |
| 33 CXFA_NodeIteratorTemplate(NodeType* pRootNode = NULL) : m_pRoot(pRootNode) { | 33 CXFA_NodeIteratorTemplate(NodeType* pRootNode = nullptr) |
| 34 : m_pRoot(pRootNode) { |
| 34 if (pRootNode) { | 35 if (pRootNode) { |
| 35 m_NodeStack.Push(pRootNode); | 36 m_NodeStack.Push(pRootNode); |
| 36 } | 37 } |
| 37 } | 38 } |
| 38 FX_BOOL Init(NodeType* pRootNode) { | 39 FX_BOOL Init(NodeType* pRootNode) { |
| 39 if (!pRootNode) { | 40 if (!pRootNode) { |
| 40 return FALSE; | 41 return FALSE; |
| 41 } | 42 } |
| 42 m_pRoot = pRootNode; | 43 m_pRoot = pRootNode; |
| 43 m_NodeStack.RemoveAll(); | 44 m_NodeStack.RemoveAll(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 65 } | 66 } |
| 66 revStack.Push(m_pRoot); | 67 revStack.Push(m_pRoot); |
| 67 while (revStack.GetSize()) { | 68 while (revStack.GetSize()) { |
| 68 m_NodeStack.Push(*revStack.GetTopElement()); | 69 m_NodeStack.Push(*revStack.GetTopElement()); |
| 69 revStack.Pop(); | 70 revStack.Pop(); |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 return TRUE; | 73 return TRUE; |
| 73 } | 74 } |
| 74 NodeType* GetCurrent() const { | 75 NodeType* GetCurrent() const { |
| 75 return m_NodeStack.GetSize() ? *m_NodeStack.GetTopElement() : NULL; | 76 return m_NodeStack.GetSize() ? *m_NodeStack.GetTopElement() : nullptr; |
| 76 } | 77 } |
| 77 NodeType* GetRoot() const { return m_pRoot; } | 78 NodeType* GetRoot() const { return m_pRoot; } |
| 78 NodeType* MoveToPrev() { | 79 NodeType* MoveToPrev() { |
| 79 int32_t nStackLength = m_NodeStack.GetSize(); | 80 int32_t nStackLength = m_NodeStack.GetSize(); |
| 80 if (nStackLength == 1) { | 81 if (nStackLength == 1) { |
| 81 return NULL; | 82 return nullptr; |
| 82 } else if (nStackLength > 1) { | 83 } else if (nStackLength > 1) { |
| 83 NodeType* pCurItem = *m_NodeStack.GetTopElement(); | 84 NodeType* pCurItem = *m_NodeStack.GetTopElement(); |
| 84 m_NodeStack.Pop(); | 85 m_NodeStack.Pop(); |
| 85 NodeType* pParentItem = *m_NodeStack.GetTopElement(); | 86 NodeType* pParentItem = *m_NodeStack.GetTopElement(); |
| 86 NodeType* pParentFirstChildItem = | 87 NodeType* pParentFirstChildItem = |
| 87 TraverseStrategy::GetFirstChild(pParentItem); | 88 TraverseStrategy::GetFirstChild(pParentItem); |
| 88 if (pCurItem == pParentFirstChildItem) { | 89 if (pCurItem == pParentFirstChildItem) { |
| 89 return pParentItem; | 90 return pParentItem; |
| 90 } | 91 } |
| 91 NodeType *pPrevItem = pParentFirstChildItem, *pPrevItemNext = NULL; | 92 NodeType *pPrevItem = pParentFirstChildItem, *pPrevItemNext = nullptr; |
| 92 for (; pPrevItem; pPrevItem = pPrevItemNext) { | 93 for (; pPrevItem; pPrevItem = pPrevItemNext) { |
| 93 pPrevItemNext = TraverseStrategy::GetNextSibling(pPrevItem); | 94 pPrevItemNext = TraverseStrategy::GetNextSibling(pPrevItem); |
| 94 if (!pPrevItemNext || pPrevItemNext == pCurItem) { | 95 if (!pPrevItemNext || pPrevItemNext == pCurItem) { |
| 95 break; | 96 break; |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 m_NodeStack.Push(pPrevItem); | 99 m_NodeStack.Push(pPrevItem); |
| 99 } else { | 100 } else { |
| 100 m_NodeStack.RemoveAll(); | 101 m_NodeStack.RemoveAll(); |
| 101 if (m_pRoot) { | 102 if (m_pRoot) { |
| 102 m_NodeStack.Push(m_pRoot); | 103 m_NodeStack.Push(m_pRoot); |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 if (m_NodeStack.GetSize() > 0) { | 106 if (m_NodeStack.GetSize() > 0) { |
| 106 NodeType* pChildItem = *m_NodeStack.GetTopElement(); | 107 NodeType* pChildItem = *m_NodeStack.GetTopElement(); |
| 107 while ((pChildItem = TraverseStrategy::GetFirstChild(pChildItem)) != | 108 while ((pChildItem = TraverseStrategy::GetFirstChild(pChildItem)) != |
| 108 NULL) { | 109 nullptr) { |
| 109 while (NodeType* pNextItem = | 110 while (NodeType* pNextItem = |
| 110 TraverseStrategy::GetNextSibling(pChildItem)) { | 111 TraverseStrategy::GetNextSibling(pChildItem)) { |
| 111 pChildItem = pNextItem; | 112 pChildItem = pNextItem; |
| 112 } | 113 } |
| 113 m_NodeStack.Push(pChildItem); | 114 m_NodeStack.Push(pChildItem); |
| 114 } | 115 } |
| 115 return *m_NodeStack.GetTopElement(); | 116 return *m_NodeStack.GetTopElement(); |
| 116 } | 117 } |
| 117 return NULL; | 118 return nullptr; |
| 118 } | 119 } |
| 119 NodeType* MoveToNext() { | 120 NodeType* MoveToNext() { |
| 120 NodeType** ppNode = NULL; | 121 NodeType** ppNode = nullptr; |
| 121 NodeType* pCurrent = GetCurrent(); | 122 NodeType* pCurrent = GetCurrent(); |
| 122 while (m_NodeStack.GetSize() > 0) { | 123 while (m_NodeStack.GetSize() > 0) { |
| 123 while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) { | 124 while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) { |
| 124 if (pCurrent != *ppNode) { | 125 if (pCurrent != *ppNode) { |
| 125 return *ppNode; | 126 return *ppNode; |
| 126 } | 127 } |
| 127 NodeType* pChild = TraverseStrategy::GetFirstChild(*ppNode); | 128 NodeType* pChild = TraverseStrategy::GetFirstChild(*ppNode); |
| 128 if (pChild == NULL) { | 129 if (!pChild) |
| 129 break; | 130 break; |
| 130 } | 131 |
| 131 m_NodeStack.Push(pChild); | 132 m_NodeStack.Push(pChild); |
| 132 } | 133 } |
| 133 while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) { | 134 while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) { |
| 134 NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode); | 135 NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode); |
| 135 m_NodeStack.Pop(); | 136 m_NodeStack.Pop(); |
| 136 if (m_NodeStack.GetSize() == 0) { | 137 if (m_NodeStack.GetSize() == 0) { |
| 137 break; | 138 break; |
| 138 } | 139 } |
| 139 if (pNext) { | 140 if (pNext) { |
| 140 m_NodeStack.Push(pNext); | 141 m_NodeStack.Push(pNext); |
| 141 break; | 142 break; |
| 142 } | 143 } |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 return NULL; | 146 return nullptr; |
| 146 } | 147 } |
| 147 NodeType* SkipChildrenAndMoveToNext() { | 148 NodeType* SkipChildrenAndMoveToNext() { |
| 148 NodeType** ppNode = nullptr; | 149 NodeType** ppNode = nullptr; |
| 149 while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) { | 150 while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) { |
| 150 NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode); | 151 NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode); |
| 151 m_NodeStack.Pop(); | 152 m_NodeStack.Pop(); |
| 152 if (m_NodeStack.GetSize() == 0) { | 153 if (m_NodeStack.GetSize() == 0) { |
| 153 break; | 154 break; |
| 154 } | 155 } |
| 155 if (pNext) { | 156 if (pNext) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 175 void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, | 176 void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, |
| 176 CFX_WideString& wsPlainText); | 177 CFX_WideString& wsPlainText); |
| 177 FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode); | 178 FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode); |
| 178 IFX_Stream* XFA_CreateWideTextRead(const CFX_WideString& wsBuffer); | 179 IFX_Stream* XFA_CreateWideTextRead(const CFX_WideString& wsBuffer); |
| 179 FX_BOOL XFA_IsLayoutElement(XFA_ELEMENT eElement, | 180 FX_BOOL XFA_IsLayoutElement(XFA_ELEMENT eElement, |
| 180 FX_BOOL bLayoutContainer = FALSE); | 181 FX_BOOL bLayoutContainer = FALSE); |
| 181 | 182 |
| 182 void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode); | 183 void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode); |
| 183 void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, | 184 void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, |
| 184 IFX_Stream* pStream, | 185 IFX_Stream* pStream, |
| 185 const FX_CHAR* pChecksum = NULL, | 186 const FX_CHAR* pChecksum = nullptr, |
| 186 FX_BOOL bSaveXML = FALSE); | 187 FX_BOOL bSaveXML = FALSE); |
| 187 | 188 |
| 188 #endif // XFA_FXFA_PARSER_XFA_UTILS_H_ | 189 #endif // XFA_FXFA_PARSER_XFA_UTILS_H_ |
| OLD | NEW |