tdf#158007 - UI: Part 23 - Unify lockdown behavior of Options dialog

for Writer - General Page.

Change-Id: I2c679ee7f8e2d282a9f9ff19fc1743cb9bb6dbe1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159250
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
diff --git a/include/comphelper/configuration.hxx b/include/comphelper/configuration.hxx
index 45228b7..652e9af 100644
--- a/include/comphelper/configuration.hxx
+++ b/include/comphelper/configuration.hxx
@@ -246,6 +246,13 @@ private:
/// to access each given localized configuration property.
template< typename T, typename U > struct ConfigurationLocalizedProperty
{
    /// Get the read-only status of the given (localized) configuration
    /// property.
    static bool isReadOnly()
    {
        return detail::ConfigurationWrapper::get().isReadOnly(T::path());
    }

    /// Get the value of the given localized configuration property, for the
    /// locale currently set at the
    /// com.sun.star.configuration.theDefaultProvider.
diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx
index 92e7541..675a2d4 100644
--- a/sw/source/ui/config/optload.cxx
+++ b/sw/source/ui/config/optload.cxx
@@ -83,16 +83,27 @@ SwLoadOptPage::SwLoadOptPage(weld::Container* pPage, weld::DialogController* pCo
    , m_xAlwaysRB(m_xBuilder->weld_radio_button("always"))
    , m_xRequestRB(m_xBuilder->weld_radio_button("onrequest"))
    , m_xNeverRB(m_xBuilder->weld_radio_button("never"))
    , m_xGridupdatelink(m_xBuilder->weld_widget("gridupdatelink"))
    , m_xUpdateLinkImg(m_xBuilder->weld_widget("lockupdatelink"))
    , m_xAutoUpdateFields(m_xBuilder->weld_check_button("updatefields"))
    , m_xAutoUpdateFieldsImg(m_xBuilder->weld_widget("lockupdatefields"))
    , m_xAutoUpdateCharts(m_xBuilder->weld_check_button("updatecharts"))
    , m_xAutoUpdateChartsImg(m_xBuilder->weld_widget("lockupdatecharts"))
    , m_xMetricLB(m_xBuilder->weld_combo_box("metric"))
    , m_xMetricImg(m_xBuilder->weld_widget("lockmetric"))
    , m_xTabFT(m_xBuilder->weld_label("tablabel"))
    , m_xTabMF(m_xBuilder->weld_metric_spin_button("tab", FieldUnit::CM))
    , m_xTabImg(m_xBuilder->weld_widget("locktab"))
    , m_xUseSquaredPageMode(m_xBuilder->weld_check_button("squaremode"))
    , m_xUseSquaredPageModeImg(m_xBuilder->weld_widget("locksquaremode"))
    , m_xUseCharUnit(m_xBuilder->weld_check_button("usecharunit"))
    , m_xUseCharUnitImg(m_xBuilder->weld_widget("lockusecharunit"))
    , m_xWordCountED(m_xBuilder->weld_entry("wordcount"))
    , m_xWordCountImg(m_xBuilder->weld_widget("lockwordcount"))
    , m_xShowStandardizedPageCount(m_xBuilder->weld_check_button("standardizedpageshow"))
    , m_xShowStandardizedPageCountImg(m_xBuilder->weld_widget("lockstandardizedpageshow"))
    , m_xStandardizedPageSizeNF(m_xBuilder->weld_spin_button("standardpagesize"))
    , m_xStandardizedPageSizeImg(m_xBuilder->weld_widget("lockstandardpagesize"))
{
    for (sal_uInt32 i = 0; i < SwFieldUnitTable::Count(); ++i)
    {
@@ -362,16 +373,51 @@ void SwLoadOptPage::Reset( const SfxItemSet* rSet)
    }
    m_xUseCharUnit->save_state();

    bool bReadOnly = officecfg::Office::Writer::Content::Update::Link::isReadOnly();
    m_xGridupdatelink->set_sensitive(!bReadOnly);
    m_xUpdateLinkImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Writer::Content::Update::Field::isReadOnly();
    m_xAutoUpdateFields->set_sensitive(!bReadOnly);
    m_xAutoUpdateFieldsImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Writer::Content::Update::Chart::isReadOnly();
    m_xAutoUpdateCharts->set_sensitive(!bReadOnly);
    m_xAutoUpdateChartsImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Writer::Layout::Other::MeasureUnit::isReadOnly();
    m_xMetricLB->set_sensitive(!bReadOnly);
    m_xMetricImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Writer::Layout::Other::TabStop::isReadOnly();
    m_xTabMF->set_sensitive(!bReadOnly);
    m_xTabImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Writer::Layout::Other::ApplyCharUnit::isReadOnly();
    m_xUseCharUnit->set_sensitive(!bReadOnly);
    m_xUseCharUnitImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Writer::Layout::Other::IsSquaredPageMode::isReadOnly();
    m_xUseSquaredPageMode->set_sensitive(!bReadOnly);
    m_xUseSquaredPageModeImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Writer::WordCount::AdditionalSeparators::isReadOnly();
    m_xWordCountED->set_text(officecfg::Office::Writer::WordCount::AdditionalSeparators::get());
    m_xWordCountED->set_sensitive(!officecfg::Office::Writer::WordCount::AdditionalSeparators::isReadOnly());
    m_xWordCountED->set_sensitive(!bReadOnly);
    m_xWordCountImg->set_visible(bReadOnly);
    m_xWordCountED->save_value();

    bReadOnly = officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::isReadOnly();
    m_xShowStandardizedPageCount->set_active(officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::get());
    m_xShowStandardizedPageCount->set_sensitive(!officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::isReadOnly());
    m_xShowStandardizedPageCount->set_sensitive(!bReadOnly);
    m_xShowStandardizedPageCountImg->set_visible(bReadOnly);
    m_xShowStandardizedPageCount->save_state();

    bReadOnly = officecfg::Office::Writer::WordCount::StandardizedPageSize::isReadOnly();
    m_xStandardizedPageSizeNF->set_value(officecfg::Office::Writer::WordCount::StandardizedPageSize::get());
    m_xStandardizedPageSizeNF->set_sensitive(!officecfg::Office::Writer::WordCount::StandardizedPageSize::isReadOnly());
    m_xStandardizedPageSizeNF->set_sensitive(!bReadOnly && m_xShowStandardizedPageCount->get_active());
    m_xStandardizedPageSizeImg->set_visible(bReadOnly);
    m_xStandardizedPageSizeNF->save_value();
    m_xStandardizedPageSizeNF->set_sensitive(m_xShowStandardizedPageCount->get_active());
}

IMPL_LINK_NOARG(SwLoadOptPage, MetricHdl, weld::ComboBox&, void)
diff --git a/sw/source/uibase/inc/optload.hxx b/sw/source/uibase/inc/optload.hxx
index 2b582bf..24ddd25 100644
--- a/sw/source/uibase/inc/optload.hxx
+++ b/sw/source/uibase/inc/optload.hxx
@@ -65,18 +65,29 @@ private:
    std::unique_ptr<weld::RadioButton> m_xAlwaysRB;
    std::unique_ptr<weld::RadioButton> m_xRequestRB;
    std::unique_ptr<weld::RadioButton> m_xNeverRB;
    std::unique_ptr<weld::Widget> m_xGridupdatelink;
    std::unique_ptr<weld::Widget> m_xUpdateLinkImg;

    std::unique_ptr<weld::CheckButton> m_xAutoUpdateFields;
    std::unique_ptr<weld::Widget> m_xAutoUpdateFieldsImg;
    std::unique_ptr<weld::CheckButton> m_xAutoUpdateCharts;
    std::unique_ptr<weld::Widget> m_xAutoUpdateChartsImg;

    std::unique_ptr<weld::ComboBox> m_xMetricLB;
    std::unique_ptr<weld::Widget> m_xMetricImg;
    std::unique_ptr<weld::Label> m_xTabFT;
    std::unique_ptr<weld::MetricSpinButton> m_xTabMF;
    std::unique_ptr<weld::Widget> m_xTabImg;
    std::unique_ptr<weld::CheckButton> m_xUseSquaredPageMode;
    std::unique_ptr<weld::Widget> m_xUseSquaredPageModeImg;
    std::unique_ptr<weld::CheckButton> m_xUseCharUnit;
    std::unique_ptr<weld::Widget> m_xUseCharUnitImg;
    std::unique_ptr<weld::Entry> m_xWordCountED;
    std::unique_ptr<weld::Widget> m_xWordCountImg;
    std::unique_ptr<weld::CheckButton> m_xShowStandardizedPageCount;
    std::unique_ptr<weld::Widget> m_xShowStandardizedPageCountImg;
    std::unique_ptr<weld::SpinButton> m_xStandardizedPageSizeNF;
    std::unique_ptr<weld::Widget> m_xStandardizedPageSizeImg;

    DECL_LINK(MetricHdl, weld::ComboBox&, void);
    DECL_LINK(StandardizedPageCountCheckHdl, weld::Toggleable&, void);
diff --git a/sw/uiconfig/swriter/ui/optgeneralpage.ui b/sw/uiconfig/swriter/ui/optgeneralpage.ui
index 86de9bf..b8999c2 100644
--- a/sw/uiconfig/swriter/ui/optgeneralpage.ui
+++ b/sw/uiconfig/swriter/ui/optgeneralpage.ui
@@ -31,7 +31,7 @@
        <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="grid4">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
@@ -53,7 +53,7 @@
                </child>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="left-attach">1</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
@@ -72,6 +72,32 @@
                </child>
              </object>
              <packing>
                <property name="left-attach">1</property>
                <property name="top-attach">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockupdatefields">
                <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="lockupdatecharts">
                <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>
@@ -103,71 +129,95 @@
        <property name="label-xalign">0</property>
        <property name="shadow-type">none</property>
        <child>
          <!-- n-columns=1 n-rows=3 -->
          <object class="GtkGrid" id="grid3">
          <!-- n-columns=2 n-rows=1 -->
          <object class="GtkGrid">
            <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>
            <child>
              <object class="GtkRadioButton" id="always">
                <property name="label" translatable="yes" context="optgeneralpage|always">_Always</property>
              <!-- n-columns=1 n-rows=3 -->
              <object class="GtkGrid" id="gridupdatelink">
                <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="active">True</property>
                <property name="draw-indicator">True</property>
                <child internal-child="accessible">
                  <object class="AtkObject" id="always-atkobject">
                    <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|always">Always updates links while loading a document, and only if the document is in a trusted file location or the global security level is Low (Not recommended).</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>
                <child>
                  <object class="GtkRadioButton" id="always">
                    <property name="label" translatable="yes" context="optgeneralpage|always">_Always</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="active">True</property>
                    <property name="draw-indicator">True</property>
                    <child internal-child="accessible">
                      <object class="AtkObject" id="always-atkobject">
                        <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|always">Always updates links while loading a document, and only if the document is in a trusted file location or the global security level is Low (Not recommended).</property>
                      </object>
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkRadioButton" id="onrequest">
                    <property name="label" translatable="yes" context="optgeneralpage|onrequest">_On request</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>
                    <property name="group">always</property>
                    <child internal-child="accessible">
                      <object class="AtkObject" id="onrequest-atkobject">
                        <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|onrequest">Updates links only on request while loading a document.</property>
                      </object>
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="top-attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkRadioButton" id="never">
                    <property name="label" translatable="yes" context="optgeneralpage|never">_Never</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>
                    <property name="group">always</property>
                    <child internal-child="accessible">
                      <object class="AtkObject" id="never-atkobject">
                        <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|never">Links are never updated while loading a document.</property>
                      </object>
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="top-attach">2</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="left-attach">1</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkRadioButton" id="onrequest">
                <property name="label" translatable="yes" context="optgeneralpage|onrequest">_On request</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>
                <property name="group">always</property>
                <child internal-child="accessible">
                  <object class="AtkObject" id="onrequest-atkobject">
                    <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|onrequest">Updates links only on request while loading a document.</property>
                  </object>
                </child>
              <object class="GtkImage" id="lockupdatelink">
                <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="GtkRadioButton" id="never">
                <property name="label" translatable="yes" context="optgeneralpage|never">_Never</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>
                <property name="group">always</property>
                <child internal-child="accessible">
                  <object class="AtkObject" id="never-atkobject">
                    <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|never">Links are never updated while loading a document.</property>
                  </object>
                </child>
              </object>
              <packing>
                <property name="left-attach">0</property>
                <property name="top-attach">2</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
          </object>
@@ -204,7 +254,7 @@
            <property name="margin-top">6</property>
            <property name="row-spacing">6</property>
            <child>
              <!-- n-columns=2 n-rows=2 -->
              <!-- n-columns=3 n-rows=2 -->
              <object class="GtkGrid" id="grid7">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
@@ -220,7 +270,7 @@
                    <property name="xalign">1</property>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
@@ -237,7 +287,7 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="left-attach">2</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
@@ -251,7 +301,7 @@
                    <property name="xalign">1</property>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">1</property>
                  </packing>
                </child>
@@ -273,7 +323,33 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="left-attach">2</property>
                    <property name="top-attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockmetric">
                    <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="locktab">
                    <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>
@@ -284,7 +360,7 @@
              </packing>
            </child>
            <child>
              <!-- n-columns=2 n-rows=1 -->
              <!-- n-columns=4 n-rows=1 -->
              <object class="GtkGrid" id="grid8">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
@@ -305,7 +381,7 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
@@ -325,7 +401,33 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="left-attach">3</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockusecharunit">
                    <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="locksquaremode">
                    <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">2</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
@@ -371,7 +473,7 @@
            <property name="hexpand">True</property>
            <property name="row-spacing">6</property>
            <child>
              <!-- n-columns=2 n-rows=1 -->
              <!-- n-columns=3 n-rows=1 -->
              <object class="GtkGrid" id="grid9">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
@@ -388,7 +490,7 @@
                    <property name="xalign">1</property>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
@@ -400,7 +502,20 @@
                    <property name="truncate-multiline">True</property>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="left-attach">2</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockwordcount">
                    <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>
@@ -411,7 +526,7 @@
              </packing>
            </child>
            <child>
              <!-- n-columns=1 n-rows=2 -->
              <!-- n-columns=2 n-rows=2 -->
              <object class="GtkGrid" id="grid10">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
@@ -426,7 +541,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">0</property>
                  </packing>
                </child>
@@ -469,6 +584,32 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="top-attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockstandardizedpageshow">
                    <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="lockstandardpagesize">
                    <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>