tdf#157861 - UI: Part 15 - Unify lockdown behavior of Options dialog

for Load/Save - MS Office Page.

Change-Id: Ifd576e5030e49bef3c73f55f4d3f23eea34a45f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158837
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx
index 7c04c20..b582b06 100644
--- a/cui/source/options/optfltr.cxx
+++ b/cui/source/options/optfltr.cxx
@@ -185,9 +185,12 @@ OfaMSFilterTabPage2::OfaMSFilterTabPage2(weld::Container* pPage, weld::DialogCon
    , sChgToFromVisio(CuiResId(RID_CUISTR_CHG_VISIO))
    , sChgToFromPDF(CuiResId(RID_CUISTR_CHG_PDF))
    , m_xCheckLB(m_xBuilder->weld_tree_view("checklbcontainer"))
    , m_xHighlightingFT(m_xBuilder->weld_label("label5"))
    , m_xHighlightingRB(m_xBuilder->weld_radio_button("highlighting"))
    , m_xShadingRB(m_xBuilder->weld_radio_button("shading"))
    , m_xShadingImg(m_xBuilder->weld_widget("lockbuttonbox1"))
    , m_xMSOLockFileCB(m_xBuilder->weld_check_button("mso_lockfile"))
    , m_xMSOLockFileImg(m_xBuilder->weld_widget("lockmso_lockfile"))
{
    std::vector<int> aWidths
    {
@@ -351,6 +354,7 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* )
    };

    bool bFirstCol = true;
    bool bReadOnly = false;
    for( const ChkCBoxEntries & rArr : aChkArr )
    {
        // we loop through the list, alternating reading the first/second column,
@@ -365,13 +369,50 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* )
            if (rArr.eType != MSFltrPg2_CheckBoxEntries::PDF)
            {
                bCheck = (rOpt.*rArr.FnIs)();
                switch (rArr.eType)
                {
                case MSFltrPg2_CheckBoxEntries::Math:
                    if (nCol == 0)
                        bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::isReadOnly();
                    else
                        bReadOnly = officecfg::Office::Common::Filter::Microsoft::Export::MathToMathType::isReadOnly();
                    break;
                case MSFltrPg2_CheckBoxEntries::Writer:
                    if (nCol == 0)
                        bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::isReadOnly();
                    else
                        bReadOnly = officecfg::Office::Common::Filter::Microsoft::Export::WriterToWinWord::isReadOnly();
                    break;
                case MSFltrPg2_CheckBoxEntries::Calc:
                    if (nCol == 0)
                        bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::ExcelToCalc::isReadOnly();
                    else
                        bReadOnly = officecfg::Office::Common::Filter::Microsoft::Export::CalcToExcel::isReadOnly();
                    break;
                case MSFltrPg2_CheckBoxEntries::Impress:
                    if (nCol == 0)
                        bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::PowerPointToImpress::isReadOnly();
                    else
                        bReadOnly = officecfg::Office::Common::Filter::Microsoft::Export::ImpressToPowerPoint::isReadOnly();
                    break;
                case MSFltrPg2_CheckBoxEntries::SmartArt:
                    bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::isReadOnly();
                    break;
                case MSFltrPg2_CheckBoxEntries::Visio:
                    bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::isReadOnly();
                    break;
                default:
                    break;
                }
            }
            else
            {
                bCheck = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get();
                bReadOnly = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::isReadOnly();
                nCol = 0;
            }
            m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, nCol);
            m_xCheckLB->set_sensitive(nEntry, !bReadOnly, nCol);
        }
        if (rArr.eType == MSFltrPg2_CheckBoxEntries::SmartArt)
        {
@@ -385,11 +426,20 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* )
    else
        m_xShadingRB->set_active(true);

    if (officecfg::Office::Common::Filter::Microsoft::Export::CharBackgroundToHighlighting::isReadOnly())
    {
        m_xHighlightingRB->set_sensitive(false);
        m_xShadingRB->set_sensitive(false);
        m_xHighlightingFT->set_sensitive(false);
        m_xShadingImg->set_visible(true);
    }

    m_xHighlightingRB->save_state();

    m_xMSOLockFileCB->set_active(rOpt.IsMSOLockFileCreationIsEnabled());
    m_xMSOLockFileCB->save_state();
    m_xMSOLockFileCB->set_sensitive(!officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly());
    m_xMSOLockFileImg->set_visible(officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly());
}

void OfaMSFilterTabPage2::InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType )
diff --git a/cui/source/options/optfltr.hxx b/cui/source/options/optfltr.hxx
index dd4fcf1..51a51ec 100644
--- a/cui/source/options/optfltr.hxx
+++ b/cui/source/options/optfltr.hxx
@@ -67,9 +67,12 @@ class OfaMSFilterTabPage2 : public SfxTabPage
           sChgToFromPDF;

    std::unique_ptr<weld::TreeView> m_xCheckLB;
    std::unique_ptr<weld::Label> m_xHighlightingFT;
    std::unique_ptr<weld::RadioButton> m_xHighlightingRB;
    std::unique_ptr<weld::RadioButton> m_xShadingRB;
    std::unique_ptr<weld::Widget> m_xShadingImg;
    std::unique_ptr<weld::CheckButton> m_xMSOLockFileCB;
    std::unique_ptr<weld::Widget> m_xMSOLockFileImg;

    void                InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType );
    void                InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType,
