tdf#158222 - UI: Part 39 - Unify lockdown behavior of Options dialog

for Impress - General Page.

Change-Id: Idd7240b6c0ccfec8929e2f224a63ec5c0a8ad331
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159854
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
diff --git a/sd/source/ui/dlg/tpoption.cxx b/sd/source/ui/dlg/tpoption.cxx
index c7ee084..b177c8e 100644
--- a/sd/source/ui/dlg/tpoption.cxx
+++ b/sd/source/ui/dlg/tpoption.cxx
@@ -23,6 +23,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <com/sun/star/uno/Exception.hpp>
#include <officecfg/Office/Impress.hxx>
#include <sfx2/module.hxx>
#include <svx/svxids.hrc>
#include <svx/strarray.hxx>
@@ -197,15 +198,24 @@ SdTpOptionsMisc::SdTpOptionsMisc(weld::Container* pPage, weld::DialogController*
    , nWidth(0)
    , nHeight(0)
    , m_xCbxQuickEdit(m_xBuilder->weld_check_button("qickedit"))
    , m_xCbxQuickEditImg(m_xBuilder->weld_widget("lockqickedit"))
    , m_xCbxPickThrough(m_xBuilder->weld_check_button("textselected"))
    , m_xCbxPickThroughImg(m_xBuilder->weld_widget("locktextselected"))
    , m_xNewDocumentFrame(m_xBuilder->weld_frame("newdocumentframe"))
    , m_xCbxStartWithTemplate(m_xBuilder->weld_check_button("startwithwizard"))
    , m_xCbxStartWithTemplateImg(m_xBuilder->weld_widget("lockstartwithwizard"))
    , m_xCbxMasterPageCache(m_xBuilder->weld_check_button("backgroundback"))
    , m_xCbxMasterPageCacheImg(m_xBuilder->weld_widget("lockbackgroundback"))
    , m_xCbxCopy(m_xBuilder->weld_check_button("copywhenmove"))
    , m_xCbxCopyImg(m_xBuilder->weld_widget("lockcopywhenmove"))
    , m_xCbxMarkedHitMovesAlways(m_xBuilder->weld_check_button("objalwymov"))
    , m_xCbxMarkedHitMovesAlwaysImg(m_xBuilder->weld_widget("lockobjalwymov"))
    , m_xLbMetric(m_xBuilder->weld_combo_box("units"))
    , m_xLbMetricImg(m_xBuilder->weld_widget("lockunits"))
    , m_xMtrFldTabstop(m_xBuilder->weld_metric_spin_button("metricFields", FieldUnit::MM))
    , m_xMtrFldTabstopImg(m_xBuilder->weld_widget("locktabstop"))
    , m_xCbxCompatibility(m_xBuilder->weld_check_button("cbCompatibility"))
    , m_xCbxCompatibilityImg(m_xBuilder->weld_widget("lockcbCompatibility"))
    , m_xScaleFrame(m_xBuilder->weld_frame("scaleframe"))
    , m_xCbScale(m_xBuilder->weld_combo_box("scaleBox"))
    , m_xNewDocLb(m_xBuilder->weld_label("newdoclbl"))
@@ -432,13 +442,41 @@ void SdTpOptionsMisc::Reset( const SfxItemSet* rAttrs )
{
    SdOptionsMiscItem aOptsItem( rAttrs->Get( ATTR_OPTIONS_MISC ) );

    bool bReadOnly = officecfg::Office::Impress::Misc::NewDoc::AutoPilot::isReadOnly();
    m_xCbxStartWithTemplate->set_active( aOptsItem.GetOptionsMisc().IsStartWithTemplate() );
    m_xCbxStartWithTemplate->set_sensitive(!bReadOnly);
    m_xCbxStartWithTemplateImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Impress::Misc::ObjectMoveable::isReadOnly();
    m_xCbxMarkedHitMovesAlways->set_active( aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways() );
    m_xCbxMarkedHitMovesAlways->set_sensitive(!bReadOnly);
    m_xCbxMarkedHitMovesAlwaysImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Impress::Misc::TextObject::QuickEditing::isReadOnly();
    m_xCbxQuickEdit->set_active( aOptsItem.GetOptionsMisc().IsQuickEdit() );
    m_xCbxQuickEdit->set_sensitive(!bReadOnly);
    m_xCbxQuickEditImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Impress::Misc::TextObject::Selectable::isReadOnly();
    m_xCbxPickThrough->set_active( aOptsItem.GetOptionsMisc().IsPickThrough() );
    m_xCbxPickThrough->set_sensitive(!bReadOnly);
    m_xCbxPickThroughImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Impress::Misc::BackgroundCache::isReadOnly();
    m_xCbxMasterPageCache->set_active( aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching() );
    m_xCbxMasterPageCache->set_sensitive(!bReadOnly);
    m_xCbxMasterPageCacheImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Impress::Misc::CopyWhileMoving::isReadOnly();
    m_xCbxCopy->set_active( aOptsItem.GetOptionsMisc().IsDragWithCopy() );
    m_xCbxCopy->set_sensitive(!bReadOnly);
    m_xCbxCopyImg->set_visible(bReadOnly);

    bReadOnly = officecfg::Office::Impress::Misc::Compatibility::AddBetween::isReadOnly();
    m_xCbxCompatibility->set_active( aOptsItem.GetOptionsMisc().IsSummationOfParagraphs() );
    m_xCbxCompatibility->set_sensitive(!bReadOnly);
    m_xCbxCompatibilityImg->set_visible(bReadOnly);

    m_xCbxDistort->set_active( aOptsItem.GetOptionsMisc().IsCrookNoContortion() );
    m_xCbxStartWithTemplate->save_state();
    m_xCbxMarkedHitMovesAlways->save_state();
@@ -477,6 +515,21 @@ void SdTpOptionsMisc::Reset( const SfxItemSet* rAttrs )
        const SfxUInt16Item& rItem = rAttrs->Get( nWhich2 );
        SetMetricValue( *m_xMtrFldTabstop, rItem.GetValue(), eUnit );
    }

    if (SdOptionsGeneric::isMetricSystem())
        bReadOnly = officecfg::Office::Impress::Layout::Other::MeasureUnit::Metric::isReadOnly();
    else
        bReadOnly = officecfg::Office::Impress::Layout::Other::MeasureUnit::NonMetric::isReadOnly();
    m_xLbMetric->set_sensitive(!bReadOnly);
    m_xLbMetricImg->set_visible(bReadOnly);

    if (SdOptionsGeneric::isMetricSystem())
        bReadOnly = officecfg::Office::Impress::Layout::Other::TabStop::Metric::isReadOnly();
    else
        bReadOnly = officecfg::Office::Impress::Layout::Other::TabStop::NonMetric::isReadOnly();
    m_xMtrFldTabstop->set_sensitive(!bReadOnly);
    m_xMtrFldTabstopImg->set_visible(bReadOnly);

    m_xLbMetric->save_value();
    m_xMtrFldTabstop->save_value();
    //Scale
@@ -613,7 +666,7 @@ void SdTpOptionsMisc::UpdateCompatibilityControls()
        // bIsEnabled and disable the controls.
    }

    m_xCbxCompatibility->set_sensitive(bIsEnabled);
    m_xCbxCompatibility->set_sensitive(bIsEnabled && !officecfg::Office::Impress::Misc::Compatibility::AddBetween::isReadOnly());
}

