1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pamain.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include "tools/testtoolloader.hxx"
36 #include "vcl/svapp.hxx"
37 #include "vcl/wrkwin.hxx"
38 #include "vcl/unowrap.hxx"
40 #include "padialog.hxx"
42 #include "desktopcontext.hxx"
44 #include "cppuhelper/bootstrap.hxx"
45 #include "comphelper/processfactory.hxx"
46 #include "ucbhelper/contentbroker.hxx"
47 #include "ucbhelper/configurationkeys.hxx"
48 #include "unotools/configmgr.hxx"
50 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
52 using namespace padmin
;
55 using namespace com::sun::star::uno
;
56 using namespace com::sun::star::lang
;
57 using namespace comphelper
;
59 // -----------------------------------------------------------------------
61 class MyApp
: public Application
65 virtual USHORT
Exception( USHORT nError
);
67 static void ReadStringHook( String
& );
72 void MyApp::ReadStringHook( String
& rStr
)
74 static String maProduct
;
75 if( ! maProduct
.Len() )
77 Any aRet
= utl::ConfigManager::GetDirectConfigProperty( utl::ConfigManager::PRODUCTNAME
);
80 maProduct
= String( aProd
);
82 rStr
.SearchAndReplaceAllAscii( "%PRODUCTNAME", maProduct
);
86 // -----------------------------------------------------------------------
88 USHORT
MyApp::Exception( USHORT nError
)
90 switch( nError
& EXC_MAJORTYPE
)
92 case EXC_RSCNOTLOADED
:
93 Abort( String::CreateFromAscii( "Error: could not load language resources.\nPlease check your installation.\n" ) );
105 //-------------------------------------------------
106 // create the global service-manager
107 //-------------------------------------------------
108 Reference
< XMultiServiceFactory
> xFactory
;
111 Reference
< XComponentContext
> xCtx
= defaultBootstrap_InitialComponentContext();
112 xFactory
= Reference
< XMultiServiceFactory
>( xCtx
->getServiceManager(), UNO_QUERY
);
114 setProcessServiceFactory( xFactory
);
116 catch( com::sun::star::uno::Exception
& rExc
)
120 if( ! xFactory
.is() )
122 fprintf( stderr
, "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
126 // Detect desktop environment - need to do this as early as possible
127 com::sun::star::uno::setCurrentContext(
128 new DesktopContext( com::sun::star::uno::getCurrentContext() ) );
133 Sequence
< Any
> aArgs( 2 );
134 aArgs
[ 0 ] <<= OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL
);
135 aArgs
[ 1 ] <<= OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE
);
136 #if OSL_DEBUG_LEVEL > 1
139 ::ucbhelper::ContentBroker::initialize( xFactory
, aArgs
);
141 #if OSL_DEBUG_LEVEL > 1
144 fprintf( stderr
, "Error creating UCB, installation must be in disorder. Exiting.\n" );
150 * Initialize the Java UNO AccessBridge if accessibility is turned on
153 if( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() )
156 if( !InitAccessBridge( true, bQuitApp
) )
161 // initialize test-tool library (if available)
162 tools::InitTestToolLib();
164 ResMgr::SetReadStringHook( MyApp::ReadStringHook
);
166 pPADialog
= PADialog::Create( NULL
, FALSE
);
167 Application::SetDisplayName( pPADialog
->GetText() );
168 pPADialog
->SetIcon(501);
169 pPADialog
->Execute();
172 tools::DeInitTestToolLib();
177 ::ucbhelper::ContentBroker::deinitialize();