summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/xfa_document_serialize.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-07-11 08:20:58 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-11 08:20:58 -0700
commita1b0772321e9b839073b9b312bac22143f2d4011 (patch)
treeff6d64879b0d54dd30242f77139eca7e8384343e /xfa/fxfa/parser/xfa_document_serialize.cpp
parentd1cf239fa6be42baa02028efd1617d5af27d82e1 (diff)
downloadpdfium-a1b0772321e9b839073b9b312bac22143f2d4011.tar.xz
Remove IXFA_Parser, cleanup XFA parser code.
The IXFA_Parser only created a CXFA_SimpleParser, the CXFA_DocumentParser is only created in one spot and doesn't need all the IXFA_Parser methods. This CL removes IXFA_Parser, instantiates the CXFA_SimpleParser where needed and cleans up surrounding code. Review-Url: https://codereview.chromium.org/2123133004
Diffstat (limited to 'xfa/fxfa/parser/xfa_document_serialize.cpp')
-rw-r--r--xfa/fxfa/parser/xfa_document_serialize.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp
index febfa3e827..428b470c13 100644
--- a/xfa/fxfa/parser/xfa_document_serialize.cpp
+++ b/xfa/fxfa/parser/xfa_document_serialize.cpp
@@ -12,7 +12,6 @@
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
#include "xfa/fxfa/parser/xfa_object.h"
-#include "xfa/fxfa/parser/xfa_parser.h"
#include "xfa/fxfa/parser/xfa_parser_imp.h"
#include "xfa/fxfa/parser/xfa_script.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -22,34 +21,31 @@ CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument)
ASSERT(m_pDocument);
}
FX_BOOL CXFA_DataImporter::ImportData(IFX_FileRead* pDataDocument) {
- IXFA_Parser* pDataDocumentParser = IXFA_Parser::Create(m_pDocument);
- if (!pDataDocumentParser) {
+ std::unique_ptr<CXFA_SimpleParser> pDataDocumentParser(
+ new CXFA_SimpleParser(m_pDocument, false));
+ if (!pDataDocumentParser)
return FALSE;
- }
+
if (pDataDocumentParser->StartParse(pDataDocument, XFA_XDPPACKET_Datasets) !=
XFA_PARSESTATUS_Ready) {
- pDataDocumentParser->Release();
return FALSE;
}
- if (pDataDocumentParser->DoParse(nullptr) < XFA_PARSESTATUS_Done) {
- pDataDocumentParser->Release();
+ if (pDataDocumentParser->DoParse(nullptr) < XFA_PARSESTATUS_Done)
return FALSE;
- }
+
CXFA_Node* pImportDataRoot = pDataDocumentParser->GetRootNode();
- if (!pImportDataRoot) {
- pDataDocumentParser->Release();
+ if (!pImportDataRoot)
return FALSE;
- }
+
CXFA_Node* pDataModel =
ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets));
- if (!pDataModel) {
- pDataDocumentParser->Release();
+ if (!pDataModel)
return FALSE;
- }
+
CXFA_Node* pDataNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Data));
- if (pDataNode) {
+ if (pDataNode)
pDataModel->RemoveChild(pDataNode);
- }
+
if (pImportDataRoot->GetElementType() == XFA_Element::DataModel) {
while (CXFA_Node* pChildNode =
pImportDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) {
@@ -59,15 +55,14 @@ FX_BOOL CXFA_DataImporter::ImportData(IFX_FileRead* pDataDocument) {
} else {
CFDE_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode();
CFDE_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent);
- if (pParentXMLNode) {
+ if (pParentXMLNode)
pParentXMLNode->RemoveChildNode(pXMLNode);
- }
pDataModel->InsertChild(pImportDataRoot);
}
m_pDocument->DoDataRemerge(FALSE);
- pDataDocumentParser->Release();
return TRUE;
}
+
CFX_WideString XFA_ExportEncodeAttribute(const CFX_WideString& str) {
CFX_WideTextBuf textBuf;
int32_t iLen = str.GetLength();
@@ -487,7 +482,7 @@ FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream,
CXFA_Node* pNode,
uint32_t dwFlag,
const FX_CHAR* pChecksum) {
- CFDE_XMLDoc* pXMLDoc = m_pDocument->GetParser()->GetXMLDoc();
+ CFDE_XMLDoc* pXMLDoc = m_pDocument->GetXMLDoc();
if (pNode->IsModelNode()) {
switch (pNode->GetPacketID()) {
case XFA_XDPPACKET_XDP: {