From 3d06022ce5e7467c2ee12da97a2492b5be23885e Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 22 Mar 2017 15:29:20 -0400 Subject: Remove unused docview flag When creating the XFA doc view we always pass the same docview flag (0). So, the map will only ever have one item in it. This Cl simplifies the code by removing the map and just dealing with a single doc view. Change-Id: If17e2cda4c3f6c1f45dec921844f09538cc890fc Reviewed-on: https://pdfium-review.googlesource.com/3149 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- xfa/fxfa/app/xfa_ffdoc.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'xfa/fxfa/app/xfa_ffdoc.cpp') diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index b6dba7f71a..22450a74fe 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -270,30 +270,27 @@ void CXFA_FFDoc::StopLoad() { } } -CXFA_FFDocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) { - if (!m_TypeToDocViewMap[dwView]) - m_TypeToDocViewMap[dwView] = pdfium::MakeUnique(this); +CXFA_FFDocView* CXFA_FFDoc::CreateDocView() { + if (!m_DocView) + m_DocView = pdfium::MakeUnique(this); - return m_TypeToDocViewMap[dwView].get(); + return m_DocView.get(); } CXFA_FFDocView* CXFA_FFDoc::GetDocView(CXFA_LayoutProcessor* pLayout) { - for (const auto& pair : m_TypeToDocViewMap) { - if (pair.second->GetXFALayout() == pLayout) - return pair.second.get(); - } - return nullptr; + return m_DocView && m_DocView->GetXFALayout() == pLayout ? m_DocView.get() + : nullptr; } CXFA_FFDocView* CXFA_FFDoc::GetDocView() { - auto it = m_TypeToDocViewMap.begin(); - return it != m_TypeToDocViewMap.end() ? it->second.get() : nullptr; + return m_DocView.get(); } bool CXFA_FFDoc::OpenDoc(const CFX_RetainPtr& pStream) { m_pStream = pStream; return true; } + bool CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { if (!pPDFDoc) return false; @@ -329,16 +326,15 @@ bool CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { } bool CXFA_FFDoc::CloseDoc() { - for (const auto& pair : m_TypeToDocViewMap) - pair.second->RunDocClose(); + if (m_DocView) + m_DocView->RunDocClose(); CXFA_Document* doc = m_pDocumentParser ? m_pDocumentParser->GetDocument() : nullptr; if (doc) doc->ClearLayoutData(); - m_TypeToDocViewMap.clear(); - + m_DocView.reset(); m_pNotify.reset(nullptr); m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this); -- cgit v1.2.3