Make isProductVersionUpgraded update ooSetupLastVersion again

This was changed in commit dd889b2903
(Resolves tdf#159573 and tdf#137931 - WhatsNew or Welcome dialog,
2024-03-27).

This change doesn't require opening a module (and checking if WhatsNew
dialog is needed) to update the configuration - it will be updated
immediately in runGraphicsRenderTests.

Change-Id: I595b6898c46998e7a0805ffbf7a710dbf0d2a5e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168855
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Mike Kaganski 2024-06-14 14:48:53 +05:00
parent 9950056918
commit 00ed1c5c02
4 changed files with 65 additions and 32 deletions

View file

@ -9,25 +9,14 @@
*/ */
#pragma once #pragma once
#include <unotools/configmgr.hxx> #include <sal/config.h>
#include <o3tl/string_view.hxx>
#include <unotools/unotoolsdllapi.h>
namespace utl namespace utl
{ {
/** This method is called when there's a need to determine if the /** This method is called when there's a need to determine if the
* current version of LibreOffice has been upgraded to a newer one. * current version of LibreOffice has been upgraded to a newer one.
@param aUpdateVersion This variable is used to determine if
LibreOffice's previous version should be updated.
*/ */
static bool isProductVersionUpgraded() bool UNOTOOLS_DLLPUBLIC isProductVersionUpgraded();
{
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, '.'));
return (iCurrent > iLast);
}
} }

View file

@ -1639,8 +1639,10 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
bool bIsWhatsNewShown = false; //suppress tipoftheday if whatsnew was shown bool bIsWhatsNewShown = false; //suppress tipoftheday if whatsnew was shown
//what's new dialog //what's new dialog
if (utl::isProductVersionUpgraded() && !IsInModalMode()) static bool wantsWhatsNew = utl::isProductVersionUpgraded() && !IsInModalMode();
if (wantsWhatsNew)
{ {
wantsWhatsNew = false;
if (officecfg::Setup::Product::WhatsNew::get()) if (officecfg::Setup::Product::WhatsNew::get())
{ {
VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("whatsnew", "", SfxResId(STR_WHATSNEW_TEXT), InfobarType::INFO); VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("whatsnew", "", SfxResId(STR_WHATSNEW_TEXT), InfobarType::INFO);
@ -1653,22 +1655,6 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
bIsInfobarShown = true; bIsInfobarShown = true;
bIsWhatsNewShown = true; bIsWhatsNewShown = true;
} }
//update lastversion
OUString sSetupVersion = utl::ConfigManager::getProductVersion();
try
{
std::shared_ptr<comphelper::ConfigurationChanges> batch(
comphelper::ConfigurationChanges::create());
officecfg::Setup::Product::ooSetupLastVersion::set(sSetupVersion, 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?)");
}
} }
// show tip-of-the-day dialog if it due, but not if there is the impress modal template dialog // show tip-of-the-day dialog if it due, but not if there is the impress modal template dialog

View file

@ -106,6 +106,7 @@ $(eval $(call gb_Library_add_exception_objects,utl,\
unotools/source/misc/syslocale \ unotools/source/misc/syslocale \
unotools/source/misc/wincodepage \ unotools/source/misc/wincodepage \
unotools/source/misc/ServiceDocumenter \ unotools/source/misc/ServiceDocumenter \
unotools/source/misc/VersionConfig \
unotools/source/misc/ZipPackageHelper \ unotools/source/misc/ZipPackageHelper \
unotools/source/streaming/streamwrap \ unotools/source/streaming/streamwrap \
unotools/source/ucbhelper/localfilehelper \ unotools/source/ucbhelper/localfilehelper \

View file

@ -0,0 +1,57 @@
/* -*- 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/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
{
std::shared_ptr<comphelper::ConfigurationChanges> batch(
comphelper::ConfigurationChanges::create());
officecfg::Setup::Product::ooSetupLastVersion::set(sSetupVersion, 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: */