From 76020fc9751e55661d1c01b6cd92dfcb1fd56e6a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 18 May 2017 15:51:20 -0700 Subject: Move CCodec_ModuleMgr ownership to CPDF_ModuleMgr. More straight forward than CFX_GEModule owning in and CPDF_ModuleMgr holding a pointer to it. Remove assumptions that the codec modules may return nullptr, and do IWYU. Change-Id: Iba7fc3c7ec223fd6d29a1ab74ed13d35689bc5d5 Reviewed-on: https://pdfium-review.googlesource.com/5654 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fxfa/parser/cxfa_localemgr.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_localemgr.cpp b/xfa/fxfa/parser/cxfa_localemgr.cpp index 0a691a6ceb..fbb12e2b48 100644 --- a/xfa/fxfa/parser/cxfa_localemgr.cpp +++ b/xfa/fxfa/parser/cxfa_localemgr.cpp @@ -11,9 +11,9 @@ #include #include +#include "core/fpdfapi/cpdf_modulemgr.h" #include "core/fxcodec/fx_codec.h" #include "core/fxcrt/xml/cxml_element.h" -#include "core/fxge/cfx_gemodule.h" #include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodelocale.h" @@ -1056,23 +1056,17 @@ static std::unique_ptr XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) { if (!pBuf || nBufLen <= 0) return nullptr; - CFX_GEModule* pGeModule = CFX_GEModule::Get(); - if (!pGeModule) - return nullptr; - - CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); - if (!pCodecMgr) - return nullptr; - std::unique_ptr pLocale; uint8_t* pOut = nullptr; uint32_t dwSize; + CCodec_ModuleMgr* pCodecMgr = CPDF_ModuleMgr::Get()->GetCodecModule(); pCodecMgr->GetFlateModule()->FlateOrLZWDecode(false, pBuf, nBufLen, true, 0, 0, 0, 0, 0, pOut, dwSize); - if (pOut) { - pLocale = CXML_Element::Parse(pOut, dwSize); - FX_Free(pOut); - } + if (!pOut) + return nullptr; + + std::unique_ptr pLocale = CXML_Element::Parse(pOut, dwSize); + FX_Free(pOut); return pLocale ? pdfium::MakeUnique(std::move(pLocale)) : nullptr; } -- cgit v1.2.3