bump product version to 4.1.6.2
[LibreOffice.git] / desktop / source / app / appfirststart.cxx
blob97ca6e149e6d77640d38ba2cc8aba76659ff611b
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 <osl/file.hxx>
21 #include <rtl/bootstrap.hxx>
22 #include <rtl/ustring.hxx>
23 #include <unotools/configmgr.hxx>
25 #include <comphelper/processfactory.hxx>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/beans/NamedValue.hpp>
28 #include <com/sun/star/configuration/theDefaultProvider.hpp>
29 #include <com/sun/star/util/XChangesBatch.hpp>
31 #include "app.hxx"
33 using namespace ::desktop;
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::beans;
36 using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::uno;
39 static const char aAccessSrvc[] = "com.sun.star.configuration.ConfigurationUpdateAccess";
41 /* Local function - get access to the configuration */
42 static Reference< XPropertySet > impl_getConfigurationAccess( const OUString& rPath )
44 Reference< XMultiServiceFactory > xConfigProvider(
45 configuration::theDefaultProvider::get(
46 comphelper::getProcessComponentContext() ) );
47 Sequence< Any > aArgs( 1 );
48 NamedValue aValue( OUString( "nodepath" ), makeAny( rPath ) );
49 aArgs[0] <<= aValue;
50 return Reference< XPropertySet >(
51 xConfigProvider->createInstanceWithArguments( OUString(aAccessSrvc), aArgs ), UNO_QUERY_THROW );
54 void Desktop::DoRestartActionsIfNecessary( sal_Bool bQuickStart )
56 if ( bQuickStart )
58 try
60 Reference< XPropertySet > xPSet = impl_getConfigurationAccess( OUString( "org.openoffice.Setup/Office" ) );
62 OUString sPropName( "OfficeRestartInProgress" );
63 Any aRestart = xPSet->getPropertyValue( sPropName );
64 sal_Bool bRestart = sal_False;
65 if ( ( aRestart >>= bRestart ) && bRestart )
67 xPSet->setPropertyValue( sPropName, makeAny( sal_False ) );
68 Reference< util::XChangesBatch >( xPSet, UNO_QUERY_THROW )->commitChanges();
70 Sequence< Any > aSeq( 1 );
71 sal_Bool bQuickstart = shouldLaunchQuickstart();
72 aSeq[0] <<= bQuickstart;
74 css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
75 Reference < XInitialization > xQuickstart(
76 xContext->getServiceManager()->createInstanceWithContext("com.sun.star.office.Quickstart", xContext),
77 UNO_QUERY_THROW );
78 xQuickstart->initialize( aSeq );
81 catch( const uno::Exception& )
83 // this is no critical operation so it should not prevent office from starting
88 void Desktop::SetRestartState()
90 try
92 Reference< XPropertySet > xPSet = impl_getConfigurationAccess( OUString( "org.openoffice.Setup/Office" ) );
93 OUString sPropName( "OfficeRestartInProgress" );
94 xPSet->setPropertyValue( sPropName, makeAny( sal_True ) );
95 Reference< util::XChangesBatch >( xPSet, UNO_QUERY_THROW )->commitChanges();
97 catch( const uno::Exception& )
99 // this is no critical operation, ignore the exception
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */