diff options
author | tsepez <tsepez@chromium.org> | 2016-05-16 17:05:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-16 17:05:38 -0700 |
commit | 3857904e520ecb06bad545e4e4bfcf4e60dd1f52 (patch) | |
tree | 20f4108f4f09cdfdce50ff2b788c8c8d481cd7ea /xfa/fxfa | |
parent | 3301ab30aeec548833eb2d693bd3eebf9d1c28ce (diff) | |
download | pdfium-3857904e520ecb06bad545e4e4bfcf4e60dd1f52.tar.xz |
Remove Release() { delete this; } in CFXA_Data{Importer,Exporter}
Review-Url: https://codereview.chromium.org/1988453002
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffdoc.cpp | 41 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_serialize.h | 3 |
2 files changed, 19 insertions, 25 deletions
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index f33e4e0585..8297dce9ec 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -362,34 +362,29 @@ CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { ? static_cast<CFDE_XMLElement*>(pXMLNode) : NULL; } + FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, IFX_FileWrite* pFile, CXFA_ChecksumContext* pCSContext) { - CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument); + std::unique_ptr<CXFA_DataExporter> pExport( + new CXFA_DataExporter(m_pDocument)); uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); - CXFA_Node* pNode = NULL; - if (packetHash == XFA_HASHCODE_Xfa) { - pNode = m_pDocument->GetRoot(); - } else { - pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); - } - FX_BOOL bFlags = FALSE; - if (pNode) { - CFX_ByteString bsChecksum; - if (pCSContext) { - pCSContext->GetChecksum(bsChecksum); - } - bFlags = pExport->Export( - pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : NULL); - } else { - bFlags = pExport->Export(pFile); - } - pExport->Release(); - return bFlags; + CXFA_Node* pNode = packetHash == XFA_HASHCODE_Xfa + ? m_pDocument->GetRoot() + : ToNode(m_pDocument->GetXFAObject(packetHash)); + if (!pNode) + return pExport->Export(pFile); + + CFX_ByteString bsChecksum; + if (pCSContext) + pCSContext->GetChecksum(bsChecksum); + + return pExport->Export(pFile, pNode, 0, + bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); } -FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { - std::unique_ptr<CXFA_DataImporter, ReleaseDeleter<CXFA_DataImporter>> - importer(new CXFA_DataImporter(m_pDocument)); +FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { + std::unique_ptr<CXFA_DataImporter> importer( + new CXFA_DataImporter(m_pDocument)); return importer->ImportData(pStream); } diff --git a/xfa/fxfa/parser/xfa_document_serialize.h b/xfa/fxfa/parser/xfa_document_serialize.h index 6448953231..9136efce90 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.h +++ b/xfa/fxfa/parser/xfa_document_serialize.h @@ -19,7 +19,6 @@ class CXFA_DataImporter { public: explicit CXFA_DataImporter(CXFA_Document* pDocument); - void Release() { delete this; } FX_BOOL ImportData(IFX_FileRead* pDataDocument); protected: @@ -30,7 +29,6 @@ class CXFA_DataExporter { public: explicit CXFA_DataExporter(CXFA_Document* pDocument); - void Release() { delete this; } FX_BOOL Export(IFX_FileWrite* pWrite); FX_BOOL Export(IFX_FileWrite* pWrite, CXFA_Node* pNode, @@ -42,6 +40,7 @@ class CXFA_DataExporter { CXFA_Node* pNode, uint32_t dwFlag, const FX_CHAR* pChecksum); + CXFA_Document* const m_pDocument; }; |