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 "xfa/fgas/font/cfgas_fontmgr.h" 16 #include "xfa/fwl/cfwl_notedriver.h" 17 #include "xfa/fwl/cfwl_widgetmgr.h" 18 #include "xfa/fxfa/cxfa_ffdoc.h" 19 #include "xfa/fxfa/cxfa_ffwidgethandler.h" 20 #include "xfa/fxfa/cxfa_fontmgr.h" 21 #include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h" 22 #include "xfa/fxfa/cxfa_fwltheme.h" 23 24 namespace { 25 26 bool g_skipFontLoadForTesting = false; 27 28 } // namespace 29 30 // static SkipFontLoadForTesting(bool skip)31void CXFA_FFApp::SkipFontLoadForTesting(bool skip) { 32 g_skipFontLoadForTesting = skip; 33 } 34 CXFA_FFApp(IXFA_AppProvider * pProvider)35CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) : m_pProvider(pProvider) { 36 // Ensure fully initialized before making an app based on |this|. 37 m_pFWLApp = pdfium::MakeUnique<CFWL_App>(this); 38 } 39 ~CXFA_FFApp()40CXFA_FFApp::~CXFA_FFApp() {} 41 GetFDEFontMgr()42CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() { 43 if (!m_pFDEFontMgr) { 44 m_pFDEFontMgr = pdfium::MakeUnique<CFGAS_FontMgr>(); 45 if (!g_skipFontLoadForTesting) { 46 if (!m_pFDEFontMgr->EnumFonts()) 47 m_pFDEFontMgr = nullptr; 48 } 49 } 50 return m_pFDEFontMgr.get(); 51 } 52 GetFWLTheme(CXFA_FFDoc * doc)53CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme(CXFA_FFDoc* doc) { 54 if (!m_pFWLTheme) { 55 auto fwl_theme = pdfium::MakeUnique<CXFA_FWLTheme>(this); 56 if (fwl_theme->LoadCalendarFont(doc)) 57 m_pFWLTheme = std::move(fwl_theme); 58 } 59 return m_pFWLTheme.get(); 60 } 61 GetWidgetMgrAdapter()62CFWL_WidgetMgr::AdapterIface* CXFA_FFApp::GetWidgetMgrAdapter() { 63 if (!m_pAdapterWidgetMgr) 64 m_pAdapterWidgetMgr = pdfium::MakeUnique<CXFA_FWLAdapterWidgetMgr>(); 65 return m_pAdapterWidgetMgr.get(); 66 } 67 GetTimerHandler()68TimerHandlerIface* CXFA_FFApp::GetTimerHandler() { 69 return m_pProvider->GetTimerHandler(); 70 } 71 ClearEventTargets()72void CXFA_FFApp::ClearEventTargets() { 73 m_pFWLApp->GetNoteDriver()->ClearEventTargets(); 74 } 75