merge the formfield patch from ooo-build
[ooovba.git] / desktop / source / splash / firststart.cxx
blob5b9447627f155523b77012bf7ee9a03fcc97de55
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: firststart.cxx,v $
10 * $Revision: 1.9 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_desktop.hxx"
34 #include "firststart.hxx"
35 #include "../migration/wizard.hxx"
36 #include <comphelper/sequenceashashmap.hxx>
38 using namespace rtl;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::beans;
43 namespace desktop{
46 const char* FirstStart::interfaces[] =
48 "com.sun.star.task.XJob",
49 NULL,
51 const char* FirstStart::implementationName = "com.sun.star.comp.desktop.FirstStart";
52 const char* FirstStart::serviceName = "com.sun.star.task.Job";
54 OUString FirstStart::GetImplementationName()
56 return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationName));
59 Sequence< OUString > FirstStart::GetSupportedServiceNames()
61 sal_Int32 nSize = (sizeof( interfaces ) / sizeof( const char *)) - 1;
62 Sequence< OUString > aResult( nSize );
64 for( sal_Int32 i = 0; i < nSize; i++ )
65 aResult[i] = OUString::createFromAscii( interfaces[i] );
66 return aResult;
69 Reference< XInterface > SAL_CALL FirstStart::CreateInstance(
70 const Reference< XMultiServiceFactory >& rSMgr )
72 static osl::Mutex aMutex;
73 osl::MutexGuard guard( aMutex );
74 return (XComponent*) ( new FirstStart( rSMgr ) );
77 FirstStart::FirstStart( const Reference< XMultiServiceFactory >& xFactory ) :
78 m_aListeners( m_aMutex ),
79 m_xServiceManager( xFactory )
83 FirstStart::~FirstStart()
87 // XComponent
88 void SAL_CALL FirstStart::dispose() throw ( RuntimeException )
90 EventObject aObject;
91 aObject.Source = (XComponent*)this;
92 m_aListeners.disposeAndClear( aObject );
95 void SAL_CALL FirstStart::addEventListener( const Reference< XEventListener > & aListener) throw ( RuntimeException )
97 m_aListeners.addInterface( aListener );
100 void SAL_CALL FirstStart::removeEventListener( const Reference< XEventListener > & aListener ) throw ( RuntimeException )
102 m_aListeners.removeInterface( aListener );
105 // XServiceInfo
106 ::rtl::OUString SAL_CALL FirstStart::getImplementationName()
107 throw ( RuntimeException )
109 return FirstStart::GetImplementationName();
112 sal_Bool SAL_CALL FirstStart::supportsService( const ::rtl::OUString& rServiceName )
113 throw ( RuntimeException )
115 sal_Int32 nSize = sizeof( interfaces ) / sizeof( const char *);
117 for( sal_Int32 i = 0; i < nSize; i++ )
118 if ( rServiceName.equalsAscii( interfaces[i] ))
119 return sal_True;
120 return sal_False;
123 Sequence< ::rtl::OUString > SAL_CALL FirstStart::getSupportedServiceNames()
124 throw ( RuntimeException )
126 return FirstStart::GetSupportedServiceNames();
129 // XJob
130 Any SAL_CALL FirstStart::execute(const Sequence<NamedValue>& args)
131 throw ( RuntimeException )
133 static const ::rtl::OUString ARG_LICENSENEEDED( RTL_CONSTASCII_USTRINGPARAM( "LicenseNeedsAcceptance" ) );
134 static const ::rtl::OUString ARG_LICENSEPATH( RTL_CONSTASCII_USTRINGPARAM( "LicensePath" ) );
136 ::comphelper::SequenceAsHashMap lArgs(args);
138 sal_Bool bLicenseNeeded = lArgs.getUnpackedValueOrDefault( ARG_LICENSENEEDED, (sal_Bool)sal_True );
139 rtl::OUString aLicensePath = lArgs.getUnpackedValueOrDefault( ARG_LICENSEPATH, rtl::OUString() );
141 FirstStartWizard fsw( NULL, bLicenseNeeded && ( aLicensePath.getLength() > 0 ), aLicensePath );
142 return makeAny( (sal_Bool)fsw.Execute() );
145 // XJobExecutor
146 void SAL_CALL FirstStart::trigger(const OUString&)
147 throw ( RuntimeException )
149 // trigger wizard with override, so it gets started regardless of
150 // configuration
151 Sequence<NamedValue> seq(1);
152 seq[0] = NamedValue(
153 OUString::createFromAscii("Override"),
154 makeAny(sal_True));
155 execute(seq);
159 } // namespace desktop