diff --git a/cui/uiconfig/ui/optfltrembedpage.ui b/cui/uiconfig/ui/optfltrembedpage.ui
index f8c6b5a..b5401ff 100644
--- a/cui/uiconfig/ui/optfltrembedpage.ui
+++ b/cui/uiconfig/ui/optfltrembedpage.ui
@@ -208,43 +208,22 @@
        <property name="label-xalign">0</property>
        <property name="shadow-type">none</property>
        <child>
          <object class="GtkBox" id="box2">
          <!-- 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="spacing">18</property>
            <child>
              <object class="GtkLabel" id="label5">
              <object class="GtkBox" id="box2">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="label" translatable="yes" context="optfltrembedpage|label5">Export as:</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkButtonBox" id="buttonbox1">
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="layout-style">start</property>
                <property name="margin-start">12</property>
                <property name="margin-top">6</property>
                <property name="spacing">18</property>
                <child>
                  <object class="GtkRadioButton" id="highlighting">
                    <property name="label" translatable="yes" context="optfltrembedpage|highlighting">Highlighting</property>
                  <object class="GtkLabel" id="label5">
                    <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="highlighting-atkobject">
                        <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|highlighting">Microsoft Office has two character attributes similar to Writer character background. Select the appropriate attribute (highlighting or shading) which you would like to use during export to Microsoft Office file formats.</property>
                      </object>
                    </child>
                    <property name="can-focus">False</property>
                    <property name="label" translatable="yes" context="optfltrembedpage|label5">Export as:</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -253,18 +232,51 @@
                  </packing>
                </child>
                <child>
                  <object class="GtkRadioButton" id="shading">
                    <property name="label" translatable="yes" context="optfltrembedpage|shading">Shading</property>
                  <object class="GtkButtonBox" id="buttonbox1">
                    <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">highlighting</property>
                    <child internal-child="accessible">
                      <object class="AtkObject" id="shading-atkobject">
                        <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|shading">Microsoft Office has two character attributes similar to Writer character background. Select the appropriate attribute (highlighting or shading) which you would like to use during export to Microsoft Office file formats.</property>
                    <property name="can-focus">False</property>
                    <property name="layout-style">start</property>
                    <child>
                      <object class="GtkRadioButton" id="highlighting">
                        <property name="label" translatable="yes" context="optfltrembedpage|highlighting">Highlighting</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="highlighting-atkobject">
                            <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|highlighting">Microsoft Office has two character attributes similar to Writer character background. Select the appropriate attribute (highlighting or shading) which you would like to use during export to Microsoft Office file formats.</property>
                          </object>
                        </child>
                      </object>
                      <packing>
                        <property name="expand">False</property>
                        <property name="fill">True</property>
                        <property name="position">0</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkRadioButton" id="shading">
                        <property name="label" translatable="yes" context="optfltrembedpage|shading">Shading</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">highlighting</property>
                        <child internal-child="accessible">
                          <object class="AtkObject" id="shading-atkobject">
                            <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|shading">Microsoft Office has two character attributes similar to Writer character background. Select the appropriate attribute (highlighting or shading) which you would like to use during export to Microsoft Office file formats.</property>
                          </object>
                        </child>
                      </object>
                      <packing>
                        <property name="expand">False</property>
                        <property name="fill">True</property>
                        <property name="position">1</property>
                      </packing>
                    </child>
                  </object>
                  <packing>
@@ -275,9 +287,21 @@
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
                <property name="left-attach">1</property>
                <property name="top-attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage" id="lockbuttonbox1">
                <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>
@@ -312,18 +336,42 @@
            <property name="margin-top">6</property>
            <property name="layout-style">start</property>
            <child>
              <object class="GtkCheckButton" id="mso_lockfile">
                <property name="label" translatable="yes" context="optfltrembedpage|mso_lockfile">Create MSO lock file</property>
              <!-- n-columns=2 n-rows=1 -->
              <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="active">True</property>
                <property name="draw-indicator">True</property>
                <child internal-child="accessible">
                  <object class="AtkObject" id="mso_lockfile-atkobject">
                    <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|mso_lockfile">Mark this checkbox to generate a Microsoft Office lock file in addition to this office suite's own lock file.</property>
                <property name="can-focus">False</property>
                <child>
                  <object class="GtkCheckButton" id="mso_lockfile">
                    <property name="label" translatable="yes" context="optfltrembedpage|mso_lockfile">Create MSO lock file</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="mso_lockfile-atkobject">
                        <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|mso_lockfile">Mark this checkbox to generate a Microsoft Office lock file in addition to this office suite's own lock file.</property>
                      </object>
                    </child>
                  </object>
                  <packing>
                    <property name="left-attach">1</property>
                    <property name="top-attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkImage" id="lockmso_lockfile">
                    <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>
              <packing>