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 #ifndef INCLUDED_DESKTOP_INC_APP_HXX
21 #define INCLUDED_DESKTOP_INC_APP_HXX
22 
23 #include <boost/optional.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <sal/log.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/timer.hxx>
28 #include <unotools/bootstrap.hxx>
29 #include <unotools/resmgr.hxx>
30 #include <com/sun/star/frame/XDesktop2.hpp>
31 #include <com/sun/star/task/XStatusIndicator.hpp>
32 #include <com/sun/star/uno/Reference.h>
33 
34 #include <memory>
35 #include <thread>
36 
37 namespace com { namespace sun { namespace star { namespace uno {
38  class XComponentContext;
39 } } } }
40 
41 namespace desktop
42 {
43 
44 /*--------------------------------------------------------------------
45  Description: Application-class
46  --------------------------------------------------------------------*/
47 class CommandLineArgs;
48 class Lockfile;
49 struct ConvertData;
50 class Desktop : public Application
51 {
52  int doShutdown();
53 
54  public:
56  {
66  };
68  {
71  };
72 
73  Desktop();
74  virtual ~Desktop() override;
75  virtual int Main( ) override;
76  virtual void Init() override;
77  virtual void InitFinished() override;
78  virtual void DeInit() override;
79  virtual bool QueryExit() override;
80  virtual void Exception(ExceptionCategory nCategory) override;
81  virtual void OverrideSystemSettings( AllSettings& rSettings ) override;
82  virtual void AppEvent( const ApplicationEvent& rAppEvent ) override;
83 
84  DECL_LINK( OpenClients_Impl, void*, void );
85 
86  static void OpenClients();
87  static void OpenDefault();
88  static void CheckOpenCLCompute(const css::uno::Reference<css::frame::XDesktop2> &);
89 
90  DECL_STATIC_LINK( Desktop, EnableAcceptors_Impl, void*, void);
91 
92  static void HandleAppEvent( const ApplicationEvent& rAppEvent );
94 
95  static void HandleBootstrapErrors(
96  BootstrapError nError, OUString const & aMessage );
98  BootstrapError nError, OUString const & aMessage )
99  {
100  if ( m_aBootstrapError == BE_OK )
101  {
102  SAL_INFO("desktop.app", "SetBootstrapError: " << nError << " '" << aMessage << "'");
103  m_aBootstrapError = nError;
104  m_aBootstrapErrorMessage = aMessage;
105  }
106  }
107 
109  {
110  m_aBootstrapStatus = nStatus;
111  }
113  {
114  return m_aBootstrapStatus;
115  }
116 
117  // first-start (ever) related methods
118  static bool CheckExtensionDependencies();
119 
120  static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop* pDesktop = nullptr);
121  void SetSplashScreenText( const OUString& rText );
122  void SetSplashScreenProgress( sal_Int32 );
123 
124  // Bootstrap methods
125  static void InitApplicationServiceManager();
126  // throws an exception upon failure
127 
128  private:
129  void RegisterServices(
130  css::uno::Reference< css::uno::XComponentContext > const & context);
131  static void DeregisterServices();
132 
133  public:
134  static void CreateTemporaryDirectory();
135  static void RemoveTemporaryDirectory();
136 
137  private:
138  static bool InitializeConfiguration();
139  static void FlushConfiguration();
140  static bool InitializeQuickstartMode( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
141 
142  static void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const OUString& aMsg );
143 
144  // Create an error message depending on bootstrap failure code and an optional file url
145  static OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
146  const OUString& aFileURL );
147 
148  css::uno::Reference<css::task::XStatusIndicator> m_rSplashScreen;
149  void OpenSplashScreen();
150  void CloseSplashScreen();
151 
152  DECL_STATIC_LINK( Desktop, ImplInitFilterHdl, ::ConvertData&, bool );
153  DECL_STATIC_LINK( Desktop, AsyncInitFirstRun, Timer*, void );
158  void CheckFirstRun( );
159 
160  static void ShowBackingComponent(Desktop * progress);
161 
162  // on-demand acceptors
163  static void createAcceptor(const OUString& aDescription);
164  static void destroyAcceptor(const OUString& aDescription);
165 
171 
172  std::unique_ptr<Lockfile> m_xLockfile;
174  std::thread m_aUpdateThread;
175 };
176 
177 OUString GetURL_Impl(
178  const OUString& rName, boost::optional< OUString > const & cwdUrl );
179 
180 OUString ReplaceStringHookProc(const OUString& rStr);
181 
182 }
183 
184 #endif // INCLUDED_DESKTOP_INC_APP_HXX
185 
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void destroyAcceptor(const OUString &aDescription)
Definition: appinit.cxx:206
css::uno::Reference< css::task::XStatusIndicator > m_rSplashScreen
Definition: app.hxx:148
static bool InitializeConfiguration()
Definition: app.cxx:1759
void OpenSplashScreen()
Definition: app.cxx:2417
virtual void AppEvent(const ApplicationEvent &rAppEvent) override
Definition: app.cxx:1219
static void HandleBootstrapPathErrors(::utl::Bootstrap::Status, const OUString &aMsg)
Definition: app.cxx:627
void CheckFirstRun()
checks if the office is run the first time
Definition: app.cxx:2559
static void CreateTemporaryDirectory()
Definition: appinit.cxx:233
DECL_STATIC_LINK(Desktop, EnableAcceptors_Impl, void *, void)
virtual void DeInit() override
Definition: app.cxx:558
OUString ReplaceStringHookProc(const OUString &rStr)
Definition: app.cxx:398
std::unique_ptr< Lockfile > m_xLockfile
Definition: app.hxx:172
void SetBootstrapStatus(BootstrapStatus nStatus)
Definition: app.hxx:108
static OUString CreateErrorMsgString(utl::Bootstrap::FailureCode nFailureCode, const OUString &aFileURL)
Definition: app.cxx:653
int doShutdown()
Definition: app.cxx:1660
Definition: app.cxx:168
void SetSplashScreenProgress(sal_Int32)
Definition: app.cxx:2469
BootstrapError m_aBootstrapError
Definition: app.hxx:168
static void ShowBackingComponent(Desktop *progress)
Definition: app.cxx:2510
virtual void OverrideSystemSettings(AllSettings &rSettings) override
Definition: app.cxx:1868
static void FlushConfiguration()
Definition: app.cxx:1825
BootstrapStatus m_aBootstrapStatus
Definition: app.hxx:170
static void InitApplicationServiceManager()
Definition: appinit.cxx:75
ExceptionCategory
virtual ~Desktop() override
Definition: app.cxx:450
virtual void Init() override
Definition: app.cxx:454
static void DeregisterServices()
Definition: appinit.cxx:227
void RegisterServices(css::uno::Reference< css::uno::XComponentContext > const &context)
Definition: appinit.cxx:98
Timer m_firstRunTimer
Definition: app.hxx:173
static void RemoveTemporaryDirectory()
Definition: appinit.cxx:268
static void HandleBootstrapErrors(BootstrapError nError, OUString const &aMessage)
Definition: app.cxx:744
void SetBootstrapError(BootstrapError nError, OUString const &aMessage)
Definition: app.hxx:97
bool m_bCleanedExtensionCache
Definition: app.hxx:166
static CommandLineArgs & GetCommandLineArgs()
Definition: app.cxx:387
void SetSplashScreenText(const OUString &rText)
Definition: app.cxx:2477
static void OpenDefault()
Definition: app.cxx:2169
static void createAcceptor(const OUString &aDescription)
Definition: appinit.cxx:141
OUString m_aBootstrapErrorMessage
Definition: app.hxx:169
bool m_bServicesRegistered
Definition: app.hxx:167
std::thread m_aUpdateThread
Definition: app.hxx:174
static void HandleAppEvent(const ApplicationEvent &rAppEvent)
Definition: app.cxx:2275
static void CheckOpenCLCompute(const css::uno::Reference< css::frame::XDesktop2 > &)
static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop *pDesktop=nullptr)
#define SAL_INFO(area, stream)
virtual void InitFinished() override
Definition: app.cxx:553
static bool InitializeQuickstartMode(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: app.cxx:1833
DECL_LINK(OpenClients_Impl, void *, void)
virtual void Exception(ExceptionCategory nCategory) override
Definition: app.cxx:1148
static void OpenClients()
Definition: app.cxx:1954
virtual int Main() override
Definition: app.cxx:1240
virtual bool QueryExit() override
Definition: app.cxx:585
void CloseSplashScreen()
Definition: app.cxx:2485
static bool CheckExtensionDependencies()
BootstrapStatus GetBootstrapStatus() const
Definition: app.hxx:112
OUString GetURL_Impl(const OUString &rName, boost::optional< OUString > const &cwdUrl)
Definition: app.cxx:2226