LCOV - code coverage report
Current view: top level - desktop/source/app - appfirststart.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 31 48.4 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 18 86 20.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <osl/file.hxx>
      30                 :            : #include <rtl/bootstrap.hxx>
      31                 :            : #include <rtl/ustring.hxx>
      32                 :            : #include <unotools/configmgr.hxx>
      33                 :            : 
      34                 :            : #include <comphelper/processfactory.hxx>
      35                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      36                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      37                 :            : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      38                 :            : #include <com/sun/star/util/XChangesBatch.hpp>
      39                 :            : 
      40                 :            : #include "app.hxx"
      41                 :            : 
      42                 :            : using ::rtl::OUString;
      43                 :            : using namespace ::desktop;
      44                 :            : using namespace ::com::sun::star;
      45                 :            : using namespace ::com::sun::star::beans;
      46                 :            : 
      47                 :            : static const char aAccessSrvc[] = "com.sun.star.configuration.ConfigurationUpdateAccess";
      48                 :            : 
      49                 :            : /* Local function - get access to the configuration */
      50                 :         62 : static Reference< XPropertySet > impl_getConfigurationAccess( const OUString& rPath )
      51                 :            : {
      52                 :            :     Reference< XMultiServiceFactory > xConfigProvider(
      53                 :            :         configuration::theDefaultProvider::get(
      54 [ +  - ][ +  - ]:         62 :             comphelper::getProcessComponentContext() ) );
      55         [ +  - ]:         62 :     Sequence< Any > aArgs( 1 );
      56         [ +  - ]:         62 :     NamedValue aValue( OUString( "nodepath"  ), makeAny( rPath ) );
      57 [ +  - ][ +  - ]:         62 :     aArgs[0] <<= aValue;
      58                 :            :     return Reference< XPropertySet >(
      59 [ +  - ][ +  - ]:         62 :             xConfigProvider->createInstanceWithArguments( rtl::OUString(aAccessSrvc), aArgs ), UNO_QUERY_THROW );
         [ +  - ][ +  - ]
      60                 :            : }
      61                 :            : 
      62                 :         96 : void Desktop::DoRestartActionsIfNecessary( sal_Bool bQuickStart )
      63                 :            : {
      64         [ -  + ]:         96 :     if ( bQuickStart )
      65                 :            :     {
      66                 :            :         try
      67                 :            :         {
      68         [ #  # ]:          0 :             Reference< XPropertySet > xPSet = impl_getConfigurationAccess( OUString( "org.openoffice.Setup/Office"  ) );
      69                 :            : 
      70                 :          0 :             OUString sPropName( "OfficeRestartInProgress"  );
      71 [ #  # ][ #  # ]:          0 :             Any aRestart = xPSet->getPropertyValue( sPropName );
      72                 :          0 :             sal_Bool bRestart = sal_False;
      73 [ #  # ][ #  # ]:          0 :             if ( ( aRestart >>= bRestart ) && bRestart )
                 [ #  # ]
      74                 :            :             {
      75 [ #  # ][ #  # ]:          0 :                 xPSet->setPropertyValue( sPropName, makeAny( sal_False ) );
                 [ #  # ]
      76 [ #  # ][ #  # ]:          0 :                 Reference< util::XChangesBatch >( xPSet, UNO_QUERY_THROW )->commitChanges();
                 [ #  # ]
      77                 :            : 
      78         [ #  # ]:          0 :                 Sequence< Any > aSeq( 1 );
      79         [ #  # ]:          0 :                 sal_Bool bQuickstart = shouldLaunchQuickstart();
      80 [ #  # ][ #  # ]:          0 :                 aSeq[0] <<= bQuickstart;
      81                 :            : 
      82 [ #  # ][ #  # ]:          0 :                 Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
      83 [ #  # ][ #  # ]:          0 :                     OUString( "com.sun.star.office.Quickstart"  ) ),UNO_QUERY_THROW );
      84 [ #  # ][ #  # ]:          0 :                 xQuickstart->initialize( aSeq );
                 [ #  # ]
      85         [ #  # ]:          0 :             }
      86                 :            :         }
      87                 :          0 :         catch( const uno::Exception& )
      88                 :            :         {
      89                 :            :             // this is no critical operation so it should not prevent office from starting
      90                 :            :         }
      91                 :            :     }
      92                 :         96 : }
      93                 :            : 
      94                 :         62 : void Desktop::SetRestartState()
      95                 :            : {
      96                 :            :     try
      97                 :            :     {
      98         [ +  - ]:         62 :         Reference< XPropertySet > xPSet = impl_getConfigurationAccess( OUString( "org.openoffice.Setup/Office"  ) );
      99                 :         62 :         OUString sPropName( "OfficeRestartInProgress"  );
     100 [ +  - ][ +  - ]:         62 :         xPSet->setPropertyValue( sPropName, makeAny( sal_True ) );
                 [ +  - ]
     101 [ +  - ][ +  - ]:         62 :         Reference< util::XChangesBatch >( xPSet, UNO_QUERY_THROW )->commitChanges();
         [ #  # ][ +  - ]
     102                 :            :     }
     103                 :          0 :     catch( const uno::Exception& )
     104                 :            :     {
     105                 :            :         // this is no critical operation, ignore the exception
     106                 :            :     }
     107                 :            : 
     108                 :         62 : }
     109                 :            : 
     110                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10