void SdTpOptionsMisc::PageCreated(const SfxAllItemSet& aSet)
diff --git a/sd/source/ui/inc/tpoption.hxx b/sd/source/ui/inc/tpoption.hxx
index 5ba80c3..4184cd7 100644
--- a/sd/source/ui/inc/tpoption.hxx
+++ b/sd/source/ui/inc/tpoption.hxx
@@ -75,19 +75,28 @@ private:
    MapUnit             ePoolUnit;

    std::unique_ptr<weld::CheckButton> m_xCbxQuickEdit;
    std::unique_ptr<weld::Widget> m_xCbxQuickEditImg;
    std::unique_ptr<weld::CheckButton> m_xCbxPickThrough;
    std::unique_ptr<weld::Widget> m_xCbxPickThroughImg;

    std::unique_ptr<weld::Frame> m_xNewDocumentFrame;
    std::unique_ptr<weld::CheckButton> m_xCbxStartWithTemplate;
    std::unique_ptr<weld::Widget> m_xCbxStartWithTemplateImg;

    std::unique_ptr<weld::CheckButton> m_xCbxMasterPageCache;
    std::unique_ptr<weld::Widget> m_xCbxMasterPageCacheImg;
    std::unique_ptr<weld::CheckButton> m_xCbxCopy;
    std::unique_ptr<weld::Widget> m_xCbxCopyImg;
    std::unique_ptr<weld::CheckButton> m_xCbxMarkedHitMovesAlways;
    std::unique_ptr<weld::Widget> m_xCbxMarkedHitMovesAlwaysImg;

    std::unique_ptr<weld::ComboBox> m_xLbMetric;
    std::unique_ptr<weld::Widget> m_xLbMetricImg;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrFldTabstop;
    std::unique_ptr<weld::Widget> m_xMtrFldTabstopImg;

    std::unique_ptr<weld::CheckButton> m_xCbxCompatibility;
    std::unique_ptr<weld::Widget> m_xCbxCompatibilityImg;

    //Scale
    std::unique_ptr<weld::Frame> m_xScaleFrame;
diff --git a/sd/uiconfig/simpress/ui/optimpressgeneralpage.ui b/sd/uiconfig/simpress/ui/optimpressgeneralpage.ui
index 5566cab..60f023e 100644
--- a/sd/uiconfig/simpress/ui/optimpressgeneralpage.ui
+++ b/sd/uiconfig/simpress/ui/optimpressgeneralpage.ui
@@ -50,7 +50,7 @@
            <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="grid2">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
@@ -74,6 +74,19 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockstartwithwizard">
                    <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>
@@ -106,7 +119,7 @@
            <property name="label-xalign">0</property>
            <property name="shadow-type">none</property>
            <child>
              <!-- n-columns=1 n-rows=6 -->
              <!-- n-columns=2 n-rows=6 -->
              <object class="GtkGrid" id="grid3">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
@@ -131,7 +144,7 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
@@ -172,7 +185,7 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">4</property>
                  </packing>
                </child>
@@ -220,7 +233,7 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">5</property>
                  </packing>
                </child>
@@ -240,7 +253,7 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">2</property>
                  </packing>
                </child>
@@ -255,7 +268,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">3</property>
                  </packing>
                </child>
@@ -275,10 +288,78 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="top-attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockcopywhenmove">
                    <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="lockbackgroundback">
                    <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="lockobjalwymov">
                    <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>
                </child>
                <child>
                  <object class="GtkImage" id="lockunits">
                    <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">4</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="locktabstop">
                    <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">5</property>
                  </packing>
                </child>
                <child>
                  <placeholder/>
                </child>
              </object>
            </child>
            <child type="label">
@@ -306,7 +387,7 @@
            <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="grid6">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
@@ -329,6 +410,19 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockcbCompatibility">
                    <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>
@@ -375,7 +469,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="grid1">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
@@ -399,7 +493,7 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">0</property>
                    <property name="left-attach">1</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
@@ -418,6 +512,32 @@
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="top-attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockqickedit">
                    <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="locktextselected">
                    <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>