2011-04-04 18:02:18 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-04 11:25:41 +01:00
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2011-01-12 11:56:09 +01:00
|
|
|
|
2022-10-24 15:36:01 +02:00
|
|
|
#include <sal/config.h>
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
#include <about.hxx>
|
|
|
|
|
2020-04-29 11:39:57 +02:00
|
|
|
#include <osl/process.h> //osl_getProcessLocale
|
2022-10-24 15:36:01 +02:00
|
|
|
#include <rtl/bootstrap.hxx>
|
2020-04-29 11:39:57 +02:00
|
|
|
#include <sal/log.hxx> //SAL_WARN
|
2021-04-16 20:33:10 +02:00
|
|
|
#include <vcl/graph.hxx> //Graphic
|
2020-04-29 11:39:57 +02:00
|
|
|
#include <vcl/settings.hxx> //GetSettings
|
|
|
|
#include <vcl/svapp.hxx> //Application::
|
2019-06-04 11:34:28 +01:00
|
|
|
#include <vcl/weld.hxx>
|
2020-07-30 11:20:53 +02:00
|
|
|
#include <unotools/resmgr.hxx> //Translate
|
2011-04-04 18:02:18 +01:00
|
|
|
|
2020-04-29 11:39:57 +02:00
|
|
|
#include <config_buildid.h> //EXTRA_BUILDID
|
2021-01-08 15:10:42 +01:00
|
|
|
#include <config_features.h>
|
2020-04-29 11:39:57 +02:00
|
|
|
#include <dialmgr.hxx> //CuiResId
|
2018-12-03 18:58:38 +01:00
|
|
|
#include <i18nlangtag/languagetag.hxx>
|
2020-04-29 11:39:57 +02:00
|
|
|
#include <sfx2/app.hxx> //SfxApplication::loadBrandSvg
|
|
|
|
#include <strings.hrc>
|
2020-04-08 12:58:34 +02:00
|
|
|
#include <svtools/langhelp.hxx>
|
2020-08-18 22:23:30 +03:00
|
|
|
#include <unotools/bootstrap.hxx> //utl::Bootstrap::getBuildIdData
|
2020-04-08 12:58:34 +02:00
|
|
|
#include <unotools/configmgr.hxx> //ConfigManager::
|
2016-07-01 20:49:19 +01:00
|
|
|
|
2020-04-17 13:20:36 +02:00
|
|
|
#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
|
2020-04-21 20:19:26 +02:00
|
|
|
#include <vcl/unohelp2.hxx>
|
2020-04-17 13:20:36 +02:00
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
#include <config_feature_opencl.h>
|
2016-07-28 10:33:53 +02:00
|
|
|
#if HAVE_FEATURE_OPENCL
|
2016-07-01 20:49:19 +01:00
|
|
|
#include <opencl/openclwrapper.hxx>
|
2016-07-28 10:33:53 +02:00
|
|
|
#endif
|
2017-10-04 13:11:10 +03:00
|
|
|
#include <officecfg/Office/Calc.hxx>
|
2020-04-08 12:58:34 +02:00
|
|
|
#include <officecfg/Office/Common.hxx>
|
2011-04-04 18:02:18 +01:00
|
|
|
|
2012-07-12 15:03:51 +02:00
|
|
|
using namespace ::com::sun::star::uno;
|
2011-01-12 11:56:09 +01:00
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
AboutDialog::AboutDialog(weld::Window *pParent)
|
|
|
|
: GenericDialogController(pParent, "cui/ui/aboutdialog.ui", "AboutDialog"),
|
|
|
|
m_pCreditsButton(m_xBuilder->weld_link_button("btnCredits")),
|
|
|
|
m_pWebsiteButton(m_xBuilder->weld_link_button("btnWebsite")),
|
|
|
|
m_pReleaseNotesButton(m_xBuilder->weld_link_button("btnReleaseNotes")),
|
|
|
|
m_pCloseButton(m_xBuilder->weld_button("btnClose")),
|
2020-04-17 13:20:36 +02:00
|
|
|
m_pCopyButton(m_xBuilder->weld_button("btnCopyVersion")),
|
2020-04-08 12:58:34 +02:00
|
|
|
m_pBrandImage(m_xBuilder->weld_image("imBrand")),
|
|
|
|
m_pAboutImage(m_xBuilder->weld_image("imAbout")),
|
2020-04-29 11:39:57 +02:00
|
|
|
m_pVersionLabel(m_xBuilder->weld_label("lbVersionString")),
|
|
|
|
m_pBuildCaption(m_xBuilder->weld_label("lbBuild")),
|
|
|
|
m_pBuildLabel(m_xBuilder->weld_link_button("lbBuildString")),
|
|
|
|
m_pEnvLabel(m_xBuilder->weld_label("lbEnvString")),
|
|
|
|
m_pUILabel(m_xBuilder->weld_label("lbUIString")),
|
|
|
|
m_pLocaleLabel(m_xBuilder->weld_label("lbLocaleString")),
|
|
|
|
m_pMiscLabel(m_xBuilder->weld_label("lbMiscString")),
|
2020-04-08 12:58:34 +02:00
|
|
|
m_pCopyrightLabel(m_xBuilder->weld_label("lbCopyright")) {
|
2020-04-29 11:39:57 +02:00
|
|
|
|
|
|
|
// Labels
|
2020-04-08 12:58:34 +02:00
|
|
|
m_pVersionLabel->set_label(GetVersionString());
|
2020-04-29 11:39:57 +02:00
|
|
|
|
|
|
|
OUString sbuildId = GetBuildString();
|
|
|
|
if (IsStringValidGitHash(sbuildId)) {
|
2020-10-21 09:30:59 +02:00
|
|
|
const tools::Long nMaxChar = 25;
|
2020-05-04 21:48:17 +02:00
|
|
|
m_pBuildLabel->set_uri("https://gerrit.libreoffice.org/gitweb?p=core.git;a=log;h="
|
|
|
|
+ sbuildId);
|
|
|
|
m_pBuildLabel->set_label(sbuildId.getLength() > nMaxChar ? sbuildId.replaceAt(
|
2021-11-22 14:08:27 +02:00
|
|
|
nMaxChar, sbuildId.getLength() - nMaxChar, u"...")
|
2020-05-04 21:48:17 +02:00
|
|
|
: sbuildId);
|
2020-04-29 11:39:57 +02:00
|
|
|
} else {
|
|
|
|
m_pBuildCaption->hide();
|
|
|
|
m_pBuildLabel->hide();
|
|
|
|
}
|
|
|
|
|
2020-05-22 13:25:34 +02:00
|
|
|
m_pEnvLabel->set_label(Application::GetHWOSConfInfo(1));
|
|
|
|
m_pUILabel->set_label(Application::GetHWOSConfInfo(2));
|
2020-04-29 11:39:57 +02:00
|
|
|
m_pLocaleLabel->set_label(GetLocaleString());
|
|
|
|
m_pMiscLabel->set_label(GetMiscString());
|
2020-04-08 12:58:34 +02:00
|
|
|
m_pCopyrightLabel->set_label(GetCopyrightString());
|
|
|
|
|
2020-04-29 11:39:57 +02:00
|
|
|
// Images
|
2020-10-21 09:30:59 +02:00
|
|
|
const tools::Long nWidth(m_pCopyrightLabel->get_preferred_size().getWidth());
|
2020-04-08 12:58:34 +02:00
|
|
|
BitmapEx aBackgroundBitmap;
|
|
|
|
|
|
|
|
if (SfxApplication::loadBrandSvg(Application::GetSettings()
|
|
|
|
.GetStyleSettings()
|
|
|
|
.GetDialogColor()
|
|
|
|
.IsDark()
|
|
|
|
? "shell/logo_inverted"
|
|
|
|
: "shell/logo",
|
2020-04-29 11:39:57 +02:00
|
|
|
aBackgroundBitmap, nWidth * 0.8)) {
|
2021-04-16 20:33:10 +02:00
|
|
|
// Eliminate white background when Skia is disabled by not drawing the
|
|
|
|
// background bitmap to a VirtualDevice. On most platforms, non-Skia
|
|
|
|
// VirtualDevices will be filled with a solid color when drawing
|
|
|
|
// the bitmap.
|
|
|
|
Graphic aGraphic(aBackgroundBitmap);
|
|
|
|
m_pBrandImage->set_image(aGraphic.GetXGraphic());
|
2020-04-08 12:58:34 +02:00
|
|
|
}
|
2020-05-04 21:48:17 +02:00
|
|
|
if (SfxApplication::loadBrandSvg("shell/about", aBackgroundBitmap, nWidth * 0.9)) {
|
2021-04-16 20:33:10 +02:00
|
|
|
// Eliminate white background when Skia is disabled by not drawing the
|
|
|
|
// background bitmap to a VirtualDevice. On most platforms, non-Skia
|
|
|
|
// VirtualDevices will be filled with a solid color when drawing
|
|
|
|
// the bitmap.
|
|
|
|
Graphic aGraphic(aBackgroundBitmap);
|
|
|
|
m_pAboutImage->set_image(aGraphic.GetXGraphic());
|
2020-04-08 12:58:34 +02:00
|
|
|
}
|
|
|
|
|
2020-04-29 11:39:57 +02:00
|
|
|
// Links
|
2022-01-20 13:05:39 +01:00
|
|
|
m_pCreditsButton->set_uri(officecfg::Office::Common::Menus::CreditsURL::get());
|
2020-04-08 12:58:34 +02:00
|
|
|
|
|
|
|
OUString sURL(officecfg::Office::Common::Help::StartCenter::InfoURL::get());
|
|
|
|
localizeWebserviceURI(sURL);
|
|
|
|
m_pWebsiteButton->set_uri(sURL);
|
|
|
|
|
2020-12-22 17:22:26 +08:00
|
|
|
// See also SID_WHATSNEW in sfx2/source/appl/appserv.cxx
|
2020-04-08 12:58:34 +02:00
|
|
|
sURL = officecfg::Office::Common::Menus::ReleaseNotesURL::get() +
|
|
|
|
"?LOvers=" + utl::ConfigManager::getProductVersion() + "&LOlocale=" +
|
2020-12-22 17:22:26 +08:00
|
|
|
LanguageTag(utl::ConfigManager::getUILocale()).getBcp47();
|
2020-04-08 12:58:34 +02:00
|
|
|
m_pReleaseNotesButton->set_uri(sURL);
|
|
|
|
|
2020-04-29 11:39:57 +02:00
|
|
|
// Handler
|
2020-04-17 13:20:36 +02:00
|
|
|
m_pCopyButton->connect_clicked(LINK(this, AboutDialog, HandleClick));
|
2020-04-08 12:58:34 +02:00
|
|
|
m_pCloseButton->grab_focus();
|
2015-03-09 14:29:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
AboutDialog::~AboutDialog() {}
|
2012-04-10 12:43:48 +01:00
|
|
|
|
2022-09-27 09:37:44 +02:00
|
|
|
bool AboutDialog::IsStringValidGitHash(std::u16string_view hash) {
|
2022-11-24 22:19:39 +03:00
|
|
|
return std::all_of(hash.begin(), hash.end(),
|
|
|
|
[](auto &rSymbol) { return std::isxdigit(rSymbol); });
|
2014-11-16 01:58:54 +05:30
|
|
|
}
|
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
OUString AboutDialog::GetVersionString() {
|
2022-10-24 15:36:01 +02:00
|
|
|
OUString arch;
|
|
|
|
auto const ok = rtl::Bootstrap::get("_ARCH", arch);
|
|
|
|
assert(ok); (void) ok;
|
2022-10-25 11:34:13 +02:00
|
|
|
OUString sVersion = CuiResId(TranslateId(nullptr, "%ABOUTBOXPRODUCTVERSION%ABOUTBOXPRODUCTVERSIONSUFFIX")) + " (" + arch + ")";
|
2021-01-08 15:10:42 +01:00
|
|
|
|
|
|
|
#if HAVE_FEATURE_COMMUNITY_FLAVOR
|
|
|
|
sVersion += " / LibreOffice Community";
|
|
|
|
#endif
|
|
|
|
|
2020-04-29 11:39:57 +02:00
|
|
|
return sVersion;
|
|
|
|
}
|
2015-01-10 17:07:42 +01:00
|
|
|
|
2020-08-18 22:23:30 +03:00
|
|
|
OUString AboutDialog::GetBuildString()
|
|
|
|
{
|
|
|
|
OUString sBuildId(utl::Bootstrap::getBuildIdData(""));
|
2020-08-31 15:37:33 +02:00
|
|
|
SAL_WARN_IF(sBuildId.isEmpty(), "cui.dialogs", "No BUILDID in bootstrap file");
|
2020-04-29 11:39:57 +02:00
|
|
|
|
2020-04-30 16:32:59 +02:00
|
|
|
return sBuildId;
|
2020-04-29 11:39:57 +02:00
|
|
|
}
|
2020-04-08 12:58:34 +02:00
|
|
|
|
2020-07-30 11:20:53 +02:00
|
|
|
OUString AboutDialog::GetLocaleString(const bool bLocalized) {
|
2020-04-29 11:39:57 +02:00
|
|
|
|
2020-04-30 16:32:59 +02:00
|
|
|
OUString sLocaleStr;
|
2020-04-29 11:39:57 +02:00
|
|
|
|
|
|
|
rtl_Locale *pLocale;
|
|
|
|
osl_getProcessLocale(&pLocale);
|
|
|
|
if (pLocale && pLocale->Language) {
|
|
|
|
if (pLocale->Country && rtl_uString_getLength(pLocale->Country) > 0)
|
2020-04-30 16:32:59 +02:00
|
|
|
sLocaleStr = OUString::unacquired(&pLocale->Language) + "_" +
|
2020-04-29 11:39:57 +02:00
|
|
|
OUString::unacquired(&pLocale->Country);
|
|
|
|
else
|
2020-04-30 16:32:59 +02:00
|
|
|
sLocaleStr = OUString(pLocale->Language);
|
2020-04-29 11:39:57 +02:00
|
|
|
if (pLocale->Variant && rtl_uString_getLength(pLocale->Variant) > 0)
|
2020-04-30 16:32:59 +02:00
|
|
|
sLocaleStr += OUString(pLocale->Variant);
|
2020-04-08 12:58:34 +02:00
|
|
|
}
|
|
|
|
|
2020-04-30 16:32:59 +02:00
|
|
|
sLocaleStr = Application::GetSettings().GetLanguageTag().getBcp47() + " (" +
|
|
|
|
sLocaleStr + ")";
|
2020-04-08 12:58:34 +02:00
|
|
|
|
2020-04-29 11:39:57 +02:00
|
|
|
OUString aUILocaleStr =
|
|
|
|
Application::GetSettings().GetUILanguageTag().getBcp47();
|
2020-07-30 11:20:53 +02:00
|
|
|
OUString sUILocaleStr;
|
|
|
|
if (bLocalized)
|
2021-11-26 01:01:47 +02:00
|
|
|
sUILocaleStr = CuiResId(RID_CUISTR_ABOUT_UILOCALE);
|
2020-07-30 11:20:53 +02:00
|
|
|
else
|
2021-11-26 01:01:47 +02:00
|
|
|
sUILocaleStr = Translate::get(RID_CUISTR_ABOUT_UILOCALE, Translate::Create("cui", LanguageTag("en-US")));
|
2020-07-30 11:20:53 +02:00
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
if (sUILocaleStr.indexOf("$LOCALE") == -1) {
|
|
|
|
SAL_WARN("cui.dialogs", "translated uilocale string in translations "
|
|
|
|
"doesn't contain $LOCALE placeholder");
|
|
|
|
sUILocaleStr += " $LOCALE";
|
|
|
|
}
|
2020-04-29 11:39:57 +02:00
|
|
|
sUILocaleStr = sUILocaleStr.replaceAll("$LOCALE", aUILocaleStr);
|
|
|
|
|
|
|
|
return sLocaleStr + "; " + sUILocaleStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString AboutDialog::GetMiscString() {
|
|
|
|
|
|
|
|
OUString sMisc;
|
|
|
|
|
|
|
|
bool const extra = EXTRA_BUILDID[0] != '\0';
|
|
|
|
// extracted from the 'if' to avoid Clang -Wunreachable-code
|
|
|
|
if (extra) {
|
|
|
|
sMisc = EXTRA_BUILDID "\n";
|
|
|
|
}
|
2020-04-08 12:58:34 +02:00
|
|
|
|
2022-04-07 11:44:48 +03:00
|
|
|
OUString aCalcMode; // Calc calculation mode
|
2017-10-04 13:11:10 +03:00
|
|
|
|
|
|
|
#if HAVE_FEATURE_OPENCL
|
2022-08-26 09:52:01 +02:00
|
|
|
if (openclwrapper::GPUEnv::isOpenCLEnabled())
|
2022-04-07 11:44:48 +03:00
|
|
|
aCalcMode += " CL";
|
2016-07-28 10:33:53 +02:00
|
|
|
#endif
|
2016-07-01 20:49:19 +01:00
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
static const bool bThreadingProhibited =
|
|
|
|
std::getenv("SC_NO_THREADED_CALCULATION");
|
|
|
|
bool bThreadedCalc = officecfg::Office::Calc::Formula::Calculation::
|
|
|
|
UseThreadedCalculationForFormulaGroups::get();
|
2017-10-04 13:11:10 +03:00
|
|
|
|
2022-08-26 09:52:01 +02:00
|
|
|
if (!bThreadingProhibited && bThreadedCalc) {
|
2022-04-07 11:44:48 +03:00
|
|
|
aCalcMode += " threaded";
|
2020-04-08 12:58:34 +02:00
|
|
|
}
|
2017-10-04 13:11:10 +03:00
|
|
|
|
2021-02-12 13:54:35 +05:30
|
|
|
if (officecfg::Office::Calc::Defaults::Sheet::JumboSheets::get())
|
|
|
|
{
|
2022-04-07 11:44:48 +03:00
|
|
|
aCalcMode += " Jumbo";
|
2021-02-12 13:54:35 +05:30
|
|
|
}
|
2022-04-07 11:44:48 +03:00
|
|
|
|
|
|
|
if (aCalcMode.isEmpty())
|
|
|
|
aCalcMode = " default";
|
|
|
|
sMisc += "Calc:" + aCalcMode;
|
2017-10-04 13:11:10 +03:00
|
|
|
|
2020-04-29 11:39:57 +02:00
|
|
|
return sMisc;
|
2012-04-10 12:43:48 +01:00
|
|
|
}
|
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
OUString AboutDialog::GetCopyrightString() {
|
2021-11-26 01:01:47 +02:00
|
|
|
OUString sVendorTextStr(CuiResId(RID_CUISTR_ABOUT_VENDOR));
|
2020-04-08 12:58:34 +02:00
|
|
|
OUString aCopyrightString =
|
2021-11-26 01:01:47 +02:00
|
|
|
sVendorTextStr + "\n" + CuiResId(RID_CUISTR_ABOUT_COPYRIGHT) + "\n";
|
2012-04-10 12:43:48 +01:00
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
if (utl::ConfigManager::getProductName() == "LibreOffice")
|
2021-11-26 01:01:47 +02:00
|
|
|
aCopyrightString += CuiResId(RID_CUISTR_ABOUT_BASED_ON);
|
2020-04-08 12:58:34 +02:00
|
|
|
else
|
2021-11-26 01:01:47 +02:00
|
|
|
aCopyrightString += CuiResId(RID_CUISTR_ABOUT_DERIVED);
|
2012-04-10 12:43:48 +01:00
|
|
|
|
2020-04-08 12:58:34 +02:00
|
|
|
return aCopyrightString;
|
2012-04-10 12:43:48 +01:00
|
|
|
}
|
|
|
|
|
2020-07-30 11:20:53 +02:00
|
|
|
// special labels to comply with previous version info
|
|
|
|
// untranslated English for QA
|
2020-04-17 13:20:36 +02:00
|
|
|
IMPL_LINK_NOARG(AboutDialog, HandleClick, weld::Button &, void) {
|
|
|
|
css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
|
|
|
|
css::datatransfer::clipboard::SystemClipboard::create(
|
|
|
|
comphelper::getProcessComponentContext());
|
2020-04-29 11:39:57 +02:00
|
|
|
|
2020-07-10 13:43:04 +02:00
|
|
|
OUString sInfo = "Version: " + m_pVersionLabel->get_label() + "\n" // version
|
|
|
|
"Build ID: " + GetBuildString() + "\n" + // build id
|
|
|
|
Application::GetHWOSConfInfo(0,false) + "\n" // env+UI
|
2020-07-30 11:20:53 +02:00
|
|
|
"Locale: " + GetLocaleString(false) + "\n" + // locale
|
|
|
|
GetMiscString(); // misc
|
2020-04-29 11:39:57 +02:00
|
|
|
|
|
|
|
vcl::unohelper::TextDataObject::CopyStringTo(sInfo, xClipboard);
|
2020-04-17 13:20:36 +02:00
|
|
|
}
|
2020-08-18 09:43:04 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|