CppunitTest_sc_tiledrendering2: move to tiledrendering folder
[LibreOffice.git] / unotools / source / misc / VersionConfig.cxx
blob80373ce73430963d78ec0993dff1cf017d64b69f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #include <sal/config.h>
12 #include <com/sun/star/lang/IllegalArgumentException.hpp>
14 #include <officecfg/Office/Common.hxx>
15 #include <officecfg/Setup.hxx>
17 #include <o3tl/string_view.hxx>
18 #include <sal/log.hxx>
19 #include <unotools/configmgr.hxx>
20 #include <unotools/VersionConfig.hxx>
22 namespace utl
24 bool isProductVersionUpgraded()
26 static const bool bUpgraded = []() {
27 OUString sSetupVersion = utl::ConfigManager::getProductVersion();
28 sal_Int32 iCurrent = o3tl::toInt32(o3tl::getToken(sSetupVersion, 0, '.')) * 10
29 + o3tl::toInt32(o3tl::getToken(sSetupVersion, 1, '.'));
30 OUString sLastVersion
31 = 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, '.'));
34 if (iCurrent > iLast)
36 //update lastversion
37 try
39 auto batch(comphelper::ConfigurationChanges::create());
40 officecfg::Setup::Product::ooSetupLastVersion::set(sSetupVersion, batch);
41 // tdf#35568: an upgrade must repeat the first run routine
42 officecfg::Office::Common::Misc::FirstRun::set(true, batch);
43 batch->commit();
45 catch (css::lang::IllegalArgumentException&)
46 { //If the value was readOnly.
47 SAL_WARN("desktop.updater", "Updating property ooSetupLastVersion to version "
48 << sSetupVersion
49 << " failed (read-only property?)");
51 return true;
53 return false;
54 }();
55 return bUpgraded;
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */