2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 using com
.sun
.star
.frame
;
12 using com
.sun
.star
.lang
;
13 using com
.sun
.star
.uno
;
17 public static bool atWork
= false;
19 private static int Main()
23 // Connect to a new instance of the Office
24 XComponentContext context
= NativeBootstrap
.bootstrap();
25 Console
.WriteLine("Connected to a running office...");
27 // Get a reference to the Desktop service
28 XDesktop2 desktop
= Desktop
.create(context
);
30 // Create our termination request listener, and register it
31 TerminateListener listener
= new TerminateListener();
32 desktop
.addTerminateListener(listener
);
34 // Try to terminate while we are at work.
36 bool terminated
= desktop
.terminate();
37 Console
.WriteLine("The Office {0}", terminated
38 ? "has been terminated"
39 : "is still running, we are at work");
41 // Try to terminate when we are NOT at work.
43 terminated
= desktop
.terminate();
44 Console
.WriteLine("The Office {0}", terminated
45 ? "has been terminated"
46 : "is still running. Something else prevents termination, such as the quickstarter.");
52 Console
.Error
.WriteLine(ex
);