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
19#include <com/sun/star/task/OfficeRestartManager.hpp>
20#include <com/sun/star/task/XInteractionHandler.hpp>
21
23 : GenericDialogController(pParent, "svx/ui/crashreportdlg.ui", "CrashReportDialog")
24 , mxBtnSend(m_xBuilder->weld_button("btn_send"))
25 , mxBtnCancel(m_xBuilder->weld_button("btn_cancel"))
26 , mxBtnClose(m_xBuilder->weld_button("btn_close"))
27 , mxEditPreUpload(m_xBuilder->weld_label("ed_pre"))
28 , mxEditPostUpload(m_xBuilder->weld_text_view("ed_post"))
29 , mxFtBugReport(m_xBuilder->weld_text_view("ed_bugreport"))
30 , mxCBSafeMode(m_xBuilder->weld_check_button("check_safemode"))
31 , mxPrivacyPolicyButton(m_xBuilder->weld_link_button("btnPrivacyPolicy"))
32{
33 maSuccessMsg = mxEditPostUpload->get_text();
34
35 auto nWidth = mxEditPreUpload->get_preferred_size().Width();
36 nWidth = std::max(nWidth, mxCBSafeMode->get_size_request().Width());
37 mxEditPreUpload->set_size_request(nWidth, -1);
38 mxCBSafeMode->set_size_request(nWidth, -1);
39
40 mxBtnSend->connect_clicked(LINK(this, CrashReportDialog, BtnHdl));
41 mxBtnCancel->connect_clicked(LINK(this, CrashReportDialog, BtnHdl));
42 mxBtnClose->connect_clicked(LINK(this, CrashReportDialog, BtnHdl));
43
44 mxPrivacyPolicyButton->set_uri(
45 officecfg::Office::Common::Menus::PrivacyPolicyURL::get()
46 + "?type=crashreport&LOvers=" + utl::ConfigManager::getProductVersion()
47 + "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getBcp47());
48}
49
51
53{
54 short nRet = GenericDialogController::run();
55
56 // Check whether to go to safe mode
57 if (mxCBSafeMode->get_active())
58 {
60 css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext())
61 ->requestRestart(css::uno::Reference<css::task::XInteractionHandler>());
62 }
63 return nRet;
64}
65
67{
68 if (&rBtn == mxBtnSend.get())
69 {
70 std::string response;
71 bool bSuccess = CrashReporter::readSendConfig(response);
72
73 OUString aCrashID = OUString::createFromAscii(response.c_str());
74
75 if (bSuccess)
76 {
77 OUString aProcessedMessage
78 = maSuccessMsg.replaceAll("%CRASHID", aCrashID.replaceAll("Crash-ID=", ""));
79
80 // vclbuilder seems to replace _ with ~ even in text
81 mxEditPostUpload->set_text(aProcessedMessage.replaceAll("~", "_"));
82 }
83 else
84 {
85 mxEditPostUpload->set_text(aCrashID);
86 }
87
88 mxBtnClose->show();
89 mxFtBugReport->show();
90 mxEditPostUpload->show();
91 mxBtnSend->set_sensitive(false);
92 mxBtnCancel->set_sensitive(false);
93 mxBtnClose->grab_focus();
94
95 mxEditPreUpload->hide();
96 mxBtnSend->hide();
97 mxBtnCancel->hide();
98
99 m_xDialog->resize_to_request();
100 }
101 else if (&rBtn == mxBtnCancel.get())
102 {
103 m_xDialog->response(RET_CLOSE);
104 }
105 else if (&rBtn == mxBtnClose.get())
106 {
107 m_xDialog->response(RET_CLOSE);
108 }
109}
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
virtual ~CrashReportDialog() override
std::unique_ptr< weld::TextView > mxEditPostUpload
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()
IMPL_LINK(CrashReportDialog, BtnHdl, weld::Button &, rBtn, void)
Reference< XComponentContext > getProcessComponentContext()
RET_CLOSE