summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp23
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h2
-rw-r--r--xfa/fxfa/fxfa.h6
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp21
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.h8
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.h5
8 files changed, 35 insertions, 36 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index 0ba7f31995..e28561dca1 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -96,8 +96,7 @@ bool CPDFXFA_Context::LoadXFADoc() {
return false;
}
- int iStatus = m_pXFADoc->Load();
- if (iStatus != XFA_PARSESTATUS_Done) {
+ if (!m_pXFADoc->Load()) {
CloseXFADoc();
SetLastError(FPDF_ERR_XFALOAD);
return false;
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 655e58ff7f..4c6ae67de7 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -164,15 +164,16 @@ CXFA_FFDoc::~CXFA_FFDoc() {
CloseDoc();
}
-int32_t CXFA_FFDoc::Load() {
+bool CXFA_FFDoc::Load() {
m_pNotify = pdfium::MakeUnique<CXFA_FFNotify>(this);
m_pDocumentParser = pdfium::MakeUnique<CXFA_DocumentParser>(m_pNotify.get());
-
- int32_t iStatus = m_pDocumentParser->Parse(m_pStream, XFA_PacketType::Xdp);
- if (iStatus != XFA_PARSESTATUS_Done)
- return iStatus;
+ if (!m_pDocumentParser->Parse(m_pStream, XFA_PacketType::Xdp))
+ return false;
if (!m_pPDFDoc)
- return XFA_PARSESTATUS_SyntaxErr;
+ return false;
+
+ // At this point we've got an XFA document and we want to always return
+ // true to signify the load succeeded.
m_pPDFFontMgr = pdfium::MakeUnique<CFGAS_PDFFontMgr>(
GetPDFDoc(), GetApp()->GetFDEFontMgr());
@@ -181,29 +182,29 @@ int32_t CXFA_FFDoc::Load() {
CXFA_Node* pConfig = ToNode(
m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config));
if (!pConfig)
- return iStatus;
+ return true;
CXFA_Acrobat* pAcrobat =
pConfig->GetFirstChildByClass<CXFA_Acrobat>(XFA_Element::Acrobat);
if (!pAcrobat)
- return iStatus;
+ return true;
CXFA_Acrobat7* pAcrobat7 =
pAcrobat->GetFirstChildByClass<CXFA_Acrobat7>(XFA_Element::Acrobat7);
if (!pAcrobat7)
- return iStatus;
+ return true;
CXFA_DynamicRender* pDynamicRender =
pAcrobat7->GetFirstChildByClass<CXFA_DynamicRender>(
XFA_Element::DynamicRender);
if (!pDynamicRender)
- return iStatus;
+ return true;
WideString wsType = pDynamicRender->JSObject()->GetContent(false);
if (wsType == L"required")
m_FormType = FormType::kXFAFull;
- return iStatus;
+ return true;
}
bool XFA_GetPDFContentsFromPDFXML(CFX_XMLNode* pPDFElement,
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index 2d9127c056..59b3f57cac 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -58,7 +58,7 @@ class CXFA_FFDoc {
}
FormType GetFormType() const { return m_FormType; }
- int32_t Load();
+ bool Load();
CXFA_FFDocView* CreateDocView();
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index 4a1f8b32fc..82ad90fc36 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -43,12 +43,6 @@ enum class FormType {
kXFAForeground = 3,
};
-#define XFA_PARSESTATUS_StatusErr -3
-#define XFA_PARSESTATUS_StreamErr -2
-#define XFA_PARSESTATUS_SyntaxErr -1
-#define XFA_PARSESTATUS_Ready 0
-#define XFA_PARSESTATUS_Done 100
-
#define XFA_PRINTOPT_ShowDialog 0x00000001
#define XFA_PRINTOPT_CanCancel 0x00000002
#define XFA_PRINTOPT_ShrinkPage 0x00000004
diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp
index 01e95b1c3a..b44e5e0552 100644
--- a/xfa/fxfa/parser/cxfa_dataimporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp
@@ -27,8 +27,7 @@ CXFA_DataImporter::~CXFA_DataImporter() {}
bool CXFA_DataImporter::ImportData(
const RetainPtr<IFX_SeekableStream>& pDataDocument) {
CXFA_SimpleParser parser(m_pDocument.Get());
- int status = parser.Parse(pDataDocument, XFA_PacketType::Datasets);
- if (status < XFA_PARSESTATUS_Done)
+ if (!parser.Parse(pDataDocument, XFA_PacketType::Datasets))
return false;
CXFA_Node* pImportDataRoot = parser.GetRootNode();
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 883f684768..52b5e333c0 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -18,17 +18,22 @@ CXFA_DocumentParser::~CXFA_DocumentParser() {
m_pDocument->ReleaseXMLNodesIfNeeded();
}
-int32_t CXFA_DocumentParser::Parse(const RetainPtr<IFX_SeekableStream>& pStream,
- XFA_PacketType ePacketID) {
+bool CXFA_DocumentParser::Parse(const RetainPtr<IFX_SeekableStream>& pStream,
+ XFA_PacketType ePacketID) {
m_pDocument = pdfium::MakeUnique<CXFA_Document>(GetNotify());
- m_nodeParser.SetFactory(m_pDocument.get());
- if (!m_nodeParser.Parse(pStream, ePacketID))
- return XFA_PARSESTATUS_StatusErr;
+ // Note, we don't pass the document into the constructor as currently that
+ // triggers different behaviour in the parser.
+ CXFA_SimpleParser parser;
+ parser.SetFactory(m_pDocument.get());
- ASSERT(m_pDocument);
- m_pDocument->SetRoot(m_nodeParser.GetRootNode());
- return XFA_PARSESTATUS_Done;
+ if (!parser.Parse(pStream, ePacketID))
+ return false;
+
+ m_pXMLRoot = parser.GetXMLRoot();
+
+ m_pDocument->SetRoot(parser.GetRootNode());
+ return true;
}
CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const {
diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h
index c7056c215a..1075f48ef4 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.h
+++ b/xfa/fxfa/parser/cxfa_document_parser.h
@@ -22,18 +22,16 @@ class CXFA_DocumentParser {
explicit CXFA_DocumentParser(CXFA_FFNotify* pNotify);
~CXFA_DocumentParser();
- int32_t Parse(const RetainPtr<IFX_SeekableStream>& pStream,
- XFA_PacketType ePacketID);
+ bool Parse(const RetainPtr<IFX_SeekableStream>& pStream,
+ XFA_PacketType ePacketID);
CXFA_FFNotify* GetNotify() const;
CXFA_Document* GetDocument() const;
private:
UnownedPtr<CXFA_FFNotify> const m_pNotify;
- // Note, the |m_nodeParser| has an unowned pointer to the |m_pDocument| so
- // the |m_nodeParser| must be cleaned up first.
+ std::unique_ptr<CFX_XMLNode> m_pXMLRoot;
std::unique_ptr<CXFA_Document> m_pDocument;
- CXFA_SimpleParser m_nodeParser;
};
#endif // XFA_FXFA_PARSER_CXFA_DOCUMENT_PARSER_H_
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h
index 61edf8e8e6..157983fe8e 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.h
+++ b/xfa/fxfa/parser/cxfa_simple_parser.h
@@ -8,14 +8,15 @@
#define XFA_FXFA_PARSER_CXFA_SIMPLE_PARSER_H_
#include <memory>
+#include <utility>
+#include "core/fxcrt/xml/cfx_xmlnode.h"
#include "xfa/fxfa/fxfa_basic.h"
class CXFA_Document;
class CXFA_Node;
class CFX_XMLDoc;
class CFX_XMLInstruction;
-class CFX_XMLNode;
class IFX_SeekableStream;
class CFX_SeekableStreamProxy;
@@ -30,6 +31,8 @@ class CXFA_SimpleParser {
CFX_XMLNode* ParseXMLData(const ByteString& wsXML);
void ConstructXFANode(CXFA_Node* pXFANode, CFX_XMLNode* pXMLNode);
+
+ std::unique_ptr<CFX_XMLNode> GetXMLRoot() { return std::move(m_pNodeTree); }
CXFA_Node* GetRootNode() const;
// Called later for the ctor with no parameters.