LibreOffice Module svx (master) 1
crashreportdlg.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
10#include "crashreportdlg.hxx"
11
13#include <sfx2/safemode.hxx>
17#include <officecfg/Office/Common.hxx>
18#include <vcl/svapp.hxx>
19
20#include <com/sun/star/task/OfficeRestartManager.hpp>
21#include <com/sun/star/task/XInteractionHandler.hpp>
22
23IMPL_STATIC_LINK_NOARG(CrashReportDialog, InstallLOKNotifierHdl, void*,
25{
26 return GetpApp();
27}
28
30 : GenericDialogController(pParent, "svx/ui/crashreportdlg.ui", "CrashReportDialog")
31 , mxBtnSend(m_xBuilder->weld_button("btn_send"))
32 , mxBtnCancel(m_xBuilder->weld_button("btn_cancel"))
33 , mxBtnClose(m_xBuilder->weld_button("btn_close"))
34 , mxEditPreUpload(m_xBuilder->weld_label("ed_pre"))
35 , mxEditPostUpload(m_xBuilder->weld_label("ed_post"))
36 , mxLinkButton(m_xBuilder->weld_link_button("linkbutton"))
37 , mxFtBugReport(m_xBuilder->weld_label("ed_bugreport"))
38 , mxCBSafeMode(m_xBuilder->weld_check_button("check_safemode"))
39 , mxPrivacyPolicyButton(m_xBuilder->weld_link_button("btnPrivacyPolicy"))
40{
41 maLinkTemplate = mxLinkButton->get_uri();
42
43 auto nWidth = mxEditPreUpload->get_preferred_size().Width();
44 nWidth = std::max(nWidth, mxCBSafeMode->get_size_request().Width());
45 mxEditPreUpload->set_size_request(nWidth, -1);
46 mxCBSafeMode->set_size_request(nWidth, -1);
47
48 mxBtnSend->connect_clicked(LINK(this, CrashReportDialog, BtnHdl));
49 mxBtnCancel->connect_clicked(LINK(this, CrashReportDialog, BtnHdl));
50 mxBtnClose->connect_clicked(LINK(this, CrashReportDialog, BtnHdl));
51
52 mxPrivacyPolicyButton->set_uri(
53 officecfg::Office::Common::Menus::PrivacyPolicyURL::get()
54 + "?type=crashreport&LOvers=" + utl::ConfigManager::getProductVersion()
55 + "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getBcp47());
56
57 m_xDialog->SetInstallLOKNotifierHdl(LINK(this, CrashReportDialog, InstallLOKNotifierHdl));
58}
59
61
63{
64 short nRet = GenericDialogController::run();
65
66 // Check whether to go to safe mode
67 if (mxCBSafeMode->get_active())
68 {
70 css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext())
71 ->requestRestart(css::uno::Reference<css::task::XInteractionHandler>());
72 }
73 return nRet;
74}
75
77{
78 if (&rBtn == mxBtnSend.get())
79 {
80 std::string response;
81 bool bSuccess = CrashReporter::readSendConfig(response);
82
83 OUString aCrashID = OUString::createFromAscii(response);
84
85 if (bSuccess)
86 {
87 OUString aProcessedLink
88 = maLinkTemplate.replaceAll("%CRASHID", aCrashID.replaceAll("Crash-ID=", ""));
89
90 // vclbuilder seems to replace _ with ~ even in text
91 mxLinkButton->set_label(aProcessedLink.replaceAll("~", "_"));
92 mxLinkButton->set_uri(aProcessedLink);
93 }
94 else
95 {
96 mxEditPostUpload->set_label(aCrashID);
97 }
98
99 mxLinkButton->set_visible(bSuccess);
100
101 mxBtnClose->show();
102 mxFtBugReport->show();
103 mxEditPostUpload->show();
104 mxBtnSend->set_sensitive(false);
105 mxBtnCancel->set_sensitive(false);
106 mxBtnClose->grab_focus();
107
108 mxEditPreUpload->hide();
109 mxBtnSend->hide();
110 mxBtnCancel->hide();
111
112 m_xDialog->resize_to_request();
113 }
114 else if (&rBtn == mxBtnCancel.get())
115 {
116 m_xDialog->response(RET_CLOSE);
117 }
118 else if (&rBtn == mxBtnClose.get())
119 {
120 m_xDialog->response(RET_CLOSE);
121 }
122}
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< weld::LinkButton > mxLinkButton
virtual ~CrashReportDialog() override
std::unique_ptr< weld::Button > mxBtnClose
std::unique_ptr< weld::LinkButton > mxPrivacyPolicyButton
std::unique_ptr< weld::CheckButton > mxCBSafeMode
std::unique_ptr< weld::Button > mxBtnCancel
std::unique_ptr< weld::Button > mxBtnSend
std::unique_ptr< weld::Label > mxEditPreUpload
virtual short run() override
CrashReportDialog(weld::Window *pParent)
static bool putFlag()
static OUString getProductVersion()
static OUString getUILocale()
std::shared_ptr< weld::Dialog > m_xDialog
IMPL_STATIC_LINK_NOARG(CrashReportDialog, InstallLOKNotifierHdl, void *, vcl::ILibreOfficeKitNotifier *)
IMPL_LINK(CrashReportDialog, BtnHdl, weld::Button &, rBtn, void)
Reference< XComponentContext > getProcessComponentContext()
VCL_DLLPUBLIC Application * GetpApp()
RET_CLOSE