1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #include <officecfg/Setup.hxx>
13 #include <unotools/configmgr.hxx>
14 #include <o3tl/string_view.hxx>
16 #include <com/sun/star/lang/IllegalArgumentException.hpp>
20 /** This method is called when there's a need to determine if the
21 * current version of LibreOffice has been upgraded to a newer one.
23 @param aUpdateVersion This variable is used to determine if
24 LibreOffice's previous version should be updated.
26 static bool isProductVersionUpgraded(bool aUpdateVersion
)
28 OUString sSetupVersion
= utl::ConfigManager::getProductVersion();
29 sal_Int32 iCurrent
= o3tl::toInt32(o3tl::getToken(sSetupVersion
, 0, '.')) * 10
30 + o3tl::toInt32(o3tl::getToken(sSetupVersion
, 1, '.'));
31 OUString sLastVersion
= officecfg::Setup::Product::ooSetupLastVersion::get().value_or("0.0");
32 sal_Int32 iLast
= o3tl::toInt32(o3tl::getToken(sLastVersion
, 0, '.')) * 10
33 + o3tl::toInt32(o3tl::getToken(sLastVersion
, 1, '.'));
37 { //update lastversion
40 std::shared_ptr
<comphelper::ConfigurationChanges
> batch(
41 comphelper::ConfigurationChanges::create());
42 officecfg::Setup::Product::ooSetupLastVersion::set(sSetupVersion
, batch
);
45 catch (css::lang::IllegalArgumentException
&)
46 { //If the value was readOnly.
47 SAL_WARN("desktop.updater", "Updating property ooSetupLastVersion to version "
49 << " failed (read-only property?)");