tdf#158464 - UI: Part 47 - Unify lockdown behavior of Options dialog

for Calc - General Page.

Change-Id: I2ff8edd0fb10a3f388459d842c79b157bc3861f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160407
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
This commit is contained in:
Balazs Varga 2023-12-06 23:29:47 +01:00
parent 030b72df0a
commit 4022666087
3 changed files with 325 additions and 61 deletions

View file

@ -81,22 +81,34 @@ class ScTpLayoutOptions : public SfxTabPage
ScDocument *pDoc;
std::unique_ptr<weld::ComboBox> m_xUnitLB;
std::unique_ptr<weld::Widget> m_xUnitImg;
std::unique_ptr<weld::MetricSpinButton> m_xTabMF;
std::unique_ptr<weld::Widget> m_xTabImg;
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_xUpdateLinksImg;
std::unique_ptr<weld::CheckButton> m_xAlignCB;
std::unique_ptr<weld::Widget> m_xAlignImg;
std::unique_ptr<weld::ComboBox> m_xAlignLB;
std::unique_ptr<weld::CheckButton> m_xEditModeCB;
std::unique_ptr<weld::Widget> m_xEditModeImg;
std::unique_ptr<weld::CheckButton> m_xFormatCB;
std::unique_ptr<weld::Widget> m_xFormatImg;
std::unique_ptr<weld::CheckButton> m_xExpRefCB;
std::unique_ptr<weld::Widget> m_xExpRefImg;
std::unique_ptr<weld::CheckButton> m_xSortRefUpdateCB;
std::unique_ptr<weld::Widget> m_xSortRefUpdateImg;
std::unique_ptr<weld::CheckButton> m_xMarkHdrCB;
std::unique_ptr<weld::Widget> m_xMarkHdrImg;
std::unique_ptr<weld::CheckButton> m_xReplWarnCB;
std::unique_ptr<weld::Widget> m_xReplWarnImg;
std::unique_ptr<weld::CheckButton> m_xLegacyCellSelectionCB;
std::unique_ptr<weld::Widget> m_xLegacyCellSelectionImg;
std::unique_ptr<weld::CheckButton> m_xEnterPasteModeCB;
std::unique_ptr<weld::Widget> m_xEnterPasteModeImg;
DECL_LINK(MetricHdl, weld::ComboBox&, void );
DECL_LINK( AlignHdl, weld::Toggleable&, void );

View file

