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

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

Issue 2451493002: Refcount all the IFX_ stream classes all the time. (Closed)
Patch Set: Clean up cast expression 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.h ('k') | xfa/fxfa/parser/cxfa_dataimporter.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 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 #include "xfa/fxfa/parser/cxfa_dataexporter.h" 7 #include "xfa/fxfa/parser/cxfa_dataexporter.h"
8 8
9 #include "core/fxcrt/fx_basic.h" 9 #include "core/fxcrt/fx_basic.h"
10 #include "xfa/fde/xml/fde_xml_imp.h" 10 #include "xfa/fde/xml/fde_xml_imp.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 wsContentType == FX_WSTRC(L"text/html")) { 190 wsContentType == FX_WSTRC(L"text/html")) {
191 CFDE_XMLNode* pExDataXML = pNode->GetXMLMappingNode(); 191 CFDE_XMLNode* pExDataXML = pNode->GetXMLMappingNode();
192 if (!pExDataXML) 192 if (!pExDataXML)
193 break; 193 break;
194 194
195 CFDE_XMLNode* pRichTextXML = 195 CFDE_XMLNode* pRichTextXML =
196 pExDataXML->GetNodeItem(CFDE_XMLNode::FirstChild); 196 pExDataXML->GetNodeItem(CFDE_XMLNode::FirstChild);
197 if (!pRichTextXML) 197 if (!pRichTextXML)
198 break; 198 break;
199 199
200 IFX_MemoryStream* pMemStream = IFX_MemoryStream::Create(true); 200 CFX_RetainPtr<IFX_MemoryStream> pMemStream =
201 IFX_MemoryStream::Create(true);
202
203 // Note: ambiguous without cast below.
201 IFGAS_Stream* pTempStream = IFGAS_Stream::CreateStream( 204 IFGAS_Stream* pTempStream = IFGAS_Stream::CreateStream(
202 (IFX_SeekableWriteStream*)pMemStream, FX_STREAMACCESS_Text | 205 CFX_RetainPtr<IFX_SeekableWriteStream>(pMemStream),
203 FX_STREAMACCESS_Write | 206 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write |
204 FX_STREAMACCESS_Append); 207 FX_STREAMACCESS_Append);
208
205 pTempStream->SetCodePage(FX_CODEPAGE_UTF8); 209 pTempStream->SetCodePage(FX_CODEPAGE_UTF8);
206 pRichTextXML->SaveXMLNode(pTempStream); 210 pRichTextXML->SaveXMLNode(pTempStream);
207 wsChildren += CFX_WideString::FromUTF8( 211 wsChildren += CFX_WideString::FromUTF8(
208 CFX_ByteStringC(pMemStream->GetBuffer(), pMemStream->GetSize())); 212 CFX_ByteStringC(pMemStream->GetBuffer(), pMemStream->GetSize()));
209 pTempStream->Release(); 213 pTempStream->Release();
210 pMemStream->Release();
211 } else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml && 214 } else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml &&
212 wsContentType == FX_WSTRC(L"text/xml")) { 215 wsContentType == FX_WSTRC(L"text/xml")) {
213 CFX_WideString wsRawValue; 216 CFX_WideString wsRawValue;
214 pRawValueNode->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue, false); 217 pRawValueNode->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue, false);
215 if (wsRawValue.IsEmpty()) 218 if (wsRawValue.IsEmpty())
216 break; 219 break;
217 220
218 CFX_WideStringArray wsSelTextArray; 221 CFX_WideStringArray wsSelTextArray;
219 int32_t iStart = 0; 222 int32_t iStart = 0;
220 int32_t iEnd = wsRawValue.Find(L'\n', iStart); 223 int32_t iEnd = wsRawValue.Find(L'\n', iStart);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); 440 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element);
438 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", 441 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode",
439 L"dataGroup"); 442 L"dataGroup");
440 } 443 }
441 444
442 CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument) 445 CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument)
443 : m_pDocument(pDocument) { 446 : m_pDocument(pDocument) {
444 ASSERT(m_pDocument); 447 ASSERT(m_pDocument);
445 } 448 }
446 449
447 bool CXFA_DataExporter::Export(IFX_SeekableWriteStream* pWrite) { 450 bool CXFA_DataExporter::Export(
451 const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite) {
448 return Export(pWrite, m_pDocument->GetRoot(), 0, nullptr); 452 return Export(pWrite, m_pDocument->GetRoot(), 0, nullptr);
449 } 453 }
450 454
451 bool CXFA_DataExporter::Export(IFX_SeekableWriteStream* pWrite, 455 bool CXFA_DataExporter::Export(
452 CXFA_Node* pNode, 456 const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite,
453 uint32_t dwFlag, 457 CXFA_Node* pNode,
454 const FX_CHAR* pChecksum) { 458 uint32_t dwFlag,
455 if (!pWrite) { 459 const FX_CHAR* pChecksum) {
456 ASSERT(false); 460 ASSERT(pWrite);
461 if (!pWrite)
457 return false; 462 return false;
458 } 463
459 IFGAS_Stream* pStream = IFGAS_Stream::CreateStream( 464 IFGAS_Stream* pStream = IFGAS_Stream::CreateStream(
460 pWrite, 465 pWrite,
461 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); 466 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append);
462 if (!pStream) 467 if (!pStream)
463 return false; 468 return false;
464 469
465 pStream->SetCodePage(FX_CODEPAGE_UTF8); 470 pStream->SetCodePage(FX_CODEPAGE_UTF8);
466 bool bRet = Export(pStream, pNode, dwFlag, pChecksum); 471 bool bRet = Export(pStream, pNode, dwFlag, pChecksum);
467 pStream->Release(); 472 pStream->Release();
468 return bRet; 473 return bRet;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) 537 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element)
533 return false; 538 return false;
534 539
535 XFA_DataExporter_DealWithDataGroupNode(pExportNode); 540 XFA_DataExporter_DealWithDataGroupNode(pExportNode);
536 pElement->SetString(L"xmlns:xfa", L"http://www.xfa.org/schema/xfa-data/1.0/"); 541 pElement->SetString(L"xmlns:xfa", L"http://www.xfa.org/schema/xfa-data/1.0/");
537 pXMLDoc->SaveXMLNode(pStream, pElement); 542 pXMLDoc->SaveXMLNode(pStream, pElement);
538 pElement->RemoveAttribute(L"xmlns:xfa"); 543 pElement->RemoveAttribute(L"xmlns:xfa");
539 544
540 return true; 545 return true;
541 } 546 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_dataexporter.h ('k') | xfa/fxfa/parser/cxfa_dataimporter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698