basctl/sdi/baside.sdi               |   12 +++++++++++
 basctl/source/basicide/basides1.cxx |   38 ++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

New commits:
commit 943b8b45d80e295b1333fdc28bc8cf7ca8f95902
Author:     Rafael Lima <rafael.palma.l...@gmail.com>
AuthorDate: Sun Feb 12 17:15:52 2023 -0300
Commit:     Rafael Lima <rafael.palma.l...@gmail.com>
CommitDate: Wed Feb 22 13:36:30 2023 +0000

    tdf#153572 Implement .uno:ZoomPlus and .uno:ZoomMinus in the Basic IDE
    
    This patch implements the commands .uno:ZoomPlus and .uno:ZoomMinus in the 
Basic IDE to allow the user to zoom in/out of the code editor. With these 
commands it is possible to create a keyboard shortcut for zooming in/out.
    
    Notice that this patch only implements the commands, but it does not create 
a default shortcut, since defining which shortcut should be used needs to be 
discussed first.
    
    Change-Id: I02866b9e731bf23181d0ecfc32f978ec110e33f9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146841
    Tested-by: Jenkins
    Tested-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>

diff --git a/basctl/sdi/baside.sdi b/basctl/sdi/baside.sdi
index c1fc9b4f39e3..0d32339fc833 100644
--- a/basctl/sdi/baside.sdi
+++ b/basctl/sdi/baside.sdi
@@ -337,6 +337,18 @@ shell basctl_Shell
         StateMethod     = GetState;
     ]
 
+    SID_ZOOM_IN
+    [
+        ExecMethod      = ExecuteGlobal;
+        StateMethod     = GetState;
+    ]
+
+    SID_ZOOM_OUT
+    [
+        ExecMethod      = ExecuteGlobal;
+        StateMethod     = GetState;
+    ]
+
     SID_BASICIDE_CURRENT_ZOOM
     [
         StateMethod     = GetState;
diff --git a/basctl/source/basicide/basides1.cxx 
b/basctl/source/basicide/basides1.cxx
index c690dccddc54..5e985211aa42 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -58,6 +58,7 @@
 #include <vcl/weld.hxx>
 #include <svx/zoomsliderctrl.hxx>
 #include <svx/zoomslideritem.hxx>
+#include <basegfx/utils/zoomtools.hxx>
 
 constexpr sal_Int32 TAB_HEIGHT_MARGIN = 10;
 
@@ -68,6 +69,17 @@ using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::frame;
 
+static void lcl_InvalidateZoomSlots(SfxBindings* pBindings)
+{
+    if (!pBindings)
+        return;
+
+    static sal_uInt16 const aInval[] = {
+        SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, 0
+    };
+    pBindings->Invalidate(aInval);
+}
+
 void Shell::ExecuteSearch( SfxRequest& rReq )
 {
     if ( !pCurWin )
@@ -771,6 +783,22 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
 
             if (pArgs && pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem 
) == SfxItemState::SET)
                 SetGlobalEditorZoomLevel(static_cast<const 
SvxZoomSliderItem*>(pItem)->GetValue());
+
+            lcl_InvalidateZoomSlots(GetBindingsPtr());
+        }
+        break;
+
+        case SID_ZOOM_IN:
+        case SID_ZOOM_OUT:
+        {
+            const sal_uInt16 nOldZoom = GetCurrentZoomSliderValue();
+            sal_uInt16 nNewZoom;
+            if (nSlot == SID_ZOOM_IN)
+                nNewZoom = std::min<sal_uInt16>(GetMaxZoom(), 
basegfx::zoomtools::zoomIn(nOldZoom));
+            else
+                nNewZoom = std::max<sal_uInt16>(GetMinZoom(), 
basegfx::zoomtools::zoomOut(nOldZoom));
+            SetGlobalEditorZoomLevel(nNewZoom);
+            lcl_InvalidateZoomSlots(GetBindingsPtr());
         }
         break;
 
@@ -1137,6 +1165,16 @@ void Shell::GetState(SfxItemSet &rSet)
             }
             break;
 
+            case SID_ZOOM_IN:
+            case SID_ZOOM_OUT:
+            {
+                const sal_uInt16 nCurrentZoom = GetCurrentZoomSliderValue();
+                if ((nWh == SID_ZOOM_IN && nCurrentZoom >= GetMaxZoom()) ||
+                    (nWh == SID_ZOOM_OUT && nCurrentZoom <= GetMinZoom()))
+                    rSet.DisableItem(nWh);
+            }
+            break;
+
             case SID_ATTR_ZOOMSLIDER:
             {
                 // The zoom slider is only visible in a module window

Reply via email to