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 <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index aaa0e98..653e086 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -119,7 +119,7 @@
else
m_iDocType = DOCTYPE_STATIC_XFA;
- m_pXFADocView = m_pXFADoc->CreateDocView(XFA_DOCVIEW_View);
+ m_pXFADocView = m_pXFADoc->CreateDocView();
if (m_pXFADocView->StartLayout() < 0) {
CloseXFADoc();
SetLastError(FPDF_ERR_XFALAYOUT);
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp
index b6dba7f..22450a7 100644
--- a/xfa/fxfa/app/xfa_ffdoc.cpp
+++ b/xfa/fxfa/app/xfa_ffdoc.cpp
@@ -270,30 +270,27 @@
}
}
-CXFA_FFDocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) {
- if (!m_TypeToDocViewMap[dwView])
- m_TypeToDocViewMap[dwView] = pdfium::MakeUnique<CXFA_FFDocView>(this);
+CXFA_FFDocView* CXFA_FFDoc::CreateDocView() {
+ if (!m_DocView)
+ m_DocView = pdfium::MakeUnique<CXFA_FFDocView>(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<IFX_SeekableReadStream>& pStream) {
m_pStream = pStream;
return true;
}
+
bool CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) {
if (!pPDFDoc)
return false;
@@ -329,16 +326,15 @@
}
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);
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index 8a26826..cfe5618 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -39,9 +39,6 @@
#define XFA_IDNo 3
#define XFA_IDYes 4
-#define XFA_DOCVIEW_View 0x00000000
-#define XFA_DOCVIEW_MasterPage 0x00000001
-#define XFA_DOCVIEW_Design 0x00000002
#define XFA_DOCTYPE_Dynamic 0
#define XFA_DOCTYPE_Static 1
#define XFA_DOCTYPE_XDP 2
diff --git a/xfa/fxfa/xfa_ffdoc.h b/xfa/fxfa/xfa_ffdoc.h
index 4407970..af2bf2c 100644
--- a/xfa/fxfa/xfa_ffdoc.h
+++ b/xfa/fxfa/xfa_ffdoc.h
@@ -38,7 +38,7 @@
int32_t DoLoad(IFX_Pause* pPause = nullptr);
void StopLoad();
- CXFA_FFDocView* CreateDocView(uint32_t dwView = 0);
+ CXFA_FFDocView* CreateDocView();
bool OpenDoc(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream);
bool OpenDoc(CPDF_Document* pPDFDoc);
@@ -67,7 +67,7 @@
std::unique_ptr<CXFA_FFNotify> m_pNotify;
CPDF_Document* m_pPDFDoc;
std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap;
- std::map<uint32_t, std::unique_ptr<CXFA_FFDocView>> m_TypeToDocViewMap;
+ std::unique_ptr<CXFA_FFDocView> m_DocView;
uint32_t m_dwDocType;
};