tdf#157702 - UI: Part 2 - Unify lockdown behavior of Options dialog

for General Page.

Change-Id: Ide7c387d1b9f8ebba7f7801cdd69b1e1a93f90e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158196
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index c8a569a..f0e2cf26 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -160,35 +160,36 @@ bool lcl_HasSystemFilePicker()
OfaMiscTabPage::OfaMiscTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
    : SfxTabPage(pPage, pController, "cui/ui/optgeneralpage.ui", "OptGeneralPage", &rSet)
    , m_xExtHelpCB(m_xBuilder->weld_check_button("exthelp"))
    , m_xExtHelpImg(m_xBuilder->weld_widget("lockexthelp"))
    , m_xPopUpNoHelpCB(m_xBuilder->weld_check_button("popupnohelp"))
    , m_xPopUpNoHelpImg(m_xBuilder->weld_widget("lockpopupnohelp"))
    , m_xShowTipOfTheDay(m_xBuilder->weld_check_button("cbShowTipOfTheDay"))
    , m_xShowTipOfTheDayImg(m_xBuilder->weld_widget("lockcbShowTipOfTheDay"))
    , m_xFileDlgFrame(m_xBuilder->weld_widget("filedlgframe"))
    , m_xFileDlgROImage(m_xBuilder->weld_widget("lockimage"))
    , m_xFileDlgCB(m_xBuilder->weld_check_button("filedlg"))
    , m_xDocStatusCB(m_xBuilder->weld_check_button("docstatus"))
    , m_xDocStatusImg(m_xBuilder->weld_widget("lockdocstatus"))
    , m_xYearFrame(m_xBuilder->weld_widget("yearframe"))
    , m_xYearLabel(m_xBuilder->weld_label("yearslabel"))
    , m_xYearValueField(m_xBuilder->weld_spin_button("year"))
    , m_xToYearFT(m_xBuilder->weld_label("toyear"))
    , m_xYearFrameImg(m_xBuilder->weld_widget("lockyears"))
#if HAVE_FEATURE_BREAKPAD
    , m_xPrivacyFrame(m_xBuilder->weld_widget("privacyframe"))
    , m_xCrashReport(m_xBuilder->weld_check_button("crashreport"))
    , m_xCrashReportImg(m_xBuilder->weld_widget("lockcrashreport"))
#endif
#if defined(_WIN32)
    , m_xQuickStarterFrame(m_xBuilder->weld_widget("quickstarter"))
    , m_xQuickLaunchCB(m_xBuilder->weld_check_button("quicklaunch"))
    , m_xQuickLaunchImg(m_xBuilder->weld_widget("lockquicklaunch"))
    , m_xFileAssocFrame(m_xBuilder->weld_widget("fileassoc"))
    , m_xFileAssocBtn(m_xBuilder->weld_button("assocfiles"))
    , m_xPerformFileExtCheck(m_xBuilder->weld_check_button("cbPerformFileExtCheck"))
    , m_xPerformFileExtImg(m_xBuilder->weld_widget("lockcbPerformFileExtCheck"))
