summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorHeiko Tietze <tietze.heiko@gmail.com>2024-11-27 14:33:49 +0100
committerHeiko Tietze <heiko.tietze@documentfoundation.org>2024-12-03 11:24:48 +0100
commita0db0bd2e8558bfd1b2f7491a90221280f4a38d0 (patch)
tree69517821f2b2e931725b2add89870ee956728bbc /sc/source/ui
parente99ef8f347870b42eeef5ff94672d1f32e8c0af9 (diff)
Resolves tdf#127937 - Feedback for AutoCalculate
Shows an icon in the statusbar if autocalc is off; clicking the icon toggles autocalc on Change-Id: I7fb3296281647583f6f761427d35dcd79282f06c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177418 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/app/acctrl.cxx83
-rw-r--r--sc/source/ui/app/scdll.cxx2
-rw-r--r--sc/source/ui/inc/acctrl.hxx41
-rw-r--r--sc/source/ui/view/preview.cxx1
4 files changed, 127 insertions, 0 deletions
diff --git a/sc/source/ui/app/acctrl.cxx b/sc/source/ui/app/acctrl.cxx
new file mode 100644
index 000000000000..4f3ac234c3dc
--- /dev/null
+++ b/sc/source/ui/app/acctrl.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <tools/debug.hxx>
+
+#include <svl/eitem.hxx>
+#include <vcl/event.hxx>
+#include <vcl/image.hxx>
+#include <vcl/status.hxx>
+
+#include <acctrl.hxx>
+#include <bitmaps.hlst>
+#include <scresid.hxx>
+#include <strings.hrc>
+
+SFX_IMPL_STATUSBAR_CONTROL(ScAutoCalculateControl, SfxBoolItem);
+
+ScAutoCalculateControl::ScAutoCalculateControl(sal_uInt16 _nSlotId, sal_uInt16 _nId,
+ StatusBar& rStb)
+ : SfxStatusBarControl(_nSlotId, _nId, rStb)
+{
+}
+
+ScAutoCalculateControl::~ScAutoCalculateControl() {}
+
+void ScAutoCalculateControl::StateChangedAtStatusBarControl(sal_uInt16, SfxItemState eState,
+ const SfxPoolItem* pState)
+{
+ if (eState != SfxItemState::DEFAULT || SfxItemState::DISABLED == eState)
+ return;
+
+ auto pItem = static_cast<const SfxBoolItem*>(pState);
+ if (!pItem)
+ {
+ SAL_WARN("sc", "Item wasn't a SfxBoolItem");
+ return;
+ }
+ m_bIsActive = pItem->GetValue();
+
+ GetStatusBar().SetQuickHelpText(GetId(), m_bIsActive ? "" : ScResId(STR_AUTOCALC_OFF));
+ GetStatusBar().Invalidate();
+}
+
+void ScAutoCalculateControl::Paint(const UserDrawEvent& rUsrEvt)
+{
+ vcl::RenderContext* pDev = rUsrEvt.GetRenderContext();
+ tools::Rectangle aRect(rUsrEvt.GetRect());
+ pDev->Erase();
+
+ if (!m_bIsActive)
+ {
+ const Image aImage(StockImage::Yes, RID_BMP_CALCULATOR_RED);
+
+ Point aPt = aRect.TopLeft();
+ aPt += Point((aRect.GetSize().getWidth() - aImage.GetSizePixel().getWidth()) / 2,
+ (aRect.GetSize().getHeight() - aImage.GetSizePixel().getHeight()) / 2);
+
+ pDev->DrawImage(aPt, aImage);
+ }
+}
+
+void ScAutoCalculateControl::Click()
+{
+ if (!m_bIsActive)
+ SfxStatusBarControl::Click(); // exec FID_AUTO_CALC and toggle AutoCalc on
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 694e7afdb666..c08e6a47c5f8 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -86,6 +86,7 @@
#include <filter.hxx>
#include <scabstdlg.hxx>
+#include <acctrl.hxx>
OUString ScResId(TranslateId aId)
{
@@ -173,6 +174,7 @@ void ScDLL::Init()
SvxZoomSliderControl ::RegisterControl(SID_ATTR_ZOOMSLIDER, pMod);
SvxModifyControl ::RegisterControl(SID_DOC_MODIFIED, pMod);
XmlSecStatusBarControl ::RegisterControl( SID_SIGNATURE, pMod );
+ ScAutoCalculateControl ::RegisterControl(FID_AUTO_CALC, pMod);
SvxPosSizeStatusBarControl ::RegisterControl(SID_ATTR_SIZE, pMod);
diff --git a/sc/source/ui/inc/acctrl.hxx b/sc/source/ui/inc/acctrl.hxx
new file mode 100644
index 000000000000..cfc8338286ac
--- /dev/null
+++ b/sc/source/ui/inc/acctrl.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <sfx2/stbitem.hxx>
+
+class ScAutoCalculateControl final : public SfxStatusBarControl
+{
+public:
+ ScAutoCalculateControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb);
+ virtual ~ScAutoCalculateControl() override;
+
+ virtual void StateChangedAtStatusBarControl(sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState) override;
+ virtual void Paint(const UserDrawEvent& rUsrEvt) override;
+ virtual void Click() override;
+
+ SFX_DECL_STATUSBAR_CONTROL();
+
+private:
+ bool m_bIsActive;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 51699f6aa4c7..4a96b4c61d6f 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -896,6 +896,7 @@ void ScPreview::StaticInvalidate()
SfxBindings& rBindings = pViewFrm->GetBindings();
rBindings.Invalidate(SID_STATUS_DOCPOS);
+ rBindings.Invalidate(FID_AUTO_CALC);
rBindings.Invalidate(SID_ROWCOL_SELCOUNT);
rBindings.Invalidate(SID_STATUS_PAGESTYLE);
rBindings.Invalidate(SID_PREVIEW_PREVIOUS);