summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp2
-rw-r--r--xfa/fxfa/app/xfa_ffdoc.cpp26
-rw-r--r--xfa/fxfa/fxfa.h3
-rw-r--r--xfa/fxfa/xfa_ffdoc.h4
4 files changed, 14 insertions, 21 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index aaa0e9849b..653e086e16 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -119,7 +119,7 @@ bool CPDFXFA_Context::LoadXFADoc() {
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 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<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::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);
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index 8a268269e0..cfe5618e6e 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -39,9 +39,6 @@ class IXFA_WidgetIterator;
#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 44079704e7..af2bf2c796 100644
--- a/xfa/fxfa/xfa_ffdoc.h
+++ b/xfa/fxfa/xfa_ffdoc.h
@@ -38,7 +38,7 @@ class CXFA_FFDoc {
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 @@ class CXFA_FFDoc {
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;
};