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