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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 IFX_MemoryStream* pMemStream = IFX_MemoryStream::Create(true); |
201 IFX_Stream* pTempStream = IFX_Stream::CreateStream( | 201 IFGAS_Stream* pTempStream = IFGAS_Stream::CreateStream( |
202 (IFX_SeekableWriteStream*)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 && |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 buf << FX_WSTRC(L"\n>"); | 310 buf << FX_WSTRC(L"\n>"); |
311 buf << wsChildren; | 311 buf << wsChildren; |
312 buf << FX_WSTRC(L"</"); | 312 buf << FX_WSTRC(L"</"); |
313 buf << wsElement; | 313 buf << wsElement; |
314 buf << FX_WSTRC(L"\n>"); | 314 buf << FX_WSTRC(L"\n>"); |
315 } | 315 } |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 void RegenerateFormFile_Container(CXFA_Node* pNode, | 319 void RegenerateFormFile_Container(CXFA_Node* pNode, |
320 IFX_Stream* pStream, | 320 IFGAS_Stream* pStream, |
321 bool bSaveXML = false) { | 321 bool bSaveXML = false) { |
322 XFA_Element eType = pNode->GetElementType(); | 322 XFA_Element eType = pNode->GetElementType(); |
323 if (eType == XFA_Element::Field || eType == XFA_Element::Draw || | 323 if (eType == XFA_Element::Field || eType == XFA_Element::Draw || |
324 !pNode->IsContainerNode()) { | 324 !pNode->IsContainerNode()) { |
325 CFX_WideTextBuf buf; | 325 CFX_WideTextBuf buf; |
326 RegenerateFormFile_Changed(pNode, buf, bSaveXML); | 326 RegenerateFormFile_Changed(pNode, buf, bSaveXML); |
327 FX_STRSIZE nLen = buf.GetLength(); | 327 FX_STRSIZE nLen = buf.GetLength(); |
328 if (nLen > 0) | 328 if (nLen > 0) |
329 pStream->WriteString((const FX_WCHAR*)buf.GetBuffer(), nLen); | 329 pStream->WriteString((const FX_WCHAR*)buf.GetBuffer(), nLen); |
330 return; | 330 return; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 pStream->WriteString(wsElement.c_str(), wsElement.GetLength()); | 364 pStream->WriteString(wsElement.c_str(), wsElement.GetLength()); |
365 pStream->WriteString(L"\n>", 2); | 365 pStream->WriteString(L"\n>", 2); |
366 } else { | 366 } else { |
367 pStream->WriteString(L"\n/>", 3); | 367 pStream->WriteString(L"\n/>", 3); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 } // namespace | 371 } // namespace |
372 | 372 |
373 void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, | 373 void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, |
374 IFX_Stream* pStream, | 374 IFGAS_Stream* pStream, |
375 const FX_CHAR* pChecksum, | 375 const FX_CHAR* pChecksum, |
376 bool bSaveXML) { | 376 bool bSaveXML) { |
377 if (pNode->IsModelNode()) { | 377 if (pNode->IsModelNode()) { |
378 static const FX_WCHAR s_pwsTagName[] = L"<form"; | 378 static const FX_WCHAR s_pwsTagName[] = L"<form"; |
379 static const FX_WCHAR s_pwsClose[] = L"</form\n>"; | 379 static const FX_WCHAR s_pwsClose[] = L"</form\n>"; |
380 pStream->WriteString(s_pwsTagName, FXSYS_wcslen(s_pwsTagName)); | 380 pStream->WriteString(s_pwsTagName, FXSYS_wcslen(s_pwsTagName)); |
381 if (pChecksum) { | 381 if (pChecksum) { |
382 static const FX_WCHAR s_pwChecksum[] = L" checksum=\""; | 382 static const FX_WCHAR s_pwChecksum[] = L" checksum=\""; |
383 CFX_WideString wsChecksum = CFX_WideString::FromUTF8(pChecksum); | 383 CFX_WideString wsChecksum = CFX_WideString::FromUTF8(pChecksum); |
384 pStream->WriteString(s_pwChecksum, FXSYS_wcslen(s_pwChecksum)); | 384 pStream->WriteString(s_pwChecksum, FXSYS_wcslen(s_pwChecksum)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 449 } |
450 | 450 |
451 bool CXFA_DataExporter::Export(IFX_SeekableWriteStream* pWrite, | 451 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 IFGAS_Stream* pStream = IFGAS_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); |
462 if (!pStream) | 462 if (!pStream) |
463 return false; | 463 return false; |
464 | 464 |
465 pStream->SetCodePage(FX_CODEPAGE_UTF8); | 465 pStream->SetCodePage(FX_CODEPAGE_UTF8); |
466 bool bRet = Export(pStream, pNode, dwFlag, pChecksum); | 466 bool bRet = Export(pStream, pNode, dwFlag, pChecksum); |
467 pStream->Release(); | 467 pStream->Release(); |
468 return bRet; | 468 return bRet; |
469 } | 469 } |
470 | 470 |
471 bool CXFA_DataExporter::Export(IFX_Stream* pStream, | 471 bool CXFA_DataExporter::Export(IFGAS_Stream* pStream, |
472 CXFA_Node* pNode, | 472 CXFA_Node* pNode, |
473 uint32_t dwFlag, | 473 uint32_t dwFlag, |
474 const FX_CHAR* pChecksum) { | 474 const FX_CHAR* pChecksum) { |
475 CFDE_XMLDoc* pXMLDoc = m_pDocument->GetXMLDoc(); | 475 CFDE_XMLDoc* pXMLDoc = m_pDocument->GetXMLDoc(); |
476 if (pNode->IsModelNode()) { | 476 if (pNode->IsModelNode()) { |
477 switch (pNode->GetPacketID()) { | 477 switch (pNode->GetPacketID()) { |
478 case XFA_XDPPACKET_XDP: { | 478 case XFA_XDPPACKET_XDP: { |
479 static const FX_WCHAR s_pwsPreamble[] = | 479 static const FX_WCHAR s_pwsPreamble[] = |
480 L"<xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">"; | 480 L"<xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">"; |
481 pStream->WriteString(s_pwsPreamble, FXSYS_wcslen(s_pwsPreamble)); | 481 pStream->WriteString(s_pwsPreamble, FXSYS_wcslen(s_pwsPreamble)); |
(...skipping 50 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 |