Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: xfa/fxfa/parser/cxfa_node.cpp

Issue 2559763002: Refcount IFGAS_ streams all the time, too (Closed)
Patch Set: more Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/cxfa_dataexporter.cpp ('k') | xfa/fxfa/parser/cxfa_simple_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { 1438 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) {
1439 pArguments->GetReturnValue()->SetString(bsXMLHeader); 1439 pArguments->GetReturnValue()->SetString(bsXMLHeader);
1440 return; 1440 return;
1441 } 1441 }
1442 XFA_DataExporter_DealWithDataGroupNode(this); 1442 XFA_DataExporter_DealWithDataGroupNode(this);
1443 } 1443 }
1444 CFX_RetainPtr<IFX_MemoryStream> pMemoryStream = 1444 CFX_RetainPtr<IFX_MemoryStream> pMemoryStream =
1445 IFX_MemoryStream::Create(true); 1445 IFX_MemoryStream::Create(true);
1446 1446
1447 // Note: ambiguious below without static_cast. 1447 // Note: ambiguious below without static_cast.
1448 std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> pStream( 1448 CFX_RetainPtr<IFGAS_Stream> pStream = IFGAS_Stream::CreateStream(
1449 IFGAS_Stream::CreateStream( 1449 CFX_RetainPtr<IFX_SeekableWriteStream>(pMemoryStream),
1450 CFX_RetainPtr<IFX_SeekableWriteStream>(pMemoryStream), 1450 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append);
1451 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write |
1452 FX_STREAMACCESS_Append));
1453 1451
1454 if (!pStream) { 1452 if (!pStream) {
1455 pArguments->GetReturnValue()->SetString(bsXMLHeader); 1453 pArguments->GetReturnValue()->SetString(bsXMLHeader);
1456 return; 1454 return;
1457 } 1455 }
1458 pStream->SetCodePage(FX_CODEPAGE_UTF8); 1456 pStream->SetCodePage(FX_CODEPAGE_UTF8);
1459 pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength()); 1457 pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength());
1460 if (GetPacketID() == XFA_XDPPACKET_Form) 1458 if (GetPacketID() == XFA_XDPPACKET_Form)
1461 XFA_DataExporter_RegenerateFormFile(this, pStream.get(), nullptr, true); 1459 XFA_DataExporter_RegenerateFormFile(this, pStream, nullptr, true);
1462 else 1460 else
1463 pElement->SaveXMLNode(pStream.get()); 1461 pElement->SaveXMLNode(pStream);
1464 // TODO(weili): Check whether we need to save pretty print XML, pdfium:501. 1462 // TODO(weili): Check whether we need to save pretty print XML, pdfium:501.
1465 // For now, just put it here to avoid unused variable warning. 1463 // For now, just put it here to avoid unused variable warning.
1466 (void)bPrettyMode; 1464 (void)bPrettyMode;
1467 pArguments->GetReturnValue()->SetString( 1465 pArguments->GetReturnValue()->SetString(
1468 CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())); 1466 CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize()));
1469 return; 1467 return;
1470 } 1468 }
1471 pArguments->GetReturnValue()->SetString(""); 1469 pArguments->GetReturnValue()->SetString("");
1472 } 1470 }
1473 1471
(...skipping 3715 matching lines...) Expand 10 before | Expand all | Expand 10 after
5189 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); 5187 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild);
5190 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); 5188 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild);
5191 for (; pSrcChild && pDstChild; 5189 for (; pSrcChild && pDstChild;
5192 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), 5190 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling),
5193 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 5191 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
5194 MoveBufferMapData(pSrcChild, pDstChild, pKey, true); 5192 MoveBufferMapData(pSrcChild, pDstChild, pKey, true);
5195 } 5193 }
5196 } 5194 }
5197 pSrcModule->MoveBufferMapData(pDstModule, pKey); 5195 pSrcModule->MoveBufferMapData(pDstModule, pKey);
5198 } 5196 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_dataexporter.cpp ('k') | xfa/fxfa/parser/cxfa_simple_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698