diff options
-rw-r--r-- | include/unotools/VersionConfig.hxx | 19 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 20 | ||||
-rw-r--r-- | unotools/Library_utl.mk | 1 | ||||
-rw-r--r-- | unotools/source/misc/VersionConfig.cxx | 57 |
4 files changed, 65 insertions, 32 deletions
diff --git a/include/unotools/VersionConfig.hxx b/include/unotools/VersionConfig.hxx index e109a96e4c3a..57aebd7c9ec1 100644 --- a/include/unotools/VersionConfig.hxx +++ b/include/unotools/VersionConfig.hxx @@ -9,25 +9,14 @@ */ #pragma once -#include <unotools/configmgr.hxx> -#include <o3tl/string_view.hxx> +#include <sal/config.h> + +#include <unotools/unotoolsdllapi.h> namespace utl { /** This method is called when there's a need to determine if the * 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() -{ - 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); -} +bool UNOTOOLS_DLLPUBLIC isProductVersionUpgraded(); } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 414ee53c1deb..ffa63ca0585d 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1639,8 +1639,10 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) bool bIsWhatsNewShown = false; //suppress tipoftheday if whatsnew was shown //what's new dialog - if (utl::isProductVersionUpgraded() && !IsInModalMode()) + static bool wantsWhatsNew = utl::isProductVersionUpgraded() && !IsInModalMode(); + if (wantsWhatsNew) { + wantsWhatsNew = false; if (officecfg::Setup::Product::WhatsNew::get()) { 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; 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 diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk index 1c5a0ac2391d..9764cdc695bd 100644 --- a/unotools/Library_utl.mk +++ b/unotools/Library_utl.mk @@ -106,6 +106,7 @@ $(eval $(call gb_Library_add_exception_objects,utl,\ unotools/source/misc/syslocale \ unotools/source/misc/wincodepage \ unotools/source/misc/ServiceDocumenter \ + unotools/source/misc/VersionConfig \ unotools/source/misc/ZipPackageHelper \ unotools/source/streaming/streamwrap \ unotools/source/ucbhelper/localfilehelper \ diff --git a/unotools/source/misc/VersionConfig.cxx b/unotools/source/misc/VersionConfig.cxx new file mode 100644 index 000000000000..f24451f6913d --- /dev/null +++ b/unotools/source/misc/VersionConfig.cxx @@ -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: */ |