Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cxfa_dataexporter.cpp
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "xfa/fxfa/parser/cxfa_dataexporter.h"
8
9#include "core/fxcrt/fx_codepage.h"
10#include "core/fxcrt/xml/cfx_xmlelement.h"
11#include "core/fxcrt/xml/cfx_xmlnode.h"
12#include "third_party/base/check.h"
13#include "xfa/fxfa/parser/cxfa_document.h"
14#include "xfa/fxfa/parser/cxfa_node.h"
15#include "xfa/fxfa/parser/xfa_utils.h"
16
18
20
22 CXFA_Node* pNode) {
23 DCHECK(pStream);
24
25 if (pNode->IsModelNode()) {
26 switch (pNode->GetPacketType()) {
27 case XFA_PacketType::Xdp: {
28 pStream->WriteString(
29 "<xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">");
30 for (CXFA_Node* pChild = pNode->GetFirstChild(); pChild;
31 pChild = pChild->GetNextSibling()) {
32 Export(pStream, pChild);
33 }
34 pStream->WriteString("</xdp:xdp>\n");
35 break;
36 }
37 case XFA_PacketType::Datasets: {
38 CFX_XMLElement* pElement = ToXMLElement(pNode->GetXMLMappingNode());
39 if (!pElement)
40 return false;
41
42 CXFA_Node* pDataNode = pNode->GetFirstChild();
43 DCHECK(pDataNode);
45 pElement->Save(pStream);
46 break;
47 }
48 case XFA_PacketType::Form:
50 break;
51 case XFA_PacketType::Template:
52 default: {
53 CFX_XMLElement* pElement = ToXMLElement(pNode->GetXMLMappingNode());
54 if (!pElement)
55 return false;
56
57 pElement->Save(pStream);
58 break;
59 }
60 }
61 return true;
62 }
63
64 CXFA_Node* pDataNode = pNode->GetParent();
65 CXFA_Node* pExportNode = pNode;
66 for (CXFA_Node* pChildNode = pDataNode->GetFirstChild(); pChildNode;
67 pChildNode = pChildNode->GetNextSibling()) {
68 if (pChildNode != pNode) {
69 pExportNode = pDataNode;
70 break;
71 }
72 }
73 CFX_XMLElement* pElement = ToXMLElement(pExportNode->GetXMLMappingNode());
74 if (!pElement)
75 return false;
76
78 pElement->SetAttribute(L"xmlns:xfa",
79 L"http://www.xfa.org/schema/xfa-data/1.0/");
80 pElement->Save(pStream);
81 pElement->RemoveAttribute(L"xmlns:xfa");
82 return true;
83}
CFX_XMLElement * ToXMLElement(CFX_XMLNode *pNode)
void Save(const RetainPtr< IFX_RetainableWriteStream > &pXMLStream) override
void SetAttribute(const WideString &name, const WideString &value)
void RemoveAttribute(const WideString &name)
bool Export(const RetainPtr< IFX_SeekableStream > &pWrite, CXFA_Node *pNode)
CFX_XMLNode * GetXMLMappingNode() const
Definition cxfa_node.h:184
XFA_PacketType GetPacketType() const
Definition cxfa_node.h:146
bool IsModelNode() const
Definition cxfa_object.h:72
XFA_PacketType
Definition fxfa_basic.h:44
void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node *pDataNode)
void XFA_DataExporter_RegenerateFormFile(CXFA_Node *pNode, const RetainPtr< IFX_SeekableStream > &pStream, bool bSaveXML)