diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-08 19:57:00 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-08 19:57:00 +0000 |
commit | f96dfed065f9c6789811f43b69cd5ab4d85466ac (patch) | |
tree | 77da02be4215167c7c13faaf88c3ffe13d3eb91c /fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | |
parent | 3305678c7c954ba11be0ed089f7acd2b09af0779 (diff) | |
download | pdfium-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/fpdfxfa/cpdfxfa_docenvironment.cpp')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 43 |
1 files changed, 26 insertions, 17 deletions
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; |