fbc285d
From b179235f702e474b115ca479b603052f422346fd Mon Sep 17 00:00:00 2001
fbc285d
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
fbc285d
Date: Wed, 7 May 2014 16:16:17 +0100
fbc285d
Subject: [PATCH] center slide after changing zoom
fbc285d
fbc285d
Change-Id: I08698b06d0485d2cd3573af665e0621b42d37349
fbc285d
---
fbc285d
 sd/source/ui/inc/ViewShell.hxx |  1 +
fbc285d
 sd/source/ui/view/viewshe2.cxx | 27 +++++++++++++++++++++++++++
fbc285d
 sd/source/ui/view/viewshel.cxx |  1 +
fbc285d
 3 files changed, 29 insertions(+)
fbc285d
fbc285d
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
fbc285d
index ce5ea31..87edbc5 100644
fbc285d
--- a/sd/source/ui/inc/ViewShell.hxx
fbc285d
+++ b/sd/source/ui/inc/ViewShell.hxx
fbc285d
@@ -206,6 +206,7 @@ public:
fbc285d
     virtual void UpdateScrollBars (void);
fbc285d
     void    Scroll(long nX, long nY);
fbc285d
     void    ScrollLines(long nX, long nY);
fbc285d
+    void    ScrollCenter();
fbc285d
     virtual void    SetZoom(long nZoom);
fbc285d
     virtual void    SetZoomRect(const Rectangle& rZoomRect);
fbc285d
     void    InitWindows(const Point& rViewOrigin, const Size& rViewSize,
fbc285d
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
fbc285d
index 5f98d68..8f91d6c 100644
fbc285d
--- a/sd/source/ui/view/viewshe2.cxx
fbc285d
+++ b/sd/source/ui/view/viewshe2.cxx
fbc285d
@@ -365,6 +365,33 @@ void ViewShell::SetZoom(long nZoom)
fbc285d
     UpdateScrollBars();
fbc285d
 }
fbc285d
 
fbc285d
+namespace
fbc285d
+{
fbc285d
+    void CenterScrollBar(ScrollBar *pBar)
fbc285d
+    {
fbc285d
+        long nVisSize = pBar->GetVisibleSize();
fbc285d
+        long nMin = pBar->GetRangeMin();
fbc285d
+        long nMax = pBar->GetRangeMax();
fbc285d
+        long nLen = nMax - nMin - nVisSize;
fbc285d
+        long nPos = nMin + nLen/2;
fbc285d
+        pBar->DoScroll(nPos);
fbc285d
+    }
fbc285d
+}
fbc285d
+
fbc285d
+void ViewShell::ScrollCenter()
fbc285d
+{
fbc285d
+    if (mpHorizontalScrollBar.get() != NULL)
fbc285d
+        CenterScrollBar(mpHorizontalScrollBar.get());
fbc285d
+
fbc285d
+    //zoom mode with no panning of the current slide, i.e. the
fbc285d
+    //scrollbar is in change slide mode not pan slide mode
fbc285d
+    if (IsPageFlipMode())
fbc285d
+        return;
fbc285d
+
fbc285d
+    if (mpVerticalScrollBar.get() != NULL)
fbc285d
+        CenterScrollBar(mpVerticalScrollBar.get());
fbc285d
+}
fbc285d
+
fbc285d
 /**
fbc285d
  * Set zoom rectangle for active window. Sets all split windows to the same zoom
fbc285d
  * factor.
fbc285d
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
fbc285d
index 28e272e..17bcf5f 100644
fbc285d
--- a/sd/source/ui/view/viewshel.cxx
fbc285d
+++ b/sd/source/ui/view/viewshel.cxx
fbc285d
@@ -683,6 +683,7 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
fbc285d
                             nNewZoom = std::min( (long) pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom ));
fbc285d
 
fbc285d
                         SetZoom( nNewZoom );
fbc285d
+                        ScrollCenter(); //center slide after changing zoom
fbc285d
                         Invalidate( SID_ATTR_ZOOM );
fbc285d
                         Invalidate( SID_ATTR_ZOOMSLIDER );
fbc285d
 
fbc285d
-- 
fbc285d
1.9.0
fbc285d