tdf#107471 Add checkbox to enable/disable sending crash reports to TDF

Also hide it when compiled with --disable-breakpad i.e. most Linux distributions

Change-Id: I5d392e22410614550aa9602d0c30b0b81ec22ea0
Reviewed-on: https://gerrit.libreoffice.org/76771
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 63ad892a..4a2fc69 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -263,6 +263,7 @@ OfaMiscTabPage::OfaMiscTabPage(TabPageParent pParent, const SfxItemSet& rSet)
    , m_xYearValueField(m_xBuilder->weld_spin_button("year"))
    , m_xToYearFT(m_xBuilder->weld_label("toyear"))
    , m_xCollectUsageInfo(m_xBuilder->weld_check_button("collectusageinfo"))
    , m_xCrashReport(m_xBuilder->weld_check_button("crashreport"))
    , m_xQuickStarterFrame(m_xBuilder->weld_widget("quickstarter"))
#if defined(UNX)
    , m_xQuickLaunchCB(m_xBuilder->weld_check_button("systray"))
@@ -362,6 +363,14 @@ bool OfaMiscTabPage::FillItemSet( SfxItemSet* rSet )
        bModified = true;
    }

#if HAVE_FEATURE_BREAKPAD
    if (m_xCrashReport->get_state_changed_from_saved())
    {
        officecfg::Office::Common::Misc::CrashReport::set(m_xCrashReport->get_active(), batch);
        bModified = true;
    }
#endif

    batch->commit();

    if( m_xQuickLaunchCB->get_state_changed_from_saved())
@@ -405,6 +414,14 @@ void OfaMiscTabPage::Reset( const SfxItemSet* rSet )
    m_xCollectUsageInfo->set_sensitive(!officecfg::Office::Common::Misc::CollectUsageInformation::isReadOnly());
    m_xCollectUsageInfo->save_state();

#if HAVE_FEATURE_BREAKPAD
    m_xCrashReport->set_active(officecfg::Office::Common::Misc::CrashReport::get());
    m_xCrashReport->set_sensitive(!officecfg::Office::Common::Misc::CrashReport::isReadOnly());
    m_xCrashReport->save_state();
#else
    m_xCrashReport->hide();
#endif

    SfxItemState eState = rSet->GetItemState( SID_ATTR_QUICKLAUNCHER, false, &pItem );
    if ( SfxItemState::SET == eState )
        m_xQuickLaunchCB->set_active( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx
index 2200a29..319d0ac 100644
--- a/cui/source/options/optgdlg.hxx
+++ b/cui/source/options/optgdlg.hxx
@@ -56,6 +56,7 @@ private:
    std::unique_ptr<weld::SpinButton> m_xYearValueField;
    std::unique_ptr<weld::Label> m_xToYearFT;
    std::unique_ptr<weld::CheckButton> m_xCollectUsageInfo;
    std::unique_ptr<weld::CheckButton> m_xCrashReport;
    std::unique_ptr<weld::Widget> m_xQuickStarterFrame;
    std::unique_ptr<weld::CheckButton> m_xQuickLaunchCB;

diff --git a/cui/uiconfig/ui/optgeneralpage.ui b/cui/uiconfig/ui/optgeneralpage.ui
index 9a87396..2e8d70a 100644
--- a/cui/uiconfig/ui/optgeneralpage.ui
+++ b/cui/uiconfig/ui/optgeneralpage.ui
@@ -63,7 +63,6 @@
                  <object class="GtkCheckButton" id="cbShowTipOfTheDay">
                    <property name="label" translatable="yes" context="optgeneralpage|TipOfTheDayCheckbox">Show "Tip of the Day" dialog on start-up</property>
                    <property name="visible">True</property>
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="receives_default">False</property>
                    <property name="active">True</property>
@@ -328,14 +327,41 @@
            <property name="top_padding">6</property>
            <property name="left_padding">12</property>
            <child>
              <object class="GtkCheckButton" id="collectusageinfo">
                <property name="label" translatable="yes" context="optgeneralpage|collectusageinfo">Collect usage data and send it to The Document Foundation</property>
              <object class="GtkGrid">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">False</property>
                <property name="use_underline">True</property>
                <property name="xalign">0</property>
                <property name="draw_indicator">True</property>
                <property name="can_focus">False</property>
                <child>
                  <object class="GtkCheckButton" id="collectusageinfo">
                    <property name="label" translatable="yes" context="optgeneralpage|collectusageinfo">Collect usage data and send it to The Document Foundation</property>
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="receives_default">False</property>
                    <property name="margin_top">1</property>
                    <property name="use_underline">True</property>
                    <property name="xalign">0</property>
                    <property name="draw_indicator">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkCheckButton" id="crashreport">
                    <property name="label" translatable="yes" context="optgeneralpage|crashreport">Sen_d crash reports to The Document Foundation</property>
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="receives_default">False</property>
                    <property name="halign">start</property>
                    <property name="use_underline">True</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">1</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 4feef4a..380e21f 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2005,7 +2005,7 @@ void Desktop::OpenClients()
#endif

#if HAVE_FEATURE_BREAKPAD
    if (crashReportInfoExists())
    if (officecfg::Office::Common::Misc::CrashReport::get() && crashReportInfoExists())
        handleCrashReport();
#endif

diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index b389379..d216c02 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5471,6 +5471,13 @@
        </info>
        <value>false</value>
      </prop>
      <prop oor:name="CrashReport" oor:type="xs:boolean" oor:nillable="false">
        <!-- UIHints: Tools - Options - General -->
        <info>
          <desc>Enable sending crash reports to The Document Foundation</desc>
        </info>
        <value>true</value>
      </prop>
      <prop oor:name="ShowTipOfTheDay" oor:type="xs:boolean" oor:nillable="false">
        <!-- UIHints: Tools - Options - General -->
        <info>