Branch data 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/wrkwin.hxx"
25 : : #include "vcl/unowrap.hxx"
26 : :
27 : : #include "padialog.hxx"
28 : : #include "helper.hxx"
29 : : #include "desktopcontext.hxx"
30 : :
31 : : #include "cppuhelper/bootstrap.hxx"
32 : : #include "comphelper/processfactory.hxx"
33 : : #include "ucbhelper/contentbroker.hxx"
34 : : #include "ucbhelper/configurationkeys.hxx"
35 : : #include "unotools/configmgr.hxx"
36 : :
37 : : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
38 : : #include "com/sun/star/lang/XComponent.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 : MyApp aMyApp;
58 : :
59 : 0 : rtl::OUString MyApp::ReadStringHook( const rtl::OUString& rStr )
60 : : {
61 : : return rStr.replaceAll(
62 : 0 : rtl::OUString("%PRODUCTNAME"), utl::ConfigManager::getProductName() );
63 : : };
64 : :
65 : :
66 : : // -----------------------------------------------------------------------
67 : :
68 : 0 : sal_uInt16 MyApp::Exception( sal_uInt16 nError )
69 : : {
70 : 0 : switch( nError & EXC_MAJORTYPE )
71 : : {
72 : : case EXC_RSCNOTLOADED:
73 : 0 : Abort( rtl::OUString( "Error: could not load language resources.\nPlease check your installation.\n" ) );
74 : 0 : break;
75 : : }
76 : 0 : return 0;
77 : : }
78 : :
79 : 0 : int MyApp::Main()
80 : : {
81 : : PADialog* pPADialog;
82 : :
83 : 0 : EnableAutoHelpId();
84 : :
85 : : //-------------------------------------------------
86 : : // create the global service-manager
87 : : //-------------------------------------------------
88 : 0 : Reference< XComponentContext > xCtx;
89 : 0 : Reference< XMultiServiceFactory > xFactory;
90 : : try
91 : : {
92 : 0 : xCtx = defaultBootstrap_InitialComponentContext();
93 : 0 : xFactory = Reference< XMultiServiceFactory >( xCtx->getServiceManager(), UNO_QUERY );
94 : 0 : if( xFactory.is() )
95 : 0 : setProcessServiceFactory( xFactory );
96 : : }
97 : 0 : catch( const com::sun::star::uno::Exception& )
98 : : {
99 : : }
100 : :
101 : 0 : if( ! xFactory.is() )
102 : : {
103 : 0 : fprintf( stderr, "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
104 : 0 : exit( 1 );
105 : : }
106 : :
107 : : // Detect desktop environment - need to do this as early as possible
108 : : com::sun::star::uno::setCurrentContext(
109 : 0 : new DesktopContext( com::sun::star::uno::getCurrentContext() ) );
110 : :
111 : : /*
112 : : * Create UCB.
113 : : */
114 : 0 : Sequence< Any > aArgs( 2 );
115 : 0 : aArgs[ 0 ] <<= OUString( UCB_CONFIGURATION_KEY1_LOCAL );
116 : 0 : aArgs[ 1 ] <<= OUString( UCB_CONFIGURATION_KEY2_OFFICE );
117 : : #if OSL_DEBUG_LEVEL > 1
118 : : sal_Bool bSuccess =
119 : : #endif
120 : 0 : ::ucbhelper::ContentBroker::initialize( xFactory, aArgs );
121 : :
122 : : #if OSL_DEBUG_LEVEL > 1
123 : : if ( !bSuccess )
124 : : {
125 : : fprintf( stderr, "Error creating UCB, installation must be in disorder. Exiting.\n" );
126 : : exit( 1 );
127 : : }
128 : : #endif
129 : :
130 : : /*
131 : : * Initialize the Java UNO AccessBridge if accessibility is turned on
132 : : */
133 : :
134 : 0 : if( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() )
135 : : {
136 : : sal_Bool bQuitApp;
137 : 0 : if( !InitAccessBridge( true, bQuitApp ) )
138 : 0 : if( bQuitApp )
139 : 0 : return EXIT_FAILURE;
140 : : }
141 : :
142 : 0 : ResMgr::SetReadStringHook( MyApp::ReadStringHook );
143 : :
144 : 0 : pPADialog = PADialog::Create( NULL , sal_False );
145 : 0 : Application::SetDisplayName( pPADialog->GetText() );
146 : 0 : pPADialog->SetIcon(501);
147 : 0 : pPADialog->Execute();
148 : 0 : delete pPADialog;
149 : :
150 : : /*
151 : : * clean up UCB
152 : : */
153 : 0 : ::ucbhelper::ContentBroker::deinitialize();
154 : :
155 : : /*
156 : : * clean up UNO
157 : : */
158 : : try
159 : : {
160 : 0 : Reference<XComponent> xComp(xCtx, UNO_QUERY_THROW);
161 : 0 : xComp->dispose();
162 : : }
163 : 0 : catch(...)
164 : : {
165 : : }
166 : :
167 : 0 : return EXIT_SUCCESS;
168 : 0 : }
169 : :
170 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|