diff --git a/icon-themes/colibre/sc/res/calculator_red.png b/icon-themes/colibre/sc/res/calculator_red.png new file mode 100644 index 000000000000..8580bbfa792f Binary files /dev/null and b/icon-themes/colibre/sc/res/calculator_red.png differ diff --git a/icon-themes/colibre_svg/sc/res/calculator_red.svg b/icon-themes/colibre_svg/sc/res/calculator_red.svg new file mode 100644 index 000000000000..eed78c352241 --- /dev/null +++ b/icon-themes/colibre_svg/sc/res/calculator_red.svg @@ -0,0 +1 @@ + diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 824b02714f4d..5a0aa6107562 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -378,6 +378,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/ui/Accessibility/AccessibleTableBase \ sc/source/ui/Accessibility/AccessibleText \ sc/source/ui/Accessibility/DrawModelBroadcaster \ + sc/source/ui/app/acctrl \ sc/source/ui/app/client \ sc/source/ui/app/drwtrans \ sc/source/ui/app/inputhdl \ diff --git a/sc/inc/bitmaps.hlst b/sc/inc/bitmaps.hlst index 540e44bd0bf1..34cf808d8754 100644 --- a/sc/inc/bitmaps.hlst +++ b/sc/inc/bitmaps.hlst @@ -124,4 +124,6 @@ inline constexpr OUString RID_SVXBMP_SLIDERBUTTON = u"svx/res/slidezoombutton_10 inline constexpr OUString RID_SVXBMP_SLIDERDECREASE = u"svx/res/slidezoomout_10.png"_ustr; inline constexpr OUString RID_SVXBMP_SLIDERINCREASE = u"svx/res/slidezoomin_10.png"_ustr; +inline constexpr OUString RID_BMP_CALCULATOR_RED = u"sc/res/calculator_red.png"_ustr; + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc index faaa5e64998b..193061581938 100644 --- a/sc/inc/strings.hrc +++ b/sc/inc/strings.hrc @@ -447,5 +447,6 @@ #define STR_CONTENT_WITH_UNKNOWN_ENCRYPTION NC_("STR_CONTENT_WITH_UNKNOWN_ENCRYPTION", "Document contains DRM content that is encrypted with an unknown encryption method. Only the un-encrypted content will be shown.") +#define STR_AUTOCALC_OFF NC_("STR_AUTOCALC_OFF", "AutoCalculate: Off\nClick to enable.") /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 + +#include +#include +#include +#include + +#include +#include +#include +#include + +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(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 #include +#include 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 + +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); diff --git a/sc/uiconfig/scalc/statusbar/statusbar.xml b/sc/uiconfig/scalc/statusbar/statusbar.xml index fe4994249b62..e148b28628d1 100644 --- a/sc/uiconfig/scalc/statusbar/statusbar.xml +++ b/sc/uiconfig/scalc/statusbar/statusbar.xml @@ -25,6 +25,7 @@ +