summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-08 19:57:00 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-08 19:57:00 +0000
commitf96dfed065f9c6789811f43b69cd5ab4d85466ac (patch)
tree77da02be4215167c7c13faaf88c3ffe13d3eb91c /fpdfsdk
parent3305678c7c954ba11be0ed089f7acd2b09af0779 (diff)
downloadpdfium-f96dfed065f9c6789811f43b69cd5ab4d85466ac.tar.xz
Convert CXFA_FFDoc::SavePackage to accept a CXFA_Node
This CL converts SavePackage to accept the CXFA_Node to export instead of the HASHCODE of the object to retrieve. This simplifies the code in SavePackage as we don't have to detect if this is the Xfa hashcode. Change-Id: I73ef9c4aa3d16f433e2d4568fab5f6d34c214635 Reviewed-on: https://pdfium-review.googlesource.com/18111 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfsave.cpp14
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp43
2 files changed, 36 insertions, 21 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;