#endif
{
    if (!lcl_HasSystemFilePicker())
        m_xFileDlgFrame->hide();
    else if (officecfg::Office::Common::Misc::UseSystemFileDialog::isReadOnly())
    {
        m_xFileDlgROImage->show();
        m_xFileDlgCB->set_sensitive(false);
    }

#if HAVE_FEATURE_BREAKPAD
    m_xPrivacyFrame->show();
#endif
@@ -221,7 +222,7 @@ std::unique_ptr<SfxTabPage> OfaMiscTabPage::Create( weld::Container* pPage, weld
OUString OfaMiscTabPage::GetAllStrings()
{
    OUString sAllStrings;
    OUString labels[] = { "label1", "label2", "label4", "label5", "label6",
    OUString labels[] = { "label1", "label2", "label4", "label5", "yearslabel",
                          "toyear", "label7", "label8", "label9" };

    for (const auto& label : labels)
@@ -313,19 +314,48 @@ bool OfaMiscTabPage::FillItemSet( SfxItemSet* rSet )

void OfaMiscTabPage::Reset( const SfxItemSet* rSet )
{
    bool bEnable = !officecfg::Office::Common::Help::ExtendedTip::isReadOnly();
    m_xExtHelpCB->set_active( officecfg::Office::Common::Help::Tip::get() &&
            officecfg::Office::Common::Help::ExtendedTip::get() );
    m_xExtHelpCB->set_sensitive(bEnable);
    m_xExtHelpImg->set_visible(!bEnable);
    m_xExtHelpCB->save_state();

    bEnable = !officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::isReadOnly();
    m_xPopUpNoHelpCB->set_active( officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::get() );
    m_xPopUpNoHelpCB->set_sensitive(bEnable);
    m_xPopUpNoHelpImg->set_visible(!bEnable);
    m_xPopUpNoHelpCB->save_state();

    bEnable = !officecfg::Office::Common::Misc::ShowTipOfTheDay::isReadOnly();
    m_xShowTipOfTheDay->set_active( officecfg::Office::Common::Misc::ShowTipOfTheDay::get() );
    m_xShowTipOfTheDay->set_sensitive(bEnable);
    m_xShowTipOfTheDayImg->set_visible(!bEnable);
    m_xShowTipOfTheDay->save_state();
    m_xFileDlgCB->set_active( !officecfg::Office::Common::Misc::UseSystemFileDialog::get() );

    if (!lcl_HasSystemFilePicker())
        m_xFileDlgFrame->hide();
    else
    {
        bEnable = !officecfg::Office::Common::Misc::UseSystemFileDialog::isReadOnly();
        m_xFileDlgCB->set_sensitive(bEnable);
        m_xFileDlgROImage->set_visible(!bEnable);
    }
    m_xFileDlgCB->set_active(!officecfg::Office::Common::Misc::UseSystemFileDialog::get());
    m_xFileDlgCB->save_state();

    bEnable = !officecfg::Office::Common::Print::PrintingModifiesDocument::isReadOnly();
    m_xDocStatusCB->set_active(officecfg::Office::Common::Print::PrintingModifiesDocument::get());
    m_xDocStatusCB->set_sensitive(bEnable);
    m_xDocStatusImg->set_visible(!bEnable);
    m_xDocStatusCB->save_state();

    bEnable = !officecfg::Office::Common::DateFormat::TwoDigitYear::isReadOnly();
    m_xYearLabel->set_sensitive(bEnable);
    m_xYearValueField->set_sensitive(bEnable);
    m_xToYearFT->set_sensitive(bEnable);
    m_xYearFrameImg->set_visible(!bEnable);

    if ( const SfxUInt16Item* pYearItem = rSet->GetItemIfSet( SID_ATTR_YEAR2000, false ) )
    {
        m_xYearValueField->set_value( pYearItem->GetValue() );
@@ -337,6 +367,7 @@ void OfaMiscTabPage::Reset( const SfxItemSet* rSet )
#if HAVE_FEATURE_BREAKPAD
    m_xCrashReport->set_active(officecfg::Office::Common::Misc::CrashReport::get() && CrashReporter::IsDumpEnable());
    m_xCrashReport->set_sensitive(!officecfg::Office::Common::Misc::CrashReport::isReadOnly() && CrashReporter::IsDumpEnable());
    m_xCrashReportImg->set_visible(officecfg::Office::Common::Misc::CrashReport::isReadOnly() && CrashReporter::IsDumpEnable());
    m_xCrashReport->save_state();
#endif

@@ -357,6 +388,7 @@ void OfaMiscTabPage::Reset( const SfxItemSet* rSet )
        officecfg::Office::Common::Misc::PerformFileExtCheck::get());
    m_xPerformFileExtCheck->save_state();
    m_xPerformFileExtCheck->set_sensitive(!officecfg::Office::Common::Misc::PerformFileExtCheck::isReadOnly());
    m_xPerformFileExtImg->set_visible(officecfg::Office::Common::Misc::PerformFileExtCheck::isReadOnly());
#endif
}

diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx
index 7dc7e07..02c5eda 100644
--- a/cui/source/options/optgdlg.hxx
+++ b/cui/source/options/optgdlg.hxx
@@ -34,25 +34,34 @@ private:
    OUString             m_aStrDateInfo;

    std::unique_ptr<weld::CheckButton> m_xExtHelpCB;
    std::unique_ptr<weld::Widget> m_xExtHelpImg;
    std::unique_ptr<weld::CheckButton> m_xPopUpNoHelpCB;
    std::unique_ptr<weld::Widget> m_xPopUpNoHelpImg;
    std::unique_ptr<weld::CheckButton> m_xShowTipOfTheDay;
    std::unique_ptr<weld::Widget> m_xShowTipOfTheDayImg;
    std::unique_ptr<weld::Widget> m_xFileDlgFrame;
    std::unique_ptr<weld::Widget> m_xFileDlgROImage;
    std::unique_ptr<weld::CheckButton> m_xFileDlgCB;
    std::unique_ptr<weld::CheckButton> m_xDocStatusCB;
    std::unique_ptr<weld::Widget> m_xDocStatusImg;
    std::unique_ptr<weld::Widget> m_xYearFrame;
    std::unique_ptr<weld::Label> m_xYearLabel;
    std::unique_ptr<weld::SpinButton> m_xYearValueField;
    std::unique_ptr<weld::Label> m_xToYearFT;
    std::unique_ptr<weld::Widget> m_xYearFrameImg;
#if HAVE_FEATURE_BREAKPAD
    std::unique_ptr<weld::Widget> m_xPrivacyFrame;
    std::unique_ptr<weld::CheckButton> m_xCrashReport;
    std::unique_ptr<weld::Widget> m_xCrashReportImg;
#endif
#if defined(_WIN32)
    std::unique_ptr<weld::Widget> m_xQuickStarterFrame;
    std::unique_ptr<weld::CheckButton> m_xQuickLaunchCB;
    std::unique_ptr<weld::Widget> m_xQuickLaunchImg;
    std::unique_ptr<weld::Widget> m_xFileAssocFrame;
    std::unique_ptr<weld::Button> m_xFileAssocBtn;
    std::unique_ptr<weld::CheckButton> m_xPerformFileExtCheck;
    std::unique_ptr<weld::Widget> m_xPerformFileExtImg;
#endif

    DECL_LINK(TwoFigureHdl, weld::SpinButton&, void);
diff --git a/cui/uiconfig/ui/optgeneralpage.ui b/cui/uiconfig/ui/optgeneralpage.ui
index ce2743e..1f04a0c 100644
--- a/cui/uiconfig/ui/optgeneralpage.ui
+++ b/cui/uiconfig/ui/optgeneralpage.ui
@@ -23,12 +23,13 @@
        <property name="label-xalign">0</property>
        <property name="shadow-type">none</property>
        <child>
          <!-- n-columns=1 n-rows=3 -->
          <!-- n-columns=2 n-rows=3 -->
          <object class="GtkGrid" id="grid2">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="margin-start">12</property>
            <property name="margin-top">6</property>
            <property name="column-spacing">6</property>
            <child>
              <object class="GtkCheckButton" id="exthelp">
                <property name="label" translatable="yes" context="optgeneralpage|exthelp">_Extended tips</property>
@@ -44,7 +45,7 @@
                </child>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="left-attach">1</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
@@ -57,7 +58,7 @@
                <property name="draw-indicator">True</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="left-attach">1</property>
                <property name="top-attach">1</property>
              </packing>
            </child>
@@ -71,6 +72,45 @@
                <property name="draw-indicator">True</property>
              </object>
              <packing>
                <property name="left-attach">1</property>
                <property name="top-attach">2</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockexthelp">
                <property name="can-focus">False</property>
                <property name="no-show-all">True</property>
                <property name="halign">center</property>
                <property name="valign">center</property>
                <property name="icon-name">res/lock.png</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockpopupnohelp">
                <property name="can-focus">False</property>
                <property name="no-show-all">True</property>
                <property name="halign">center</property>
                <property name="valign">center</property>
                <property name="icon-name">res/lock.png</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockcbShowTipOfTheDay">
                <property name="can-focus">False</property>
                <property name="no-show-all">True</property>
                <property name="halign">center</property>
                <property name="valign">center</property>
                <property name="icon-name">res/lock.png</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">2</property>
              </packing>
@@ -159,19 +199,44 @@
        <property name="label-xalign">0</property>
        <property name="shadow-type">none</property>
        <child>
          <object class="GtkCheckButton" id="docstatus">
            <property name="label" translatable="yes" context="optgeneralpage|docstatus">_Printing sets "document modified" status</property>
          <!-- n-columns=2 n-rows=1 -->
          <object class="GtkGrid" id="grid9">
            <property name="visible">True</property>
            <property name="can-focus">True</property>
            <property name="receives-default">False</property>
            <property name="can-focus">False</property>
            <property name="margin-start">12</property>
            <property name="margin-top">6</property>
            <property name="use-underline">True</property>
            <property name="draw-indicator">True</property>
            <child internal-child="accessible">
              <object class="AtkObject" id="docstatus-atkobject">
                <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip | docstatus">Specifies whether the printing of the document counts as a modification.</property>
            <property name="column-spacing">6</property>
            <child>
              <object class="GtkCheckButton" id="docstatus">
                <property name="label" translatable="yes" context="optgeneralpage|docstatus">_Printing sets "document modified" status</property>
                <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="draw-indicator">True</property>
                <child internal-child="accessible">
                  <object class="AtkObject" id="docstatus-atkobject">
                    <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip | docstatus">Specifies whether the printing of the document counts as a modification.</property>
                  </object>
                </child>
              </object>
              <packing>
                <property name="left-attach">1</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockdocstatus">
                <property name="can-focus">False</property>
                <property name="no-show-all">True</property>
                <property name="halign">center</property>
                <property name="valign">center</property>
                <property name="icon-name">res/lock.png</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
          </object>
        </child>
@@ -198,7 +263,7 @@
        <property name="label-xalign">0</property>
        <property name="shadow-type">none</property>
        <child>
          <!-- n-columns=3 n-rows=1 -->
          <!-- n-columns=4 n-rows=1 -->
          <object class="GtkGrid" id="grid3">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
@@ -206,7 +271,7 @@
            <property name="margin-top">6</property>
            <property name="column-spacing">6</property>
            <child>
              <object class="GtkLabel" id="label6">
              <object class="GtkLabel" id="yearslabel">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="label" translatable="yes" context="optgeneralpage|label6">_Interpret as years between </property>
@@ -215,7 +280,7 @@
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="left-attach">1</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
@@ -233,7 +298,7 @@
                </child>
              </object>
              <packing>
                <property name="left-attach">1</property>
                <property name="left-attach">2</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
@@ -244,7 +309,20 @@
                <property name="label" translatable="yes" context="optgeneralpage|toyear">and </property>
              </object>
              <packing>
                <property name="left-attach">2</property>
                <property name="left-attach">3</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockyears">
                <property name="can-focus">False</property>
                <property name="no-show-all">True</property>
                <property name="halign">center</property>
                <property name="valign">center</property>
                <property name="icon-name">res/lock.png</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
@@ -268,17 +346,17 @@
    </child>
    <child>
      <object class="GtkFrame" id="privacyframe">
        <property name="visible">False</property>
        <property name="can-focus">False</property>
        <property name="label-xalign">0</property>
        <property name="shadow-type">none</property>
        <child>
          <!-- n-columns=1 n-rows=2 -->
          <object class="GtkGrid">
          <!-- n-columns=2 n-rows=2 -->
          <object class="GtkGrid" id="grid10">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="margin-start">12</property>
            <property name="margin-top">6</property>
            <property name="column-spacing">6</property>
            <child>
              <object class="GtkCheckButton" id="crashreport">
                <property name="label" translatable="yes" context="optgeneralpage|crashreport">Sen_d crash reports to The Document Foundation</property>
@@ -291,6 +369,19 @@
                <property name="draw-indicator">True</property>
              </object>
              <packing>
                <property name="left-attach">1</property>
                <property name="top-attach">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockcrashreport">
                <property name="can-focus">False</property>
                <property name="no-show-all">True</property>
                <property name="halign">center</property>
                <property name="valign">center</property>
                <property name="icon-name">res/lock.png</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">1</property>
              </packing>
@@ -298,6 +389,9 @@
            <child>
              <placeholder/>
            </child>
            <child>
              <placeholder/>
            </child>
          </object>
        </child>
        <child type="label">
@@ -318,18 +412,18 @@
    </child>
    <child>
      <object class="GtkFrame" id="quickstarter">
        <property name="visible">False</property>
        <property name="can-focus">False</property>
        <property name="label-xalign">0</property>
        <property name="shadow-type">none</property>
        <child>
          <!-- n-columns=1 n-rows=1 -->
          <!-- n-columns=2 n-rows=1 -->
          <object class="GtkGrid" id="grid7">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="margin-start">12</property>
            <property name="margin-top">6</property>
            <property name="row-spacing">6</property>
            <property name="column-spacing">6</property>
            <child>
              <object class="GtkCheckButton" id="quicklaunch">
                <property name="label" translatable="yes" context="optgeneralpage|quicklaunch">Load %PRODUCTNAME during system start-up</property>
@@ -341,6 +435,19 @@
                <property name="draw-indicator">True</property>
              </object>
              <packing>
                <property name="left-attach">1</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockquicklaunch">
                <property name="can-focus">False</property>
                <property name="no-show-all">True</property>
                <property name="halign">center</property>
                <property name="valign">center</property>
                <property name="icon-name">res/lock.png</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">0</property>
              </packing>
@@ -369,13 +476,14 @@
        <property name="label-xalign">0</property>
        <property name="shadow-type">none</property>
        <child>
          <!-- n-columns=1 n-rows=2 -->
          <!-- n-columns=2 n-rows=2 -->
          <object class="GtkGrid" id="grid8">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="margin-start">12</property>
            <property name="margin-top">6</property>
            <property name="row-spacing">6</property>
            <property name="column-spacing">6</property>
            <child>
              <object class="GtkButton" id="assocfiles">
                <property name="label" translatable="yes" context="optgeneralpage|fileassoc">Windows Default apps</property>
@@ -386,7 +494,7 @@
                <property name="use-underline">True</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="left-attach">1</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
@@ -400,10 +508,26 @@
                <property name="draw-indicator">True</property>
              </object>
              <packing>
                <property name="left-attach">1</property>
                <property name="top-attach">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockcbPerformFileExtCheck">
                <property name="can-focus">False</property>
                <property name="no-show-all">True</property>
                <property name="halign">center</property>
                <property name="valign">center</property>
                <property name="icon-name">res/lock.png</property>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">1</property>
              </packing>
            </child>
            <child>
              <placeholder/>
            </child>
          </object>
        </child>
        <child type="label">