@ -32,6 +32,9 @@
#include <scmod.hxx>
#include <svl/eitem.hxx>
#include <svtools/unitconv.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/localedatawrapper.hxx>
#include <officecfg/Office/Calc.hxx>
ScTpContentOptions::ScTpContentOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet)
: SfxTabPage(pPage, pController, "modules/scalc/ui/tpviewpage.ui", "TpViewPage", &rArgSet)
@ -318,20 +321,32 @@ ScTpLayoutOptions::ScTpLayoutOptions(weld::Container* pPage, weld::DialogControl
: SfxTabPage(pPage, pController, "modules/scalc/ui/scgeneralpage.ui", "ScGeneralPage", &rArgSet)
, pDoc(nullptr)
, m_xUnitLB(m_xBuilder->weld_combo_box("unitlb"))
, m_xUnitImg(m_xBuilder->weld_widget("lockunitlb"))
, m_xTabMF(m_xBuilder->weld_metric_spin_button("tabmf", FieldUnit::CM))
, m_xTabImg(m_xBuilder->weld_widget("locktabmf"))
, m_xAlwaysRB(m_xBuilder->weld_radio_button("alwaysrb"))
, m_xRequestRB(m_xBuilder->weld_radio_button("requestrb"))
, m_xNeverRB(m_xBuilder->weld_radio_button("neverrb"))
, m_xUpdateLinksImg(m_xBuilder->weld_widget("lockupdatelinks"))
, m_xAlignCB(m_xBuilder->weld_check_button("aligncb"))
, m_xAlignImg(m_xBuilder->weld_widget("lockaligncb"))
, m_xAlignLB(m_xBuilder->weld_combo_box("alignlb"))
, m_xEditModeCB(m_xBuilder->weld_check_button("editmodecb"))
, m_xEditModeImg(m_xBuilder->weld_widget("lockeditmodecb"))
, m_xFormatCB(m_xBuilder->weld_check_button("formatcb"))
, m_xFormatImg(m_xBuilder->weld_widget("lockformatcb"))
, m_xExpRefCB(m_xBuilder->weld_check_button("exprefcb"))
, m_xExpRefImg(m_xBuilder->weld_widget("lockexprefcb"))
, m_xSortRefUpdateCB(m_xBuilder->weld_check_button("sortrefupdatecb"))
, m_xSortRefUpdateImg(m_xBuilder->weld_widget("locksortrefupdatecb"))
, m_xMarkHdrCB(m_xBuilder->weld_check_button("markhdrcb"))
, m_xMarkHdrImg(m_xBuilder->weld_widget("lockmarkhdrcb"))
, m_xReplWarnCB(m_xBuilder->weld_check_button("replwarncb"))
, m_xReplWarnImg(m_xBuilder->weld_widget("lockreplwarncb"))
, m_xLegacyCellSelectionCB(m_xBuilder->weld_check_button("legacy_cell_selection_cb"))
, m_xLegacyCellSelectionImg(m_xBuilder->weld_widget("locklegacy_cell"))
, m_xEnterPasteModeCB(m_xBuilder->weld_check_button("enter_paste_mode_cb"))
, m_xEnterPasteModeImg(m_xBuilder->weld_widget("lockenter_paste"))
{
SetExchangeSupport();
@ -530,11 +545,33 @@ void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet )
}
::SetFieldUnit(*m_xTabMF, eFieldUnit);
}
m_xUnitLB->save_value();
bool bReadOnly = false;
MeasurementSystem eSys = ScGlobal::getLocaleData().getMeasurementSystemEnum();
if (eSys == MeasurementSystem::Metric)
{
bReadOnly = officecfg::Office::Calc::Layout::Other::MeasureUnit::Metric::isReadOnly();
}
else
{
bReadOnly = officecfg::Office::Calc::Layout::Other::MeasureUnit::NonMetric::isReadOnly();
}
m_xUnitLB->set_sensitive(!bReadOnly);
m_xUnitImg->set_visible(bReadOnly);
if(const SfxUInt16Item* pTabStopItem = rCoreSet->GetItemIfSet(SID_ATTR_DEFTABSTOP, false))
m_xTabMF->set_value(m_xTabMF->normalize(pTabStopItem->GetValue()), FieldUnit::TWIP);
m_xTabMF->save_value();
if (eSys == MeasurementSystem::Metric)
{
bReadOnly = officecfg::Office::Calc::Layout::Other::TabStop::Metric::isReadOnly();
}
else
{
bReadOnly = officecfg::Office::Calc::Layout::Other::TabStop::NonMetric::isReadOnly();
}
m_xTabMF->set_sensitive(!bReadOnly);
m_xTabImg->set_visible(bReadOnly);
m_xUnitLB->save_value();
m_xTabMF->save_value();
@ -562,36 +599,83 @@ void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet )
// added to avoid warnings
}
}
if (officecfg::Office::Calc::Content::Update::Link::isReadOnly())
{
m_xAlwaysRB->set_sensitive(false);
m_xNeverRB->set_sensitive(false);
m_xRequestRB->set_sensitive(false);
m_xUpdateLinksImg->set_visible(true);
}
if(const SfxBoolItem* pSelectionItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_SELECTION, false))
m_xAlignCB->set_active(pSelectionItem->GetValue());
bReadOnly = officecfg::Office::Calc::Input::MoveSelection::isReadOnly();
m_xAlignCB->set_sensitive(!bReadOnly);
m_xAlignImg->set_visible(bReadOnly);
if(const SfxUInt16Item* pPosItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_SELECTIONPOS, false))
m_xAlignLB->set_active(pPosItem->GetValue());
bReadOnly = officecfg::Office::Calc::Input::MoveSelectionDirection::isReadOnly();
m_xAlignCB->set_sensitive(!bReadOnly);
if(const SfxBoolItem* pEditModeItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_EDITMODE, false))
m_xEditModeCB->set_active(pEditModeItem->GetValue());
bReadOnly = officecfg::Office::Calc::Input::SwitchToEditMode::isReadOnly();
m_xEditModeCB->set_sensitive(!bReadOnly);
m_xEditModeImg->set_visible(bReadOnly);
if(const SfxBoolItem* pExpandItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_FMT_EXPAND, false))
m_xFormatCB->set_active(pExpandItem->GetValue());
bReadOnly = officecfg::Office::Calc::Input::ExpandFormatting::isReadOnly();
m_xFormatCB->set_sensitive(!bReadOnly);
m_xFormatImg->set_visible(bReadOnly);
if(const SfxBoolItem* pExpandItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_REF_EXPAND, false))
m_xExpRefCB->set_active(pExpandItem->GetValue());
bReadOnly = officecfg::Office::Calc::Input::ExpandReference::isReadOnly();
m_xExpRefCB->set_sensitive(!bReadOnly);
m_xExpRefImg->set_visible(bReadOnly);
if (const SfxBoolItem* pUpdateItem = rCoreSet->GetItemIfSet(SID_SC_OPT_SORT_REF_UPDATE))
m_xSortRefUpdateCB->set_active(pUpdateItem->GetValue());
bReadOnly = officecfg::Office::Calc::Input::UpdateReferenceOnSort::isReadOnly();
m_xSortRefUpdateCB->set_sensitive(!bReadOnly);
m_xSortRefUpdateImg->set_visible(bReadOnly);
if(const SfxBoolItem* pHeaderItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_MARK_HEADER, false))
m_xMarkHdrCB->set_active(pHeaderItem->GetValue());
bReadOnly = officecfg::Office::Calc::Input::HighlightSelection::isReadOnly();
m_xMarkHdrCB->set_sensitive(!bReadOnly);
m_xMarkHdrImg->set_visible(bReadOnly);
if( const SfxBoolItem* pWarnItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_REPLCELLSWARN, false ) )
m_xReplWarnCB->set_active( pWarnItem->GetValue() );
bReadOnly = officecfg::Office::Calc::Input::ReplaceCellsWarning::isReadOnly();
m_xReplWarnCB->set_sensitive(!bReadOnly);
m_xReplWarnImg->set_visible(bReadOnly);
if( const SfxBoolItem* pSelectionItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_LEGACY_CELL_SELECTION, false ) )
m_xLegacyCellSelectionCB->set_active( pSelectionItem->GetValue() );
bReadOnly = officecfg::Office::Calc::Input::LegacyCellSelection::isReadOnly();
m_xLegacyCellSelectionCB->set_sensitive(!bReadOnly);
m_xLegacyCellSelectionImg->set_visible(bReadOnly);
if( const SfxBoolItem* pPasteModeItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_ENTER_PASTE_MODE, false ) )
m_xEnterPasteModeCB->set_active( pPasteModeItem->GetValue() );
bReadOnly = officecfg::Office::Calc::Input::EnterPasteMode::isReadOnly();
m_xEnterPasteModeCB->set_sensitive(!bReadOnly);
m_xEnterPasteModeImg->set_visible(bReadOnly);
m_xAlignCB->save_state();
m_xAlignLB->save_value();
m_xEditModeCB->save_state();
@ -638,7 +722,8 @@ IMPL_LINK_NOARG(ScTpLayoutOptions, MetricHdl, weld::ComboBox&, void)
IMPL_LINK(ScTpLayoutOptions, AlignHdl, weld::Toggleable&, rBox, void)
{
m_xAlignLB->set_sensitive(rBox.get_active());
m_xAlignLB->set_sensitive(rBox.get_active() &&
!officecfg::Office::Calc::Input::MoveSelectionDirection::isReadOnly());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -22,7 +22,7 @@
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
<!-- n-columns=2 n-rows=2 -->
<!-- n-columns=3 n-rows=2 -->
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -40,7 +40,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>
@ -54,7 +54,7 @@
<property name="xalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
@ -72,7 +72,7 @@
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="left-attach">2</property>
<property name="top-attach">1</property>
</packing>
</child>
@ -87,10 +87,36 @@
</child>
</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="lockunitlb">
<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="locktabmf">
<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>
</object>
</child>
<child type="label">
@ -117,59 +143,83 @@
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
<object class="GtkBox">
<!-- 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="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkRadioButton" id="alwaysrb">
<property name="label" translatable="yes" context="scgeneralpage|alwaysrb">_Always (from trusted locations)</property>
<object class="GtkBox">
<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>
<property name="can-focus">False</property>
<property name="margin-start">12</property>
<property name="margin-top">6</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkRadioButton" id="alwaysrb">
<property name="label" translatable="yes" context="scgeneralpage|alwaysrb">_Always (from trusted locations)</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>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="requestrb">
<property name="label" translatable="yes" context="scgeneralpage|requestrb">_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">alwaysrb</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="neverrb">
<property name="label" translatable="yes" context="scgeneralpage|neverrb">_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">alwaysrb</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="requestrb">
<property name="label" translatable="yes" context="scgeneralpage|requestrb">_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">alwaysrb</property>
<object class="GtkImage" id="lockupdatelinks">
<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="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="neverrb">
<property name="label" translatable="yes" context="scgeneralpage|neverrb">_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">alwaysrb</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
@ -212,7 +262,7 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<!-- n-columns=2 n-rows=9 -->
<!-- n-columns=3 n-rows=9 -->
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -236,7 +286,7 @@
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="width">2</property>
</packing>
@ -256,7 +306,7 @@
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="width">2</property>
</packing>
@ -276,7 +326,7 @@
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
<property name="width">2</property>
</packing>
@ -300,7 +350,7 @@
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="left-attach">2</property>
<property name="top-attach">0</property>
</packing>
</child>
@ -314,7 +364,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>
@ -333,7 +383,7 @@
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
<property name="width">2</property>
</packing>
@ -353,7 +403,7 @@
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="width">2</property>
</packing>
@ -368,7 +418,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">2</property>
<property name="width">2</property>
</packing>
@ -388,7 +438,7 @@
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="width">2</property>
</packing>
@ -402,11 +452,128 @@
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockaligncb">
<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="lockeditmodecb">
<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="lockenter_paste">
<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="lockformatcb">
<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">3</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockexprefcb">
<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="locksortrefupdatecb">
<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>
<object class="GtkImage" id="lockmarkhdrcb">
<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">6</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockreplwarncb">
<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">7</property>
</packing>
</child>
<child>
<object class="GtkImage" id="locklegacy_cell">
<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">8</property>
</packing>
</child>
</object>
</child>
</object>