From 1cfc2e2c92e1259341ee18cf87be63c4dcebd33d Mon Sep 17 00:00:00 2001 From: Sahil Gautam Date: Wed, 17 Apr 2024 18:12:18 +0530 Subject: tdf#63374 Change cell background color when in edit mode Set the edit cell background (EditView) color to CALCCELLFOCUS and allow enabling/disabling via a checkbox tools > options > Calc > View > Edit cell background highlighting Change-Id: I1216dfa0880e1080d23059512e3801d6af3b3c11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165075 Tested-by: Jenkins Tested-by: Heiko Tietze Reviewed-by: Heiko Tietze --- .../registry/schema/org/openoffice/Office/Calc.xcs | 8 +++++ sc/source/ui/inc/tpview.hxx | 2 ++ sc/source/ui/optdlg/tpview.cxx | 16 +++++++++ sc/source/ui/view/gridwin4.cxx | 10 ++++++ sc/uiconfig/scalc/ui/tpviewpage.ui | 42 +++++++++++++++++++--- 5 files changed, 73 insertions(+), 5 deletions(-) diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs index 5582b346910d..fb6edf076f17 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs @@ -137,6 +137,14 @@ false + + + + Indicates whether the edit cell background highlighting is enabled or not. + + + false + diff --git a/sc/source/ui/inc/tpview.hxx b/sc/source/ui/inc/tpview.hxx index 97addc9f530d..ace65836d800 100644 --- a/sc/source/ui/inc/tpview.hxx +++ b/sc/source/ui/inc/tpview.hxx @@ -47,6 +47,8 @@ class ScTpContentOptions : public SfxTabPage std::unique_ptr m_xValueImg; std::unique_ptr m_xColRowHighCB; std::unique_ptr m_xColRowHighImg; + std::unique_ptr m_xEditCellBgHighCB; + std::unique_ptr m_xEditCellBgHighImg; std::unique_ptr m_xAnchorCB; std::unique_ptr m_xAnchorImg; std::unique_ptr m_xRangeFindCB; diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx index 779dcdd3a96c..d4d9f6731add 100644 --- a/sc/source/ui/optdlg/tpview.cxx +++ b/sc/source/ui/optdlg/tpview.cxx @@ -54,6 +54,8 @@ ScTpContentOptions::ScTpContentOptions(weld::Container* pPage, weld::DialogContr , m_xValueImg(m_xBuilder->weld_widget("lockvalue")) , m_xColRowHighCB(m_xBuilder->weld_check_button("colrowhigh")) , m_xColRowHighImg(m_xBuilder->weld_widget("lockcolrowhigh")) + , m_xEditCellBgHighCB(m_xBuilder->weld_check_button("editcellbg")) + , m_xEditCellBgHighImg(m_xBuilder->weld_widget("lockeditcellbghigh")) , m_xAnchorCB(m_xBuilder->weld_check_button("anchor")) , m_xAnchorImg(m_xBuilder->weld_widget("lockanchor")) , m_xRangeFindCB(m_xBuilder->weld_check_button("rangefind")) @@ -97,6 +99,7 @@ ScTpContentOptions::ScTpContentOptions(weld::Container* pPage, weld::DialogContr m_xFormulaMarkCB->connect_toggled(aCBHdl); m_xValueCB->connect_toggled(aCBHdl); m_xColRowHighCB->connect_toggled(aCBHdl); + m_xEditCellBgHighCB->connect_toggled(aCBHdl); m_xAnchorCB->connect_toggled(aCBHdl); m_xVScrollCB->connect_toggled(aCBHdl); @@ -189,6 +192,13 @@ bool ScTpContentOptions::FillItemSet( SfxItemSet* rCoreSet ) pChange->commit(); bRet = true; } + if (m_xEditCellBgHighCB->get_state_changed_from_saved()) + { + auto pChange(comphelper::ConfigurationChanges::create()); + officecfg::Office::Calc::Content::Display::EditCellBackgroundHighlighting::set(m_xEditCellBgHighCB->get_active(), pChange); + pChange->commit(); + bRet = true; + } return bRet; } @@ -205,6 +215,7 @@ void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet ) m_xFormulaMarkCB->set_active(m_xLocalOptions->GetOption(VOPT_FORMULAS_MARKS)); m_xValueCB ->set_active(m_xLocalOptions->GetOption(VOPT_SYNTAX)); m_xColRowHighCB->set_active(officecfg::Office::Calc::Content::Display::ColumnRowHighlighting::get()); + m_xEditCellBgHighCB->set_active(officecfg::Office::Calc::Content::Display::EditCellBackgroundHighlighting::get()); m_xAnchorCB ->set_active(m_xLocalOptions->GetOption(VOPT_ANCHOR)); m_xObjGrfLB ->set_active( static_cast(m_xLocalOptions->GetObjMode(VOBJ_TYPE_OLE)) ); @@ -269,6 +280,10 @@ void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet ) m_xColRowHighCB->set_sensitive(!bReadOnly); m_xColRowHighImg->set_visible(bReadOnly); + bReadOnly = officecfg::Office::Calc::Content::Display::EditCellBackgroundHighlighting::isReadOnly(); + m_xEditCellBgHighCB->set_sensitive(!bReadOnly); + m_xEditCellBgHighImg->set_visible(bReadOnly); + bReadOnly = officecfg::Office::Calc::Content::Display::Anchor::isReadOnly(); m_xAnchorCB->set_sensitive(!bReadOnly); m_xAnchorImg->set_visible(bReadOnly); @@ -331,6 +346,7 @@ void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet ) m_xFormulaMarkCB->save_state(); m_xValueCB->save_state(); m_xColRowHighCB->save_state(); + m_xEditCellBgHighCB->save_state(); m_xAnchorCB->save_state(); m_xObjGrfLB->save_value(); m_xDiagramLB->save_value(); diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 5c4ea63e268a..896d44f5898b 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -720,6 +721,15 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI SCCOL nEditEndCol = mrViewData.GetEditEndCol(); SCROW nEditEndRow = mrViewData.GetEditEndRow(); + if (officecfg::Office::Calc::Content::Display::EditCellBackgroundHighlighting::get() + && !getViewData().GetMarkData().IsMarked()) + { + const Color aBackgroundColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; + Color aHighlightColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCCELLFOCUS).nColor; + aHighlightColor.Merge(aBackgroundColor, 100); + pEditView->SetBackgroundColor(aHighlightColor); + } + if ( nEditEndCol >= nX1 && nEditCol <= nX2 && nEditEndRow >= nY1 && nEditRow <= nY2 ) aOutputData.SetEditCell( nEditCol, nEditRow ); else diff --git a/sc/uiconfig/scalc/ui/tpviewpage.ui b/sc/uiconfig/scalc/ui/tpviewpage.ui index 2213fd24bd38..68d41c216387 100644 --- a/sc/uiconfig/scalc/ui/tpviewpage.ui +++ b/sc/uiconfig/scalc/ui/tpviewpage.ui @@ -20,7 +20,7 @@ 0 none - + True False @@ -127,7 +127,7 @@ 1 - 7 + 8 @@ -192,7 +192,7 @@ 0 - 6 + 7 @@ -224,7 +224,7 @@ 1 - 6 + 7 @@ -237,7 +237,7 @@ 0 - 7 + 8 @@ -272,6 +272,38 @@ 5 + + + Edit cell background highlighting + True + True + False + True + True + + + Mark the Edit cell background highlighting checkbox to show cell frame background color as the edit cell background. + + + + + 1 + 6 + + + + + False + True + center + center + res/lock.png + + + 0 + 6 + + -- cgit