bump product version to 7.2.5.1
[LibreOffice.git] / desktop / inc / app.hxx
blobe2ecf5920aa082322d47a0b1a2b395435690c675
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <optional>
23 #include <sal/log.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/timer.hxx>
26 #include <unotools/bootstrap.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>
31 #include <memory>
32 #include <string_view>
33 #include <thread>
35 namespace com::sun::star::uno { class XComponentContext; }
37 namespace desktop
40 /*--------------------------------------------------------------------
41 Description: Application-class
42 --------------------------------------------------------------------*/
43 class CommandLineArgs;
44 class Lockfile;
45 struct ConvertData;
46 class Desktop final : public Application
48 int doShutdown();
50 public:
51 enum BootstrapError
53 BE_OK,
54 BE_UNO_SERVICEMANAGER,
55 BE_UNO_SERVICE_CONFIG_MISSING,
56 BE_PATHINFO_MISSING,
57 BE_USERINSTALL_FAILED,
58 BE_LANGUAGE_MISSING,
59 BE_USERINSTALL_NOTENOUGHDISKSPACE,
60 BE_USERINSTALL_NOWRITEACCESS,
61 BE_OFFICECONFIG_BROKEN
63 enum BootstrapStatus
65 BS_OK,
66 BS_TERMINATE
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;
81 DECL_LINK( OpenClients_Impl, void*, void );
83 static void OpenClients();
84 static void OpenDefault();
85 static void CheckOpenCLCompute(const css::uno::Reference<css::frame::XDesktop2> &);
87 DECL_STATIC_LINK( Desktop, EnableAcceptors_Impl, void*, void);
89 static void HandleAppEvent( const ApplicationEvent& rAppEvent );
90 static CommandLineArgs& GetCommandLineArgs();
92 static void HandleBootstrapErrors(
93 BootstrapError nError, OUString const & aMessage );
94 void SetBootstrapError(
95 BootstrapError nError, OUString const & aMessage )
97 if ( m_aBootstrapError == BE_OK )
99 SAL_INFO("desktop.app", "SetBootstrapError: " << nError << " '" << aMessage << "'");
100 m_aBootstrapError = nError;
101 m_aBootstrapErrorMessage = aMessage;
105 void SetBootstrapStatus( BootstrapStatus nStatus )
107 m_aBootstrapStatus = nStatus;
109 BootstrapStatus GetBootstrapStatus() const
111 return m_aBootstrapStatus;
114 // first-start (ever) related methods
115 static bool CheckExtensionDependencies();
117 static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop* pDesktop = nullptr);
118 void SetSplashScreenText( const OUString& rText );
119 void SetSplashScreenProgress( sal_Int32 );
121 // Bootstrap methods
122 static void InitApplicationServiceManager();
123 // throws an exception upon failure
125 private:
126 void RegisterServices(
127 css::uno::Reference< css::uno::XComponentContext > const & context);
128 static void DeregisterServices();
130 public:
131 static void CreateTemporaryDirectory();
132 static void RemoveTemporaryDirectory();
134 private:
135 static bool InitializeConfiguration();
136 static void FlushConfiguration();
137 static bool InitializeQuickstartMode( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
139 static void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, std::u16string_view aMsg );
141 // Create an error message depending on bootstrap failure code and an optional file url
142 static OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
143 const OUString& aFileURL );
145 css::uno::Reference<css::task::XStatusIndicator> m_rSplashScreen;
146 void OpenSplashScreen();
147 void CloseSplashScreen();
149 DECL_STATIC_LINK( Desktop, ImplInitFilterHdl, ::ConvertData&, bool );
150 DECL_STATIC_LINK( Desktop, AsyncInitFirstRun, Timer*, void );
151 /** checks if the office is run the first time
152 <p>If so, <method>DoFirstRunInitializations</method> is called (asynchronously and delayed) and the
153 respective flag in the configuration is reset.</p>
155 void CheckFirstRun( );
157 static void ShowBackingComponent(Desktop * progress);
159 // on-demand acceptors
160 static void createAcceptor(const OUString& aDescription);
161 static void destroyAcceptor(const OUString& aDescription);
163 bool m_bCleanedExtensionCache;
164 bool m_bServicesRegistered;
165 BootstrapError m_aBootstrapError;
166 OUString m_aBootstrapErrorMessage;
167 BootstrapStatus m_aBootstrapStatus;
169 std::unique_ptr<Lockfile> m_xLockfile;
170 Timer m_firstRunTimer;
171 std::thread m_aUpdateThread;
174 OUString GetURL_Impl(
175 const OUString& rName, std::optional< OUString > const & cwdUrl );
177 OUString ReplaceStringHookProc(const OUString& rStr);
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */