2010-10-12 08:53:47 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2008-01-29 09:30:07 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 21:35:08 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2008-01-29 09:30:07 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2008-01-29 09:30:07 -06:00
|
|
|
*
|
2008-04-10 21:35:08 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2008-01-29 09:30:07 -06:00
|
|
|
*
|
2008-04-10 21:35:08 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2008-01-29 09:30:07 -06:00
|
|
|
*
|
2008-04-10 21:35:08 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2008-01-29 09:30:07 -06:00
|
|
|
*
|
2008-04-10 21:35:08 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2008-01-29 09:30:07 -06:00
|
|
|
*
|
2008-04-10 21:35:08 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2008-01-29 09:30:07 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <osl/file.hxx>
|
|
|
|
#include <rtl/bootstrap.hxx>
|
|
|
|
#include <rtl/ustring.hxx>
|
2008-04-10 21:35:08 -05:00
|
|
|
#include <unotools/configmgr.hxx>
|
2008-01-29 09:30:07 -06:00
|
|
|
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/beans/NamedValue.hpp>
|
2011-11-14 15:07:23 -06:00
|
|
|
#include <com/sun/star/configuration/theDefaultProvider.hpp>
|
2010-08-05 04:53:41 -05:00
|
|
|
#include <com/sun/star/util/XChangesBatch.hpp>
|
2008-01-29 09:30:07 -06:00
|
|
|
|
|
|
|
#include "app.hxx"
|
|
|
|
|
2010-08-05 04:53:41 -05:00
|
|
|
using ::rtl::OUString;
|
|
|
|
using namespace ::desktop;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::beans;
|
2008-01-29 09:30:07 -06:00
|
|
|
|
2012-03-28 16:19:30 -05:00
|
|
|
static const char aAccessSrvc[] = "com.sun.star.configuration.ConfigurationUpdateAccess";
|
2008-01-29 09:30:07 -06:00
|
|
|
|
2010-08-05 04:53:41 -05:00
|
|
|
/* Local function - get access to the configuration */
|
|
|
|
static Reference< XPropertySet > impl_getConfigurationAccess( const OUString& rPath )
|
2008-01-29 09:30:07 -06:00
|
|
|
{
|
2011-11-14 15:07:23 -06:00
|
|
|
Reference< XMultiServiceFactory > xConfigProvider(
|
|
|
|
configuration::theDefaultProvider::get(
|
|
|
|
comphelper::getProcessComponentContext() ) );
|
2010-08-05 04:53:41 -05:00
|
|
|
Sequence< Any > aArgs( 1 );
|
2012-06-02 17:13:51 -05:00
|
|
|
NamedValue aValue( OUString( "nodepath" ), makeAny( rPath ) );
|
2010-08-05 04:53:41 -05:00
|
|
|
aArgs[0] <<= aValue;
|
|
|
|
return Reference< XPropertySet >(
|
2012-03-28 16:19:30 -05:00
|
|
|
xConfigProvider->createInstanceWithArguments( rtl::OUString(aAccessSrvc), aArgs ), UNO_QUERY_THROW );
|
2010-08-05 04:53:41 -05:00
|
|
|
}
|
2008-01-29 09:30:07 -06:00
|
|
|
|
2010-08-05 04:53:41 -05:00
|
|
|
void Desktop::DoRestartActionsIfNecessary( sal_Bool bQuickStart )
|
|
|
|
{
|
|
|
|
if ( bQuickStart )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2012-06-02 17:13:51 -05:00
|
|
|
Reference< XPropertySet > xPSet = impl_getConfigurationAccess( OUString( "org.openoffice.Setup/Office" ) );
|
2010-08-05 04:53:41 -05:00
|
|
|
|
2012-06-02 17:13:51 -05:00
|
|
|
OUString sPropName( "OfficeRestartInProgress" );
|
2010-08-05 04:53:41 -05:00
|
|
|
Any aRestart = xPSet->getPropertyValue( sPropName );
|
|
|
|
sal_Bool bRestart = sal_False;
|
|
|
|
if ( ( aRestart >>= bRestart ) && bRestart )
|
|
|
|
{
|
|
|
|
xPSet->setPropertyValue( sPropName, makeAny( sal_False ) );
|
|
|
|
Reference< util::XChangesBatch >( xPSet, UNO_QUERY_THROW )->commitChanges();
|
|
|
|
|
2010-11-25 03:38:16 -06:00
|
|
|
Sequence< Any > aSeq( 1 );
|
2010-11-25 03:40:08 -06:00
|
|
|
sal_Bool bQuickstart = shouldLaunchQuickstart();
|
|
|
|
aSeq[0] <<= bQuickstart;
|
2010-08-05 04:53:41 -05:00
|
|
|
|
|
|
|
Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
|
2012-06-02 17:13:51 -05:00
|
|
|
OUString( "com.sun.star.office.Quickstart" ) ),UNO_QUERY_THROW );
|
2010-08-05 04:53:41 -05:00
|
|
|
xQuickstart->initialize( aSeq );
|
|
|
|
}
|
|
|
|
}
|
2011-12-05 09:19:44 -06:00
|
|
|
catch( const uno::Exception& )
|
2010-08-05 04:53:41 -05:00
|
|
|
{
|
|
|
|
// this is no critical operation so it should not prevent office from starting
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Desktop::SetRestartState()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2012-06-02 17:13:51 -05:00
|
|
|
Reference< XPropertySet > xPSet = impl_getConfigurationAccess( OUString( "org.openoffice.Setup/Office" ) );
|
|
|
|
OUString sPropName( "OfficeRestartInProgress" );
|
2010-08-05 04:53:41 -05:00
|
|
|
xPSet->setPropertyValue( sPropName, makeAny( sal_True ) );
|
|
|
|
Reference< util::XChangesBatch >( xPSet, UNO_QUERY_THROW )->commitChanges();
|
|
|
|
}
|
2011-12-05 09:19:44 -06:00
|
|
|
catch( const uno::Exception& )
|
2010-08-05 04:53:41 -05:00
|
|
|
{
|
|
|
|
// this is no critical operation, ignore the exception
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-10-12 08:53:47 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|