LibreOffice Module desktop (master) 1
app.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <optional>
23#include <sal/log.hxx>
24#include <vcl/svapp.hxx>
25#include <vcl/timer.hxx>
27#include <com/sun/star/frame/XDesktop2.hpp>
28#include <com/sun/star/task/XStatusIndicator.hpp>
29#include <com/sun/star/uno/Reference.h>
30
31#include <memory>
32#include <string_view>
33#include <thread>
34
35namespace com::sun::star::uno { class XComponentContext; }
36
37namespace desktop
38{
39
40/*--------------------------------------------------------------------
41 Description: Application-class
42 --------------------------------------------------------------------*/
43class CommandLineArgs;
44class Lockfile;
45struct ConvertData;
46class Desktop final : public Application
47{
48 int doShutdown();
49
50 public:
52 {
62 };
64 {
67 };
68
69 Desktop();
70 virtual ~Desktop() override;
71 virtual int Main( ) override;
72 virtual void Init() override;
73 virtual void InitFinished() override;
74 virtual void DeInit() override;
75 virtual bool QueryExit() override;
76 virtual void Shutdown() override;
77 virtual void Exception(ExceptionCategory nCategory) override;
78 virtual void OverrideSystemSettings( AllSettings& rSettings ) override;
79 virtual void AppEvent( const ApplicationEvent& rAppEvent ) override;
80
81 DECL_LINK( OpenClients_Impl, void*, void );
82
83 static void OpenClients();
84 static void OpenDefault();
85 static void CheckOpenCLCompute(const css::uno::Reference<css::frame::XDesktop2> &);
86
87 DECL_STATIC_LINK( Desktop, EnableAcceptors_Impl, void*, void);
88
89 static void HandleAppEvent( const ApplicationEvent& rAppEvent );
91
92 static void HandleBootstrapErrors(
93 BootstrapError nError, OUString const & aMessage );
95 BootstrapError nError, OUString const & aMessage )
96 {
97 if ( m_aBootstrapError == BE_OK )
98 {
99 SAL_INFO("desktop.app", "SetBootstrapError: " << nError << " '" << aMessage << "'");
100 m_aBootstrapError = nError;
101 m_aBootstrapErrorMessage = aMessage;
102 }
103 }
104
106 {
107 m_aBootstrapStatus = nStatus;
108 }
110 {
111 return m_aBootstrapStatus;
112 }
113
114 // first-start (ever) related methods
115 static bool CheckExtensionDependencies();
116
117 static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop* pDesktop = nullptr);
118 void SetSplashScreenText( const OUString& rText );
119 void SetSplashScreenProgress( sal_Int32 );
120
121 // Bootstrap methods
122 static void InitApplicationServiceManager();
123 // throws an exception upon failure
124
125 private:
126 void RegisterServices();
127 static void DeregisterServices();
128
129 public:
130 static void CreateTemporaryDirectory();
131 static void RemoveTemporaryDirectory();
132
133 private:
134 static bool InitializeConfiguration();
135 static void FlushConfiguration();
136 static bool InitializeQuickstartMode( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
137
138 static void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, std::u16string_view aMsg );
139
140 // Create an error message depending on bootstrap failure code and an optional file url
141 static OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
142 const OUString& aFileURL );
143
144 css::uno::Reference<css::task::XStatusIndicator> m_rSplashScreen;
145 void OpenSplashScreen();
146 void CloseSplashScreen();
147
148 DECL_STATIC_LINK( Desktop, ImplInitFilterHdl, ::ConvertData&, bool );
149 DECL_STATIC_LINK( Desktop, AsyncInitFirstRun, Timer*, void );
154 void CheckFirstRun( );
155
156 static void ShowBackingComponent(Desktop * progress);
157
158 // on-demand acceptors
159 static void createAcceptor(const OUString& aDescription);
160 static void destroyAcceptor(const OUString& aDescription);
161
167
168 std::unique_ptr<Lockfile> m_xLockfile;
170 std::thread m_aUpdateThread;
171};
172
173OUString GetURL_Impl(
174 const OUString& rName, std::optional< OUString > const & cwdUrl );
175
176OUString ReplaceStringHookProc(const OUString& rStr);
177
178}
179
180/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DECL_STATIC_LINK(Desktop, AsyncInitFirstRun, Timer *, void)
DECL_STATIC_LINK(Desktop, EnableAcceptors_Impl, void *, void)
static bool CheckExtensionDependencies()
static void RemoveTemporaryDirectory()
Definition: appinit.cxx:265
static void DeregisterServices()
Definition: appinit.cxx:224
static void destroyAcceptor(const OUString &aDescription)
Definition: appinit.cxx:203
static void CheckOpenCLCompute(const css::uno::Reference< css::frame::XDesktop2 > &)
BootstrapError m_aBootstrapError
Definition: app.hxx:164
static void FlushConfiguration()
Definition: app.cxx:1798
static void InitApplicationServiceManager()
Definition: appinit.cxx:64
static bool InitializeQuickstartMode(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: app.cxx:1806
BootstrapStatus GetBootstrapStatus() const
Definition: app.hxx:109
virtual void InitFinished() override
Definition: app.cxx:535
DECL_LINK(OpenClients_Impl, void *, void)
virtual bool QueryExit() override
Definition: app.cxx:568
OUString m_aBootstrapErrorMessage
Definition: app.hxx:165
css::uno::Reference< css::task::XStatusIndicator > m_rSplashScreen
Definition: app.hxx:144
void CloseSplashScreen()
Definition: app.cxx:2480
static void createAcceptor(const OUString &aDescription)
Definition: appinit.cxx:138
virtual void OverrideSystemSettings(AllSettings &rSettings) override
Definition: app.cxx:1841
bool m_bCleanedExtensionCache
Definition: app.hxx:162
bool m_bServicesRegistered
Definition: app.hxx:163
void RegisterServices()
Definition: appinit.cxx:87
static void HandleAppEvent(const ApplicationEvent &rAppEvent)
Definition: app.cxx:2259
Timer m_firstRunTimer
Definition: app.hxx:169
@ BE_OFFICECONFIG_BROKEN
Definition: app.hxx:61
@ BE_PATHINFO_MISSING
Definition: app.hxx:56
@ BE_USERINSTALL_FAILED
Definition: app.hxx:57
@ BE_USERINSTALL_NOWRITEACCESS
Definition: app.hxx:60
@ BE_UNO_SERVICE_CONFIG_MISSING
Definition: app.hxx:55
@ BE_USERINSTALL_NOTENOUGHDISKSPACE
Definition: app.hxx:59
@ BE_LANGUAGE_MISSING
Definition: app.hxx:58
@ BE_UNO_SERVICEMANAGER
Definition: app.hxx:54
static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop *pDesktop=nullptr)
static void OpenDefault()
Definition: app.cxx:2153
static void OpenClients()
Definition: app.cxx:1937
virtual void AppEvent(const ApplicationEvent &rAppEvent) override
Definition: app.cxx:1187
void CheckFirstRun()
checks if the office is run the first time
Definition: app.cxx:2556
void OpenSplashScreen()
Definition: app.cxx:2405
void SetBootstrapError(BootstrapError nError, OUString const &aMessage)
Definition: app.hxx:94
static CommandLineArgs & GetCommandLineArgs()
Definition: app.cxx:389
DECL_STATIC_LINK(Desktop, ImplInitFilterHdl, ::ConvertData &, bool)
static void HandleBootstrapErrors(BootstrapError nError, OUString const &aMessage)
Definition: app.cxx:732
static void CreateTemporaryDirectory()
Definition: appinit.cxx:230
static OUString CreateErrorMsgString(utl::Bootstrap::FailureCode nFailureCode, const OUString &aFileURL)
Definition: app.cxx:641
virtual void Init() override
Definition: app.cxx:439
BootstrapStatus m_aBootstrapStatus
Definition: app.hxx:166
static bool InitializeConfiguration()
Definition: app.cxx:1732
void SetSplashScreenText(const OUString &rText)
Definition: app.cxx:2468
virtual void Exception(ExceptionCategory nCategory) override
Definition: app.cxx:1122
virtual ~Desktop() override
Definition: app.cxx:435
std::thread m_aUpdateThread
Definition: app.hxx:170
static void ShowBackingComponent(Desktop *progress)
Definition: app.cxx:2507
std::unique_ptr< Lockfile > m_xLockfile
Definition: app.hxx:168
void SetSplashScreenProgress(sal_Int32)
Definition: app.cxx:2456
virtual void DeInit() override
Definition: app.cxx:540
int doShutdown()
Definition: app.cxx:1617
virtual int Main() override
Definition: app.cxx:1243
static void HandleBootstrapPathErrors(::utl::Bootstrap::Status, std::u16string_view aMsg)
Definition: app.cxx:615
virtual void Shutdown() override
Definition: app.cxx:610
void SetBootstrapStatus(BootstrapStatus nStatus)
Definition: app.hxx:105
ExceptionCategory
#define SAL_INFO(area, stream)
Definition: app.cxx:165
OUString GetURL_Impl(const OUString &rName, std::optional< OUString > const &cwdUrl)
Definition: app.cxx:2210
OUString ReplaceStringHookProc(const OUString &rStr)
Definition: app.cxx:395