summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfsave.cpp14
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp43
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp7
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h2
4 files changed, 39 insertions, 27 deletions
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 5acdef0a60..a21310dfa1 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -32,6 +32,7 @@
#include "xfa/fxfa/cxfa_ffdocview.h"
#include "xfa/fxfa/cxfa_ffwidgethandler.h"
#include "xfa/fxfa/cxfa_widgetacciterator.h"
+#include "xfa/fxfa/parser/cxfa_object.h"
#endif
#if _FX_OS_ == _FX_OS_ANDROID_
@@ -136,8 +137,10 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext,
{
RetainPtr<IFX_SeekableStream> pDsfileWrite =
pdfium::MakeRetain<CFX_MemoryStream>(false);
- if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, pDsfileWrite,
- nullptr) &&
+ CXFA_FFDoc* ffdoc = pXFADocView->GetDoc();
+ if (ffdoc->SavePackage(
+ ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Datasets)),
+ pDsfileWrite, nullptr) &&
pDsfileWrite->GetSize() > 0) {
// Datasets
pChecksum->UpdateChecksum(pDsfileWrite);
@@ -164,8 +167,11 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext,
{
RetainPtr<IFX_SeekableStream> pfileWrite =
pdfium::MakeRetain<CFX_MemoryStream>(false);
- if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite,
- pChecksum.get()) &&
+
+ CXFA_FFDoc* ffdoc = pXFADocView->GetDoc();
+ if (ffdoc->SavePackage(
+ ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)),
+ pfileWrite, pChecksum.get()) &&
pfileWrite->GetSize() > 0) {
auto pDataDict = pdfium::MakeUnique<CPDF_Dictionary>(
pPDFDocument->GetByteStringPool());
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index a49b25fc57..72b8970022 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -439,8 +439,10 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(),
content.GetLength());
- m_pContext->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Data,
- fileWrite, nullptr);
+ CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
+ ffdoc->SavePackage(
+ ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Data)), fileWrite,
+ nullptr);
} else if (fileType == FXFA_SAVEAS_XDP) {
if (!m_pContext->GetPDFDoc())
return;
@@ -470,13 +472,17 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
if (!pStream)
continue;
if (pPrePDFObj->GetString() == "form") {
- m_pContext->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Form,
- fileWrite, nullptr);
+ CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
+ ffdoc->SavePackage(
+ ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)),
+ fileWrite, nullptr);
continue;
}
if (pPrePDFObj->GetString() == "datasets") {
- m_pContext->GetXFADocView()->GetDoc()->SavePackage(
- XFA_HASHCODE_Datasets, fileWrite, nullptr);
+ CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
+ ffdoc->SavePackage(
+ ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Datasets)),
+ fileWrite, nullptr);
continue;
}
if (i == size - 1) {
@@ -716,18 +722,20 @@ bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
if (!m_pContext->GetXFADocView())
return false;
- ByteString content;
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
if (!pFormFillEnv)
return false;
+ CXFA_FFDoc* ffdoc = m_pContext->GetXFADocView()->GetDoc();
RetainPtr<IFX_SeekableStream> fileStream = MakeSeekableStream(pFileHandler);
-
if (fileType == FXFA_SAVEAS_XML) {
- const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+ static constexpr char kContent[] =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
fileStream->WriteBlock(kContent, 0, strlen(kContent));
- m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, fileStream,
- nullptr);
+
+ ffdoc->SavePackage(
+ ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Data)), fileStream,
+ nullptr);
return true;
}
@@ -787,14 +795,15 @@ bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
continue;
if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM))
continue;
+
if (pPrePDFObj->GetString() == "form") {
- m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Form, fileStream,
- nullptr);
+ ffdoc->SavePackage(
+ ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)),
+ fileStream, nullptr);
} else if (pPrePDFObj->GetString() == "datasets") {
- m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Datasets, fileStream,
- nullptr);
- } else {
- // PDF,creator.
+ ffdoc->SavePackage(
+ ToNode(ffdoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Datasets)),
+ fileStream, nullptr);
}
}
return true;
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 626defb7d2..640ac39178 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -393,13 +393,10 @@ RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(
return pDibSource;
}
-bool CXFA_FFDoc::SavePackage(XFA_HashCode code,
+bool CXFA_FFDoc::SavePackage(CXFA_Node* pNode,
const RetainPtr<IFX_SeekableStream>& pFile,
CFX_ChecksumContext* pCSContext) {
- CXFA_Document* doc = m_pDocumentParser->GetDocument();
- auto pExport = pdfium::MakeUnique<CXFA_DataExporter>(doc);
- CXFA_Node* pNode = code == XFA_HASHCODE_Xfa ? doc->GetRoot()
- : ToNode(doc->GetXFAObject(code));
+ auto pExport = pdfium::MakeUnique<CXFA_DataExporter>(GetXFADoc());
if (!pNode)
return !!pExport->Export(pFile);
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index 490b023f0d..10ffa36275 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -75,7 +75,7 @@ class CXFA_FFDoc {
int32_t& iImageYDpi);
CFGAS_PDFFontMgr* GetPDFFontMgr() const { return m_pPDFFontMgr.get(); }
- bool SavePackage(XFA_HashCode code,
+ bool SavePackage(CXFA_Node* pNode,
const RetainPtr<IFX_SeekableStream>& pFile,
CFX_ChecksumContext* pCSContext);
bool ImportData(const RetainPtr<IFX_SeekableStream>& pStream,