f1e4a97b03
1. In isProductVersionUpgraded, if it was upgraded, set FirstRun. This will run in runGraphicsRenderTests, early enough in Desktop::Main(). 2. This will make sure that Desktop::CheckFirstRun() will do its tasks, including creation of the quickstart shortcut. It is simplified a bit, to use a better WinAPI. 3. Setting FirstRun to false is moved to m_firstRunTimer's handler, to make sure that it gets run eventually, even if the first launch was terminated before the timer fired. This will not make installer itself create the quickstart shortcut: it will happen on the program's first run after an upgrade. But users now won't have to enable the option manually each time. Change-Id: Ica6cc41f1e56b8970db27d14e2be3c47910293e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168902 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
59 lines
2.2 KiB
C++
59 lines
2.2 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include <sal/config.h>
|
|
|
|
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
|
|
|
#include <officecfg/Office/Common.hxx>
|
|
#include <officecfg/Setup.hxx>
|
|
|
|
#include <o3tl/string_view.hxx>
|
|
#include <sal/log.hxx>
|
|
#include <unotools/configmgr.hxx>
|
|
#include <unotools/VersionConfig.hxx>
|
|
|
|
namespace utl
|
|
{
|
|
bool isProductVersionUpgraded()
|
|
{
|
|
static const bool bUpgraded = []() {
|
|
OUString sSetupVersion = utl::ConfigManager::getProductVersion();
|
|
sal_Int32 iCurrent = o3tl::toInt32(o3tl::getToken(sSetupVersion, 0, '.')) * 10
|
|
+ o3tl::toInt32(o3tl::getToken(sSetupVersion, 1, '.'));
|
|
OUString sLastVersion
|
|
= officecfg::Setup::Product::ooSetupLastVersion::get().value_or("0.0");
|
|
sal_Int32 iLast = o3tl::toInt32(o3tl::getToken(sLastVersion, 0, '.')) * 10
|
|
+ o3tl::toInt32(o3tl::getToken(sLastVersion, 1, '.'));
|
|
if (iCurrent > iLast)
|
|
{
|
|
//update lastversion
|
|
try
|
|
{
|
|
auto batch(comphelper::ConfigurationChanges::create());
|
|
officecfg::Setup::Product::ooSetupLastVersion::set(sSetupVersion, batch);
|
|
// tdf#35568: an upgrade must repeat the first run routine
|
|
officecfg::Office::Common::Misc::FirstRun::set(true, batch);
|
|
batch->commit();
|
|
}
|
|
catch (css::lang::IllegalArgumentException&)
|
|
{ //If the value was readOnly.
|
|
SAL_WARN("desktop.updater", "Updating property ooSetupLastVersion to version "
|
|
<< sSetupVersion
|
|
<< " failed (read-only property?)");
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}();
|
|
return bUpgraded;
|
|
}
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|