blob: 7a79f7db08352618910675d7e46a515748f29634 [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2014 The PDFium Authors
Dan Sinclair1770c022016-03-14 14:14:16 -04002// 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
Dan Sinclair80c48782017-03-23 12:11:20 -04007#include "xfa/fxfa/cxfa_ffapp.h"
Dan Sinclair1770c022016-03-14 14:14:16 -04008
dsinclair447b1f32016-12-08 10:06:32 -08009#include "xfa/fwl/cfwl_notedriver.h"
10#include "xfa/fwl/cfwl_widgetmgr.h"
Dan Sinclair80c48782017-03-23 12:11:20 -040011#include "xfa/fxfa/cxfa_ffdoc.h"
Dan Sinclair80c48782017-03-23 12:11:20 -040012#include "xfa/fxfa/cxfa_ffwidgethandler.h"
13#include "xfa/fxfa/cxfa_fontmgr.h"
Dan Sinclair24ef6332017-07-24 10:52:57 -040014#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
15#include "xfa/fxfa/cxfa_fwltheme.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040016
Tom Sepezdc3718f2021-06-09 01:01:29 +000017CXFA_FFApp::CXFA_FFApp(CallbackIface* pProvider) : m_pProvider(pProvider) {
Tom Sepez0a9d9742020-09-01 21:40:52 +000018 // Ensure fully initialized before making objects based on |this|.
Tom Sepeza7edf062020-09-09 22:48:17 +000019 m_pXFAFontMgr = cppgc::MakeGarbageCollected<CXFA_FontMgr>(
20 GetHeap()->GetAllocationHandle());
Tom Sepez0a9d9742020-09-01 21:40:52 +000021 m_pFWLApp = cppgc::MakeGarbageCollected<CFWL_App>(
22 GetHeap()->GetAllocationHandle(), this);
Tom Sepezcc205132017-05-16 14:01:47 -070023}
tsepez0aae2a72016-05-18 14:01:15 -070024
Lei Zhang0e744a22020-06-02 00:44:28 +000025CXFA_FFApp::~CXFA_FFApp() = default;
dsinclair221caf62016-04-04 12:08:40 -070026
Tom Sepez0a9d9742020-09-01 21:40:52 +000027void CXFA_FFApp::Trace(cppgc::Visitor* visitor) const {
Tom Sepeza7edf062020-09-09 22:48:17 +000028 visitor->Trace(m_pXFAFontMgr);
Tom Sepez0a9d9742020-09-01 21:40:52 +000029 visitor->Trace(m_pAdapterWidgetMgr);
30 visitor->Trace(m_pFWLTheme);
31 visitor->Trace(m_pFWLApp);
32}
33
Tom Sepeza9116722020-08-13 22:18:18 +000034bool CXFA_FFApp::LoadFWLTheme(CXFA_FFDoc* doc) {
Tom Sepez0a9d9742020-09-01 21:40:52 +000035 auto* fwl_theme = cppgc::MakeGarbageCollected<CXFA_FWLTheme>(
Tom Sepez53f083a72020-10-12 23:33:27 +000036 GetHeap()->GetAllocationHandle(), GetHeap(), this);
Tom Sepeza9116722020-08-13 22:18:18 +000037 if (!fwl_theme->LoadCalendarFont(doc))
38 return false;
39
Tom Sepez0a9d9742020-09-01 21:40:52 +000040 m_pFWLTheme = fwl_theme;
Tom Sepeza9116722020-08-13 22:18:18 +000041 return true;
Dan Sinclair1770c022016-03-14 14:14:16 -040042}
weilib4d1b572016-08-10 14:50:48 -070043
Tom Sepez12899532019-05-30 00:06:33 +000044CFWL_WidgetMgr::AdapterIface* CXFA_FFApp::GetWidgetMgrAdapter() {
Tom Sepez0a9d9742020-09-01 21:40:52 +000045 if (!m_pAdapterWidgetMgr) {
46 m_pAdapterWidgetMgr = cppgc::MakeGarbageCollected<CXFA_FWLAdapterWidgetMgr>(
47 GetHeap()->GetAllocationHandle());
48 }
49 return m_pAdapterWidgetMgr;
Dan Sinclair1770c022016-03-14 14:14:16 -040050}
weilib4d1b572016-08-10 14:50:48 -070051
Tom Sepez8a5699d2020-10-13 21:23:53 +000052CFX_Timer::HandlerIface* CXFA_FFApp::GetTimerHandler() {
Tom Sepez3e5e563e2019-08-12 17:54:25 +000053 return m_pProvider->GetTimerHandler();
Dan Sinclair1770c022016-03-14 14:14:16 -040054}
Tom Sepeza9116722020-08-13 22:18:18 +000055
56IFWL_ThemeProvider* CXFA_FFApp::GetThemeProvider() {
Tom Sepez0a9d9742020-09-01 21:40:52 +000057 return m_pFWLTheme;
Tom Sepeza9116722020-08-13 22:18:18 +000058}
Tom Sepez66028762020-08-18 20:35:37 +000059
60cppgc::Heap* CXFA_FFApp::GetHeap() {
61 return m_pProvider->GetGCHeap();
62}