LibreOffice Module cui (master) 1
about.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <about.hxx>
21
22#include <osl/process.h> //osl_getProcessLocale
23#include <sal/log.hxx> //SAL_WARN
24#include <vcl/settings.hxx> //GetSettings
25#include <vcl/svapp.hxx> //Application::
26#include <vcl/virdev.hxx> //VirtualDevice
27#include <vcl/weld.hxx>
28#include <unotools/resmgr.hxx> //Translate
29
30#include <config_buildid.h> //EXTRA_BUILDID
31#include <config_features.h>
32#include <dialmgr.hxx> //CuiResId
34#include <sfx2/app.hxx> //SfxApplication::loadBrandSvg
35#include <strings.hrc>
36#include <svtools/langhelp.hxx>
37#include <unotools/bootstrap.hxx> //utl::Bootstrap::getBuildIdData
38#include <unotools/configmgr.hxx> //ConfigManager::
39
40#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
41#include <vcl/unohelp2.hxx>
42
43#include <config_feature_opencl.h>
44#if HAVE_FEATURE_OPENCL
46#endif
47#include <officecfg/Office/Calc.hxx>
48#include <officecfg/Office/Common.hxx>
49
50using namespace ::com::sun::star::uno;
51
53 : GenericDialogController(pParent, "cui/ui/aboutdialog.ui", "AboutDialog"),
54 m_pCreditsButton(m_xBuilder->weld_link_button("btnCredits")),
55 m_pWebsiteButton(m_xBuilder->weld_link_button("btnWebsite")),
56 m_pReleaseNotesButton(m_xBuilder->weld_link_button("btnReleaseNotes")),
57 m_pCloseButton(m_xBuilder->weld_button("btnClose")),
58 m_pCopyButton(m_xBuilder->weld_button("btnCopyVersion")),
59 m_pBrandImage(m_xBuilder->weld_image("imBrand")),
60 m_pAboutImage(m_xBuilder->weld_image("imAbout")),
61 m_pVersionLabel(m_xBuilder->weld_label("lbVersionString")),
62 m_pBuildCaption(m_xBuilder->weld_label("lbBuild")),
63 m_pBuildLabel(m_xBuilder->weld_link_button("lbBuildString")),
64 m_pEnvLabel(m_xBuilder->weld_label("lbEnvString")),
65 m_pUILabel(m_xBuilder->weld_label("lbUIString")),
66 m_pLocaleLabel(m_xBuilder->weld_label("lbLocaleString")),
67 m_pMiscLabel(m_xBuilder->weld_label("lbMiscString")),
68 m_pCopyrightLabel(m_xBuilder->weld_label("lbCopyright")) {
69
70 // Labels
72
73 OUString sbuildId = GetBuildString();
74 if (IsStringValidGitHash(sbuildId)) {
75 const tools::Long nMaxChar = 25;
76 m_pBuildLabel->set_uri("https://gerrit.libreoffice.org/gitweb?p=core.git;a=log;h="
77 + sbuildId);
78 m_pBuildLabel->set_label(sbuildId.getLength() > nMaxChar ? sbuildId.replaceAt(
79 nMaxChar, sbuildId.getLength() - nMaxChar, u"...")
80 : sbuildId);
81 } else {
82 m_pBuildCaption->hide();
83 m_pBuildLabel->hide();
84 }
85
88 m_pLocaleLabel->set_label(GetLocaleString());
89 m_pMiscLabel->set_label(GetMiscString());
91
92 // Images
93 const tools::Long nWidth(m_pCopyrightLabel->get_preferred_size().getWidth());
94 BitmapEx aBackgroundBitmap;
95
97 .GetStyleSettings()
98 .GetDialogColor()
99 .IsDark()
100 ? "shell/logo_inverted"
101 : "shell/logo",
102 aBackgroundBitmap, nWidth * 0.8)) {
104 m_pBrandImage->create_virtual_device();
105 m_pVirDev->SetOutputSizePixel(aBackgroundBitmap.GetSizePixel());
106 m_pVirDev->DrawBitmapEx(Point(0, 0), aBackgroundBitmap);
107 m_pBrandImage->set_image(m_pVirDev.get());
108 m_pVirDev.disposeAndClear();
109 }
110 if (SfxApplication::loadBrandSvg("shell/about", aBackgroundBitmap, nWidth * 0.9)) {
112 m_pAboutImage->create_virtual_device();
113 m_pVirDev->SetOutputSizePixel(aBackgroundBitmap.GetSizePixel());
114 m_pVirDev->DrawBitmapEx(Point(0, 0), aBackgroundBitmap);
115 m_pAboutImage->set_image(m_pVirDev.get());
116 m_pVirDev.disposeAndClear();
117 }
118
119 // Links
120 m_pCreditsButton->set_uri(officecfg::Office::Common::Menus::CreditsURL::get());
121
122 OUString sURL(officecfg::Office::Common::Help::StartCenter::InfoURL::get());
124 m_pWebsiteButton->set_uri(sURL);
125
126 // See also SID_WHATSNEW in sfx2/source/appl/appserv.cxx
127 sURL = officecfg::Office::Common::Menus::ReleaseNotesURL::get() +
128 "?LOvers=" + utl::ConfigManager::getProductVersion() + "&LOlocale=" +
130 m_pReleaseNotesButton->set_uri(sURL);
131
132 // Handler
133 m_pCopyButton->connect_clicked(LINK(this, AboutDialog, HandleClick));
134 m_pCloseButton->grab_focus();
135}
136
138
139bool AboutDialog::IsStringValidGitHash(const OUString &hash) {
140 for (int i = 0; i < hash.getLength(); i++) {
141 if (!std::isxdigit(hash[i])) {
142 return false;
143 }
144 }
145 return true;
146}
147
149 OUString sVersion = CuiResId(TranslateId(nullptr, "%ABOUTBOXPRODUCTVERSION%ABOUTBOXPRODUCTVERSIONSUFFIX"));
150
151#ifdef _WIN64
152 sVersion += " (x64)";
153#elif defined(_WIN32)
154 sVersion += " (x86)";
155#endif
156
157#if HAVE_FEATURE_COMMUNITY_FLAVOR
158 sVersion += " / LibreOffice Community";
159#endif
160
161 return sVersion;
162}
163
165{
166 OUString sBuildId(utl::Bootstrap::getBuildIdData(""));
167 SAL_WARN_IF(sBuildId.isEmpty(), "cui.dialogs", "No BUILDID in bootstrap file");
168
169 return sBuildId;
170}
171
172OUString AboutDialog::GetLocaleString(const bool bLocalized) {
173
174 OUString sLocaleStr;
175
176 rtl_Locale *pLocale;
177 osl_getProcessLocale(&pLocale);
178 if (pLocale && pLocale->Language) {
179 if (pLocale->Country && rtl_uString_getLength(pLocale->Country) > 0)
180 sLocaleStr = OUString::unacquired(&pLocale->Language) + "_" +
181 OUString::unacquired(&pLocale->Country);
182 else
183 sLocaleStr = OUString(pLocale->Language);
184 if (pLocale->Variant && rtl_uString_getLength(pLocale->Variant) > 0)
185 sLocaleStr += OUString(pLocale->Variant);
186 }
187
188 sLocaleStr = Application::GetSettings().GetLanguageTag().getBcp47() + " (" +
189 sLocaleStr + ")";
190
191 OUString aUILocaleStr =
193 OUString sUILocaleStr;
194 if (bLocalized)
195 sUILocaleStr = CuiResId(RID_CUISTR_ABOUT_UILOCALE);
196 else
197 sUILocaleStr = Translate::get(RID_CUISTR_ABOUT_UILOCALE, Translate::Create("cui", LanguageTag("en-US")));
198
199 if (sUILocaleStr.indexOf("$LOCALE") == -1) {
200 SAL_WARN("cui.dialogs", "translated uilocale string in translations "
201 "doesn't contain $LOCALE placeholder");
202 sUILocaleStr += " $LOCALE";
203 }
204 sUILocaleStr = sUILocaleStr.replaceAll("$LOCALE", aUILocaleStr);
205
206 return sLocaleStr + "; " + sUILocaleStr;
207}
208
210
211 OUString sMisc;
212
213 bool const extra = EXTRA_BUILDID[0] != '\0';
214 // extracted from the 'if' to avoid Clang -Wunreachable-code
215 if (extra) {
216 sMisc = EXTRA_BUILDID "\n";
217 }
218
219 OUString aCalcMode; // Calc calculation mode
220
221#if HAVE_FEATURE_OPENCL
223 aCalcMode += " CL";
224#endif
225
226 static const bool bThreadingProhibited =
227 std::getenv("SC_NO_THREADED_CALCULATION");
228 bool bThreadedCalc = officecfg::Office::Calc::Formula::Calculation::
229 UseThreadedCalculationForFormulaGroups::get();
230
231 if (!bThreadingProhibited && bThreadedCalc) {
232 aCalcMode += " threaded";
233 }
234
235 if (officecfg::Office::Calc::Defaults::Sheet::JumboSheets::get())
236 {
237 aCalcMode += " Jumbo";
238 }
239
240 if (aCalcMode.isEmpty())
241 aCalcMode = " default";
242 sMisc += "Calc:" + aCalcMode;
243
244 return sMisc;
245}
246
248 OUString sVendorTextStr(CuiResId(RID_CUISTR_ABOUT_VENDOR));
249 OUString aCopyrightString =
250 sVendorTextStr + "\n" + CuiResId(RID_CUISTR_ABOUT_COPYRIGHT) + "\n";
251
252 if (utl::ConfigManager::getProductName() == "LibreOffice")
253 aCopyrightString += CuiResId(RID_CUISTR_ABOUT_BASED_ON);
254 else
255 aCopyrightString += CuiResId(RID_CUISTR_ABOUT_DERIVED);
256
257 return aCopyrightString;
258}
259
260// special labels to comply with previous version info
261// untranslated English for QA
263 css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
264 css::datatransfer::clipboard::SystemClipboard::create(
266
267 OUString sInfo = "Version: " + m_pVersionLabel->get_label() + "\n" // version
268 "Build ID: " + GetBuildString() + "\n" + // build id
269 Application::GetHWOSConfInfo(0,false) + "\n" // env+UI
270 "Locale: " + GetLocaleString(false) + "\n" + // locale
271 GetMiscString(); // misc
272
274}
275/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPL_LINK_NOARG(AboutDialog, HandleClick, weld::Button &, void)
Definition: about.cxx:262
static bool IsStringValidGitHash(const OUString &hash)
Definition: about.cxx:139
std::unique_ptr< weld::Label > m_pBuildCaption
Definition: about.hxx:35
std::unique_ptr< weld::Button > m_pCopyButton
Definition: about.hxx:30
std::unique_ptr< weld::Image > m_pAboutImage
Definition: about.hxx:33
std::unique_ptr< weld::Label > m_pMiscLabel
Definition: about.hxx:40
virtual ~AboutDialog() override
Definition: about.cxx:137
static OUString GetCopyrightString()
Definition: about.cxx:247
static OUString GetLocaleString(bool bLocalized=true)
Definition: about.cxx:172
std::unique_ptr< weld::Label > m_pVersionLabel
Definition: about.hxx:34
std::unique_ptr< weld::Button > m_pCloseButton
Definition: about.hxx:29
std::unique_ptr< weld::Image > m_pBrandImage
Definition: about.hxx:32
std::unique_ptr< weld::LinkButton > m_pBuildLabel
Definition: about.hxx:36
std::unique_ptr< weld::Label > m_pCopyrightLabel
Definition: about.hxx:41
std::unique_ptr< weld::Label > m_pEnvLabel
Definition: about.hxx:37
std::unique_ptr< weld::Label > m_pLocaleLabel
Definition: about.hxx:39
std::unique_ptr< weld::LinkButton > m_pCreditsButton
Definition: about.hxx:26
std::unique_ptr< weld::LinkButton > m_pReleaseNotesButton
Definition: about.hxx:28
std::unique_ptr< weld::LinkButton > m_pWebsiteButton
Definition: about.hxx:27
static OUString GetBuildString()
Definition: about.cxx:164
static OUString GetVersionString()
Definition: about.cxx:148
AboutDialog(weld::Window *pParent)
Definition: about.cxx:52
std::unique_ptr< weld::Label > m_pUILabel
Definition: about.hxx:38
static OUString GetMiscString()
Definition: about.cxx:209
const LanguageTag & GetLanguageTag() const
const LanguageTag & GetUILanguageTag() const
static OUString GetHWOSConfInfo(const int bSelection=0, bool bLocalize=true)
static const AllSettings & GetSettings()
const Size & GetSizePixel() const
const OUString & getBcp47(bool bResolveSystem=true) const
static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth)
void disposeAndClear()
reference_type * get() const
static OUString getBuildIdData(OUString const &_sDefault)
static OUString getProductVersion()
static OUString getUILocale()
static OUString getProductName()
static void CopyStringTo(const OUString &rContent, const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rxClipboard, const vcl::ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
float u
SVT_DLLPUBLIC void localizeWebserviceURI(OUString &io_rURI)
const char * pLocale
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
OUString get(TranslateId sContextAndId, const std::locale &loc)
Reference< XComponentContext > getProcessComponentContext()
int i
long Long
static bool isOpenCLEnabled()