diff options
-rw-r--r-- | sd/source/ui/inc/ViewShell.hxx | 1 | ||||
-rw-r--r-- | sd/source/ui/view/viewshel.cxx | 44 |
2 files changed, 45 insertions, 0 deletions
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index 5454639687ed..a7b24ef57759 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -455,6 +455,7 @@ protected: rtl::Reference<FuPoor> mxCurrentFunction; rtl::Reference<FuPoor> mxOldFunction; std::unique_ptr<ZoomList> mpZoomList; + double mfLastZoomScale; Point maViewPos; Size maViewSize; diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 296b42d064c7..efc4d7a7687f 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -178,6 +178,7 @@ void ViewShell::construct() mpView = nullptr; mpFrameView = nullptr; mpZoomList = nullptr; + mfLastZoomScale = 0; mbStartShowWithDialog = false; mnPrintedHandoutPageNum = 1; mnPrintedHandoutPageCount = 0; @@ -751,6 +752,49 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi } break; + case CommandEventId::GestureZoom: + { + const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData(); + + Reference<XSlideShowController> xSlideShowController(SlideShow::GetSlideShowController(GetViewShellBase())); + + if (pData->meEventType == GestureEventZoomType::Begin) + { + mfLastZoomScale = pData->mfScaleDelta; + bDone = true; + break; + } + + if (pData->meEventType == GestureEventZoomType::Update) + { + double deltaBetweenEvents = (pData->mfScaleDelta - mfLastZoomScale) / mfLastZoomScale; + mfLastZoomScale = pData->mfScaleDelta; + + if (pData != nullptr && !GetDocSh()->IsUIActive() && !xSlideShowController.is()) + { + const ::tools::Long nOldZoom = GetActiveWindow()->GetZoom(); + ::tools::Long nNewZoom; + Point aOldMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); + + nNewZoom = nOldZoom + deltaBetweenEvents * 100; + nNewZoom = std::max<::tools::Long>(pWin->GetMinZoom(), nNewZoom); + nNewZoom = std::min<::tools::Long>(pWin->GetMaxZoom(), nNewZoom); + + SetZoom(nNewZoom); + + // Keep mouse at same doc point before zoom + Point aNewMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); + SetWinViewPos(GetWinViewPos() - (aNewMousePos - aOldMousePos)); + + Invalidate(SID_ATTR_ZOOM); + Invalidate(SID_ATTR_ZOOMSLIDER); + } + } + + bDone = true; + } + break; + default: break; } |