Line data Source code
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 : #include <stdio.h>
21 : #include <unistd.h>
22 :
23 : #include "vcl/svapp.hxx"
24 : #include "vcl/vclmain.hxx"
25 : #include "vcl/wrkwin.hxx"
26 : #include "vcl/unowrap.hxx"
27 :
28 : #include "padialog.hxx"
29 : #include "helper.hxx"
30 : #include "desktopcontext.hxx"
31 :
32 : #include "cppuhelper/bootstrap.hxx"
33 : #include "comphelper/processfactory.hxx"
34 : #include "unotools/configmgr.hxx"
35 :
36 : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
37 : #include "com/sun/star/lang/XComponent.hpp"
38 : #include "com/sun/star/ucb/UniversalContentBroker.hpp"
39 :
40 : using namespace padmin;
41 : using namespace cppu;
42 : using namespace com::sun::star::uno;
43 : using namespace com::sun::star::lang;
44 : using namespace comphelper;
45 :
46 : using ::rtl::OUString;
47 :
48 0 : class MyApp : public Application
49 : {
50 : public:
51 : int Main();
52 : virtual sal_uInt16 Exception( sal_uInt16 nError );
53 :
54 : static rtl::OUString ReadStringHook( const rtl::OUString& );
55 : };
56 :
57 0 : void vclmain::createApplication()
58 : {
59 0 : static MyApp aMyApp;
60 0 : }
61 :
62 0 : rtl::OUString MyApp::ReadStringHook( const rtl::OUString& rStr )
63 : {
64 : return rStr.replaceAll(
65 0 : rtl::OUString("%PRODUCTNAME"), utl::ConfigManager::getProductName() );
66 : };
67 :
68 :
69 : // -----------------------------------------------------------------------
70 :
71 0 : sal_uInt16 MyApp::Exception( sal_uInt16 nError )
72 : {
73 0 : switch( nError & EXC_MAJORTYPE )
74 : {
75 : case EXC_RSCNOTLOADED:
76 0 : Abort( rtl::OUString( "Error: could not load language resources.\nPlease check your installation.\n" ) );
77 0 : break;
78 : }
79 0 : return 0;
80 : }
81 :
82 0 : int MyApp::Main()
83 : {
84 : PADialog* pPADialog;
85 :
86 0 : EnableAutoHelpId();
87 :
88 : //-------------------------------------------------
89 : // create the global service-manager
90 : //-------------------------------------------------
91 0 : Reference< XComponentContext > xCtx;
92 0 : Reference< XMultiServiceFactory > xFactory;
93 : try
94 : {
95 0 : xCtx = defaultBootstrap_InitialComponentContext();
96 0 : xFactory = Reference< XMultiServiceFactory >( xCtx->getServiceManager(), UNO_QUERY );
97 0 : if( xFactory.is() )
98 0 : setProcessServiceFactory( xFactory );
99 : }
100 0 : catch( const com::sun::star::uno::Exception& )
101 : {
102 : }
103 :
104 0 : if( ! xFactory.is() )
105 : {
106 0 : fprintf( stderr, "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
107 0 : exit( 1 );
108 : }
109 :
110 : // Detect desktop environment - need to do this as early as possible
111 : com::sun::star::uno::setCurrentContext(
112 0 : new DesktopContext( com::sun::star::uno::getCurrentContext() ) );
113 :
114 : // Create UCB (for backwards compatibility, in case some code still uses
115 : // plain createInstance w/o args directly to obtain an instance):
116 0 : com::sun::star::ucb::UniversalContentBroker::create(xCtx);
117 :
118 : /*
119 : * Initialize the Java UNO AccessBridge if accessibility is turned on
120 : */
121 :
122 0 : if( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() )
123 : {
124 : bool bQuitApp;
125 0 : if( !InitAccessBridge( true, bQuitApp ) )
126 0 : if( bQuitApp )
127 0 : return EXIT_FAILURE;
128 : }
129 :
130 0 : ResMgr::SetReadStringHook( MyApp::ReadStringHook );
131 :
132 0 : pPADialog = PADialog::Create( NULL , sal_False );
133 0 : Application::SetDisplayName( pPADialog->GetText() );
134 0 : pPADialog->SetIcon(501);
135 0 : pPADialog->Execute();
136 0 : delete pPADialog;
137 :
138 : /*
139 : * clean up UNO
140 : */
141 : try
142 : {
143 0 : Reference<XComponent> xComp(xCtx, UNO_QUERY_THROW);
144 0 : xComp->dispose();
145 : }
146 0 : catch(...)
147 : {
148 : }
149 :
150 0 : return EXIT_SUCCESS;
151 : }
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|