OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "xfa/fxfa/parser/xfa_object.h" | 7 #include "xfa/fxfa/parser/xfa_object.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "core/fxcrt/fx_ext.h" | 14 #include "core/fxcrt/fx_ext.h" |
15 #include "fxjs/cfxjse_value.h" | 15 #include "fxjs/cfxjse_value.h" |
| 16 #include "third_party/base/ptr_util.h" |
16 #include "third_party/base/stl_util.h" | 17 #include "third_party/base/stl_util.h" |
17 #include "xfa/fde/xml/fde_xml_imp.h" | 18 #include "xfa/fde/xml/fde_xml_imp.h" |
18 #include "xfa/fgas/crt/fgas_codepage.h" | 19 #include "xfa/fgas/crt/fgas_codepage.h" |
19 #include "xfa/fxfa/app/xfa_ffnotify.h" | 20 #include "xfa/fxfa/app/xfa_ffnotify.h" |
20 #include "xfa/fxfa/cxfa_eventparam.h" | 21 #include "xfa/fxfa/cxfa_eventparam.h" |
21 #include "xfa/fxfa/parser/cxfa_document.h" | 22 #include "xfa/fxfa/parser/cxfa_document.h" |
22 #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" | 23 #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" |
23 #include "xfa/fxfa/parser/cxfa_measurement.h" | 24 #include "xfa/fxfa/parser/cxfa_measurement.h" |
24 #include "xfa/fxfa/parser/cxfa_occur.h" | 25 #include "xfa/fxfa/parser/cxfa_occur.h" |
25 #include "xfa/fxfa/parser/cxfa_scriptcontext.h" | 26 #include "xfa/fxfa/parser/cxfa_scriptcontext.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 std::map<CXFA_Node*, std::unique_ptr<CXFA_NodeSetPairMap>>; | 112 std::map<CXFA_Node*, std::unique_ptr<CXFA_NodeSetPairMap>>; |
112 | 113 |
113 CXFA_NodeSetPair* NodeSetPairForNode(CXFA_Node* pNode, | 114 CXFA_NodeSetPair* NodeSetPairForNode(CXFA_Node* pNode, |
114 CXFA_NodeSetPairMapMap* pMap) { | 115 CXFA_NodeSetPairMapMap* pMap) { |
115 CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); | 116 CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); |
116 uint32_t dwNameHash = pNode->GetNameHash(); | 117 uint32_t dwNameHash = pNode->GetNameHash(); |
117 if (!pParentNode || !dwNameHash) | 118 if (!pParentNode || !dwNameHash) |
118 return nullptr; | 119 return nullptr; |
119 | 120 |
120 if (!(*pMap)[pParentNode]) | 121 if (!(*pMap)[pParentNode]) |
121 (*pMap)[pParentNode].reset(new CXFA_NodeSetPairMap); | 122 (*pMap)[pParentNode] = pdfium::MakeUnique<CXFA_NodeSetPairMap>(); |
122 | 123 |
123 CXFA_NodeSetPairMap* pNodeSetPairMap = (*pMap)[pParentNode].get(); | 124 CXFA_NodeSetPairMap* pNodeSetPairMap = (*pMap)[pParentNode].get(); |
124 if (!(*pNodeSetPairMap)[dwNameHash]) | 125 if (!(*pNodeSetPairMap)[dwNameHash]) |
125 (*pNodeSetPairMap)[dwNameHash].reset(new CXFA_NodeSetPair); | 126 (*pNodeSetPairMap)[dwNameHash] = pdfium::MakeUnique<CXFA_NodeSetPair>(); |
126 | 127 |
127 return (*pNodeSetPairMap)[dwNameHash].get(); | 128 return (*pNodeSetPairMap)[dwNameHash].get(); |
128 } | 129 } |
129 | 130 |
130 void ReorderDataNodes(const CXFA_NodeSet& sSet1, | 131 void ReorderDataNodes(const CXFA_NodeSet& sSet1, |
131 const CXFA_NodeSet& sSet2, | 132 const CXFA_NodeSet& sSet2, |
132 bool bInsertBefore) { | 133 bool bInsertBefore) { |
133 CXFA_NodeSetPairMapMap rgMap; | 134 CXFA_NodeSetPairMapMap rgMap; |
134 for (CXFA_Node* pNode : sSet1) { | 135 for (CXFA_Node* pNode : sSet1) { |
135 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap); | 136 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap); |
(...skipping 5053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5189 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); | 5190 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); |
5190 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); | 5191 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); |
5191 for (; pSrcChild && pDstChild; | 5192 for (; pSrcChild && pDstChild; |
5192 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), | 5193 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), |
5193 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 5194 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
5194 MoveBufferMapData(pSrcChild, pDstChild, pKey, true); | 5195 MoveBufferMapData(pSrcChild, pDstChild, pKey, true); |
5195 } | 5196 } |
5196 } | 5197 } |
5197 pSrcModule->MoveBufferMapData(pDstModule, pKey); | 5198 pSrcModule->MoveBufferMapData(pDstModule, pKey); |
5198 } | 5199 } |
OLD | NEW |