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 #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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = FX_CreateMemoryStream(TRUE); | 200 IFX_MemoryStream* pMemStream = FX_CreateMemoryStream(TRUE); |
201 IFX_Stream* pTempStream = IFX_Stream::CreateStream( | 201 IFX_Stream* pTempStream = IFX_Stream::CreateStream( |
202 (IFX_FileWrite*)pMemStream, FX_STREAMACCESS_Text | | 202 (IFX_SeekableWriteStream*)pMemStream, FX_STREAMACCESS_Text | |
203 FX_STREAMACCESS_Write | | 203 FX_STREAMACCESS_Write | |
204 FX_STREAMACCESS_Append); | 204 FX_STREAMACCESS_Append); |
205 pTempStream->SetCodePage(FX_CODEPAGE_UTF8); | 205 pTempStream->SetCodePage(FX_CODEPAGE_UTF8); |
206 pRichTextXML->SaveXMLNode(pTempStream); | 206 pRichTextXML->SaveXMLNode(pTempStream); |
207 wsChildren += CFX_WideString::FromUTF8( | 207 wsChildren += CFX_WideString::FromUTF8( |
208 CFX_ByteStringC(pMemStream->GetBuffer(), pMemStream->GetSize())); | 208 CFX_ByteStringC(pMemStream->GetBuffer(), pMemStream->GetSize())); |
209 pTempStream->Release(); | 209 pTempStream->Release(); |
210 pMemStream->Release(); | 210 pMemStream->Release(); |
211 } else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml && | 211 } else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml && |
212 wsContentType == FX_WSTRC(L"text/xml")) { | 212 wsContentType == FX_WSTRC(L"text/xml")) { |
213 CFX_WideString wsRawValue; | 213 CFX_WideString wsRawValue; |
214 pRawValueNode->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue, FALSE); | 214 pRawValueNode->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue, FALSE); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); | 437 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); |
438 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", | 438 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", |
439 L"dataGroup"); | 439 L"dataGroup"); |
440 } | 440 } |
441 | 441 |
442 CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument) | 442 CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument) |
443 : m_pDocument(pDocument) { | 443 : m_pDocument(pDocument) { |
444 ASSERT(m_pDocument); | 444 ASSERT(m_pDocument); |
445 } | 445 } |
446 | 446 |
447 FX_BOOL CXFA_DataExporter::Export(IFX_FileWrite* pWrite) { | 447 FX_BOOL CXFA_DataExporter::Export(IFX_SeekableWriteStream* pWrite) { |
448 return Export(pWrite, m_pDocument->GetRoot(), 0, nullptr); | 448 return Export(pWrite, m_pDocument->GetRoot(), 0, nullptr); |
449 } | 449 } |
450 | 450 |
451 FX_BOOL CXFA_DataExporter::Export(IFX_FileWrite* pWrite, | 451 FX_BOOL CXFA_DataExporter::Export(IFX_SeekableWriteStream* pWrite, |
452 CXFA_Node* pNode, | 452 CXFA_Node* pNode, |
453 uint32_t dwFlag, | 453 uint32_t dwFlag, |
454 const FX_CHAR* pChecksum) { | 454 const FX_CHAR* pChecksum) { |
455 if (!pWrite) { | 455 if (!pWrite) { |
456 ASSERT(false); | 456 ASSERT(false); |
457 return FALSE; | 457 return FALSE; |
458 } | 458 } |
459 IFX_Stream* pStream = IFX_Stream::CreateStream( | 459 IFX_Stream* pStream = IFX_Stream::CreateStream( |
460 pWrite, | 460 pWrite, |
461 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); | 461 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) | 532 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) |
533 return FALSE; | 533 return FALSE; |
534 | 534 |
535 XFA_DataExporter_DealWithDataGroupNode(pExportNode); | 535 XFA_DataExporter_DealWithDataGroupNode(pExportNode); |
536 pElement->SetString(L"xmlns:xfa", L"http://www.xfa.org/schema/xfa-data/1.0/"); | 536 pElement->SetString(L"xmlns:xfa", L"http://www.xfa.org/schema/xfa-data/1.0/"); |
537 pXMLDoc->SaveXMLNode(pStream, pElement); | 537 pXMLDoc->SaveXMLNode(pStream, pElement); |
538 pElement->RemoveAttribute(L"xmlns:xfa"); | 538 pElement->RemoveAttribute(L"xmlns:xfa"); |
539 | 539 |
540 return TRUE; | 540 return TRUE; |
541 } | 541 } |
OLD | NEW |