update credits
[LibreOffice.git] / padmin / source / pamain.cxx
blobbbccadf032c104c0083d89ffab7f2dcfec65e67a
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 #include <stdio.h>
21 #include <unistd.h>
23 #include "vcl/svapp.hxx"
24 #include "vcl/vclmain.hxx"
25 #include "vcl/wrkwin.hxx"
26 #include "vcl/unowrap.hxx"
28 #include "padialog.hxx"
29 #include "helper.hxx"
30 #include "desktopcontext.hxx"
32 #include "cppuhelper/bootstrap.hxx"
33 #include "comphelper/processfactory.hxx"
34 #include "unotools/configmgr.hxx"
36 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
37 #include "com/sun/star/lang/XComponent.hpp"
38 #include "com/sun/star/ucb/UniversalContentBroker.hpp"
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;
47 class MyApp : public Application
49 public:
50 int Main();
51 virtual sal_uInt16 Exception( sal_uInt16 nError );
53 static OUString ReadStringHook( const OUString& );
56 void vclmain::createApplication()
58 static MyApp aMyApp;
61 OUString MyApp::ReadStringHook( const OUString& rStr )
63 return rStr.replaceAll(
64 OUString("%PRODUCTNAME"), utl::ConfigManager::getProductName() );
68 // -----------------------------------------------------------------------
70 sal_uInt16 MyApp::Exception( sal_uInt16 nError )
72 switch( nError & EXC_MAJORTYPE )
74 case EXC_RSCNOTLOADED:
75 Abort( OUString( "Error: could not load language resources.\nPlease check your installation.\n" ) );
76 break;
78 return 0;
81 int MyApp::Main()
83 PADialog* pPADialog;
85 EnableAutoHelpId();
87 //-------------------------------------------------
88 // create the global service-manager
89 //-------------------------------------------------
90 Reference< XComponentContext > xCtx;
91 Reference< XMultiServiceFactory > xFactory;
92 try
94 xCtx = defaultBootstrap_InitialComponentContext();
95 xFactory = Reference< XMultiServiceFactory >( xCtx->getServiceManager(), UNO_QUERY );
96 if( xFactory.is() )
97 setProcessServiceFactory( xFactory );
99 catch( const com::sun::star::uno::Exception& )
103 if( ! xFactory.is() )
105 fprintf( stderr, "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
106 exit( 1 );
109 // Detect desktop environment - need to do this as early as possible
110 com::sun::star::uno::setCurrentContext(
111 new DesktopContext( com::sun::star::uno::getCurrentContext() ) );
113 // Create UCB (for backwards compatibility, in case some code still uses
114 // plain createInstance w/o args directly to obtain an instance):
115 com::sun::star::ucb::UniversalContentBroker::create(xCtx);
118 * Initialize the Java UNO AccessBridge if accessibility is turned on
121 if( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() )
123 bool bQuitApp;
124 if( !InitAccessBridge( true, bQuitApp ) )
125 if( bQuitApp )
126 return EXIT_FAILURE;
129 ResMgr::SetReadStringHook( MyApp::ReadStringHook );
131 pPADialog = PADialog::Create( NULL , sal_False );
132 Application::SetDisplayName( pPADialog->GetText() );
133 pPADialog->SetIcon(501);
134 pPADialog->Execute();
135 delete pPADialog;
138 * clean up UNO
142 Reference<XComponent> xComp(xCtx, UNO_QUERY_THROW);
143 xComp->dispose();
145 catch(...)
149 return EXIT_SUCCESS;
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */