1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <svx/svxids.hrc>
23 #include <sfx2/bindings.hxx>
24 #include <sfx2/viewfrm.hxx>
26 #include <svx/svdpagv.hxx>
28 #include "FrameView.hxx"
29 #include "ViewShell.hxx"
32 #include "drawdoc.hxx"
33 #include "zoomlist.hxx"
37 sal_uInt16 SidArrayZoom
[] = {
43 TYPEINIT1( FuZoom
, FuPoor
);
51 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
),
62 mpViewShell
->DrawMarkRect(aZoomRect
);
65 bStartDrag
= sal_False
;
69 FunctionReference
FuZoom::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
71 FunctionReference
xFunc( new FuZoom( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
75 sal_Bool
FuZoom::MouseButtonDown(const MouseEvent
& rMEvt
)
77 // remember button state for creation of own MouseEvents
78 SetMouseButtonCode(rMEvt
.GetButtons());
80 mpWindow
->CaptureMouse();
81 bStartDrag
= sal_True
;
83 aBeginPosPix
= rMEvt
.GetPosPixel();
84 aBeginPos
= mpWindow
->PixelToLogic(aBeginPosPix
);
89 sal_Bool
FuZoom::MouseMove(const MouseEvent
& rMEvt
)
95 mpViewShell
->DrawMarkRect(aZoomRect
);
98 Point aPosPix
= rMEvt
.GetPosPixel();
101 aEndPos
= mpWindow
->PixelToLogic(aPosPix
);
102 aBeginPos
= mpWindow
->PixelToLogic(aBeginPosPix
);
104 if (nSlotId
== SID_ZOOM_PANNING
)
108 Point aScroll
= aBeginPos
- aEndPos
;
110 if (aScroll
.X() != 0 || aScroll
.Y() != 0)
112 Size aWorkSize
= mpView
->GetWorkArea().GetSize();
113 Size aPageSize
= mpView
->GetSdrPageView()->GetPage()->GetSize();
114 aScroll
.X() /= aWorkSize
.Width() / aPageSize
.Width();
115 aScroll
.Y() /= aWorkSize
.Height() / aPageSize
.Height();
116 mpViewShell
->Scroll(aScroll
.X(), aScroll
.Y());
117 aBeginPosPix
= aPosPix
;
122 Rectangle
aRect(aBeginPos
, aEndPos
);
125 mpViewShell
->DrawMarkRect(aZoomRect
);
134 sal_Bool
FuZoom::MouseButtonUp(const MouseEvent
& rMEvt
)
136 // remember button state for creation of own MouseEvents
137 SetMouseButtonCode(rMEvt
.GetButtons());
142 mpViewShell
->DrawMarkRect(aZoomRect
);
143 bVisible
= sal_False
;
146 Point aPosPix
= rMEvt
.GetPosPixel();
148 if(SID_ZOOM_PANNING
!= nSlotId
)
151 Size aZoomSizePixel
= mpWindow
->LogicToPixel(aZoomRect
).GetSize();
152 sal_uLong nTol
= DRGPIX
+ DRGPIX
;
154 if ( aZoomSizePixel
.Width() < (long) nTol
&& aZoomSizePixel
.Height() < (long) nTol
)
156 // click at place: double zoom factor
157 Point aPos
= mpWindow
->PixelToLogic(aPosPix
);
158 Size aSize
= mpWindow
->PixelToLogic(mpWindow
->GetOutputSizePixel());
161 aPos
.X() -= aSize
.Width() / 2;
162 aPos
.Y() -= aSize
.Height() / 2;
163 aZoomRect
.SetPos(aPos
);
164 aZoomRect
.SetSize(aSize
);
167 mpViewShell
->SetZoomRect(aZoomRect
);
170 Rectangle aVisAreaWin
= mpWindow
->PixelToLogic(Rectangle(Point(0,0),
171 mpWindow
->GetOutputSizePixel()));
172 mpViewShell
->GetZoomList()->InsertZoomRect(aVisAreaWin
);
174 bStartDrag
= sal_False
;
175 mpWindow
->ReleaseMouse();
176 mpViewShell
->Cancel();
181 void FuZoom::Activate()
183 aPtr
= mpWindow
->GetPointer();
185 if (nSlotId
== SID_ZOOM_PANNING
)
187 mpWindow
->SetPointer(Pointer(POINTER_HAND
));
191 mpWindow
->SetPointer(Pointer(POINTER_MAGNIFY
));
195 void FuZoom::Deactivate()
197 mpWindow
->SetPointer( aPtr
);
198 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom
);
200 } // end of namespace sd
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */