xref: /AOO41X/main/sd/source/ui/view/sdwindow.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #include "Window.hxx"
32*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
33*cdf0e10cSrcweir #include <sfx2/request.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
36*cdf0e10cSrcweir #include <svx/svxids.hrc>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <editeng/outliner.hxx>
39*cdf0e10cSrcweir #include <editeng/editview.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include "app.hrc"
42*cdf0e10cSrcweir #include "helpids.h"
43*cdf0e10cSrcweir #include "ViewShell.hxx"
44*cdf0e10cSrcweir #include "DrawViewShell.hxx"
45*cdf0e10cSrcweir #include "View.hxx"
46*cdf0e10cSrcweir #include "FrameView.hxx"
47*cdf0e10cSrcweir #include "OutlineViewShell.hxx"
48*cdf0e10cSrcweir #include "drawdoc.hxx"
49*cdf0e10cSrcweir #include "AccessibleDrawDocumentView.hxx"
50*cdf0e10cSrcweir #include "WindowUpdater.hxx"
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace sd {
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #define SCROLL_LINE_FACT   0.05     // Faktor fuer Zeilenscrolling
55*cdf0e10cSrcweir #define SCROLL_PAGE_FACT   0.5      // Faktor fuer Seitenscrolling
56*cdf0e10cSrcweir #define SCROLL_SENSITIVE   20       // Sensitiver Bereich (Pixel)
57*cdf0e10cSrcweir #define ZOOM_MULTIPLICATOR 10000    // Multiplikator um Rundungsfehler zu vermeiden
58*cdf0e10cSrcweir #define MIN_ZOOM	       5        // Minimaler Zoomfaktor
59*cdf0e10cSrcweir #define MAX_ZOOM	       3000	    // Maximaler Zoomfaktor
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir /*************************************************************************
63*cdf0e10cSrcweir |*
64*cdf0e10cSrcweir |* Konstruktor
65*cdf0e10cSrcweir |*
66*cdf0e10cSrcweir \************************************************************************/
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir Window::Window(::Window* pParent)
69*cdf0e10cSrcweir     : ::Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
70*cdf0e10cSrcweir 	  DropTargetHelper( this ),
71*cdf0e10cSrcweir       mpShareWin(NULL),
72*cdf0e10cSrcweir       maWinPos(0, 0),			// vorsichtshalber; die Werte sollten aber
73*cdf0e10cSrcweir       maViewOrigin(0, 0),		// vom Besitzer des Fensters neu gesetzt
74*cdf0e10cSrcweir       maViewSize(1000, 1000),	// werden
75*cdf0e10cSrcweir       mnMinZoom(MIN_ZOOM),
76*cdf0e10cSrcweir       mnMaxZoom(MAX_ZOOM),
77*cdf0e10cSrcweir 	  mbMinZoomAutoCalc(false),
78*cdf0e10cSrcweir       mbCalcMinZoomByMinSide(true),
79*cdf0e10cSrcweir       mbCenterAllowed(true),
80*cdf0e10cSrcweir       mnTicks (0),
81*cdf0e10cSrcweir       mbDraggedFrom(false),
82*cdf0e10cSrcweir       mpViewShell(NULL),
83*cdf0e10cSrcweir       mbUseDropScroll (true)
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir 	SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 	MapMode aMap(GetMapMode());
88*cdf0e10cSrcweir 	aMap.SetMapUnit(MAP_100TH_MM);
89*cdf0e10cSrcweir 	SetMapMode(aMap);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	// Damit im Diamodus die ::WindowColor genommen wird
92*cdf0e10cSrcweir 	SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetWindowColor() ) );
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	// adjust contrast mode initially
95*cdf0e10cSrcweir 	bool bUseContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
96*cdf0e10cSrcweir     SetDrawMode( bUseContrast
97*cdf0e10cSrcweir         ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
98*cdf0e10cSrcweir         : ViewShell::OUTPUT_DRAWMODE_COLOR );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	// Hilfe-ID setzen
101*cdf0e10cSrcweir 	// SetHelpId(HID_SD_WIN_DOCUMENT);
102*cdf0e10cSrcweir 	SetUniqueId(HID_SD_WIN_DOCUMENT);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	// #i78183# Added after discussed with AF
105*cdf0e10cSrcweir 	EnableRTL(sal_False);
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir /*************************************************************************
109*cdf0e10cSrcweir |*
110*cdf0e10cSrcweir |* Destruktor
111*cdf0e10cSrcweir |*
112*cdf0e10cSrcweir \************************************************************************/
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir Window::~Window (void)
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir     if (mpViewShell != NULL)
117*cdf0e10cSrcweir     {
118*cdf0e10cSrcweir         WindowUpdater* pWindowUpdater = mpViewShell->GetWindowUpdater();
119*cdf0e10cSrcweir         if (pWindowUpdater != NULL)
120*cdf0e10cSrcweir             pWindowUpdater->UnregisterWindow (this);
121*cdf0e10cSrcweir     }
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir void Window::SetViewShell (ViewShell* pViewSh)
128*cdf0e10cSrcweir {
129*cdf0e10cSrcweir     WindowUpdater* pWindowUpdater = NULL;
130*cdf0e10cSrcweir     // Unregister at device updater of old view shell.
131*cdf0e10cSrcweir     if (mpViewShell != NULL)
132*cdf0e10cSrcweir     {
133*cdf0e10cSrcweir         pWindowUpdater = mpViewShell->GetWindowUpdater();
134*cdf0e10cSrcweir         if (pWindowUpdater != NULL)
135*cdf0e10cSrcweir             pWindowUpdater->UnregisterWindow (this);
136*cdf0e10cSrcweir     }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     mpViewShell = pViewSh;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     // Register at device updater of new view shell
141*cdf0e10cSrcweir     if (mpViewShell != NULL)
142*cdf0e10cSrcweir     {
143*cdf0e10cSrcweir         pWindowUpdater = mpViewShell->GetWindowUpdater();
144*cdf0e10cSrcweir         if (pWindowUpdater != NULL)
145*cdf0e10cSrcweir             pWindowUpdater->RegisterWindow (this);
146*cdf0e10cSrcweir     }
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir void Window::CalcMinZoom()
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir     // Are we entitled to change the minimal zoom factor?
152*cdf0e10cSrcweir 	if ( mbMinZoomAutoCalc )
153*cdf0e10cSrcweir 	{
154*cdf0e10cSrcweir         // Get current zoom factor.
155*cdf0e10cSrcweir 		long nZoom = GetZoom();
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 		if ( mpShareWin )
158*cdf0e10cSrcweir 		{
159*cdf0e10cSrcweir 			mpShareWin->CalcMinZoom();
160*cdf0e10cSrcweir 			mnMinZoom = mpShareWin->mnMinZoom;
161*cdf0e10cSrcweir 		}
162*cdf0e10cSrcweir 		else
163*cdf0e10cSrcweir 		{
164*cdf0e10cSrcweir             // Get the rectangle of the output area in logical coordinates
165*cdf0e10cSrcweir             // and calculate the scaling factors that would lead to the view
166*cdf0e10cSrcweir             // area (also called application area) to completely fill the
167*cdf0e10cSrcweir             // window.
168*cdf0e10cSrcweir 			Size aWinSize = PixelToLogic(GetOutputSizePixel());
169*cdf0e10cSrcweir 			sal_uLong nX = (sal_uLong) ((double) aWinSize.Width()
170*cdf0e10cSrcweir                 * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Width());
171*cdf0e10cSrcweir 			sal_uLong nY = (sal_uLong) ((double) aWinSize.Height()
172*cdf0e10cSrcweir                 * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Height());
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir             // Decide whether to take the larger or the smaller factor.
175*cdf0e10cSrcweir 			sal_uLong nFact;
176*cdf0e10cSrcweir 			if (mbCalcMinZoomByMinSide)
177*cdf0e10cSrcweir                 nFact = Min(nX, nY);
178*cdf0e10cSrcweir 			else
179*cdf0e10cSrcweir                 nFact = Max(nX, nY);
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir             // The factor is tansfomed according to the current zoom factor.
182*cdf0e10cSrcweir 			nFact = nFact * nZoom / ZOOM_MULTIPLICATOR;
183*cdf0e10cSrcweir 			mnMinZoom = Max((sal_uInt16) MIN_ZOOM, (sal_uInt16) nFact);
184*cdf0e10cSrcweir 		}
185*cdf0e10cSrcweir         // If the current zoom factor is smaller than the calculated minimal
186*cdf0e10cSrcweir         // zoom factor then set the new minimal factor as the current zoom
187*cdf0e10cSrcweir         // factor.
188*cdf0e10cSrcweir 		if ( nZoom < (long) mnMinZoom )
189*cdf0e10cSrcweir 			SetZoomFactor(mnMinZoom);
190*cdf0e10cSrcweir 	}
191*cdf0e10cSrcweir }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir void Window::SetMinZoom (long int nMin)
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir     mnMinZoom = (sal_uInt16) nMin;
199*cdf0e10cSrcweir }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir long Window::GetMinZoom (void) const
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir     return mnMinZoom;
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir void Window::SetMaxZoom (long int nMax)
213*cdf0e10cSrcweir {
214*cdf0e10cSrcweir     mnMaxZoom = (sal_uInt16) nMax;
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir long Window::GetMaxZoom (void) const
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir     return mnMaxZoom;
223*cdf0e10cSrcweir }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir long Window::GetZoom (void) const
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir 	if( GetMapMode().GetScaleX().GetDenominator() )
231*cdf0e10cSrcweir 	{
232*cdf0e10cSrcweir 		return GetMapMode().GetScaleX().GetNumerator() * 100L
233*cdf0e10cSrcweir 			/ GetMapMode().GetScaleX().GetDenominator();
234*cdf0e10cSrcweir 	}
235*cdf0e10cSrcweir 	else
236*cdf0e10cSrcweir 	{
237*cdf0e10cSrcweir 		return 0;
238*cdf0e10cSrcweir 	}
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir /*************************************************************************
245*cdf0e10cSrcweir |*
246*cdf0e10cSrcweir |* Resize event
247*cdf0e10cSrcweir |*
248*cdf0e10cSrcweir \************************************************************************/
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir void Window::Resize()
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir 	::Window::Resize();
253*cdf0e10cSrcweir 	CalcMinZoom();
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     if( mpViewShell && mpViewShell->GetViewFrame() )
256*cdf0e10cSrcweir         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir /*************************************************************************
260*cdf0e10cSrcweir |*
261*cdf0e10cSrcweir |* PrePaint event
262*cdf0e10cSrcweir |*
263*cdf0e10cSrcweir \************************************************************************/
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir void Window::PrePaint()
266*cdf0e10cSrcweir {
267*cdf0e10cSrcweir 	if ( mpViewShell )
268*cdf0e10cSrcweir 		mpViewShell->PrePaint();
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir /*************************************************************************
272*cdf0e10cSrcweir |*
273*cdf0e10cSrcweir |* Paint event
274*cdf0e10cSrcweir |*
275*cdf0e10cSrcweir \************************************************************************/
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir void Window::Paint(const Rectangle& rRect)
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir 	if ( mpViewShell )
280*cdf0e10cSrcweir 		mpViewShell->Paint(rRect, this);
281*cdf0e10cSrcweir }
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir /*************************************************************************
284*cdf0e10cSrcweir |*
285*cdf0e10cSrcweir |* Keyboard event
286*cdf0e10cSrcweir |*
287*cdf0e10cSrcweir \************************************************************************/
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir void Window::KeyInput(const KeyEvent& rKEvt)
290*cdf0e10cSrcweir {
291*cdf0e10cSrcweir 	if (!(mpViewShell && mpViewShell->KeyInput(rKEvt, this)))
292*cdf0e10cSrcweir 	{
293*cdf0e10cSrcweir 		if (mpViewShell && rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
294*cdf0e10cSrcweir 		{
295*cdf0e10cSrcweir             mpViewShell->GetViewShell()->Escape();
296*cdf0e10cSrcweir 		}
297*cdf0e10cSrcweir 		else
298*cdf0e10cSrcweir 		{
299*cdf0e10cSrcweir 			::Window::KeyInput(rKEvt);
300*cdf0e10cSrcweir 		}
301*cdf0e10cSrcweir 	}
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir /*************************************************************************
305*cdf0e10cSrcweir |*
306*cdf0e10cSrcweir |* MouseButtonDown event
307*cdf0e10cSrcweir |*
308*cdf0e10cSrcweir \************************************************************************/
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir void Window::MouseButtonDown(const MouseEvent& rMEvt)
311*cdf0e10cSrcweir {
312*cdf0e10cSrcweir 	if ( mpViewShell )
313*cdf0e10cSrcweir 		mpViewShell->MouseButtonDown(rMEvt, this);
314*cdf0e10cSrcweir }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir /*************************************************************************
317*cdf0e10cSrcweir |*
318*cdf0e10cSrcweir |* MouseMove event
319*cdf0e10cSrcweir |*
320*cdf0e10cSrcweir \************************************************************************/
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir void Window::MouseMove(const MouseEvent& rMEvt)
323*cdf0e10cSrcweir {
324*cdf0e10cSrcweir 	if ( mpViewShell )
325*cdf0e10cSrcweir 		mpViewShell->MouseMove(rMEvt, this);
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir /*************************************************************************
329*cdf0e10cSrcweir |*
330*cdf0e10cSrcweir |* MouseButtonUp event
331*cdf0e10cSrcweir |*
332*cdf0e10cSrcweir \************************************************************************/
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir void Window::MouseButtonUp(const MouseEvent& rMEvt)
335*cdf0e10cSrcweir {
336*cdf0e10cSrcweir 	mnTicks = 0;
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 	if ( mpViewShell )
339*cdf0e10cSrcweir 		mpViewShell->MouseButtonUp(rMEvt, this);
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir /*************************************************************************
343*cdf0e10cSrcweir |*
344*cdf0e10cSrcweir |* Command event
345*cdf0e10cSrcweir |*
346*cdf0e10cSrcweir \************************************************************************/
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir void Window::Command(const CommandEvent& rCEvt)
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir 	if ( mpViewShell )
351*cdf0e10cSrcweir 		mpViewShell->Command(rCEvt, this);
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir long Window::Notify( NotifyEvent& rNEvt )
355*cdf0e10cSrcweir {
356*cdf0e10cSrcweir     long nResult = sal_False;
357*cdf0e10cSrcweir     if ( mpViewShell )
358*cdf0e10cSrcweir     {
359*cdf0e10cSrcweir         nResult = mpViewShell->Notify(rNEvt, this);
360*cdf0e10cSrcweir     }
361*cdf0e10cSrcweir     if( !nResult )
362*cdf0e10cSrcweir         nResult = ::Window::Notify( rNEvt );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir     return nResult;
365*cdf0e10cSrcweir }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir /*************************************************************************
369*cdf0e10cSrcweir |*
370*cdf0e10cSrcweir |* RequestHelp event
371*cdf0e10cSrcweir |*
372*cdf0e10cSrcweir \************************************************************************/
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir void Window::RequestHelp(const HelpEvent& rEvt)
375*cdf0e10cSrcweir {
376*cdf0e10cSrcweir 	if ( mpViewShell )
377*cdf0e10cSrcweir 	{
378*cdf0e10cSrcweir 		if( !mpViewShell->RequestHelp( rEvt, this) )
379*cdf0e10cSrcweir 			::Window::RequestHelp( rEvt );
380*cdf0e10cSrcweir 	}
381*cdf0e10cSrcweir 	else
382*cdf0e10cSrcweir 		::Window::RequestHelp( rEvt );
383*cdf0e10cSrcweir }
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir Point Window::GetWinViewPos (void) const
389*cdf0e10cSrcweir {
390*cdf0e10cSrcweir     return maWinPos;
391*cdf0e10cSrcweir }
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir Point Window::GetViewOrigin (void) const
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir     return maViewOrigin;
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir Size Window::GetViewSize (void) const
405*cdf0e10cSrcweir {
406*cdf0e10cSrcweir     return maViewSize;
407*cdf0e10cSrcweir }
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir /*************************************************************************
413*cdf0e10cSrcweir |*
414*cdf0e10cSrcweir |* Position der linken oberen Ecke des im Fenster sichtbaren Bereichs
415*cdf0e10cSrcweir |* setzen
416*cdf0e10cSrcweir |*
417*cdf0e10cSrcweir \************************************************************************/
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir void Window::SetWinViewPos(const Point& rPnt)
420*cdf0e10cSrcweir {
421*cdf0e10cSrcweir 	maWinPos = rPnt;
422*cdf0e10cSrcweir }
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir /*************************************************************************
425*cdf0e10cSrcweir |*
426*cdf0e10cSrcweir |* Ursprung der Darstellung in Bezug zur gesamten Arbeitsflaeche setzen
427*cdf0e10cSrcweir |*
428*cdf0e10cSrcweir \************************************************************************/
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir void Window::SetViewOrigin(const Point& rPnt)
431*cdf0e10cSrcweir {
432*cdf0e10cSrcweir 	maViewOrigin = rPnt;
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir /*************************************************************************
436*cdf0e10cSrcweir |*
437*cdf0e10cSrcweir |* Groesse der gesamten Arbeitsflaeche, die mit dem Fenster betrachtet
438*cdf0e10cSrcweir |* werden kann, setzen
439*cdf0e10cSrcweir |*
440*cdf0e10cSrcweir \************************************************************************/
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir void Window::SetViewSize(const Size& rSize)
443*cdf0e10cSrcweir {
444*cdf0e10cSrcweir 	maViewSize = rSize;
445*cdf0e10cSrcweir 	CalcMinZoom();
446*cdf0e10cSrcweir }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir void Window::SetCenterAllowed (bool bIsAllowed)
452*cdf0e10cSrcweir {
453*cdf0e10cSrcweir     mbCenterAllowed = bIsAllowed;
454*cdf0e10cSrcweir }
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir long Window::SetZoomFactor(long nZoom)
460*cdf0e10cSrcweir {
461*cdf0e10cSrcweir     // Clip the zoom factor to the valid range marked by nMinZoom as
462*cdf0e10cSrcweir     // calculated by CalcMinZoom() and the constant MAX_ZOOM.
463*cdf0e10cSrcweir 	if ( nZoom > MAX_ZOOM )
464*cdf0e10cSrcweir         nZoom = MAX_ZOOM;
465*cdf0e10cSrcweir 	if ( nZoom < (long) mnMinZoom )
466*cdf0e10cSrcweir         nZoom = mnMinZoom;
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir     // Set the zoom factor at the window's map mode.
469*cdf0e10cSrcweir 	MapMode aMap(GetMapMode());
470*cdf0e10cSrcweir 	aMap.SetScaleX(Fraction(nZoom, 100));
471*cdf0e10cSrcweir 	aMap.SetScaleY(Fraction(nZoom, 100));
472*cdf0e10cSrcweir 	SetMapMode(aMap);
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir     // Update the map mode's origin (to what effect?).
475*cdf0e10cSrcweir 	UpdateMapOrigin();
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir     // Update the view's snapping to the the new zoom factor.
478*cdf0e10cSrcweir 	if ( mpViewShell && mpViewShell->ISA(DrawViewShell) )
479*cdf0e10cSrcweir 		((DrawViewShell*) mpViewShell)->GetView()->
480*cdf0e10cSrcweir 										RecalcLogicSnapMagnetic(*this);
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir     // Return the zoom factor just in case it has been changed above to lie
483*cdf0e10cSrcweir     // inside the valid range.
484*cdf0e10cSrcweir 	return nZoom;
485*cdf0e10cSrcweir }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir void Window::SetZoomIntegral(long nZoom)
488*cdf0e10cSrcweir {
489*cdf0e10cSrcweir     // Clip the zoom factor to the valid range marked by nMinZoom as
490*cdf0e10cSrcweir     // previously calculated by <member>CalcMinZoom()</member> and the
491*cdf0e10cSrcweir     // MAX_ZOOM constant.
492*cdf0e10cSrcweir 	if ( nZoom > MAX_ZOOM )
493*cdf0e10cSrcweir         nZoom = MAX_ZOOM;
494*cdf0e10cSrcweir 	if ( nZoom < (long) mnMinZoom )
495*cdf0e10cSrcweir         nZoom = mnMinZoom;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir     // Calculate the window's new origin.
498*cdf0e10cSrcweir 	Size aSize = PixelToLogic(GetOutputSizePixel());
499*cdf0e10cSrcweir 	long nW = aSize.Width()  * GetZoom() / nZoom;
500*cdf0e10cSrcweir 	long nH = aSize.Height() * GetZoom() / nZoom;
501*cdf0e10cSrcweir 	maWinPos.X() += (aSize.Width()  - nW) / 2;
502*cdf0e10cSrcweir 	maWinPos.Y() += (aSize.Height() - nH) / 2;
503*cdf0e10cSrcweir 	if ( maWinPos.X() < 0 ) maWinPos.X() = 0;
504*cdf0e10cSrcweir 	if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0;
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir     // Finally update this window's map mode to the given zoom factor that
507*cdf0e10cSrcweir     // has been clipped to the valid range.
508*cdf0e10cSrcweir 	SetZoomFactor(nZoom);
509*cdf0e10cSrcweir }
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir long Window::GetZoomForRect( const Rectangle& rZoomRect )
512*cdf0e10cSrcweir {
513*cdf0e10cSrcweir 	long nRetZoom = 100;
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir     if( (rZoomRect.GetWidth() != 0) && (rZoomRect.GetHeight() != 0))
516*cdf0e10cSrcweir     {
517*cdf0e10cSrcweir         // Calculate the scale factors which will lead to the given
518*cdf0e10cSrcweir         // rectangle being fully visible (when translated accordingly) as
519*cdf0e10cSrcweir         // large as possible in the output area independently in both
520*cdf0e10cSrcweir         // coordinate directions .
521*cdf0e10cSrcweir 		sal_uLong nX(0L);
522*cdf0e10cSrcweir 		sal_uLong nY(0L);
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir         const Size aWinSize( PixelToLogic(GetOutputSizePixel()) );
525*cdf0e10cSrcweir 		if(rZoomRect.GetHeight())
526*cdf0e10cSrcweir 		{
527*cdf0e10cSrcweir 			nX = (sal_uLong) ((double) aWinSize.Height()
528*cdf0e10cSrcweir 			   * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight());
529*cdf0e10cSrcweir 		}
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 		if(rZoomRect.GetWidth())
532*cdf0e10cSrcweir 		{
533*cdf0e10cSrcweir 			nY = (sal_uLong) ((double) aWinSize.Width()
534*cdf0e10cSrcweir 				* (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth());
535*cdf0e10cSrcweir 		}
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir         // Use the smaller one of both so that the zoom rectangle will be
538*cdf0e10cSrcweir         // fully visible with respect to both coordinate directions.
539*cdf0e10cSrcweir 		sal_uLong nFact = Min(nX, nY);
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir         // Transform the current zoom factor so that it leads to the desired
542*cdf0e10cSrcweir         // scaling.
543*cdf0e10cSrcweir 		nRetZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir         // Calculate the new origin.
546*cdf0e10cSrcweir 		if ( nFact == 0 )
547*cdf0e10cSrcweir 		{
548*cdf0e10cSrcweir             // Don't change anything if the scale factor is degenrate.
549*cdf0e10cSrcweir 			nRetZoom = GetZoom();
550*cdf0e10cSrcweir 		}
551*cdf0e10cSrcweir 		else
552*cdf0e10cSrcweir 		{
553*cdf0e10cSrcweir             // Clip the zoom factor to the valid range marked by nMinZoom as
554*cdf0e10cSrcweir             // previously calculated by <member>CalcMinZoom()</member> and the
555*cdf0e10cSrcweir             // MAX_ZOOM constant.
556*cdf0e10cSrcweir 	        if ( nRetZoom > MAX_ZOOM )
557*cdf0e10cSrcweir                 nRetZoom = MAX_ZOOM;
558*cdf0e10cSrcweir 	        if ( nRetZoom < (long) mnMinZoom )
559*cdf0e10cSrcweir                 nRetZoom = mnMinZoom;
560*cdf0e10cSrcweir        }
561*cdf0e10cSrcweir     }
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir     return nRetZoom;
564*cdf0e10cSrcweir }
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir /** Recalculate the zoom factor and translation so that the given rectangle
567*cdf0e10cSrcweir     is displayed centered and as large as possible while still being fully
568*cdf0e10cSrcweir     visible in the window.
569*cdf0e10cSrcweir */
570*cdf0e10cSrcweir long Window::SetZoomRect (const Rectangle& rZoomRect)
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir 	long nNewZoom = 100;
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir 	if (rZoomRect.GetWidth() == 0 || rZoomRect.GetHeight() == 0)
575*cdf0e10cSrcweir 	{
576*cdf0e10cSrcweir         // The given rectangle is degenerate.  Use the default zoom factor
577*cdf0e10cSrcweir         // (above) of 100%.
578*cdf0e10cSrcweir 		SetZoomIntegral(nNewZoom);
579*cdf0e10cSrcweir 	}
580*cdf0e10cSrcweir 	else
581*cdf0e10cSrcweir 	{
582*cdf0e10cSrcweir 		Point aPos = rZoomRect.TopLeft();
583*cdf0e10cSrcweir         // Transform the output area from pixel coordinates into logical
584*cdf0e10cSrcweir         // coordinates.
585*cdf0e10cSrcweir 		Size aWinSize = PixelToLogic(GetOutputSizePixel());
586*cdf0e10cSrcweir         // Paranoia!  The degenerate case of zero width or height has been
587*cdf0e10cSrcweir         // taken care of above.
588*cdf0e10cSrcweir 		DBG_ASSERT(rZoomRect.GetWidth(), "ZoomRect-Breite = 0!");
589*cdf0e10cSrcweir 		DBG_ASSERT(rZoomRect.GetHeight(), "ZoomRect-Hoehe = 0!");
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir         // Calculate the scale factors which will lead to the given
592*cdf0e10cSrcweir         // rectangle being fully visible (when translated accordingly) as
593*cdf0e10cSrcweir         // large as possible in the output area independently in both
594*cdf0e10cSrcweir         // coordinate directions .
595*cdf0e10cSrcweir 		sal_uLong nX(0L);
596*cdf0e10cSrcweir 		sal_uLong nY(0L);
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 		if(rZoomRect.GetHeight())
599*cdf0e10cSrcweir 		{
600*cdf0e10cSrcweir 			nX = (sal_uLong) ((double) aWinSize.Height()
601*cdf0e10cSrcweir 			   * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight());
602*cdf0e10cSrcweir 		}
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 		if(rZoomRect.GetWidth())
605*cdf0e10cSrcweir 		{
606*cdf0e10cSrcweir 			nY = (sal_uLong) ((double) aWinSize.Width()
607*cdf0e10cSrcweir 				* (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth());
608*cdf0e10cSrcweir 		}
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir         // Use the smaller one of both so that the zoom rectangle will be
611*cdf0e10cSrcweir         // fully visible with respect to both coordinate directions.
612*cdf0e10cSrcweir 		sal_uLong nFact = Min(nX, nY);
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir         // Transform the current zoom factor so that it leads to the desired
615*cdf0e10cSrcweir         // scaling.
616*cdf0e10cSrcweir 		long nZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir         // Calculate the new origin.
619*cdf0e10cSrcweir 		if ( nFact == 0 )
620*cdf0e10cSrcweir 		{
621*cdf0e10cSrcweir             // Don't change anything if the scale factor is degenrate.
622*cdf0e10cSrcweir 			nNewZoom = GetZoom();
623*cdf0e10cSrcweir 		}
624*cdf0e10cSrcweir 		else
625*cdf0e10cSrcweir 		{
626*cdf0e10cSrcweir             // Calculate the new window position that centers the given
627*cdf0e10cSrcweir             // rectangle on the screen.
628*cdf0e10cSrcweir 			if ( nZoom > MAX_ZOOM )
629*cdf0e10cSrcweir 				nFact = nFact * MAX_ZOOM / nZoom;
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir 			maWinPos = maViewOrigin + aPos;
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir 			aWinSize.Width() = (long) ((double) aWinSize.Width() * (double) ZOOM_MULTIPLICATOR / (double) nFact);
634*cdf0e10cSrcweir 			maWinPos.X() += (rZoomRect.GetWidth() - aWinSize.Width()) / 2;
635*cdf0e10cSrcweir 			aWinSize.Height() = (long) ((double) aWinSize.Height() * (double) ZOOM_MULTIPLICATOR / (double) nFact);
636*cdf0e10cSrcweir 			maWinPos.Y() += (rZoomRect.GetHeight() - aWinSize.Height()) / 2;
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 			if ( maWinPos.X() < 0 )	maWinPos.X() = 0;
639*cdf0e10cSrcweir 			if ( maWinPos.Y() < 0 )	maWinPos.Y() = 0;
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir             // Adapt the window's map mode to the new zoom factor.
642*cdf0e10cSrcweir 			nNewZoom = SetZoomFactor(nZoom);
643*cdf0e10cSrcweir 		}
644*cdf0e10cSrcweir 	}
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir 	return(nNewZoom);
647*cdf0e10cSrcweir }
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir void Window::SetMinZoomAutoCalc (bool bAuto)
653*cdf0e10cSrcweir {
654*cdf0e10cSrcweir     mbMinZoomAutoCalc = bAuto;
655*cdf0e10cSrcweir }
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir /*************************************************************************
661*cdf0e10cSrcweir |*
662*cdf0e10cSrcweir |* Neuen MapMode-Origin berechnen und setzen; wenn aWinPos.X()/Y()
663*cdf0e10cSrcweir |* gleich -1 ist, wird die entsprechende Position zentriert
664*cdf0e10cSrcweir |* (z.B. fuer Initialisierung)
665*cdf0e10cSrcweir |*
666*cdf0e10cSrcweir \************************************************************************/
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir void Window::UpdateMapOrigin(sal_Bool bInvalidate)
669*cdf0e10cSrcweir {
670*cdf0e10cSrcweir 	sal_Bool	bChanged = sal_False;
671*cdf0e10cSrcweir 	Size	aWinSize = PixelToLogic(GetOutputSizePixel());
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir 	if ( mbCenterAllowed )
674*cdf0e10cSrcweir 	{
675*cdf0e10cSrcweir 		if ( maWinPos.X() > maViewSize.Width() - aWinSize.Width() )
676*cdf0e10cSrcweir 		{
677*cdf0e10cSrcweir 			maWinPos.X() = maViewSize.Width() - aWinSize.Width();
678*cdf0e10cSrcweir 			bChanged = sal_True;
679*cdf0e10cSrcweir 		}
680*cdf0e10cSrcweir 		if ( maWinPos.Y() > maViewSize.Height() - aWinSize.Height() )
681*cdf0e10cSrcweir 		{
682*cdf0e10cSrcweir 			maWinPos.Y() = maViewSize.Height() - aWinSize.Height();
683*cdf0e10cSrcweir 			bChanged = sal_True;
684*cdf0e10cSrcweir 		}
685*cdf0e10cSrcweir 		if ( aWinSize.Width() > maViewSize.Width() || maWinPos.X() < 0 )
686*cdf0e10cSrcweir 		{
687*cdf0e10cSrcweir 			maWinPos.X() = maViewSize.Width()  / 2 - aWinSize.Width()  / 2;
688*cdf0e10cSrcweir 			bChanged = sal_True;
689*cdf0e10cSrcweir 		}
690*cdf0e10cSrcweir 		if ( aWinSize.Height() > maViewSize.Height() || maWinPos.Y() < 0 )
691*cdf0e10cSrcweir 		{
692*cdf0e10cSrcweir 			maWinPos.Y() = maViewSize.Height() / 2 - aWinSize.Height() / 2;
693*cdf0e10cSrcweir 			bChanged = sal_True;
694*cdf0e10cSrcweir 		}
695*cdf0e10cSrcweir     }
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir     UpdateMapMode ();
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir     if (bChanged && bInvalidate)
700*cdf0e10cSrcweir         Invalidate();
701*cdf0e10cSrcweir }
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir void Window::UpdateMapMode (void)
707*cdf0e10cSrcweir {
708*cdf0e10cSrcweir 	Size aWinSize = PixelToLogic(GetOutputSizePixel());
709*cdf0e10cSrcweir     maWinPos -= maViewOrigin;
710*cdf0e10cSrcweir     Size aPix(maWinPos.X(), maWinPos.Y());
711*cdf0e10cSrcweir     aPix = LogicToPixel(aPix);
712*cdf0e10cSrcweir     // Groesse muss vielfaches von BRUSH_SIZE sein, damit Muster
713*cdf0e10cSrcweir     // richtig dargestellt werden
714*cdf0e10cSrcweir     // #i2237#
715*cdf0e10cSrcweir     // removed old stuff here which still forced zoom to be
716*cdf0e10cSrcweir     // %BRUSH_SIZE which is outdated now
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir     if (mpViewShell && mpViewShell->ISA(DrawViewShell))
719*cdf0e10cSrcweir     {
720*cdf0e10cSrcweir         Size aViewSizePixel = LogicToPixel(maViewSize);
721*cdf0e10cSrcweir         Size aWinSizePixel = LogicToPixel(aWinSize);
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir         // Seite soll nicht am Fensterrand "kleben"
724*cdf0e10cSrcweir         if (aPix.Width() == 0)
725*cdf0e10cSrcweir         {
726*cdf0e10cSrcweir             // #i2237#
727*cdf0e10cSrcweir             // Since BRUSH_SIZE alignment is outdated now, i use the
728*cdf0e10cSrcweir             // former constant here directly
729*cdf0e10cSrcweir             aPix.Width() -= 8;
730*cdf0e10cSrcweir         }
731*cdf0e10cSrcweir         if (aPix.Height() == 0)
732*cdf0e10cSrcweir         {
733*cdf0e10cSrcweir             // #i2237#
734*cdf0e10cSrcweir             // Since BRUSH_SIZE alignment is outdated now, i use the
735*cdf0e10cSrcweir             // former constant here directly
736*cdf0e10cSrcweir             aPix.Height() -= 8;
737*cdf0e10cSrcweir         }
738*cdf0e10cSrcweir     }
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir     aPix = PixelToLogic(aPix);
741*cdf0e10cSrcweir     maWinPos.X() = aPix.Width();
742*cdf0e10cSrcweir     maWinPos.Y() = aPix.Height();
743*cdf0e10cSrcweir 	Point aNewOrigin (-maWinPos.X(), -maWinPos.Y());
744*cdf0e10cSrcweir     maWinPos += maViewOrigin;
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir 	MapMode aMap(GetMapMode());
747*cdf0e10cSrcweir     aMap.SetOrigin(aNewOrigin);
748*cdf0e10cSrcweir     SetMapMode(aMap);
749*cdf0e10cSrcweir }
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir /*************************************************************************
755*cdf0e10cSrcweir |*
756*cdf0e10cSrcweir |* X-Position des sichtbaren Bereichs als Bruchteil (< 1)
757*cdf0e10cSrcweir |* der gesamten Arbeitsbereichbreite zuruegeben
758*cdf0e10cSrcweir |*
759*cdf0e10cSrcweir \************************************************************************/
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir double Window::GetVisibleX()
762*cdf0e10cSrcweir {
763*cdf0e10cSrcweir 	return ((double) maWinPos.X() / maViewSize.Width());
764*cdf0e10cSrcweir }
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir /*************************************************************************
767*cdf0e10cSrcweir |*
768*cdf0e10cSrcweir |* Y-Position des sichtbaren Bereichs als Bruchteil (< 1)
769*cdf0e10cSrcweir |* der gesamten Arbeitsbereichhoehe zuruegeben
770*cdf0e10cSrcweir |*
771*cdf0e10cSrcweir \************************************************************************/
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir double Window::GetVisibleY()
774*cdf0e10cSrcweir {
775*cdf0e10cSrcweir 	return ((double) maWinPos.Y() / maViewSize.Height());
776*cdf0e10cSrcweir }
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir /*************************************************************************
779*cdf0e10cSrcweir |*
780*cdf0e10cSrcweir |* X- und Y-Position des sichtbaren Bereichs als Bruchteile (< 1)
781*cdf0e10cSrcweir |* der gesamten Arbeitsbereichgroesse setzen
782*cdf0e10cSrcweir |* negative Werte werden ignoriert
783*cdf0e10cSrcweir |*
784*cdf0e10cSrcweir \************************************************************************/
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir void Window::SetVisibleXY(double fX, double fY)
787*cdf0e10cSrcweir {
788*cdf0e10cSrcweir 	long nOldX = maWinPos.X();
789*cdf0e10cSrcweir 	long nOldY = maWinPos.Y();
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir 	if ( fX >= 0 )
792*cdf0e10cSrcweir 		maWinPos.X() = (long) (fX * maViewSize.Width());
793*cdf0e10cSrcweir 	if ( fY >= 0 )
794*cdf0e10cSrcweir 		maWinPos.Y() = (long) (fY * maViewSize.Height());
795*cdf0e10cSrcweir 	UpdateMapOrigin(sal_False);
796*cdf0e10cSrcweir     //	Size sz(nOldX - aWinPos.X(), nOldY - aWinPos.Y());
797*cdf0e10cSrcweir     //	sz = LogicToPixel(sz);
798*cdf0e10cSrcweir 	Scroll(nOldX - maWinPos.X(), nOldY - maWinPos.Y(), SCROLL_CHILDREN);
799*cdf0e10cSrcweir 	Update();
800*cdf0e10cSrcweir }
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir /*************************************************************************
803*cdf0e10cSrcweir |*
804*cdf0e10cSrcweir |* Breite des sichtbaren Bereichs im Verhaeltnis zur
805*cdf0e10cSrcweir |* gesamten Arbeitsbereichbreite zuruegeben
806*cdf0e10cSrcweir |*
807*cdf0e10cSrcweir \************************************************************************/
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir double Window::GetVisibleWidth()
810*cdf0e10cSrcweir {
811*cdf0e10cSrcweir 	Size aWinSize = PixelToLogic(GetOutputSizePixel());
812*cdf0e10cSrcweir 	if ( aWinSize.Width() > maViewSize.Width() )
813*cdf0e10cSrcweir 		aWinSize.Width() = maViewSize.Width();
814*cdf0e10cSrcweir 	return ((double) aWinSize.Width() / maViewSize.Width());
815*cdf0e10cSrcweir }
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir /*************************************************************************
818*cdf0e10cSrcweir |*
819*cdf0e10cSrcweir |* Hoehe des sichtbaren Bereichs im Verhaeltnis zur
820*cdf0e10cSrcweir |* gesamten Arbeitsbereichhoehe zuruegeben
821*cdf0e10cSrcweir |*
822*cdf0e10cSrcweir \************************************************************************/
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir double Window::GetVisibleHeight()
825*cdf0e10cSrcweir {
826*cdf0e10cSrcweir 	Size aWinSize = PixelToLogic(GetOutputSizePixel());
827*cdf0e10cSrcweir 	if ( aWinSize.Height() > maViewSize.Height() )
828*cdf0e10cSrcweir 		aWinSize.Height() = maViewSize.Height();
829*cdf0e10cSrcweir 	return ((double) aWinSize.Height() / maViewSize.Height());
830*cdf0e10cSrcweir }
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir /*************************************************************************
833*cdf0e10cSrcweir |*
834*cdf0e10cSrcweir |* Breite einer Scrollspalte im Verhaeltnis zur gesamten
835*cdf0e10cSrcweir |* Arbeitsbereichbreite zuruegeben
836*cdf0e10cSrcweir |*
837*cdf0e10cSrcweir \************************************************************************/
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir double Window::GetScrlLineWidth()
840*cdf0e10cSrcweir {
841*cdf0e10cSrcweir 	return (GetVisibleWidth() * SCROLL_LINE_FACT);
842*cdf0e10cSrcweir }
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir /*************************************************************************
845*cdf0e10cSrcweir |*
846*cdf0e10cSrcweir |* Breite einer Scrollspalte im Verhaeltnis zur gesamten
847*cdf0e10cSrcweir |* Arbeitsbereichhoehe zuruegeben
848*cdf0e10cSrcweir |*
849*cdf0e10cSrcweir \************************************************************************/
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir double Window::GetScrlLineHeight()
852*cdf0e10cSrcweir {
853*cdf0e10cSrcweir 	return (GetVisibleHeight() * SCROLL_LINE_FACT);
854*cdf0e10cSrcweir }
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir /*************************************************************************
857*cdf0e10cSrcweir |*
858*cdf0e10cSrcweir |* Breite einer Scrollpage im Verhaeltnis zur gesamten
859*cdf0e10cSrcweir |* Arbeitsbereichbreite zuruegeben
860*cdf0e10cSrcweir |*
861*cdf0e10cSrcweir \************************************************************************/
862*cdf0e10cSrcweir 
863*cdf0e10cSrcweir double Window::GetScrlPageWidth()
864*cdf0e10cSrcweir {
865*cdf0e10cSrcweir 	return (GetVisibleWidth() * SCROLL_PAGE_FACT);
866*cdf0e10cSrcweir }
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir /*************************************************************************
869*cdf0e10cSrcweir |*
870*cdf0e10cSrcweir |* Breite einer Scrollpage im Verhaeltnis zur gesamten
871*cdf0e10cSrcweir |* Arbeitsbereichhoehe zuruegeben
872*cdf0e10cSrcweir |*
873*cdf0e10cSrcweir \************************************************************************/
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir double Window::GetScrlPageHeight()
876*cdf0e10cSrcweir {
877*cdf0e10cSrcweir 	return (GetVisibleHeight() * SCROLL_PAGE_FACT);
878*cdf0e10cSrcweir }
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir /*************************************************************************
881*cdf0e10cSrcweir |*
882*cdf0e10cSrcweir |* Fenster deaktivieren
883*cdf0e10cSrcweir |*
884*cdf0e10cSrcweir \************************************************************************/
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir void Window::LoseFocus()
887*cdf0e10cSrcweir {
888*cdf0e10cSrcweir 	mnTicks = 0;
889*cdf0e10cSrcweir     ::Window::LoseFocus ();
890*cdf0e10cSrcweir }
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir /*************************************************************************
893*cdf0e10cSrcweir |*
894*cdf0e10cSrcweir |* Fenster aktivieren
895*cdf0e10cSrcweir |*
896*cdf0e10cSrcweir \************************************************************************/
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir void Window::GrabFocus()
899*cdf0e10cSrcweir {
900*cdf0e10cSrcweir 	mnTicks		 = 0;
901*cdf0e10cSrcweir     ::Window::GrabFocus ();
902*cdf0e10cSrcweir }
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir 
905*cdf0e10cSrcweir /*************************************************************************
906*cdf0e10cSrcweir |*
907*cdf0e10cSrcweir |* DataChanged
908*cdf0e10cSrcweir |*
909*cdf0e10cSrcweir \************************************************************************/
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir void Window::DataChanged( const DataChangedEvent& rDCEvt )
912*cdf0e10cSrcweir {
913*cdf0e10cSrcweir 	::Window::DataChanged( rDCEvt );
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir 	// PRINTER bei allen Dokumenten weglassen, die keinen Printer benutzen.
916*cdf0e10cSrcweir 	// FONTS und FONTSUBSTITUTION weglassen, wenn keine Textausgaben
917*cdf0e10cSrcweir 	// vorhanden sind, bzw. wenn das Dokument keinen Text zulaesst.
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
920*cdf0e10cSrcweir 		 (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
921*cdf0e10cSrcweir 		 (rDCEvt.GetType() == DATACHANGED_FONTS) ||
922*cdf0e10cSrcweir 		 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
923*cdf0e10cSrcweir 		 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
924*cdf0e10cSrcweir 		  (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
925*cdf0e10cSrcweir 	{
926*cdf0e10cSrcweir 		if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
927*cdf0e10cSrcweir 			 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
928*cdf0e10cSrcweir 		{
929*cdf0e10cSrcweir             // When the screen zoom factor has changed then reset the zoom
930*cdf0e10cSrcweir             // factor of the frame to allways display the whole page.
931*cdf0e10cSrcweir             const AllSettings* pOldSettings = rDCEvt.GetOldSettings ();
932*cdf0e10cSrcweir             const AllSettings& rNewSettings = GetSettings ();
933*cdf0e10cSrcweir             if (pOldSettings)
934*cdf0e10cSrcweir                 if (pOldSettings->GetStyleSettings().GetScreenZoom()
935*cdf0e10cSrcweir                     != rNewSettings.GetStyleSettings().GetScreenZoom())
936*cdf0e10cSrcweir                     mpViewShell->GetViewFrame()->GetDispatcher()->
937*cdf0e10cSrcweir                         Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 			// ScrollBars neu anordnen bzw. Resize ausloesen, da sich
940*cdf0e10cSrcweir 			// ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
941*cdf0e10cSrcweir 			// Resize-Handler aber auch die Groesse der ScrollBars aus
942*cdf0e10cSrcweir 			// den Settings abgefragt werden.
943*cdf0e10cSrcweir 			Resize();
944*cdf0e10cSrcweir 
945*cdf0e10cSrcweir 			// Daten neu Setzen, die aus den Systemeinstellungen bzw. aus
946*cdf0e10cSrcweir 			// den Settings uebernommen werden. Evtl. weitere Daten neu
947*cdf0e10cSrcweir 			// berechnen, da sich auch die Aufloesung hierdurch geaendert
948*cdf0e10cSrcweir 			// haben kann.
949*cdf0e10cSrcweir             if( mpViewShell )
950*cdf0e10cSrcweir             {
951*cdf0e10cSrcweir 				const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
952*cdf0e10cSrcweir 				SvtAccessibilityOptions aAccOptions;
953*cdf0e10cSrcweir 		        sal_uLong                   nOutputMode;
954*cdf0e10cSrcweir 			    sal_uInt16                  nPreviewSlot;
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir 				if( rStyleSettings.GetHighContrastMode() )
957*cdf0e10cSrcweir 					nOutputMode = ViewShell::OUTPUT_DRAWMODE_CONTRAST;
958*cdf0e10cSrcweir 				else
959*cdf0e10cSrcweir 					nOutputMode = ViewShell::OUTPUT_DRAWMODE_COLOR;
960*cdf0e10cSrcweir 
961*cdf0e10cSrcweir 				if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
962*cdf0e10cSrcweir 					nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
963*cdf0e10cSrcweir 				else
964*cdf0e10cSrcweir 					nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir                 if( mpViewShell->ISA( DrawViewShell ) )
967*cdf0e10cSrcweir                 {
968*cdf0e10cSrcweir 			        SetDrawMode( nOutputMode );
969*cdf0e10cSrcweir                     mpViewShell->GetFrameView()->SetDrawMode( nOutputMode );
970*cdf0e10cSrcweir // #110094#-7
971*cdf0e10cSrcweir //			        mpViewShell->GetView()->ReleaseMasterPagePaintCache();
972*cdf0e10cSrcweir 			        Invalidate();
973*cdf0e10cSrcweir                 }
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir                 // #103100# Overwrite window color for OutlineView
976*cdf0e10cSrcweir                 if( mpViewShell->ISA(OutlineViewShell ) )
977*cdf0e10cSrcweir                 {
978*cdf0e10cSrcweir                     svtools::ColorConfig aColorConfig;
979*cdf0e10cSrcweir                     const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
980*cdf0e10cSrcweir 					SetBackground( Wallpaper( aDocColor ) );
981*cdf0e10cSrcweir                 }
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir                 SfxRequest aReq( nPreviewSlot, 0, mpViewShell->GetDocSh()->GetDoc()->GetItemPool() );
984*cdf0e10cSrcweir                 mpViewShell->ExecReq( aReq );
985*cdf0e10cSrcweir 				mpViewShell->Invalidate();
986*cdf0e10cSrcweir                 mpViewShell->ArrangeGUIElements();
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir 				// #101928# re-create handles to show new outfit
989*cdf0e10cSrcweir 				if(mpViewShell->ISA(DrawViewShell))
990*cdf0e10cSrcweir 				{
991*cdf0e10cSrcweir 					mpViewShell->GetView()->AdjustMarkHdl();
992*cdf0e10cSrcweir 				}
993*cdf0e10cSrcweir             }
994*cdf0e10cSrcweir         }
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir 		if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
997*cdf0e10cSrcweir 			 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
998*cdf0e10cSrcweir 			  (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
999*cdf0e10cSrcweir 		{
1000*cdf0e10cSrcweir 			// Virtuelle Device die auch von der Aufloesung oder von
1001*cdf0e10cSrcweir 			// Systemeinstellungen abhaengen, sollten geupdatet werden.
1002*cdf0e10cSrcweir 			// Ansonsten sollte zumindest bei DATACHANGED_DISPLAY
1003*cdf0e10cSrcweir 			// die virtuellen Devices geupdatet werden, da es einige
1004*cdf0e10cSrcweir 			// Systeme erlauben die Aufloesung und Farbtiefe waehrend
1005*cdf0e10cSrcweir 			// der Laufzeit zu aendern oder eben bei Palettenaenderungen
1006*cdf0e10cSrcweir 			// die virtuellen Device geupdatet werden muessen, da bei
1007*cdf0e10cSrcweir 			// Ausgaben ein anderes Farbmatching stattfinden kann.
1008*cdf0e10cSrcweir 		}
1009*cdf0e10cSrcweir 
1010*cdf0e10cSrcweir 		if ( rDCEvt.GetType() == DATACHANGED_FONTS )
1011*cdf0e10cSrcweir 		{
1012*cdf0e10cSrcweir 			// Wenn das Dokument Font-AuswahlBoxen anbietet, muessen
1013*cdf0e10cSrcweir 			// diese geupdatet werden. Wie dies genau aussehen muss,
1014*cdf0e10cSrcweir 			// weiss ich leider auch nicht. Aber evtl. kann man das
1015*cdf0e10cSrcweir 			// ja global handeln. Dies muessten wir evtl. mal
1016*cdf0e10cSrcweir 			// mit PB absprechen, aber der ist derzeit leider Krank.
1017*cdf0e10cSrcweir 			// Also bevor dies hier gehandelt wird, vorher mit
1018*cdf0e10cSrcweir 			// PB und mir absprechen.
1019*cdf0e10cSrcweir 		}
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir 		if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
1022*cdf0e10cSrcweir 			 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) )
1023*cdf0e10cSrcweir 		{
1024*cdf0e10cSrcweir 			// Formatierung neu durchfuehren, da Fonts die im Dokument
1025*cdf0e10cSrcweir 			// vorkommen, nicht mehr vorhanden sein muessen oder
1026*cdf0e10cSrcweir 			// jetzt vorhanden sind oder durch andere ersetzt wurden
1027*cdf0e10cSrcweir 			// sind.
1028*cdf0e10cSrcweir 			if( mpViewShell )
1029*cdf0e10cSrcweir 			{
1030*cdf0e10cSrcweir 				DrawDocShell* pDocSh = mpViewShell->GetDocSh();
1031*cdf0e10cSrcweir 				if( pDocSh )
1032*cdf0e10cSrcweir 					pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) );
1033*cdf0e10cSrcweir 			}
1034*cdf0e10cSrcweir 		}
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir 		if ( rDCEvt.GetType() == DATACHANGED_PRINTER )
1037*cdf0e10cSrcweir 		{
1038*cdf0e10cSrcweir 			// Wie hier die Behandlung aussehen soll, weiss ich leider
1039*cdf0e10cSrcweir 			// selbst noch nicht. Evtl. mal einen Printer loeschen und
1040*cdf0e10cSrcweir 			// schauen was gemacht werden muss. Evtl. muesste ich in
1041*cdf0e10cSrcweir 			// VCL dafuer noch etwas einbauen, wenn der benutze Printer
1042*cdf0e10cSrcweir 			// geloescht wird. Ansonsten wuerde ich hier evtl. die
1043*cdf0e10cSrcweir 			// Formatierung neu berechnen, wenn der aktuelle Drucker
1044*cdf0e10cSrcweir 			// zerstoert wurde.
1045*cdf0e10cSrcweir 			if( mpViewShell )
1046*cdf0e10cSrcweir 			{
1047*cdf0e10cSrcweir 				DrawDocShell* pDocSh = mpViewShell->GetDocSh();
1048*cdf0e10cSrcweir 				if( pDocSh )
1049*cdf0e10cSrcweir 					pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) );
1050*cdf0e10cSrcweir 			}
1051*cdf0e10cSrcweir 		}
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir 		// Alles neu ausgeben
1054*cdf0e10cSrcweir 		Invalidate();
1055*cdf0e10cSrcweir 	}
1056*cdf0e10cSrcweir }
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir 
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir /*************************************************************************
1062*cdf0e10cSrcweir |*
1063*cdf0e10cSrcweir |* DropTargetHelper::AcceptDrop
1064*cdf0e10cSrcweir |*
1065*cdf0e10cSrcweir \************************************************************************/
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir sal_Int8 Window::AcceptDrop( const AcceptDropEvent& rEvt )
1068*cdf0e10cSrcweir {
1069*cdf0e10cSrcweir 	sal_Int8 nRet = DND_ACTION_NONE;
1070*cdf0e10cSrcweir 
1071*cdf0e10cSrcweir 	if( mpViewShell && !mpViewShell->GetDocSh()->IsReadOnly() )
1072*cdf0e10cSrcweir 	{
1073*cdf0e10cSrcweir 		if( mpViewShell )
1074*cdf0e10cSrcweir 			nRet = mpViewShell->AcceptDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir 		if (mbUseDropScroll && ! mpViewShell->ISA(OutlineViewShell))
1077*cdf0e10cSrcweir 			DropScroll( rEvt.maPosPixel );
1078*cdf0e10cSrcweir 	}
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir 	return nRet;
1081*cdf0e10cSrcweir }
1082*cdf0e10cSrcweir 
1083*cdf0e10cSrcweir /*************************************************************************
1084*cdf0e10cSrcweir |*
1085*cdf0e10cSrcweir |* DropTargetHelper::ExecuteDrop
1086*cdf0e10cSrcweir |*
1087*cdf0e10cSrcweir \************************************************************************/
1088*cdf0e10cSrcweir 
1089*cdf0e10cSrcweir sal_Int8 Window::ExecuteDrop( const ExecuteDropEvent& rEvt )
1090*cdf0e10cSrcweir {
1091*cdf0e10cSrcweir 	sal_Int8 nRet = DND_ACTION_NONE;
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir 	if( mpViewShell )
1094*cdf0e10cSrcweir 	{
1095*cdf0e10cSrcweir 		nRet = mpViewShell->ExecuteDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
1096*cdf0e10cSrcweir 	}
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir 	return nRet;
1099*cdf0e10cSrcweir }
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir 
1102*cdf0e10cSrcweir 
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir void Window::SetUseDropScroll (bool bUseDropScroll)
1105*cdf0e10cSrcweir {
1106*cdf0e10cSrcweir     mbUseDropScroll = bUseDropScroll;
1107*cdf0e10cSrcweir }
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir 
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir /*************************************************************************
1113*cdf0e10cSrcweir |*
1114*cdf0e10cSrcweir |* Scrolling bei AcceptDrop-Events
1115*cdf0e10cSrcweir |*
1116*cdf0e10cSrcweir \************************************************************************/
1117*cdf0e10cSrcweir 
1118*cdf0e10cSrcweir void Window::DropScroll(const Point& rMousePos)
1119*cdf0e10cSrcweir {
1120*cdf0e10cSrcweir 	short nDx = 0;
1121*cdf0e10cSrcweir 	short nDy = 0;
1122*cdf0e10cSrcweir 
1123*cdf0e10cSrcweir 	Size aSize = GetOutputSizePixel();
1124*cdf0e10cSrcweir 
1125*cdf0e10cSrcweir 	if (aSize.Width() > SCROLL_SENSITIVE * 3)
1126*cdf0e10cSrcweir 	{
1127*cdf0e10cSrcweir 		if ( rMousePos.X() < SCROLL_SENSITIVE )
1128*cdf0e10cSrcweir 		{
1129*cdf0e10cSrcweir 			nDx = -1;
1130*cdf0e10cSrcweir 		}
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir 		if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE )
1133*cdf0e10cSrcweir 		{
1134*cdf0e10cSrcweir 			nDx = 1;
1135*cdf0e10cSrcweir 		}
1136*cdf0e10cSrcweir 	}
1137*cdf0e10cSrcweir 
1138*cdf0e10cSrcweir 	if (aSize.Height() > SCROLL_SENSITIVE * 3)
1139*cdf0e10cSrcweir 	{
1140*cdf0e10cSrcweir 		if ( rMousePos.Y() < SCROLL_SENSITIVE )
1141*cdf0e10cSrcweir 		{
1142*cdf0e10cSrcweir 			nDy = -1;
1143*cdf0e10cSrcweir 		}
1144*cdf0e10cSrcweir 
1145*cdf0e10cSrcweir 		if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE )
1146*cdf0e10cSrcweir 		{
1147*cdf0e10cSrcweir 			nDy = 1;
1148*cdf0e10cSrcweir 		}
1149*cdf0e10cSrcweir 	}
1150*cdf0e10cSrcweir 
1151*cdf0e10cSrcweir 	if ( (nDx || nDy) && (rMousePos.X()!=0 || rMousePos.Y()!=0 ) )
1152*cdf0e10cSrcweir 	{
1153*cdf0e10cSrcweir         if (mnTicks > 20)
1154*cdf0e10cSrcweir             mpViewShell->ScrollLines(nDx, nDy);
1155*cdf0e10cSrcweir 		else
1156*cdf0e10cSrcweir             mnTicks ++;
1157*cdf0e10cSrcweir 	}
1158*cdf0e10cSrcweir }
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir 
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir ::com::sun::star::uno::Reference<
1164*cdf0e10cSrcweir     ::com::sun::star::accessibility::XAccessible>
1165*cdf0e10cSrcweir     Window::CreateAccessible (void)
1166*cdf0e10cSrcweir {
1167*cdf0e10cSrcweir     if (mpViewShell != NULL)
1168*cdf0e10cSrcweir         return mpViewShell->CreateAccessibleDocumentView (this);
1169*cdf0e10cSrcweir     else
1170*cdf0e10cSrcweir     {
1171*cdf0e10cSrcweir         OSL_TRACE ("::sd::Window::CreateAccessible: no view shell");
1172*cdf0e10cSrcweir         return ::Window::CreateAccessible ();
1173*cdf0e10cSrcweir     }
1174*cdf0e10cSrcweir }
1175*cdf0e10cSrcweir 
1176*cdf0e10cSrcweir XubString Window::GetSurroundingText() const
1177*cdf0e10cSrcweir {
1178*cdf0e10cSrcweir     if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE )
1179*cdf0e10cSrcweir     {
1180*cdf0e10cSrcweir     	return XubString();
1181*cdf0e10cSrcweir     }
1182*cdf0e10cSrcweir     else if ( mpViewShell->GetView()->IsTextEdit() )
1183*cdf0e10cSrcweir     {
1184*cdf0e10cSrcweir 	    OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView();
1185*cdf0e10cSrcweir 	    return pOLV->GetEditView().GetSurroundingText();
1186*cdf0e10cSrcweir     }
1187*cdf0e10cSrcweir     else
1188*cdf0e10cSrcweir     {
1189*cdf0e10cSrcweir     	return XubString();
1190*cdf0e10cSrcweir     }
1191*cdf0e10cSrcweir }
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir Selection Window::GetSurroundingTextSelection() const
1194*cdf0e10cSrcweir {
1195*cdf0e10cSrcweir     if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE )
1196*cdf0e10cSrcweir     {
1197*cdf0e10cSrcweir 	    return Selection( 0, 0 );
1198*cdf0e10cSrcweir     }
1199*cdf0e10cSrcweir     else if ( mpViewShell->GetView()->IsTextEdit() )
1200*cdf0e10cSrcweir     {
1201*cdf0e10cSrcweir 	    OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView();
1202*cdf0e10cSrcweir 	    return pOLV->GetEditView().GetSurroundingTextSelection();
1203*cdf0e10cSrcweir     }
1204*cdf0e10cSrcweir     else
1205*cdf0e10cSrcweir     {
1206*cdf0e10cSrcweir         return Selection( 0, 0 );
1207*cdf0e10cSrcweir     }
1208*cdf0e10cSrcweir }
1209*cdf0e10cSrcweir 
1210*cdf0e10cSrcweir } // end of namespace sd
1211