Kaydet (Commit) 3a14fa97 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up configuration access in Desktop::CheckFirstRun

Change-Id: I8765f0939302bd7ed24de4539e682330f4f4d59b
üst 058deb4a
...@@ -66,10 +66,11 @@ ...@@ -66,10 +66,11 @@
#include <com/sun/star/frame/XUIControllerRegistration.hpp> #include <com/sun/star/frame/XUIControllerRegistration.hpp>
#include <toolkit/unohlp.hxx> #include <toolkit/unohlp.hxx>
#include <comphelper/configuration.hxx>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <unotools/configmgr.hxx> #include <unotools/configmgr.hxx>
#include <unotools/confignode.hxx>
#include <unotools/moduleoptions.hxx> #include <unotools/moduleoptions.hxx>
#include <officecfg/Office/Common.hxx>
#include <officecfg/Office/Recovery.hxx> #include <officecfg/Office/Recovery.hxx>
#include <osl/file.hxx> #include <osl/file.hxx>
#include <osl/process.h> #include <osl/process.h>
...@@ -2912,70 +2913,45 @@ void Desktop::ShowBackingComponent(Desktop * progress) ...@@ -2912,70 +2913,45 @@ void Desktop::ShowBackingComponent(Desktop * progress)
// ======================================================================== // ========================================================================
void Desktop::CheckFirstRun( ) void Desktop::CheckFirstRun( )
{ {
const ::rtl::OUString sCommonMiscNodeName("/org.openoffice.Office.Common/Misc"); if (officecfg::Office::Common::Misc::FirstRun::get())
const ::rtl::OUString sFirstRunNodeName("FirstRun"); {
// this has once been done using a vos timer. this could lead to problems when
// -------------------------------------------------------------------- // the timer would trigger when the app is already going down again, since VCL would
// check if this is the first office start // no longer be available. Since the old handler would do a postUserEvent to the main
// thread anyway, we can use a vcl timer here to prevent the race contition (#107197#)
// for this, open the Common/Misc node where this info is stored m_firstRunTimer.SetTimeout(3000); // 3 sec.
::utl::OConfigurationTreeRoot aCommonMisc = ::utl::OConfigurationTreeRoot::createWithServiceFactory( m_firstRunTimer.SetTimeoutHdl(LINK(this, Desktop, AsyncInitFirstRun));
::comphelper::getProcessServiceFactory( ), m_firstRunTimer.Start();
sCommonMiscNodeName,
2,
::utl::OConfigurationTreeRoot::CM_UPDATABLE
);
// read the flag
OSL_ENSURE( aCommonMisc.isValid(), "Desktop::CheckFirstRun: could not open the config node needed!" );
sal_Bool bIsFirstRun = sal_False;
aCommonMisc.getNodeValue( sFirstRunNodeName ) >>= bIsFirstRun;
if ( !bIsFirstRun )
// nothing to do ....
return;
// --------------------------------------------------------------------
// it is the first run
// this has once been done using a vos timer. this could lead to problems when
// the timer would trigger when the app is already going down again, since VCL would
// no longer be available. Since the old handler would do a postUserEvent to the main
// thread anyway, we can use a vcl timer here to prevent the race contition (#107197#)
m_firstRunTimer.SetTimeout(3000); // 3 sec.
m_firstRunTimer.SetTimeoutHdl(LINK(this, Desktop, AsyncInitFirstRun));
m_firstRunTimer.Start();
#ifdef WNT #ifdef WNT
// Check if Quckstarter should be started (on Windows only) // Check if Quckstarter should be started (on Windows only)
TCHAR szValue[8192]; TCHAR szValue[8192];
DWORD nValueSize = sizeof(szValue); DWORD nValueSize = sizeof(szValue);
HKEY hKey; HKEY hKey;
if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, "Software\\LibreOffice", &hKey ) ) if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, "Software\\LibreOffice", &hKey ) )
{
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("RunQuickstartAtFirstStart"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) )
{ {
sal_Bool bQuickstart( sal_True ); if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("RunQuickstartAtFirstStart"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) )
sal_Bool bAutostart( sal_True ); {
Sequence< Any > aSeq( 2 ); sal_Bool bQuickstart( sal_True );
aSeq[0] <<= bQuickstart; sal_Bool bAutostart( sal_True );
aSeq[1] <<= bAutostart; Sequence< Any > aSeq( 2 );
aSeq[0] <<= bQuickstart;
Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance( aSeq[1] <<= bAutostart;
OUString::createFromAscii( "com.sun.star.office.Quickstart" )),UNO_QUERY );
if ( xQuickstart.is() ) Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
xQuickstart->initialize( aSeq ); OUString::createFromAscii( "com.sun.star.office.Quickstart" )),UNO_QUERY );
RegCloseKey( hKey ); if ( xQuickstart.is() )
xQuickstart->initialize( aSeq );
RegCloseKey( hKey );
}
} }
}
#endif #endif
// -------------------------------------------------------------------- boost::shared_ptr< comphelper::ConfigurationChanges > batch(
// reset the config flag comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Misc::FirstRun::set(false, batch);
// set the value batch->commit();
aCommonMisc.setNodeValue( sFirstRunNodeName, makeAny( (sal_Bool)sal_False ) ); }
// commit the changes
aCommonMisc.commit();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment