1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10*5b190011SAndrew Rist * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5b190011SAndrew Rist * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19*5b190011SAndrew Rist * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "fuzoom.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <svx/svxids.hrc> 31cdf0e10cSrcweir #include <sfx2/bindings.hxx> 32cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 33cdf0e10cSrcweir #include "app.hrc" 34cdf0e10cSrcweir #include <svx/svdpagv.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #ifndef SD_FRAMW_VIEW_HXX 37cdf0e10cSrcweir #include "FrameView.hxx" 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include "ViewShell.hxx" 40cdf0e10cSrcweir #include "View.hxx" 41cdf0e10cSrcweir #ifndef SD_WINDOW_SHELL_HXX 42cdf0e10cSrcweir #include "Window.hxx" 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #include "drawdoc.hxx" 45cdf0e10cSrcweir #include "zoomlist.hxx" 46cdf0e10cSrcweir 47cdf0e10cSrcweir namespace sd { 48cdf0e10cSrcweir 49cdf0e10cSrcweir sal_uInt16 SidArrayZoom[] = { 50cdf0e10cSrcweir SID_ATTR_ZOOM, 51cdf0e10cSrcweir SID_ZOOM_OUT, 52cdf0e10cSrcweir SID_ZOOM_IN, 53cdf0e10cSrcweir 0 }; 54cdf0e10cSrcweir 55cdf0e10cSrcweir TYPEINIT1( FuZoom, FuPoor ); 56cdf0e10cSrcweir 57cdf0e10cSrcweir /************************************************************************* 58cdf0e10cSrcweir |* 59cdf0e10cSrcweir |* Konstruktor 60cdf0e10cSrcweir |* 61cdf0e10cSrcweir \************************************************************************/ 62cdf0e10cSrcweir 63cdf0e10cSrcweir FuZoom::FuZoom( 64cdf0e10cSrcweir ViewShell* pViewSh, 65cdf0e10cSrcweir ::sd::Window* pWin, 66cdf0e10cSrcweir ::sd::View* pView, 67cdf0e10cSrcweir SdDrawDocument* pDoc, 68cdf0e10cSrcweir SfxRequest& rReq) 69cdf0e10cSrcweir : FuPoor(pViewSh, pWin, pView, pDoc, rReq), 70cdf0e10cSrcweir bVisible(sal_False), 71cdf0e10cSrcweir bStartDrag(sal_False) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir /************************************************************************* 76cdf0e10cSrcweir |* 77cdf0e10cSrcweir |* Destruktor 78cdf0e10cSrcweir |* 79cdf0e10cSrcweir \************************************************************************/ 80cdf0e10cSrcweir 81cdf0e10cSrcweir FuZoom::~FuZoom() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir if (bVisible) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir // Hide ZoomRect 86cdf0e10cSrcweir mpViewShell->DrawMarkRect(aZoomRect); 87cdf0e10cSrcweir 88cdf0e10cSrcweir bVisible = sal_False; 89cdf0e10cSrcweir bStartDrag = sal_False; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir FunctionReference FuZoom::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir FunctionReference xFunc( new FuZoom( pViewSh, pWin, pView, pDoc, rReq ) ); 96cdf0e10cSrcweir return xFunc; 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir /************************************************************************* 100cdf0e10cSrcweir |* 101cdf0e10cSrcweir |* MouseButtonDown-event 102cdf0e10cSrcweir |* 103cdf0e10cSrcweir \************************************************************************/ 104cdf0e10cSrcweir 105cdf0e10cSrcweir sal_Bool FuZoom::MouseButtonDown(const MouseEvent& rMEvt) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir // #95491# remember button state for creation of own MouseEvents 108cdf0e10cSrcweir SetMouseButtonCode(rMEvt.GetButtons()); 109cdf0e10cSrcweir 110cdf0e10cSrcweir mpWindow->CaptureMouse(); 111cdf0e10cSrcweir bStartDrag = sal_True; 112cdf0e10cSrcweir 113cdf0e10cSrcweir aBeginPosPix = rMEvt.GetPosPixel(); 114cdf0e10cSrcweir aBeginPos = mpWindow->PixelToLogic(aBeginPosPix); 115cdf0e10cSrcweir 116cdf0e10cSrcweir return sal_True; 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir /************************************************************************* 120cdf0e10cSrcweir |* 121cdf0e10cSrcweir |* MouseMove-event 122cdf0e10cSrcweir |* 123cdf0e10cSrcweir \************************************************************************/ 124cdf0e10cSrcweir 125cdf0e10cSrcweir sal_Bool FuZoom::MouseMove(const MouseEvent& rMEvt) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir if (bStartDrag) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir if (bVisible) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir mpViewShell->DrawMarkRect(aZoomRect); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir Point aPosPix = rMEvt.GetPosPixel(); 135cdf0e10cSrcweir ForceScroll(aPosPix); 136cdf0e10cSrcweir 137cdf0e10cSrcweir aEndPos = mpWindow->PixelToLogic(aPosPix); 138cdf0e10cSrcweir aBeginPos = mpWindow->PixelToLogic(aBeginPosPix); 139cdf0e10cSrcweir 140cdf0e10cSrcweir if (nSlotId == SID_ZOOM_PANNING) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir // Panning 143cdf0e10cSrcweir 144cdf0e10cSrcweir Point aScroll = aBeginPos - aEndPos; 145cdf0e10cSrcweir 146cdf0e10cSrcweir // #i2237# 147cdf0e10cSrcweir // removed old stuff here which still forced zoom to be 148cdf0e10cSrcweir // %BRUSH_SIZE which is outdated now 149cdf0e10cSrcweir 150cdf0e10cSrcweir if (aScroll.X() != 0 || aScroll.Y() != 0) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir Size aWorkSize = mpView->GetWorkArea().GetSize(); 153cdf0e10cSrcweir Size aPageSize = mpView->GetSdrPageView()->GetPage()->GetSize(); 154cdf0e10cSrcweir aScroll.X() /= aWorkSize.Width() / aPageSize.Width(); 155cdf0e10cSrcweir aScroll.Y() /= aWorkSize.Height() / aPageSize.Height(); 156cdf0e10cSrcweir mpViewShell->Scroll(aScroll.X(), aScroll.Y()); 157cdf0e10cSrcweir aBeginPosPix = aPosPix; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir } 160cdf0e10cSrcweir else 161cdf0e10cSrcweir { 162cdf0e10cSrcweir Rectangle aRect(aBeginPos, aEndPos); 163cdf0e10cSrcweir aZoomRect = aRect; 164cdf0e10cSrcweir aZoomRect.Justify(); 165cdf0e10cSrcweir mpViewShell->DrawMarkRect(aZoomRect); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir bVisible = sal_True; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir return bStartDrag; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir /************************************************************************* 175cdf0e10cSrcweir |* 176cdf0e10cSrcweir |* MouseButtonUp-event 177cdf0e10cSrcweir |* 178cdf0e10cSrcweir \************************************************************************/ 179cdf0e10cSrcweir 180cdf0e10cSrcweir sal_Bool FuZoom::MouseButtonUp(const MouseEvent& rMEvt) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir // #95491# remember button state for creation of own MouseEvents 183cdf0e10cSrcweir SetMouseButtonCode(rMEvt.GetButtons()); 184cdf0e10cSrcweir 185cdf0e10cSrcweir if (bVisible) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir // Hide ZoomRect 188cdf0e10cSrcweir mpViewShell->DrawMarkRect(aZoomRect); 189cdf0e10cSrcweir bVisible = sal_False; 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir Point aPosPix = rMEvt.GetPosPixel(); 193cdf0e10cSrcweir 194cdf0e10cSrcweir if(SID_ZOOM_PANNING != nSlotId) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir // Zoom 197cdf0e10cSrcweir Size aZoomSizePixel = mpWindow->LogicToPixel(aZoomRect).GetSize(); 198cdf0e10cSrcweir sal_uLong nTol = DRGPIX + DRGPIX; 199cdf0e10cSrcweir 200cdf0e10cSrcweir if ( aZoomSizePixel.Width() < (long) nTol && aZoomSizePixel.Height() < (long) nTol ) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir // Klick auf der Stelle: Zoomfaktor verdoppeln 203cdf0e10cSrcweir Point aPos = mpWindow->PixelToLogic(aPosPix); 204cdf0e10cSrcweir Size aSize = mpWindow->PixelToLogic(mpWindow->GetOutputSizePixel()); 205cdf0e10cSrcweir aSize.Width() /= 2; 206cdf0e10cSrcweir aSize.Height() /= 2; 207cdf0e10cSrcweir aPos.X() -= aSize.Width() / 2; 208cdf0e10cSrcweir aPos.Y() -= aSize.Height() / 2; 209cdf0e10cSrcweir aZoomRect.SetPos(aPos); 210cdf0e10cSrcweir aZoomRect.SetSize(aSize); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir mpViewShell->SetZoomRect(aZoomRect); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir Rectangle aVisAreaWin = mpWindow->PixelToLogic(Rectangle(Point(0,0), 217cdf0e10cSrcweir mpWindow->GetOutputSizePixel())); 218cdf0e10cSrcweir mpViewShell->GetZoomList()->InsertZoomRect(aVisAreaWin); 219cdf0e10cSrcweir 220cdf0e10cSrcweir bStartDrag = sal_False; 221cdf0e10cSrcweir mpWindow->ReleaseMouse(); 222cdf0e10cSrcweir mpViewShell->Cancel(); 223cdf0e10cSrcweir 224cdf0e10cSrcweir return sal_True; 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir /************************************************************************* 228cdf0e10cSrcweir |* 229cdf0e10cSrcweir |* Function aktivieren 230cdf0e10cSrcweir |* 231cdf0e10cSrcweir \************************************************************************/ 232cdf0e10cSrcweir 233cdf0e10cSrcweir void FuZoom::Activate() 234cdf0e10cSrcweir { 235cdf0e10cSrcweir aPtr = mpWindow->GetPointer(); 236cdf0e10cSrcweir 237cdf0e10cSrcweir if (nSlotId == SID_ZOOM_PANNING) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir mpWindow->SetPointer(Pointer(POINTER_HAND)); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir else 242cdf0e10cSrcweir { 243cdf0e10cSrcweir mpWindow->SetPointer(Pointer(POINTER_MAGNIFY)); 244cdf0e10cSrcweir } 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir /************************************************************************* 248cdf0e10cSrcweir |* 249cdf0e10cSrcweir |* Function deaktivieren 250cdf0e10cSrcweir |* 251cdf0e10cSrcweir \************************************************************************/ 252cdf0e10cSrcweir 253cdf0e10cSrcweir void FuZoom::Deactivate() 254cdf0e10cSrcweir { 255cdf0e10cSrcweir mpWindow->SetPointer( aPtr ); 256cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom ); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir } // end of namespace sd 259