1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuzoom.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
37 #include <svx/svxids.hrc>
38 #include <sfx2/bindings.hxx>
39 #include <sfx2/viewfrm.hxx>
41 #include <svx/svdpagv.hxx>
43 #ifndef SD_FRAMW_VIEW_HXX
44 #include "FrameView.hxx"
46 #include "ViewShell.hxx"
48 #ifndef SD_WINDOW_SHELL_HXX
51 #include "drawdoc.hxx"
52 #include "zoomlist.hxx"
56 USHORT SidArrayZoom
[] = {
62 TYPEINIT1( FuZoom
, FuPoor
);
64 /*************************************************************************
68 \************************************************************************/
76 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
),
82 /*************************************************************************
86 \************************************************************************/
93 mpViewShell
->DrawMarkRect(aZoomRect
);
100 FunctionReference
FuZoom::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
102 FunctionReference
xFunc( new FuZoom( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
106 /*************************************************************************
108 |* MouseButtonDown-event
110 \************************************************************************/
112 BOOL
FuZoom::MouseButtonDown(const MouseEvent
& rMEvt
)
114 // #95491# remember button state for creation of own MouseEvents
115 SetMouseButtonCode(rMEvt
.GetButtons());
117 mpWindow
->CaptureMouse();
120 aBeginPosPix
= rMEvt
.GetPosPixel();
121 aBeginPos
= mpWindow
->PixelToLogic(aBeginPosPix
);
126 /*************************************************************************
130 \************************************************************************/
132 BOOL
FuZoom::MouseMove(const MouseEvent
& rMEvt
)
138 mpViewShell
->DrawMarkRect(aZoomRect
);
141 Point aPosPix
= rMEvt
.GetPosPixel();
142 ForceScroll(aPosPix
);
144 aEndPos
= mpWindow
->PixelToLogic(aPosPix
);
145 aBeginPos
= mpWindow
->PixelToLogic(aBeginPosPix
);
147 if (nSlotId
== SID_ZOOM_PANNING
)
151 Point aScroll
= aBeginPos
- aEndPos
;
154 // removed old stuff here which still forced zoom to be
155 // %BRUSH_SIZE which is outdated now
157 if (aScroll
.X() != 0 || aScroll
.Y() != 0)
159 Size aWorkSize
= mpView
->GetWorkArea().GetSize();
160 Size aPageSize
= mpView
->GetSdrPageView()->GetPage()->GetSize();
161 aScroll
.X() /= aWorkSize
.Width() / aPageSize
.Width();
162 aScroll
.Y() /= aWorkSize
.Height() / aPageSize
.Height();
163 mpViewShell
->Scroll(aScroll
.X(), aScroll
.Y());
164 aBeginPosPix
= aPosPix
;
169 Rectangle
aRect(aBeginPos
, aEndPos
);
172 mpViewShell
->DrawMarkRect(aZoomRect
);
181 /*************************************************************************
183 |* MouseButtonUp-event
185 \************************************************************************/
187 BOOL
FuZoom::MouseButtonUp(const MouseEvent
& rMEvt
)
189 // #95491# remember button state for creation of own MouseEvents
190 SetMouseButtonCode(rMEvt
.GetButtons());
195 mpViewShell
->DrawMarkRect(aZoomRect
);
199 Point aPosPix
= rMEvt
.GetPosPixel();
201 if(SID_ZOOM_PANNING
!= nSlotId
)
204 Size aZoomSizePixel
= mpWindow
->LogicToPixel(aZoomRect
).GetSize();
205 ULONG nTol
= DRGPIX
+ DRGPIX
;
207 if ( aZoomSizePixel
.Width() < (long) nTol
&& aZoomSizePixel
.Height() < (long) nTol
)
209 // Klick auf der Stelle: Zoomfaktor verdoppeln
210 Point aPos
= mpWindow
->PixelToLogic(aPosPix
);
211 Size aSize
= mpWindow
->PixelToLogic(mpWindow
->GetOutputSizePixel());
214 aPos
.X() -= aSize
.Width() / 2;
215 aPos
.Y() -= aSize
.Height() / 2;
216 aZoomRect
.SetPos(aPos
);
217 aZoomRect
.SetSize(aSize
);
220 mpViewShell
->SetZoomRect(aZoomRect
);
223 Rectangle aVisAreaWin
= mpWindow
->PixelToLogic(Rectangle(Point(0,0),
224 mpWindow
->GetOutputSizePixel()));
225 mpViewShell
->GetZoomList()->InsertZoomRect(aVisAreaWin
);
228 mpWindow
->ReleaseMouse();
229 mpViewShell
->Cancel();
234 /*************************************************************************
236 |* Function aktivieren
238 \************************************************************************/
240 void FuZoom::Activate()
242 aPtr
= mpWindow
->GetPointer();
244 if (nSlotId
== SID_ZOOM_PANNING
)
246 mpWindow
->SetPointer(Pointer(POINTER_HAND
));
250 mpWindow
->SetPointer(Pointer(POINTER_MAGNIFY
));
254 /*************************************************************************
256 |* Function deaktivieren
258 \************************************************************************/
260 void FuZoom::Deactivate()
262 mpWindow
->SetPointer( aPtr
);
263 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom
);
265 } // end of namespace sd