1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "xfa/fxfa/cxfa_ffapp.h" 8 9 #include <algorithm> 10 #include <memory> 11 #include <utility> 12 #include <vector> 13 14 #include "third_party/base/ptr_util.h" 15 #include "third_party/base/stl_util.h" 16 #include "xfa/fgas/font/cfgas_fontmgr.h" 17 #include "xfa/fwl/cfwl_notedriver.h" 18 #include "xfa/fwl/cfwl_widgetmgr.h" 19 #include "xfa/fxfa/cxfa_ffdoc.h" 20 #include "xfa/fxfa/cxfa_ffwidgethandler.h" 21 #include "xfa/fxfa/cxfa_fontmgr.h" 22 #include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h" 23 #include "xfa/fxfa/cxfa_fwltheme.h" 24 CXFA_FFApp(IXFA_AppProvider * pProvider)25CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) : m_pProvider(pProvider) { 26 // Ensure fully initialized before making an app based on |this|. 27 m_pFWLApp = pdfium::MakeUnique<CFWL_App>(this); 28 } 29 ~CXFA_FFApp()30CXFA_FFApp::~CXFA_FFApp() {} 31 CreateDoc(IXFA_DocEnvironment * pDocEnvironment,CPDF_Document * pPDFDoc)32std::unique_ptr<CXFA_FFDoc> CXFA_FFApp::CreateDoc( 33 IXFA_DocEnvironment* pDocEnvironment, 34 CPDF_Document* pPDFDoc) { 35 if (!pPDFDoc) 36 return nullptr; 37 38 auto pDoc = pdfium::MakeUnique<CXFA_FFDoc>(this, pDocEnvironment); 39 if (!pDoc->OpenDoc(pPDFDoc)) 40 return nullptr; 41 42 return pDoc; 43 } 44 SetDefaultFontMgr(std::unique_ptr<CFGAS_DefaultFontManager> pFontMgr)45void CXFA_FFApp::SetDefaultFontMgr( 46 std::unique_ptr<CFGAS_DefaultFontManager> pFontMgr) { 47 if (!m_pFontMgr) 48 m_pFontMgr = pdfium::MakeUnique<CXFA_FontMgr>(); 49 m_pFontMgr->SetDefFontMgr(std::move(pFontMgr)); 50 } 51 GetXFAFontMgr() const52CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() const { 53 return m_pFontMgr.get(); 54 } 55 GetFDEFontMgr()56CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() { 57 if (!m_pFDEFontMgr) { 58 m_pFDEFontMgr = pdfium::MakeUnique<CFGAS_FontMgr>(); 59 if (!m_pFDEFontMgr->EnumFonts()) 60 m_pFDEFontMgr = nullptr; 61 } 62 return m_pFDEFontMgr.get(); 63 } 64 GetFWLTheme()65CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() { 66 if (!m_pFWLTheme) 67 m_pFWLTheme = pdfium::MakeUnique<CXFA_FWLTheme>(this); 68 return m_pFWLTheme.get(); 69 } 70 GetFWLAdapterWidgetMgr()71CXFA_FWLAdapterWidgetMgr* CXFA_FFApp::GetFWLAdapterWidgetMgr() { 72 if (!m_pAdapterWidgetMgr) 73 m_pAdapterWidgetMgr = pdfium::MakeUnique<CXFA_FWLAdapterWidgetMgr>(); 74 return m_pAdapterWidgetMgr.get(); 75 } 76 GetTimerMgr() const77IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() const { 78 return m_pProvider->GetTimerMgr(); 79 } 80 ClearEventTargets()81void CXFA_FFApp::ClearEventTargets() { 82 m_pFWLApp->GetNoteDriver()->ClearEventTargets(); 83 } 84