xref: /AOO41X/main/sw/source/ui/uiview/viewport.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_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include "hintids.hxx"
33*cdf0e10cSrcweir #include <vcl/help.hxx>
34*cdf0e10cSrcweir #include <svx/ruler.hxx>
35*cdf0e10cSrcweir #include <editeng/paperinf.hxx>
36*cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
37*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
38*cdf0e10cSrcweir #ifndef _VIEW_HXX
39*cdf0e10cSrcweir #include <view.hxx>
40*cdf0e10cSrcweir #endif
41*cdf0e10cSrcweir #include <wrtsh.hxx>
42*cdf0e10cSrcweir #include <swmodule.hxx>
43*cdf0e10cSrcweir #include <viewopt.hxx>
44*cdf0e10cSrcweir #include <frmatr.hxx>
45*cdf0e10cSrcweir #ifndef _DOCSH_HXX
46*cdf0e10cSrcweir #include <docsh.hxx>
47*cdf0e10cSrcweir #endif
48*cdf0e10cSrcweir #ifndef _CMDID_H
49*cdf0e10cSrcweir #include <cmdid.h>
50*cdf0e10cSrcweir #endif
51*cdf0e10cSrcweir #include <edtwin.hxx>
52*cdf0e10cSrcweir #include <scroll.hxx>
53*cdf0e10cSrcweir #ifndef _WVIEW_HXX
54*cdf0e10cSrcweir #include <wview.hxx>
55*cdf0e10cSrcweir #endif
56*cdf0e10cSrcweir #include <usrpref.hxx>
57*cdf0e10cSrcweir #include <pagedesc.hxx>
58*cdf0e10cSrcweir #include <workctrl.hxx>
59*cdf0e10cSrcweir #include <crsskip.hxx>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #include <PostItMgr.hxx>
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir //Das SetVisArea der DocShell darf nicht vom InnerResizePixel gerufen werden.
66*cdf0e10cSrcweir //Unsere Einstellungen muessen aber stattfinden.
67*cdf0e10cSrcweir #ifndef WB_RIGHT_ALIGNED
68*cdf0e10cSrcweir #define WB_RIGHT_ALIGNED    ((WinBits)0x00008000)
69*cdf0e10cSrcweir #endif
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir static sal_Bool bProtectDocShellVisArea = sal_False;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir static sal_uInt16 nPgNum = 0;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir sal_Bool SwView::IsDocumentBorder()
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir     return GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ||
78*cdf0e10cSrcweir            pWrtShell->GetViewOptions()->getBrowseMode() ||
79*cdf0e10cSrcweir            SVX_ZOOM_PAGEWIDTH_NOBORDER == (SvxZoomType)pWrtShell->GetViewOptions()->GetZoomType();
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir inline long GetLeftMargin( SwView &rView )
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir     SvxZoomType eType = (SvxZoomType)rView.GetWrtShell().GetViewOptions()->GetZoomType();
85*cdf0e10cSrcweir 	long lRet = rView.GetWrtShell().GetAnyCurRect(RECT_PAGE_PRT).Left();
86*cdf0e10cSrcweir 	return eType == SVX_ZOOM_PERCENT   ? lRet + DOCUMENTBORDER :
87*cdf0e10cSrcweir            eType == SVX_ZOOM_PAGEWIDTH || eType == SVX_ZOOM_PAGEWIDTH_NOBORDER ? 0 :
88*cdf0e10cSrcweir 										 lRet + DOCUMENTBORDER + nLeftOfst;
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir //-------------------------------------------------------------------------
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir void lcl_GetPos(SwView* pView,
94*cdf0e10cSrcweir 				Point& rPos,
95*cdf0e10cSrcweir 				SwScrollbar* pScrollbar,
96*cdf0e10cSrcweir 				sal_Bool bBorder)
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir 	SwWrtShell &rSh = pView->GetWrtShell();
99*cdf0e10cSrcweir 	const Size aDocSz( rSh.GetDocSize() );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	const long lBorder = bBorder ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
102*cdf0e10cSrcweir 	sal_Bool bHori = pScrollbar->IsHoriScroll();
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	const long lPos = pScrollbar->GetThumbPos() + (bBorder ? DOCUMENTBORDER : 0);
105*cdf0e10cSrcweir 	long Point:: *pPt = bHori ? &Point::nA : &Point::nB;
106*cdf0e10cSrcweir 	long Size::  *pSz = bHori ? &Size::nA  : &Size::nB;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	long lDelta = lPos - rSh.VisArea().Pos().*pPt;
109*cdf0e10cSrcweir 	const long lSize = aDocSz.*pSz + lBorder;
110*cdf0e10cSrcweir 	// Bug 11693: sollte rechts oder unten zuviel Wiese sein, dann muss
111*cdf0e10cSrcweir 	// 			  diese von der VisArea herausgerechnet werden!
112*cdf0e10cSrcweir 	long nTmp = pView->GetVisArea().Right()+lDelta;
113*cdf0e10cSrcweir 	if ( bHori && nTmp > lSize )
114*cdf0e10cSrcweir 		lDelta -= nTmp - lSize;
115*cdf0e10cSrcweir 	nTmp = pView->GetVisArea().Bottom()+lDelta;
116*cdf0e10cSrcweir 	if ( !bHori && nTmp > lSize )
117*cdf0e10cSrcweir 		lDelta -= nTmp - lSize;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	rPos.*pPt += lDelta;
120*cdf0e10cSrcweir 	if ( bBorder && rPos.*pPt < DOCUMENTBORDER )
121*cdf0e10cSrcweir 		rPos.*pPt = DOCUMENTBORDER;
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir /*--------------------------------------------------------------------
125*cdf0e10cSrcweir 	Beschreibung:	Nullpunkt Lineal setzen
126*cdf0e10cSrcweir  --------------------------------------------------------------------*/
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir void SwView::InvalidateRulerPos()
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir 	static sal_uInt16 __READONLY_DATA aInval[] =
131*cdf0e10cSrcweir 	{
132*cdf0e10cSrcweir 		SID_ATTR_PARA_LRSPACE, SID_RULER_BORDERS, SID_RULER_PAGE_POS,
133*cdf0e10cSrcweir 		SID_RULER_LR_MIN_MAX, SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
134*cdf0e10cSrcweir         SID_RULER_BORDER_DISTANCE,
135*cdf0e10cSrcweir         SID_ATTR_PARA_LRSPACE_VERTICAL, SID_RULER_BORDERS_VERTICAL,
136*cdf0e10cSrcweir         SID_RULER_TEXT_RIGHT_TO_LEFT,
137*cdf0e10cSrcweir         SID_RULER_ROWS, SID_RULER_ROWS_VERTICAL, FN_STAT_PAGE,
138*cdf0e10cSrcweir         0
139*cdf0e10cSrcweir 	};
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	GetViewFrame()->GetBindings().Invalidate(aInval);
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     DBG_ASSERT(pHRuler, "warum ist das Lineal nicht da?");
144*cdf0e10cSrcweir     pHRuler->ForceUpdate();
145*cdf0e10cSrcweir     pVRuler->ForceUpdate();
146*cdf0e10cSrcweir }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir /*--------------------------------------------------------------------
149*cdf0e10cSrcweir 	Beschreibung:	begrenzt das Scrollen soweit, dass jeweils nur einen
150*cdf0e10cSrcweir 					viertel Bildschirm bis vor das Ende des Dokumentes
151*cdf0e10cSrcweir 					gescrollt werden kann.
152*cdf0e10cSrcweir  --------------------------------------------------------------------*/
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir long SwView::SetHScrollMax( long lMax )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir 	const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
157*cdf0e10cSrcweir 	const long lSize = GetDocSz().Width() + lBorder - aVisArea.GetWidth();
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	// bei negativen Werten ist das Dokument vollstaendig sichtbar;
160*cdf0e10cSrcweir 	// in diesem Fall kein Scrollen
161*cdf0e10cSrcweir 	return Max( Min( lMax, lSize ), 0L );
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir long SwView::SetVScrollMax( long lMax )
166*cdf0e10cSrcweir {
167*cdf0e10cSrcweir 	const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
168*cdf0e10cSrcweir 	long lSize = GetDocSz().Height() + lBorder - aVisArea.GetHeight();
169*cdf0e10cSrcweir 	return Max( Min( lMax, lSize), 0L );		// siehe horz.
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir Point SwView::AlignToPixel(const Point &rPt) const
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir 	return GetEditWin().PixelToLogic( GetEditWin().LogicToPixel( rPt ) );
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir /*--------------------------------------------------------------------
179*cdf0e10cSrcweir 	Beschreibung:	Dokumentgroesse hat sich geaendert
180*cdf0e10cSrcweir  --------------------------------------------------------------------*/
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir void SwView::DocSzChgd(const Size &rSz)
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir extern int bDocSzUpdated;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir aDocSz = rSz;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 	if( !pWrtShell || aVisArea.IsEmpty() )		// keine Shell -> keine Aenderung
191*cdf0e10cSrcweir 	{
192*cdf0e10cSrcweir 		bDocSzUpdated = sal_False;
193*cdf0e10cSrcweir 		return;
194*cdf0e10cSrcweir 	}
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	//Wenn Text geloescht worden ist, kann es sein, dass die VisArea hinter
197*cdf0e10cSrcweir 	//den sichtbaren Bereich verweist
198*cdf0e10cSrcweir 	Rectangle aNewVisArea( aVisArea );
199*cdf0e10cSrcweir 	bool bModified = false;
200*cdf0e10cSrcweir 	SwTwips lGreenOffset = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
201*cdf0e10cSrcweir 	SwTwips lTmp = aDocSz.Width() + lGreenOffset;
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 	if ( aNewVisArea.Right() >= lTmp  )
204*cdf0e10cSrcweir 	{
205*cdf0e10cSrcweir 		lTmp = aNewVisArea.Right() - lTmp;
206*cdf0e10cSrcweir 		aNewVisArea.Right() -= lTmp;
207*cdf0e10cSrcweir 		aNewVisArea.Left() -= lTmp;
208*cdf0e10cSrcweir         bModified = true;
209*cdf0e10cSrcweir 	}
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 	lTmp = aDocSz.Height() + lGreenOffset;
212*cdf0e10cSrcweir 	if ( aNewVisArea.Bottom() >= lTmp )
213*cdf0e10cSrcweir 	{
214*cdf0e10cSrcweir 		lTmp = aNewVisArea.Bottom() - lTmp;
215*cdf0e10cSrcweir 		aNewVisArea.Bottom() -= lTmp;
216*cdf0e10cSrcweir 		aNewVisArea.Top() -= lTmp;
217*cdf0e10cSrcweir 		bModified = true;
218*cdf0e10cSrcweir 	}
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	if ( bModified )
221*cdf0e10cSrcweir 		SetVisArea( aNewVisArea, sal_False );
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     if ( UpdateScrollbars() && !bInOuterResizePixel && !bInInnerResizePixel &&
224*cdf0e10cSrcweir             !GetViewFrame()->GetFrame().IsInPlace())
225*cdf0e10cSrcweir         OuterResizePixel( Point(),
226*cdf0e10cSrcweir 						  GetViewFrame()->GetWindow().GetOutputSizePixel() );
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir /*--------------------------------------------------------------------
230*cdf0e10cSrcweir 	Beschreibung:	Visarea neu setzen
231*cdf0e10cSrcweir  --------------------------------------------------------------------*/
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir void SwView::SetVisArea( const Rectangle &rRect, sal_Bool bUpdateScrollbar )
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	const Size aOldSz( aVisArea.GetSize() );
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 	const Point aTopLeft(	  AlignToPixel( rRect.TopLeft() ));
238*cdf0e10cSrcweir 	const Point aBottomRight( AlignToPixel( rRect.BottomRight() ));
239*cdf0e10cSrcweir 	Rectangle aLR( aTopLeft, aBottomRight );
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 	if( aLR == aVisArea )
242*cdf0e10cSrcweir 		return;
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 	const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 	// keine negative Position, keine neg. Groesse
247*cdf0e10cSrcweir 	if( aLR.Top() < lMin )
248*cdf0e10cSrcweir 	{
249*cdf0e10cSrcweir 		aLR.Bottom() += lMin - aLR.Top();
250*cdf0e10cSrcweir 		aLR.Top() = lMin;
251*cdf0e10cSrcweir 	}
252*cdf0e10cSrcweir     if( aLR.Left() < lMin )
253*cdf0e10cSrcweir 	{
254*cdf0e10cSrcweir 		aLR.Right() += lMin - aLR.Left();
255*cdf0e10cSrcweir 		aLR.Left() = lMin;
256*cdf0e10cSrcweir 	}
257*cdf0e10cSrcweir 	if( aLR.Right() < 0 )
258*cdf0e10cSrcweir 		aLR.Right() = 0;
259*cdf0e10cSrcweir 	if( aLR.Bottom() < 0 )
260*cdf0e10cSrcweir 		aLR.Bottom() = 0;
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 	if( aLR == aVisArea )
263*cdf0e10cSrcweir 		return;
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 	const Size aSize( aLR.GetSize() );
266*cdf0e10cSrcweir 	if( aSize.Width() < 0 || aSize.Height() < 0 )
267*cdf0e10cSrcweir 		return;
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 	//Bevor die Daten veraendert werden ggf. ein Update rufen. Dadurch wird
270*cdf0e10cSrcweir 	//sichergestellt, da? anliegende Paints korrekt in Dokumentkoordinaten
271*cdf0e10cSrcweir 	//umgerechnet werden.
272*cdf0e10cSrcweir 	//Vorsichtshalber tun wir das nur wenn an der Shell eine Action laeuft,
273*cdf0e10cSrcweir 	//denn dann wir nicht wirklich gepaintet sondern die Rechtecke werden
274*cdf0e10cSrcweir 	//lediglich (in Dokumentkoordinaten) vorgemerkt.
275*cdf0e10cSrcweir 	if ( pWrtShell && pWrtShell->ActionPend() )
276*cdf0e10cSrcweir 		pWrtShell->GetWin()->Update();
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 	aVisArea = aLR;
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir     const sal_Bool bOuterResize = bUpdateScrollbar && UpdateScrollbars();
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 	if ( pWrtShell )
283*cdf0e10cSrcweir 	{
284*cdf0e10cSrcweir 		pWrtShell->VisPortChgd( aVisArea );
285*cdf0e10cSrcweir 		if ( aOldSz != pWrtShell->VisArea().SSize() &&
286*cdf0e10cSrcweir 			 ( Abs(aOldSz.Width() - pWrtShell->VisArea().Width()) > 2 ||
287*cdf0e10cSrcweir 				Abs(aOldSz.Height() - pWrtShell->VisArea().Height()) > 2 ) )
288*cdf0e10cSrcweir 			pWrtShell->CheckBrowseView( sal_False );
289*cdf0e10cSrcweir 	}
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 	if ( !bProtectDocShellVisArea )
292*cdf0e10cSrcweir 	{
293*cdf0e10cSrcweir 		//Wenn die Groesse der VisArea unveraendert ist, reichen wir die
294*cdf0e10cSrcweir 		//Groesse der VisArea vom InternalObject weiter. Damit soll der
295*cdf0e10cSrcweir 		//Transport von Fehlern vermieden werden.
296*cdf0e10cSrcweir 		Rectangle aVis( aVisArea );
297*cdf0e10cSrcweir 		if ( aVis.GetSize() == aOldSz )
298*cdf0e10cSrcweir             aVis.SetSize( GetDocShell()->SfxObjectShell::GetVisArea(ASPECT_CONTENT).GetSize() );
299*cdf0e10cSrcweir                     // TODO/LATER: why casting?!
300*cdf0e10cSrcweir                     //GetDocShell()->SfxInPlaceObject::GetVisArea().GetSize() );
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir 		//Bei embedded immer mit Modify...
303*cdf0e10cSrcweir         // TODO/LATER: why casting?!
304*cdf0e10cSrcweir         GetDocShell()->SfxObjectShell::SetVisArea( aVis );
305*cdf0e10cSrcweir         /*
306*cdf0e10cSrcweir 		if ( GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
307*cdf0e10cSrcweir 			GetDocShell()->SfxInPlaceObject::SetVisArea( aVis );
308*cdf0e10cSrcweir 		else
309*cdf0e10cSrcweir             GetDocShell()->SvEmbeddedObject::SetVisArea( aVis );*/
310*cdf0e10cSrcweir 	}
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 	SfxViewShell::VisAreaChanged( aVisArea );
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir 	InvalidateRulerPos();
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	SwEditWin::ClearTip();
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir     if ( bOuterResize && !bInOuterResizePixel && !bInInnerResizePixel)
319*cdf0e10cSrcweir             OuterResizePixel( Point(),
320*cdf0e10cSrcweir 				GetViewFrame()->GetWindow().GetOutputSizePixel() );
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir /*--------------------------------------------------------------------
324*cdf0e10cSrcweir 	Beschreibung:	Pos VisArea setzen
325*cdf0e10cSrcweir  --------------------------------------------------------------------*/
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir void SwView::SetVisArea( const Point &rPt, sal_Bool bUpdateScrollbar )
328*cdf0e10cSrcweir {
329*cdf0e10cSrcweir 	//einmal alignen, damit Brushes korrekt angesetzt werden.
330*cdf0e10cSrcweir 	//MA 31. May. 96: Das geht in der BrowseView schief, weil evlt.
331*cdf0e10cSrcweir 	//nicht das ganze Dokument sichtbar wird. Da der Inhalt in Frames
332*cdf0e10cSrcweir 	//passgenau ist, kann nicht aligned werden (bessere Idee?!?!)
333*cdf0e10cSrcweir 	//MA 29. Oct. 96 (fix: Bild.de, 200%) ganz ohne Alignment geht es nicht
334*cdf0e10cSrcweir 	//mal sehen wie weit wir mit der halben BrushSize kommen.
335*cdf0e10cSrcweir 	//TODO: why BRUSH_SIZE?
336*cdf0e10cSrcweir 	Point aPt( rPt );
337*cdf0e10cSrcweir //	const long nTmp = GetWrtShell().IsFrameView() ? BRUSH_SIZE/2 : BRUSH_SIZE;
338*cdf0e10cSrcweir 	const long nTmp = GetWrtShell().IsFrameView() ? 4 : 8;
339*cdf0e10cSrcweir 	aPt = GetEditWin().LogicToPixel( aPt );
340*cdf0e10cSrcweir 	aPt.X() -= aPt.X() % nTmp;
341*cdf0e10cSrcweir 	aPt.Y() -= aPt.Y() % nTmp;
342*cdf0e10cSrcweir 	aPt = GetEditWin().PixelToLogic( aPt );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 	if ( aPt == aVisArea.TopLeft() )
345*cdf0e10cSrcweir 		return;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 	const long lXDiff = aVisArea.Left() - aPt.X();
348*cdf0e10cSrcweir 	const long lYDiff = aVisArea.Top()	- aPt.Y();
349*cdf0e10cSrcweir 	SetVisArea( Rectangle( aPt,
350*cdf0e10cSrcweir 			Point( aVisArea.Right() - lXDiff, aVisArea.Bottom() - lYDiff ) ),
351*cdf0e10cSrcweir 			bUpdateScrollbar);
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir void SwView::CheckVisArea()
356*cdf0e10cSrcweir {
357*cdf0e10cSrcweir     pHScrollbar->SetAuto( pWrtShell->GetViewOptions()->getBrowseMode() &&
358*cdf0e10cSrcweir                               !GetViewFrame()->GetFrame().IsInPlace() );
359*cdf0e10cSrcweir 	if ( IsDocumentBorder() )
360*cdf0e10cSrcweir 	{
361*cdf0e10cSrcweir 		if ( aVisArea.Left() != DOCUMENTBORDER ||
362*cdf0e10cSrcweir 			 aVisArea.Top()  != DOCUMENTBORDER )
363*cdf0e10cSrcweir 		{
364*cdf0e10cSrcweir 			Rectangle aNewVisArea( aVisArea );
365*cdf0e10cSrcweir 			aNewVisArea.Move( DOCUMENTBORDER - aVisArea.Left(),
366*cdf0e10cSrcweir 							  DOCUMENTBORDER - aVisArea.Top() );
367*cdf0e10cSrcweir 			SetVisArea( aNewVisArea, sal_True );
368*cdf0e10cSrcweir 		}
369*cdf0e10cSrcweir 	}
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir /*--------------------------------------------------------------------
373*cdf0e10cSrcweir 	Beschreibung:	Sichtbaren Bereich berechnen
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 	OUT Point *pPt:				neue Position des sichtbaren
376*cdf0e10cSrcweir 								Bereiches
377*cdf0e10cSrcweir 	IN	Rectangle &rRect:		Rechteck, das sich innerhalb des neuen
378*cdf0e10cSrcweir 								sichtbaren Bereiches befinden soll
379*cdf0e10cSrcweir 		sal_uInt16 nRange			optional exakte Angabe des Bereiches,
380*cdf0e10cSrcweir 								um den ggfs. gescrollt werden soll
381*cdf0e10cSrcweir  --------------------------------------------------------------------*/
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir void SwView::CalcPt( Point *pPt, const Rectangle &rRect,
384*cdf0e10cSrcweir 					 sal_uInt16 nRangeX, sal_uInt16 nRangeY)
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 	const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 	long nYScroll = GetYScroll();
390*cdf0e10cSrcweir 	long nDesHeight = rRect.GetHeight();
391*cdf0e10cSrcweir 	long nCurHeight = aVisArea.GetHeight();
392*cdf0e10cSrcweir 	nYScroll = Min(nYScroll, nCurHeight - nDesHeight); // wird es knapp, dann nicht zuviel scrollen
393*cdf0e10cSrcweir 	if(nDesHeight > nCurHeight) // die Hoehe reicht nicht aus, dann interessiert nYScroll nicht mehr
394*cdf0e10cSrcweir 	{
395*cdf0e10cSrcweir 		pPt->Y() = rRect.Top();
396*cdf0e10cSrcweir 		pPt->Y() = Max( lMin, pPt->Y() );
397*cdf0e10cSrcweir 	}
398*cdf0e10cSrcweir 	else if ( rRect.Top() < aVisArea.Top() )				//Verschiebung nach oben
399*cdf0e10cSrcweir 	{
400*cdf0e10cSrcweir 		pPt->Y() = rRect.Top() - (nRangeY != USHRT_MAX ? nRangeY : nYScroll);
401*cdf0e10cSrcweir 		pPt->Y() = Max( lMin, pPt->Y() );
402*cdf0e10cSrcweir 	}
403*cdf0e10cSrcweir 	else if( rRect.Bottom() > aVisArea.Bottom() )	//Verschiebung nach unten
404*cdf0e10cSrcweir 	{
405*cdf0e10cSrcweir 		pPt->Y() = rRect.Bottom() -
406*cdf0e10cSrcweir 					(aVisArea.GetHeight()) + ( nRangeY != USHRT_MAX ?
407*cdf0e10cSrcweir 			nRangeY : nYScroll );
408*cdf0e10cSrcweir 		pPt->Y() = SetVScrollMax( pPt->Y() );
409*cdf0e10cSrcweir 	}
410*cdf0e10cSrcweir 	long nXScroll = GetXScroll();
411*cdf0e10cSrcweir 	if ( rRect.Right() > aVisArea.Right() )			//Verschiebung nach rechts
412*cdf0e10cSrcweir 	{
413*cdf0e10cSrcweir 		pPt->X() = rRect.Right()  -
414*cdf0e10cSrcweir 					(aVisArea.GetWidth()) +
415*cdf0e10cSrcweir 					(nRangeX != USHRT_MAX ? nRangeX : nXScroll);
416*cdf0e10cSrcweir 		pPt->X() = SetHScrollMax( pPt->X() );
417*cdf0e10cSrcweir 	}
418*cdf0e10cSrcweir 	else if ( rRect.Left() < aVisArea.Left() )		//Verschiebung nach links
419*cdf0e10cSrcweir 	{
420*cdf0e10cSrcweir 		pPt->X() = rRect.Left() - (nRangeX != USHRT_MAX ? nRangeX : nXScroll);
421*cdf0e10cSrcweir 		pPt->X() = Max( ::GetLeftMargin( *this ) + nLeftOfst, pPt->X() );
422*cdf0e10cSrcweir 		pPt->X() = Min( rRect.Left() - nScrollX, pPt->X() );
423*cdf0e10cSrcweir 		pPt->X() = Max( 0L, pPt->X() );
424*cdf0e10cSrcweir 	}
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir /*--------------------------------------------------------------------
428*cdf0e10cSrcweir 	Beschreibung:	Scrolling
429*cdf0e10cSrcweir  --------------------------------------------------------------------*/
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir sal_Bool SwView::IsScroll( const Rectangle &rRect ) const
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir 	return bCenterCrsr || bTopCrsr || !aVisArea.IsInside(rRect);
434*cdf0e10cSrcweir }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir void SwView::Scroll( const Rectangle &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY )
438*cdf0e10cSrcweir {
439*cdf0e10cSrcweir 	if ( aVisArea.IsEmpty() )
440*cdf0e10cSrcweir 		return;
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 	Rectangle aOldVisArea( aVisArea );
443*cdf0e10cSrcweir 	long nDiffY = 0;
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 	Window* pCareWn = ViewShell::GetCareWin(GetWrtShell());
446*cdf0e10cSrcweir 	if ( pCareWn )
447*cdf0e10cSrcweir 	{
448*cdf0e10cSrcweir         Rectangle aDlgRect( GetEditWin().PixelToLogic(
449*cdf0e10cSrcweir                 pCareWn->GetWindowExtentsRelative( &GetEditWin() ) ) );
450*cdf0e10cSrcweir 		// Nur, wenn der Dialog nicht rechts oder links der VisArea liegt:
451*cdf0e10cSrcweir 		if ( aDlgRect.Left() < aVisArea.Right() &&
452*cdf0e10cSrcweir 			 aDlgRect.Right() > aVisArea.Left() )
453*cdf0e10cSrcweir 		{
454*cdf0e10cSrcweir 			// Falls wir nicht zentriert werden sollen, in der VisArea liegen
455*cdf0e10cSrcweir 			// und nicht vom Dialog ueberdeckt werden ...
456*cdf0e10cSrcweir 			if ( !bCenterCrsr && aOldVisArea.IsInside( rRect )
457*cdf0e10cSrcweir 				 && ( rRect.Left() > aDlgRect.Right()
458*cdf0e10cSrcweir 					  || rRect.Right() < aDlgRect.Left()
459*cdf0e10cSrcweir 					  || rRect.Top() > aDlgRect.Bottom()
460*cdf0e10cSrcweir 					  || rRect.Bottom() < aDlgRect.Top() ) )
461*cdf0e10cSrcweir 				return;
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 			// Ist oberhalb oder unterhalb der Dialogs mehr Platz?
464*cdf0e10cSrcweir 			long nTopDiff = aDlgRect.Top() - aVisArea.Top();
465*cdf0e10cSrcweir 			long nBottomDiff = aVisArea.Bottom() - aDlgRect.Bottom();
466*cdf0e10cSrcweir 			if ( nTopDiff < nBottomDiff )
467*cdf0e10cSrcweir 			{
468*cdf0e10cSrcweir 				if ( nBottomDiff > 0 ) // Ist unterhalb ueberhaupt Platz?
469*cdf0e10cSrcweir 				{	// dann verschieben wir die Oberkante und merken uns dies
470*cdf0e10cSrcweir 					nDiffY = aDlgRect.Bottom() - aVisArea.Top();
471*cdf0e10cSrcweir 					aVisArea.Top() += nDiffY;
472*cdf0e10cSrcweir 				}
473*cdf0e10cSrcweir 			}
474*cdf0e10cSrcweir 			else
475*cdf0e10cSrcweir 			{
476*cdf0e10cSrcweir 				if ( nTopDiff > 0 ) // Ist oberhalb ueberhaupt Platz?
477*cdf0e10cSrcweir 					aVisArea.Bottom() = aDlgRect.Top(); // Unterkante aendern
478*cdf0e10cSrcweir 			}
479*cdf0e10cSrcweir 		}
480*cdf0e10cSrcweir 	}
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir 	//s.o. !IsScroll()
483*cdf0e10cSrcweir 	if( !(bCenterCrsr || bTopCrsr) && aVisArea.IsInside( rRect ) )
484*cdf0e10cSrcweir 	{
485*cdf0e10cSrcweir 		aVisArea = aOldVisArea;
486*cdf0e10cSrcweir 		return;
487*cdf0e10cSrcweir 	}
488*cdf0e10cSrcweir 	//falls das Rechteck groesser als der sichtbare Bereich -->
489*cdf0e10cSrcweir 	//obere linke Ecke
490*cdf0e10cSrcweir 	Size aSize( rRect.GetSize() );
491*cdf0e10cSrcweir 	const Size aVisSize( aVisArea.GetSize() );
492*cdf0e10cSrcweir 	if( !aVisArea.IsEmpty() && (
493*cdf0e10cSrcweir 		aSize.Width() + GetXScroll() > aVisSize.Width() ||
494*cdf0e10cSrcweir 		aSize.Height()+ GetYScroll() > aVisSize.Height() ))
495*cdf0e10cSrcweir 	{
496*cdf0e10cSrcweir 		Point aPt( aVisArea.TopLeft() );
497*cdf0e10cSrcweir 		aSize.Width() = Min( aSize.Width(), aVisSize.Width() );
498*cdf0e10cSrcweir 		aSize.Height()= Min( aSize.Height(),aVisSize.Height());
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 		CalcPt( &aPt, Rectangle( rRect.TopLeft(), aSize ),
501*cdf0e10cSrcweir                 static_cast< sal_uInt16 >((aVisSize.Width() - aSize.Width()) / 2),
502*cdf0e10cSrcweir                 static_cast< sal_uInt16 >((aVisSize.Height()- aSize.Height())/ 2) );
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 		if( bTopCrsr )
505*cdf0e10cSrcweir 		{
506*cdf0e10cSrcweir 			const long nBorder = IsDocumentBorder() ? DOCUMENTBORDER : 0;
507*cdf0e10cSrcweir 			aPt.Y() = Min( Max( nBorder, rRect.Top() ),
508*cdf0e10cSrcweir 								aDocSz.Height() + nBorder -
509*cdf0e10cSrcweir 									aVisArea.GetHeight() );
510*cdf0e10cSrcweir 		}
511*cdf0e10cSrcweir 		aPt.Y() -= nDiffY;
512*cdf0e10cSrcweir 		aVisArea = aOldVisArea;
513*cdf0e10cSrcweir 		SetVisArea( aPt );
514*cdf0e10cSrcweir 		return;
515*cdf0e10cSrcweir 	}
516*cdf0e10cSrcweir 	if( !bCenterCrsr )
517*cdf0e10cSrcweir 	{
518*cdf0e10cSrcweir 		Point aPt( aVisArea.TopLeft() );
519*cdf0e10cSrcweir 		CalcPt( &aPt, rRect, nRangeX, nRangeY );
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 		if( bTopCrsr )
522*cdf0e10cSrcweir 		{
523*cdf0e10cSrcweir 			const long nBorder = IsDocumentBorder() ? DOCUMENTBORDER : 0;
524*cdf0e10cSrcweir 			aPt.Y() = Min( Max( nBorder, rRect.Top() ),
525*cdf0e10cSrcweir 								aDocSz.Height() + nBorder -
526*cdf0e10cSrcweir 									aVisArea.GetHeight() );
527*cdf0e10cSrcweir 		}
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir 		aPt.Y() -= nDiffY;
530*cdf0e10cSrcweir 		aVisArea = aOldVisArea;
531*cdf0e10cSrcweir 		SetVisArea( aPt );
532*cdf0e10cSrcweir 		return;
533*cdf0e10cSrcweir 	}
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir 	//Cursor zentrieren
536*cdf0e10cSrcweir 	Point aPnt( aVisArea.TopLeft() );
537*cdf0e10cSrcweir 	// ... in Y-Richtung auf jeden Fall
538*cdf0e10cSrcweir 	aPnt.Y() += ( rRect.Top() + rRect.Bottom()
539*cdf0e10cSrcweir 				  - aVisArea.Top() - aVisArea.Bottom() ) / 2 - nDiffY;
540*cdf0e10cSrcweir 	// ... in X-Richtung nur, wenn das Rechteck rechts oder links aus der
541*cdf0e10cSrcweir 	//	   VisArea hinausragt.
542*cdf0e10cSrcweir 	if ( rRect.Right() > aVisArea.Right() || rRect.Left() < aVisArea.Left() )
543*cdf0e10cSrcweir 	{
544*cdf0e10cSrcweir 		aPnt.X() += ( rRect.Left() + rRect.Right()
545*cdf0e10cSrcweir 				  - aVisArea.Left() - aVisArea.Right() ) / 2;
546*cdf0e10cSrcweir 		aPnt.X() = SetHScrollMax( aPnt.X() );
547*cdf0e10cSrcweir 		const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
548*cdf0e10cSrcweir 		aPnt.X() = Max( (GetLeftMargin( *this ) - lMin) + nLeftOfst, aPnt.X() );
549*cdf0e10cSrcweir 	}
550*cdf0e10cSrcweir 	aVisArea = aOldVisArea;
551*cdf0e10cSrcweir 	if( pCareWn )
552*cdf0e10cSrcweir 	{   // Wenn wir nur einem Dialog ausweichen wollen, wollen wir nicht ueber
553*cdf0e10cSrcweir 		// das Ende des Dokument hinausgehen.
554*cdf0e10cSrcweir 		aPnt.Y() = SetVScrollMax( aPnt.Y() );
555*cdf0e10cSrcweir 	}
556*cdf0e10cSrcweir 	SetVisArea( aPnt );
557*cdf0e10cSrcweir }
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir /*--------------------------------------------------------------------
560*cdf0e10cSrcweir 	Beschreibung:	Seitenweises Scrollen
561*cdf0e10cSrcweir 	Liefern den Wert, um den bei PageUp / -Down gescrollt werden soll
562*cdf0e10cSrcweir  --------------------------------------------------------------------*/
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir sal_Bool SwView::GetPageScrollUpOffset( SwTwips &rOff ) const
565*cdf0e10cSrcweir {
566*cdf0e10cSrcweir 	if ( !aVisArea.Top() || !aVisArea.GetHeight() )
567*cdf0e10cSrcweir 		return sal_False;
568*cdf0e10cSrcweir 	long nYScrl = GetYScroll() / 2;
569*cdf0e10cSrcweir 	rOff = -(aVisArea.GetHeight() - nYScrl);
570*cdf0e10cSrcweir 	//nicht vor den Dokumentanfang scrollen
571*cdf0e10cSrcweir 	if( aVisArea.Top() - rOff < 0 )
572*cdf0e10cSrcweir 		rOff = rOff - aVisArea.Top();
573*cdf0e10cSrcweir 	else if( GetWrtShell().GetCharRect().Top() < (aVisArea.Top() + nYScrl))
574*cdf0e10cSrcweir 		rOff += nYScrl;
575*cdf0e10cSrcweir 	return sal_True;
576*cdf0e10cSrcweir }
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir sal_Bool SwView::GetPageScrollDownOffset( SwTwips &rOff ) const
580*cdf0e10cSrcweir {
581*cdf0e10cSrcweir 	if ( !aVisArea.GetHeight() ||
582*cdf0e10cSrcweir 		 (aVisArea.GetHeight() > aDocSz.Height()) )
583*cdf0e10cSrcweir 		return sal_False;
584*cdf0e10cSrcweir 	long nYScrl = GetYScroll() / 2;
585*cdf0e10cSrcweir 	rOff = aVisArea.GetHeight() - nYScrl;
586*cdf0e10cSrcweir 	//nicht hinter das Dokumentende scrollen
587*cdf0e10cSrcweir 	if ( aVisArea.Top() + rOff > aDocSz.Height() )
588*cdf0e10cSrcweir 		rOff = aDocSz.Height() - aVisArea.Bottom();
589*cdf0e10cSrcweir 	else if( GetWrtShell().GetCharRect().Bottom() >
590*cdf0e10cSrcweir 											( aVisArea.Bottom() - nYScrl ))
591*cdf0e10cSrcweir 		rOff -= nYScrl;
592*cdf0e10cSrcweir 	return rOff > 0;
593*cdf0e10cSrcweir }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir // Seitenweises Blaettern
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir long SwView::PageUp()
598*cdf0e10cSrcweir {
599*cdf0e10cSrcweir 	if (!aVisArea.GetHeight())
600*cdf0e10cSrcweir 		return 0;
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir 	Point aPos(aVisArea.TopLeft());
603*cdf0e10cSrcweir 	aPos.Y() -= aVisArea.GetHeight() - (GetYScroll() / 2);
604*cdf0e10cSrcweir 	aPos.Y() = Max(0L, aPos.Y());
605*cdf0e10cSrcweir 	SetVisArea( aPos );
606*cdf0e10cSrcweir 	return 1;
607*cdf0e10cSrcweir }
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir long SwView::PageDown()
611*cdf0e10cSrcweir {
612*cdf0e10cSrcweir 	if ( !aVisArea.GetHeight() )
613*cdf0e10cSrcweir 		return 0;
614*cdf0e10cSrcweir 	Point aPos( aVisArea.TopLeft() );
615*cdf0e10cSrcweir 	aPos.Y() += aVisArea.GetHeight() - (GetYScroll() / 2);
616*cdf0e10cSrcweir 	aPos.Y() = SetVScrollMax( aPos.Y() );
617*cdf0e10cSrcweir 	SetVisArea( aPos );
618*cdf0e10cSrcweir 	return 1;
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir long SwView::PhyPageUp()
623*cdf0e10cSrcweir {
624*cdf0e10cSrcweir 	//aktuell sichtbare Seite erfragen, nicht formatieren
625*cdf0e10cSrcweir 	sal_uInt16 nActPage = pWrtShell->GetNextPrevPageNum( sal_False );
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir 	if( USHRT_MAX != nActPage )
628*cdf0e10cSrcweir 	{
629*cdf0e10cSrcweir 		const Point aPt( aVisArea.Left(),
630*cdf0e10cSrcweir 						 pWrtShell->GetPagePos( nActPage ).Y() );
631*cdf0e10cSrcweir 		Point aAlPt( AlignToPixel( aPt ) );
632*cdf0e10cSrcweir 		// falls ein Unterschied besteht, wurde abgeschnitten --> dann
633*cdf0e10cSrcweir 		// einen Pixel addieren, damit kein Rest der Vorgaengerseite
634*cdf0e10cSrcweir 		// sichtbar ist
635*cdf0e10cSrcweir 		if( aPt.Y() != aAlPt.Y() )
636*cdf0e10cSrcweir 			aAlPt.Y() += 3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height();
637*cdf0e10cSrcweir 		SetVisArea( aAlPt );
638*cdf0e10cSrcweir 	}
639*cdf0e10cSrcweir 	return 1;
640*cdf0e10cSrcweir }
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir long SwView::PhyPageDown()
644*cdf0e10cSrcweir {
645*cdf0e10cSrcweir 	//aktuell sichtbare Seite erfragen, nicht formatieren
646*cdf0e10cSrcweir 	sal_uInt16 nActPage = pWrtShell->GetNextPrevPageNum( sal_True );
647*cdf0e10cSrcweir 	// falls die letzte Dokumentseite sichtbar ist, nichts tun
648*cdf0e10cSrcweir 	if( USHRT_MAX != nActPage )
649*cdf0e10cSrcweir 	{
650*cdf0e10cSrcweir 		const Point aPt( aVisArea.Left(),
651*cdf0e10cSrcweir 						 pWrtShell->GetPagePos( nActPage ).Y() );
652*cdf0e10cSrcweir 		Point aAlPt( AlignToPixel( aPt ) );
653*cdf0e10cSrcweir 		// falls ein Unterschied besteht, wurde abgeschnitten --> dann
654*cdf0e10cSrcweir 		// einen Pixel addieren, damit kein Rest der Vorgaengerseite sichtbar ist
655*cdf0e10cSrcweir 		if( aPt.Y() != aAlPt.Y() )
656*cdf0e10cSrcweir 			aAlPt.Y() += 3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height();
657*cdf0e10cSrcweir 		SetVisArea( aAlPt );
658*cdf0e10cSrcweir 	}
659*cdf0e10cSrcweir 	return 1;
660*cdf0e10cSrcweir }
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir long SwView::PageUpCrsr( sal_Bool bSelect )
664*cdf0e10cSrcweir {
665*cdf0e10cSrcweir 	if ( !bSelect )
666*cdf0e10cSrcweir 	{
667*cdf0e10cSrcweir 		const sal_uInt16 eType = pWrtShell->GetFrmType(0,sal_True);
668*cdf0e10cSrcweir 		if ( eType & FRMTYPE_FOOTNOTE )
669*cdf0e10cSrcweir 		{
670*cdf0e10cSrcweir 			pWrtShell->MoveCrsr();
671*cdf0e10cSrcweir 			pWrtShell->GotoFtnAnchor();
672*cdf0e10cSrcweir 			pWrtShell->Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
673*cdf0e10cSrcweir 			return 1;
674*cdf0e10cSrcweir 		}
675*cdf0e10cSrcweir 	}
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 	SwTwips lOff = 0;
678*cdf0e10cSrcweir 	if ( GetPageScrollUpOffset( lOff ) &&
679*cdf0e10cSrcweir 		 (pWrtShell->IsCrsrReadonly() ||
680*cdf0e10cSrcweir 		  !pWrtShell->PageCrsr( lOff, bSelect )) &&
681*cdf0e10cSrcweir 		 PageUp() )
682*cdf0e10cSrcweir 	{
683*cdf0e10cSrcweir 		pWrtShell->ResetCursorStack();
684*cdf0e10cSrcweir 		return sal_True;
685*cdf0e10cSrcweir 	}
686*cdf0e10cSrcweir 	return sal_False;
687*cdf0e10cSrcweir }
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir long SwView::PageDownCrsr(sal_Bool bSelect)
691*cdf0e10cSrcweir {
692*cdf0e10cSrcweir 	SwTwips lOff = 0;
693*cdf0e10cSrcweir 	if ( GetPageScrollDownOffset( lOff ) &&
694*cdf0e10cSrcweir 		 (pWrtShell->IsCrsrReadonly() ||
695*cdf0e10cSrcweir 		  !pWrtShell->PageCrsr( lOff, bSelect )) &&
696*cdf0e10cSrcweir 		 PageDown() )
697*cdf0e10cSrcweir 	{
698*cdf0e10cSrcweir 		pWrtShell->ResetCursorStack();
699*cdf0e10cSrcweir 		return sal_True;
700*cdf0e10cSrcweir 	}
701*cdf0e10cSrcweir 	return sal_False;
702*cdf0e10cSrcweir }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir /*------------------------------------------------------------------------
705*cdf0e10cSrcweir  Beschreibung:	Handler der Scrollbars
706*cdf0e10cSrcweir ------------------------------------------------------------------------*/
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir IMPL_LINK( SwView, ScrollHdl, SwScrollbar *, pScrollbar )
709*cdf0e10cSrcweir {
710*cdf0e10cSrcweir 	if ( GetWrtShell().ActionPend() )
711*cdf0e10cSrcweir 		return 0;
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 	if ( pScrollbar->GetType() == SCROLL_DRAG )
714*cdf0e10cSrcweir 		pWrtShell->EnableSmooth( sal_False );
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir 	if(!pWrtShell->GetViewOptions()->getBrowseMode() &&
717*cdf0e10cSrcweir 		pScrollbar->GetType() == SCROLL_DRAG)
718*cdf0e10cSrcweir 	{
719*cdf0e10cSrcweir 		//Hier wieder auskommentieren wenn das mitscrollen nicht gewuenscht ist.
720*cdf0e10cSrcweir 		// JP 21.07.00: the end scrollhandler invalidate the FN_STAT_PAGE,
721*cdf0e10cSrcweir 		// 				so we dont must do it agin.
722*cdf0e10cSrcweir 		EndScrollHdl(pScrollbar);
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir 		Point aPos( aVisArea.TopLeft() );
725*cdf0e10cSrcweir 		lcl_GetPos(this, aPos, pScrollbar, IsDocumentBorder());
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir 		sal_uInt16 nPhNum = 1;
728*cdf0e10cSrcweir 		sal_uInt16 nVirtNum = 1;
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir 		String sDisplay;
731*cdf0e10cSrcweir 		if(pWrtShell->GetPageNumber( aPos.Y(), sal_False, nPhNum, nVirtNum, sDisplay ))
732*cdf0e10cSrcweir 		{
733*cdf0e10cSrcweir 			// JP 21.07.00: the end scrollhandler invalidate the FN_STAT_PAGE,
734*cdf0e10cSrcweir 			// 				so we dont must do it agin.
735*cdf0e10cSrcweir //          if(!GetViewFrame()->GetFrame().IsInPlace())
736*cdf0e10cSrcweir //				S F X_BINDINGS().Update(FN_STAT_PAGE);
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir 			//QuickHelp:
739*cdf0e10cSrcweir             if( pWrtShell->GetPageCnt() > 1 && Help::IsQuickHelpEnabled() )
740*cdf0e10cSrcweir 			{
741*cdf0e10cSrcweir 				if( !nPgNum || nPgNum != nPhNum )
742*cdf0e10cSrcweir 				{
743*cdf0e10cSrcweir 					Rectangle aRect;
744*cdf0e10cSrcweir 					aRect.Left() = pScrollbar->GetParent()->OutputToScreenPixel(
745*cdf0e10cSrcweir 										pScrollbar->GetPosPixel() ).X() -8;
746*cdf0e10cSrcweir 					aRect.Top() = pScrollbar->OutputToScreenPixel(
747*cdf0e10cSrcweir 									pScrollbar->GetPointerPosPixel() ).Y();
748*cdf0e10cSrcweir 					aRect.Right() 	= aRect.Left();
749*cdf0e10cSrcweir 					aRect.Bottom()	= aRect.Top();
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir 					String sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay ));
752*cdf0e10cSrcweir 					SwContentAtPos aCnt( SwContentAtPos::SW_OUTLINE );
753*cdf0e10cSrcweir 					pWrtShell->GetContentAtPos( aPos, aCnt );
754*cdf0e10cSrcweir 					if( aCnt.sStr.Len() )
755*cdf0e10cSrcweir 					{
756*cdf0e10cSrcweir 						sPageStr += String::CreateFromAscii(
757*cdf0e10cSrcweir 										RTL_CONSTASCII_STRINGPARAM( "  - " ));
758*cdf0e10cSrcweir 						sPageStr.Insert( aCnt.sStr, 0, 80 );
759*cdf0e10cSrcweir 						sPageStr.SearchAndReplaceAll( '\t', ' ' );
760*cdf0e10cSrcweir                         sPageStr.SearchAndReplaceAll( 0x0a, ' ' );
761*cdf0e10cSrcweir                     }
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir 					Help::ShowQuickHelp( pScrollbar, aRect, sPageStr,
764*cdf0e10cSrcweir 									QUICKHELP_RIGHT|QUICKHELP_VCENTER);
765*cdf0e10cSrcweir 				}
766*cdf0e10cSrcweir 				nPgNum = nPhNum;
767*cdf0e10cSrcweir 			}
768*cdf0e10cSrcweir 		}
769*cdf0e10cSrcweir 	}
770*cdf0e10cSrcweir 	else
771*cdf0e10cSrcweir 		EndScrollHdl(pScrollbar);
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir 	if ( pScrollbar->GetType() == SCROLL_DRAG )
774*cdf0e10cSrcweir 		pWrtShell->EnableSmooth( sal_True );
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 	return 0;
777*cdf0e10cSrcweir }
778*cdf0e10cSrcweir /*------------------------------------------------------------------------
779*cdf0e10cSrcweir  Beschreibung:	Handler der Scrollbars
780*cdf0e10cSrcweir ------------------------------------------------------------------------*/
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir IMPL_LINK( SwView, EndScrollHdl, SwScrollbar *, pScrollbar )
783*cdf0e10cSrcweir {
784*cdf0e10cSrcweir 	if ( !GetWrtShell().ActionPend() )
785*cdf0e10cSrcweir 	{
786*cdf0e10cSrcweir 		if(nPgNum)
787*cdf0e10cSrcweir 		{
788*cdf0e10cSrcweir 			nPgNum = 0;
789*cdf0e10cSrcweir 			Help::ShowQuickHelp(pScrollbar, Rectangle(), aEmptyStr, 0);
790*cdf0e10cSrcweir 		}
791*cdf0e10cSrcweir 		Point aPos( aVisArea.TopLeft() );
792*cdf0e10cSrcweir 		sal_Bool bBorder = IsDocumentBorder();
793*cdf0e10cSrcweir 		lcl_GetPos(this, aPos, pScrollbar, bBorder);
794*cdf0e10cSrcweir 		if ( bBorder && aPos == aVisArea.TopLeft() )
795*cdf0e10cSrcweir 			UpdateScrollbars();
796*cdf0e10cSrcweir 		else
797*cdf0e10cSrcweir 			SetVisArea( aPos, sal_False );
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir 		GetViewFrame()->GetBindings().Update(FN_STAT_PAGE);
800*cdf0e10cSrcweir 	}
801*cdf0e10cSrcweir 	return 0;
802*cdf0e10cSrcweir }
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir /*--------------------------------------------------------------------
805*cdf0e10cSrcweir 	Beschreibung:
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir 		berechnet die Groesse von aVisArea abhaengig von der Groesse
808*cdf0e10cSrcweir 		des EditWin auf dem Schirm.
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir  --------------------------------------------------------------------*/
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir void SwView::CalcVisArea( const Size &rOutPixel )
813*cdf0e10cSrcweir {
814*cdf0e10cSrcweir 	Point aTopLeft;
815*cdf0e10cSrcweir 	Rectangle aRect( aTopLeft, rOutPixel );
816*cdf0e10cSrcweir 	aTopLeft = GetEditWin().PixelToLogic( aTopLeft );
817*cdf0e10cSrcweir 	Point aBottomRight( GetEditWin().PixelToLogic( aRect.BottomRight() ) );
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir 	aRect.Left() = aTopLeft.X();
820*cdf0e10cSrcweir 	aRect.Top() = aTopLeft.Y();
821*cdf0e10cSrcweir 	aRect.Right() = aBottomRight.X();
822*cdf0e10cSrcweir 	aRect.Bottom() = aBottomRight.Y();
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir 	//Die Verschiebungen nach rechts und/oder unten koennen jetzt falsch
825*cdf0e10cSrcweir 	//sein (z.B. Zoom aendern, Viewgroesse aendern.
826*cdf0e10cSrcweir 	const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
827*cdf0e10cSrcweir 	if ( aRect.Left() )
828*cdf0e10cSrcweir 	{
829*cdf0e10cSrcweir 		const long lWidth = GetWrtShell().GetDocSize().Width() + lBorder;
830*cdf0e10cSrcweir 		if ( aRect.Right() > lWidth )
831*cdf0e10cSrcweir 		{
832*cdf0e10cSrcweir 			long lDelta    = aRect.Right() - lWidth;
833*cdf0e10cSrcweir 			aRect.Left()  -= lDelta;
834*cdf0e10cSrcweir 			aRect.Right() -= lDelta;
835*cdf0e10cSrcweir 		}
836*cdf0e10cSrcweir 	}
837*cdf0e10cSrcweir 	if ( aRect.Top() )
838*cdf0e10cSrcweir 	{
839*cdf0e10cSrcweir 		const long lHeight = GetWrtShell().GetDocSize().Height() + lBorder;
840*cdf0e10cSrcweir 		if ( aRect.Bottom() > lHeight )
841*cdf0e10cSrcweir 		{
842*cdf0e10cSrcweir 			long lDelta		= aRect.Bottom() - lHeight;
843*cdf0e10cSrcweir 			aRect.Top()	   -= lDelta;
844*cdf0e10cSrcweir 			aRect.Bottom() -= lDelta;
845*cdf0e10cSrcweir 		}
846*cdf0e10cSrcweir 	}
847*cdf0e10cSrcweir 	SetVisArea( aRect );
848*cdf0e10cSrcweir 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
849*cdf0e10cSrcweir     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); // for snapping points
850*cdf0e10cSrcweir }
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir /*--------------------------------------------------------------------
853*cdf0e10cSrcweir 	Beschreibung:	Bedienelemente neu anordnen
854*cdf0e10cSrcweir  --------------------------------------------------------------------*/
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir 
857*cdf0e10cSrcweir void SwView::CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool /*bInner*/ )
858*cdf0e10cSrcweir {
859*cdf0e10cSrcweir 	sal_Bool bRightVRuler = pWrtShell->GetViewOptions()->IsVRulerRight();
860*cdf0e10cSrcweir     if ( pVRuler->IsVisible() )
861*cdf0e10cSrcweir 	{
862*cdf0e10cSrcweir         long nWidth = pVRuler->GetSizePixel().Width();
863*cdf0e10cSrcweir 		if(bRightVRuler)
864*cdf0e10cSrcweir             rToFill.Right() = nWidth;
865*cdf0e10cSrcweir 		else
866*cdf0e10cSrcweir 			rToFill.Left() = nWidth;
867*cdf0e10cSrcweir 	}
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir     DBG_ASSERT(pHRuler, "warum ist das Lineal nicht da?");
870*cdf0e10cSrcweir     if ( pHRuler->IsVisible() )
871*cdf0e10cSrcweir         rToFill.Top() = pHRuler->GetSizePixel().Height();
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir 	const StyleSettings &rSet = GetEditWin().GetSettings().GetStyleSettings();
874*cdf0e10cSrcweir 	const long nTmp = rSet.GetScrollBarSize();
875*cdf0e10cSrcweir     if( pVScrollbar->IsVisible(sal_False) )
876*cdf0e10cSrcweir 	{
877*cdf0e10cSrcweir 		if(bRightVRuler)
878*cdf0e10cSrcweir             rToFill.Left() = nTmp;
879*cdf0e10cSrcweir 		else
880*cdf0e10cSrcweir 			rToFill.Right()  = nTmp;
881*cdf0e10cSrcweir 	}
882*cdf0e10cSrcweir     //#i32913# in browse mode the visibility of the horizontal scrollbar
883*cdf0e10cSrcweir     // depends on the content (fixed width tables may require a scrollbar)
884*cdf0e10cSrcweir     if ( pHScrollbar->IsVisible(pWrtShell->GetViewOptions()->getBrowseMode()) )
885*cdf0e10cSrcweir 		rToFill.Bottom() = nTmp;
886*cdf0e10cSrcweir 
887*cdf0e10cSrcweir 	SetBorderPixel( rToFill );
888*cdf0e10cSrcweir }
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir void ViewResizePixel( const Window &rRef,
892*cdf0e10cSrcweir 					const Point &rOfst,
893*cdf0e10cSrcweir 					const Size &rSize,
894*cdf0e10cSrcweir 					const Size &rEditSz,
895*cdf0e10cSrcweir 					const sal_Bool /*bInner*/,
896*cdf0e10cSrcweir                     SwScrollbar& rVScrollbar,
897*cdf0e10cSrcweir                     SwScrollbar& rHScrollbar,
898*cdf0e10cSrcweir 					ImageButton* pPageUpBtn,
899*cdf0e10cSrcweir 					ImageButton* pPageDownBtn,
900*cdf0e10cSrcweir 					ImageButton* pNaviBtn,
901*cdf0e10cSrcweir                     Window& rScrollBarBox,
902*cdf0e10cSrcweir 					SvxRuler* pVLineal,
903*cdf0e10cSrcweir 					SvxRuler* pHLineal,
904*cdf0e10cSrcweir                     sal_Bool bWebView,
905*cdf0e10cSrcweir                     sal_Bool bVRulerRight )
906*cdf0e10cSrcweir {
907*cdf0e10cSrcweir // ViewResizePixel wird auch von der PreView benutzt!!!
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir 	const sal_Bool bHLineal = pHLineal && pHLineal->IsVisible();
910*cdf0e10cSrcweir 	const long nHLinSzHeight = bHLineal ?
911*cdf0e10cSrcweir 						pHLineal->GetSizePixel().Height() : 0;
912*cdf0e10cSrcweir     const sal_Bool bVLineal = pVLineal && pVLineal->IsVisible();
913*cdf0e10cSrcweir     const long nVLinSzWidth = bVLineal ?
914*cdf0e10cSrcweir 						pVLineal->GetSizePixel().Width() : 0;
915*cdf0e10cSrcweir     long nHBSzHeight2= rHScrollbar.IsVisible( sal_False ) || !rHScrollbar.IsAuto() ?
916*cdf0e10cSrcweir 					   rRef.GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
917*cdf0e10cSrcweir     long nHBSzHeight =
918*cdf0e10cSrcweir 				rHScrollbar.IsVisible(sal_True) ||  (rHScrollbar.IsVisible( sal_False ) && !rHScrollbar.IsAuto()) ?
919*cdf0e10cSrcweir 								nHBSzHeight2:0;
920*cdf0e10cSrcweir     long nVBSzWidth = rVScrollbar.IsVisible(sal_True) ||  (rVScrollbar.IsVisible( sal_False ) && !rVScrollbar.IsAuto()) ?
921*cdf0e10cSrcweir                          rRef.GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir     if(pVLineal)
924*cdf0e10cSrcweir     {
925*cdf0e10cSrcweir         WinBits nStyle = pVLineal->GetStyle()&~WB_RIGHT_ALIGNED;
926*cdf0e10cSrcweir         Point aPos( rOfst.X(), rOfst.Y()+nHLinSzHeight );
927*cdf0e10cSrcweir 		if(bVRulerRight)
928*cdf0e10cSrcweir 		{
929*cdf0e10cSrcweir             aPos.X() += rSize.Width() - nVLinSzWidth;
930*cdf0e10cSrcweir             nStyle |= WB_RIGHT_ALIGNED;
931*cdf0e10cSrcweir         }
932*cdf0e10cSrcweir         Size  aSize( nVLinSzWidth, rEditSz.Height() );
933*cdf0e10cSrcweir 		if(!aSize.Width())
934*cdf0e10cSrcweir 			aSize.Width() = pVLineal->GetSizePixel().Width();
935*cdf0e10cSrcweir         pVLineal->SetStyle(nStyle);
936*cdf0e10cSrcweir         pVLineal->SetPosSizePixel( aPos, aSize );
937*cdf0e10cSrcweir         if(!pVLineal->IsVisible())
938*cdf0e10cSrcweir             pVLineal->Resize();
939*cdf0e10cSrcweir     }
940*cdf0e10cSrcweir //  Lineal braucht ein Resize, sonst funktioniert es nicht im unischtbaren Zustand
941*cdf0e10cSrcweir     if(pHLineal)
942*cdf0e10cSrcweir     {
943*cdf0e10cSrcweir 		Size aSize( rSize.Width(), nHLinSzHeight );
944*cdf0e10cSrcweir         if ( nVBSzWidth && !bVRulerRight)
945*cdf0e10cSrcweir 			aSize.Width() -= nVBSzWidth;
946*cdf0e10cSrcweir 		if(!aSize.Height())
947*cdf0e10cSrcweir 			aSize.Height() = pHLineal->GetSizePixel().Height();
948*cdf0e10cSrcweir 		pHLineal->SetPosSizePixel( rOfst, aSize );
949*cdf0e10cSrcweir //		#46802 VCL ruft an unsichtbaren Fenstern kein Resize
950*cdf0e10cSrcweir //      fuer das Lineal ist das aber keine gute Idee
951*cdf0e10cSrcweir 		if(!pHLineal->IsVisible())
952*cdf0e10cSrcweir 			pHLineal->Resize();
953*cdf0e10cSrcweir 	}
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir 	// Scrollbars und SizeBox anordnen
956*cdf0e10cSrcweir 	Point aScrollFillPos;
957*cdf0e10cSrcweir 	{
958*cdf0e10cSrcweir 		Point aPos( rOfst.X(),
959*cdf0e10cSrcweir 					rOfst.Y()+rSize.Height()-nHBSzHeight );
960*cdf0e10cSrcweir         if(bVRulerRight)
961*cdf0e10cSrcweir         {
962*cdf0e10cSrcweir             aPos.X() += nVBSzWidth;
963*cdf0e10cSrcweir         }
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir 		Size  aSize( rSize.Width(), nHBSzHeight2 );
966*cdf0e10cSrcweir 		if ( nVBSzWidth )
967*cdf0e10cSrcweir 			aSize.Width() -= nVBSzWidth;
968*cdf0e10cSrcweir         rHScrollbar.SetPosSizePixel( aPos, aSize );
969*cdf0e10cSrcweir 		aScrollFillPos.Y() = aPos.Y();
970*cdf0e10cSrcweir 	}
971*cdf0e10cSrcweir 	{
972*cdf0e10cSrcweir 		Point aPos( rOfst.X()+rSize.Width()-nVBSzWidth,
973*cdf0e10cSrcweir 					rOfst.Y() );
974*cdf0e10cSrcweir         Size  aSize( nVBSzWidth, rSize.Height() );
975*cdf0e10cSrcweir         if(bVRulerRight)
976*cdf0e10cSrcweir 		{
977*cdf0e10cSrcweir 			aPos.X() = rOfst.X();
978*cdf0e10cSrcweir             if(bHLineal)
979*cdf0e10cSrcweir             {
980*cdf0e10cSrcweir                 aPos.Y() += nHLinSzHeight;
981*cdf0e10cSrcweir                 aSize.Height() -= nHLinSzHeight;
982*cdf0e10cSrcweir             }
983*cdf0e10cSrcweir 		}
984*cdf0e10cSrcweir 
985*cdf0e10cSrcweir         Size  aImgSz( nVBSzWidth, nVBSzWidth );
986*cdf0e10cSrcweir 
987*cdf0e10cSrcweir 		//#55949#  wenn der Platz fuer Scrollbar und Page-Buttons zu klein wird, dann
988*cdf0e10cSrcweir 		// werden die Buttons versteckt
989*cdf0e10cSrcweir 		sal_uInt16 nCnt = pNaviBtn ? 3 : 2;
990*cdf0e10cSrcweir 		long nSubSize = (aImgSz.Width() * nCnt );
991*cdf0e10cSrcweir 		//
992*cdf0e10cSrcweir 		sal_Bool bHidePageButtons = aSize.Height() < ((bWebView ? 3 : 2) * nSubSize);
993*cdf0e10cSrcweir 		if(!bHidePageButtons)
994*cdf0e10cSrcweir 			aSize.Height() -= nSubSize;
995*cdf0e10cSrcweir 		else
996*cdf0e10cSrcweir 			aImgSz.Width() = 0;	// kein Hide, weil das im Update Scrollbar missverstanden wird
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir 		if ( nHBSzHeight )
999*cdf0e10cSrcweir 			aSize.Height() -= nHBSzHeight;
1000*cdf0e10cSrcweir         rVScrollbar.SetPosSizePixel( aPos, aSize );
1001*cdf0e10cSrcweir 
1002*cdf0e10cSrcweir 		aPos.Y() += aSize.Height();
1003*cdf0e10cSrcweir 		pPageUpBtn->SetPosSizePixel( aPos, aImgSz );
1004*cdf0e10cSrcweir 		if(pNaviBtn)
1005*cdf0e10cSrcweir 		{
1006*cdf0e10cSrcweir 			aPos.Y() += aImgSz.Height();
1007*cdf0e10cSrcweir 			pNaviBtn->SetPosSizePixel(aPos, aImgSz);
1008*cdf0e10cSrcweir 		}
1009*cdf0e10cSrcweir 
1010*cdf0e10cSrcweir 		aPos.Y() += aImgSz.Height();
1011*cdf0e10cSrcweir 		pPageDownBtn->SetPosSizePixel( aPos, aImgSz );
1012*cdf0e10cSrcweir 
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir         if( rHScrollbar.IsVisible( sal_False ) )
1015*cdf0e10cSrcweir 		{
1016*cdf0e10cSrcweir 			aScrollFillPos.X() = aPos.X();
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir             rScrollBarBox.SetPosSizePixel( aScrollFillPos,
1019*cdf0e10cSrcweir 										 Size( nHBSzHeight,	nVBSzWidth) );
1020*cdf0e10cSrcweir         }
1021*cdf0e10cSrcweir 	}
1022*cdf0e10cSrcweir }
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir 
1025*cdf0e10cSrcweir void SwView::ShowAtResize()
1026*cdf0e10cSrcweir {
1027*cdf0e10cSrcweir 	bShowAtResize = sal_False;
1028*cdf0e10cSrcweir     if ( pWrtShell->GetViewOptions()->IsViewHRuler() )
1029*cdf0e10cSrcweir         pHRuler->Show();
1030*cdf0e10cSrcweir }
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir void SwView::InnerResizePixel( const Point &rOfst, const Size &rSize )
1034*cdf0e10cSrcweir {
1035*cdf0e10cSrcweir     Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
1036*cdf0e10cSrcweir     if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
1037*cdf0e10cSrcweir     {
1038*cdf0e10cSrcweir         SvBorder aBorder( GetBorderPixel() );
1039*cdf0e10cSrcweir         Size aSize( rSize );
1040*cdf0e10cSrcweir         aSize.Width() -= (aBorder.Left() + aBorder.Right());
1041*cdf0e10cSrcweir         aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
1042*cdf0e10cSrcweir         Size aObjSizePixel = GetWindow()->LogicToPixel( aObjSize, MAP_TWIP );
1043*cdf0e10cSrcweir         SfxViewShell::SetZoomFactor( Fraction( aSize.Width(), aObjSizePixel.Width() ),
1044*cdf0e10cSrcweir                         Fraction( aSize.Height(), aObjSizePixel.Height() ) );
1045*cdf0e10cSrcweir     }
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir     bInInnerResizePixel = sal_True;
1048*cdf0e10cSrcweir     const sal_Bool bHScrollVisible = pHScrollbar->IsVisible(sal_True);
1049*cdf0e10cSrcweir     const sal_Bool bVScrollVisible = pVScrollbar->IsVisible(sal_True);
1050*cdf0e10cSrcweir 	sal_Bool bRepeat = sal_False;
1051*cdf0e10cSrcweir 	do
1052*cdf0e10cSrcweir 	{
1053*cdf0e10cSrcweir 		Size aSz( rSize );
1054*cdf0e10cSrcweir         SvBorder aBorder;
1055*cdf0e10cSrcweir         CalcAndSetBorderPixel( aBorder, sal_True );
1056*cdf0e10cSrcweir         if ( GetViewFrame()->GetFrame().IsInPlace() )
1057*cdf0e10cSrcweir         {
1058*cdf0e10cSrcweir             Size aViewSize( aSz );
1059*cdf0e10cSrcweir             Point aViewPos( rOfst );
1060*cdf0e10cSrcweir             aViewSize.Height() -= (aBorder.Top() + aBorder.Bottom());
1061*cdf0e10cSrcweir             aViewSize.Width()  -= (aBorder.Left() + aBorder.Right());
1062*cdf0e10cSrcweir             aViewPos.X() += aBorder.Left();
1063*cdf0e10cSrcweir             aViewPos.Y() += aBorder.Top();
1064*cdf0e10cSrcweir             GetEditWin().SetPosSizePixel( aViewPos, aViewSize );
1065*cdf0e10cSrcweir         }
1066*cdf0e10cSrcweir         else
1067*cdf0e10cSrcweir         {
1068*cdf0e10cSrcweir             aSz.Height() += aBorder.Top()  + aBorder.Bottom();
1069*cdf0e10cSrcweir             aSz.Width()  += aBorder.Left() + aBorder.Right();
1070*cdf0e10cSrcweir         }
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir 		Size aEditSz( GetEditWin().GetOutputSizePixel() );
1073*cdf0e10cSrcweir 		ViewResizePixel( GetEditWin(), rOfst, aSz, aEditSz, sal_True, *pVScrollbar,
1074*cdf0e10cSrcweir                             *pHScrollbar, pPageUpBtn, pPageDownBtn,
1075*cdf0e10cSrcweir 							pNaviBtn,
1076*cdf0e10cSrcweir                             *pScrollFill, pVRuler, pHRuler,
1077*cdf0e10cSrcweir                             0 != PTR_CAST(SwWebView, this),
1078*cdf0e10cSrcweir                             pWrtShell->GetViewOptions()->IsVRulerRight());
1079*cdf0e10cSrcweir 		if ( bShowAtResize )
1080*cdf0e10cSrcweir 			ShowAtResize();
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir 		if( pHRuler->IsVisible() || pVRuler->IsVisible() )
1083*cdf0e10cSrcweir 		{
1084*cdf0e10cSrcweir 			const Fraction& rFrac = GetEditWin().GetMapMode().GetScaleX();
1085*cdf0e10cSrcweir             sal_uInt16 nZoom = 100;
1086*cdf0e10cSrcweir             if (0 != rFrac.GetDenominator())
1087*cdf0e10cSrcweir                 nZoom = sal_uInt16(rFrac.GetNumerator() * 100L / rFrac.GetDenominator());
1088*cdf0e10cSrcweir 
1089*cdf0e10cSrcweir 			const Fraction aFrac( nZoom, 100 );
1090*cdf0e10cSrcweir 			pVRuler->SetZoom( aFrac );
1091*cdf0e10cSrcweir 			pHRuler->SetZoom( aFrac );
1092*cdf0e10cSrcweir 			InvalidateRulerPos();	//Inhalt invalidieren.
1093*cdf0e10cSrcweir 		}
1094*cdf0e10cSrcweir 		//CursorStack zuruecksetzen, da die Cursorpositionen fuer PageUp/-Down
1095*cdf0e10cSrcweir 		//nicht mehr zum aktuell sichtbaren Bereich passen
1096*cdf0e10cSrcweir 		pWrtShell->ResetCursorStack();
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir 		//EditWin niemals einstellen!
1099*cdf0e10cSrcweir 
1100*cdf0e10cSrcweir 		//VisArea einstellen, aber dort nicht das SetVisArea der DocShell rufen!
1101*cdf0e10cSrcweir 		bProtectDocShellVisArea = sal_True;
1102*cdf0e10cSrcweir 		CalcVisArea( aEditSz );
1103*cdf0e10cSrcweir 		//visibility changes of the automatic horizontal scrollbar
1104*cdf0e10cSrcweir 		//require to repeat the ViewResizePixel() call - but only once!
1105*cdf0e10cSrcweir 		if(bRepeat)
1106*cdf0e10cSrcweir 			bRepeat = sal_False;
1107*cdf0e10cSrcweir 		else if(bHScrollVisible != pHScrollbar->IsVisible(sal_True) ||
1108*cdf0e10cSrcweir 				bVScrollVisible != pVScrollbar->IsVisible(sal_True))
1109*cdf0e10cSrcweir 			bRepeat = sal_True;
1110*cdf0e10cSrcweir 	}while( bRepeat );
1111*cdf0e10cSrcweir 	bProtectDocShellVisArea = sal_False;
1112*cdf0e10cSrcweir     bInInnerResizePixel = sal_False;
1113*cdf0e10cSrcweir }
1114*cdf0e10cSrcweir 
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir void SwView::OuterResizePixel( const Point &rOfst, const Size &rSize )
1117*cdf0e10cSrcweir {
1118*cdf0e10cSrcweir     // FME 22.08.2003 #i16909# - return, if no size (caused by minimize window).
1119*cdf0e10cSrcweir     if ( bInOuterResizePixel || ( !rSize.Width() && !rSize.Height() ) )
1120*cdf0e10cSrcweir 		return;
1121*cdf0e10cSrcweir 	bInOuterResizePixel	= sal_True;
1122*cdf0e10cSrcweir 
1123*cdf0e10cSrcweir // feststellen, ob Scrollbars angezeigt werden duerfen
1124*cdf0e10cSrcweir 	sal_Bool bBrowse = pWrtShell->GetViewOptions()->getBrowseMode();
1125*cdf0e10cSrcweir 	sal_Bool bShowH = sal_False,
1126*cdf0e10cSrcweir 		 bShowV = sal_False,
1127*cdf0e10cSrcweir 		 bAuto  = sal_False,
1128*cdf0e10cSrcweir 		 bHAuto = bBrowse;
1129*cdf0e10cSrcweir 	switch( GetScrollingMode() )
1130*cdf0e10cSrcweir 	{
1131*cdf0e10cSrcweir 	case SCROLLING_DEFAULT:
1132*cdf0e10cSrcweir 		{
1133*cdf0e10cSrcweir 			const SwViewOption *pVOpt = pWrtShell->GetViewOptions();
1134*cdf0e10cSrcweir 			if ( !pVOpt->IsReadonly() || pVOpt->IsStarOneSetting() )
1135*cdf0e10cSrcweir 			{
1136*cdf0e10cSrcweir 				bShowH = pVOpt->IsViewHScrollBar();
1137*cdf0e10cSrcweir 				bShowV = pVOpt->IsViewVScrollBar();
1138*cdf0e10cSrcweir 				break;
1139*cdf0e10cSrcweir 			}
1140*cdf0e10cSrcweir 		}
1141*cdf0e10cSrcweir 		/* kein break hier */
1142*cdf0e10cSrcweir 	case SCROLLING_AUTO:
1143*cdf0e10cSrcweir 		bAuto = bHAuto = sal_True;
1144*cdf0e10cSrcweir 		bShowH = bShowV = sal_True;
1145*cdf0e10cSrcweir 		break;
1146*cdf0e10cSrcweir 	case SCROLLING_YES:
1147*cdf0e10cSrcweir 		bShowH = bShowV = sal_True;
1148*cdf0e10cSrcweir 		break;
1149*cdf0e10cSrcweir 	case SCROLLING_NO:
1150*cdf0e10cSrcweir 		bShowH = bShowV = bHAuto = sal_False;
1151*cdf0e10cSrcweir 		break;
1152*cdf0e10cSrcweir 	}
1153*cdf0e10cSrcweir     SwDocShell* pDocSh = GetDocShell();
1154*cdf0e10cSrcweir     sal_Bool bIsPreview = pDocSh->IsPreview();
1155*cdf0e10cSrcweir     if( bIsPreview )
1156*cdf0e10cSrcweir     {
1157*cdf0e10cSrcweir         bShowH = bShowV = bHAuto = bAuto = sal_False;
1158*cdf0e10cSrcweir     }
1159*cdf0e10cSrcweir     if(pHScrollbar->IsVisible(sal_False) != bShowH)
1160*cdf0e10cSrcweir         ShowHScrollbar(bShowH);
1161*cdf0e10cSrcweir     pHScrollbar->SetAuto( bHAuto );
1162*cdf0e10cSrcweir     if(pVScrollbar->IsVisible(sal_False) != bShowV)
1163*cdf0e10cSrcweir         ShowVScrollbar(bShowV);
1164*cdf0e10cSrcweir     pVScrollbar->SetAuto(bAuto);
1165*cdf0e10cSrcweir 
1166*cdf0e10cSrcweir 	SET_CURR_SHELL( pWrtShell );
1167*cdf0e10cSrcweir 	sal_Bool bRepeat = sal_False;
1168*cdf0e10cSrcweir 	long nCnt = 0;
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir 	sal_Bool bUnLockView = !pWrtShell->IsViewLocked();
1171*cdf0e10cSrcweir 	pWrtShell->LockView( sal_True );
1172*cdf0e10cSrcweir 	pWrtShell->LockPaint();
1173*cdf0e10cSrcweir 
1174*cdf0e10cSrcweir 	do {
1175*cdf0e10cSrcweir 		++nCnt;
1176*cdf0e10cSrcweir         const sal_Bool bScroll1 = pVScrollbar->IsVisible(sal_True);
1177*cdf0e10cSrcweir         const sal_Bool bScroll2 = pHScrollbar->IsVisible(sal_True);
1178*cdf0e10cSrcweir 		SvBorder aBorder;
1179*cdf0e10cSrcweir 		CalcAndSetBorderPixel( aBorder, sal_False );
1180*cdf0e10cSrcweir 		const Size aEditSz( GetEditWin().GetOutputSizePixel() );
1181*cdf0e10cSrcweir         ViewResizePixel( GetEditWin(), rOfst, rSize, aEditSz, sal_False, *pVScrollbar,
1182*cdf0e10cSrcweir                                 *pHScrollbar, pPageUpBtn, pPageDownBtn,
1183*cdf0e10cSrcweir 								pNaviBtn,
1184*cdf0e10cSrcweir                                 *pScrollFill, pVRuler, pHRuler,
1185*cdf0e10cSrcweir                                 0 != PTR_CAST(SwWebView, this),
1186*cdf0e10cSrcweir                                 pWrtShell->GetViewOptions()->IsVRulerRight() );
1187*cdf0e10cSrcweir 		if ( bShowAtResize )
1188*cdf0e10cSrcweir 			ShowAtResize();
1189*cdf0e10cSrcweir 
1190*cdf0e10cSrcweir         if( pHRuler->IsVisible() || pVRuler->IsVisible() )
1191*cdf0e10cSrcweir 			InvalidateRulerPos();	//Inhalt invalidieren.
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir 		//CursorStack zuruecksetzen, da die Cursorpositionen fuer PageUp/-Down
1194*cdf0e10cSrcweir 		//nicht mehr zum aktuell sichtbaren Bereich passen
1195*cdf0e10cSrcweir 		pWrtShell->ResetCursorStack();
1196*cdf0e10cSrcweir 
1197*cdf0e10cSrcweir         ASSERT( !GetEditWin().IsVisible() ||
1198*cdf0e10cSrcweir                     (( aEditSz.Width() > 0 && aEditSz.Height() > 0 )
1199*cdf0e10cSrcweir                         || !aVisArea.IsEmpty()), "Small world, isn't it?" );
1200*cdf0e10cSrcweir 
1201*cdf0e10cSrcweir 		//EditWin niemals einstellen!
1202*cdf0e10cSrcweir 
1203*cdf0e10cSrcweir 		//Die VisArea muss aber natuerlich eingestellt werden.
1204*cdf0e10cSrcweir 		//jetzt ist auch der richtige Zeitpunkt den Zoom neu zu berechnen wenn
1205*cdf0e10cSrcweir 		//es kein einfacher Faktor ist.
1206*cdf0e10cSrcweir 		pWrtShell->StartAction();
1207*cdf0e10cSrcweir 		CalcVisArea( aEditSz );
1208*cdf0e10cSrcweir 
1209*cdf0e10cSrcweir 		//Damit auch beim outplace editing die Seitenbreite sofort
1210*cdf0e10cSrcweir 		//angepasst wird.
1211*cdf0e10cSrcweir         //TODO/LATER: is that still necessary?!
1212*cdf0e10cSrcweir         /*
1213*cdf0e10cSrcweir         if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1214*cdf0e10cSrcweir             pDocSh->SetVisArea(
1215*cdf0e10cSrcweir                             pDocSh->SfxInPlaceObject::GetVisArea() );*/
1216*cdf0e10cSrcweir 		if ( pWrtShell->GetViewOptions()->GetZoomType() != SVX_ZOOM_PERCENT &&
1217*cdf0e10cSrcweir 			 !pWrtShell->GetViewOptions()->getBrowseMode() )
1218*cdf0e10cSrcweir 			_SetZoom( aEditSz, (SvxZoomType)pWrtShell->GetViewOptions()->GetZoomType(), 100, sal_True );
1219*cdf0e10cSrcweir 		pWrtShell->EndAction();
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir         bRepeat = bScroll1 != pVScrollbar->IsVisible(sal_True);
1222*cdf0e10cSrcweir 		if ( !bRepeat )
1223*cdf0e10cSrcweir             bRepeat = bScroll2 != pHScrollbar->IsVisible(sal_True);
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir 		//Nicht endlosschleifen. Moeglichst dann stoppen wenn die
1226*cdf0e10cSrcweir 		//(Auto-)Scrollbars sichtbar sind.
1227*cdf0e10cSrcweir 		if ( bRepeat &&
1228*cdf0e10cSrcweir              ( nCnt > 10 || ( nCnt > 3 && bHAuto && bAuto ) )
1229*cdf0e10cSrcweir            )
1230*cdf0e10cSrcweir 		{
1231*cdf0e10cSrcweir 			bRepeat = sal_False;
1232*cdf0e10cSrcweir 		}
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir 	}while ( bRepeat );
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir 	if( pVScrollbar->IsVisible(sal_False) || pVScrollbar->IsAuto())
1237*cdf0e10cSrcweir 	{
1238*cdf0e10cSrcweir 		sal_Bool bShowButtons = pVScrollbar->IsVisible(sal_True);
1239*cdf0e10cSrcweir 		if(pPageUpBtn && pPageUpBtn->IsVisible() != bShowButtons)
1240*cdf0e10cSrcweir 		{
1241*cdf0e10cSrcweir 			pPageUpBtn->Show(bShowButtons);
1242*cdf0e10cSrcweir 			if(pPageDownBtn)
1243*cdf0e10cSrcweir 				pPageDownBtn->Show(bShowButtons);
1244*cdf0e10cSrcweir 			if(pNaviBtn)
1245*cdf0e10cSrcweir 				pNaviBtn->Show(bShowButtons);
1246*cdf0e10cSrcweir 		}
1247*cdf0e10cSrcweir 	}
1248*cdf0e10cSrcweir 
1249*cdf0e10cSrcweir 	pWrtShell->UnlockPaint();
1250*cdf0e10cSrcweir 	if( bUnLockView )
1251*cdf0e10cSrcweir 		pWrtShell->LockView( sal_False );
1252*cdf0e10cSrcweir 
1253*cdf0e10cSrcweir     bInOuterResizePixel = sal_False;
1254*cdf0e10cSrcweir 
1255*cdf0e10cSrcweir 	if ( mpPostItMgr )
1256*cdf0e10cSrcweir 	{
1257*cdf0e10cSrcweir 		mpPostItMgr->CalcRects();
1258*cdf0e10cSrcweir 		mpPostItMgr->LayoutPostIts();
1259*cdf0e10cSrcweir 	}
1260*cdf0e10cSrcweir }
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir 
1263*cdf0e10cSrcweir void SwView::SetZoomFactor( const Fraction &rX, const Fraction &rY )
1264*cdf0e10cSrcweir {
1265*cdf0e10cSrcweir 	const Fraction &rFrac = rX < rY ? rX : rY;
1266*cdf0e10cSrcweir 	SetZoom( SVX_ZOOM_PERCENT, (short) long(rFrac * Fraction( 100, 1 )) );
1267*cdf0e10cSrcweir 
1268*cdf0e10cSrcweir 	//Um Rundungsfehler zu minimieren lassen wir von der Basisklasse ggf.
1269*cdf0e10cSrcweir 	//auch die krummen Werte einstellen
1270*cdf0e10cSrcweir 	SfxViewShell::SetZoomFactor( rX, rY );
1271*cdf0e10cSrcweir }
1272*cdf0e10cSrcweir 
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir Size SwView::GetOptimalSizePixel() const
1275*cdf0e10cSrcweir {
1276*cdf0e10cSrcweir 	Size aPgSize;
1277*cdf0e10cSrcweir 	if ( pWrtShell->GetViewOptions()->getBrowseMode() )
1278*cdf0e10cSrcweir 		aPgSize = SvxPaperInfo::GetPaperSize(PAPER_A4);
1279*cdf0e10cSrcweir 	else
1280*cdf0e10cSrcweir 	{
1281*cdf0e10cSrcweir         aPgSize = GetWrtShell().GetAnyCurRect(RECT_PAGE).SSize();
1282*cdf0e10cSrcweir         aPgSize.Width() += DOCUMENTBORDER * 2;
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir         const SwPageDesc &rDesc = pWrtShell->GetPageDesc( pWrtShell->GetCurPageDesc() );
1285*cdf0e10cSrcweir         if( nsUseOnPage::PD_MIRROR == rDesc.GetUseOn() )
1286*cdf0e10cSrcweir 		{
1287*cdf0e10cSrcweir             const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace();
1288*cdf0e10cSrcweir             const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
1289*cdf0e10cSrcweir             aPgSize.Width() += Abs( long(rLeftLRSpace.GetLeft()) - long(rLRSpace.GetLeft()) );
1290*cdf0e10cSrcweir 		}
1291*cdf0e10cSrcweir     }
1292*cdf0e10cSrcweir 	return GetEditWin().LogicToPixel( aPgSize );
1293*cdf0e10cSrcweir }
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir 
1296*cdf0e10cSrcweir sal_Bool SwView::UpdateScrollbars()
1297*cdf0e10cSrcweir {
1298*cdf0e10cSrcweir     sal_Bool bRet = sal_False;
1299*cdf0e10cSrcweir     if ( !aVisArea.IsEmpty() )
1300*cdf0e10cSrcweir 	{
1301*cdf0e10cSrcweir 		const sal_Bool bBorder = IsDocumentBorder();
1302*cdf0e10cSrcweir 		Rectangle aTmpRect( aVisArea );
1303*cdf0e10cSrcweir 		if ( bBorder )
1304*cdf0e10cSrcweir 		{
1305*cdf0e10cSrcweir 			Point aPt( DOCUMENTBORDER, DOCUMENTBORDER );
1306*cdf0e10cSrcweir 			aPt = AlignToPixel( aPt );
1307*cdf0e10cSrcweir 			aTmpRect.Move( -aPt.X(), -aPt.Y() );
1308*cdf0e10cSrcweir 		}
1309*cdf0e10cSrcweir 
1310*cdf0e10cSrcweir 		Size aTmpSz( aDocSz );
1311*cdf0e10cSrcweir 		const long lOfst = bBorder ? 0 : DOCUMENTBORDER * 2L;
1312*cdf0e10cSrcweir 		aTmpSz.Width() += lOfst; aTmpSz.Height() += lOfst;
1313*cdf0e10cSrcweir 
1314*cdf0e10cSrcweir         {
1315*cdf0e10cSrcweir             const sal_Bool bVScrollVisible = pVScrollbar->IsVisible(sal_True);
1316*cdf0e10cSrcweir             pVScrollbar->DocSzChgd( aTmpSz );
1317*cdf0e10cSrcweir             pVScrollbar->ViewPortChgd( aTmpRect );
1318*cdf0e10cSrcweir 
1319*cdf0e10cSrcweir             sal_Bool bShowButtons = pVScrollbar->IsVisible(sal_True);
1320*cdf0e10cSrcweir             if(pPageUpBtn && pPageUpBtn->IsVisible() != bShowButtons)
1321*cdf0e10cSrcweir             {
1322*cdf0e10cSrcweir                 pPageUpBtn->Show(bShowButtons);
1323*cdf0e10cSrcweir                 if(pPageDownBtn)
1324*cdf0e10cSrcweir                     pPageDownBtn->Show(bShowButtons);
1325*cdf0e10cSrcweir                 if(pNaviBtn)
1326*cdf0e10cSrcweir                     pNaviBtn->Show(bShowButtons);
1327*cdf0e10cSrcweir             }
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir             if ( bVScrollVisible != pVScrollbar->IsVisible(sal_True) )
1330*cdf0e10cSrcweir                 bRet = sal_True;
1331*cdf0e10cSrcweir         }
1332*cdf0e10cSrcweir         {
1333*cdf0e10cSrcweir             const sal_Bool bHScrollVisible = pHScrollbar->IsVisible(sal_True);
1334*cdf0e10cSrcweir             pHScrollbar->DocSzChgd( aTmpSz );
1335*cdf0e10cSrcweir             pHScrollbar->ViewPortChgd( aTmpRect );
1336*cdf0e10cSrcweir             if ( bHScrollVisible != pHScrollbar->IsVisible(sal_True) )
1337*cdf0e10cSrcweir                 bRet = sal_True;
1338*cdf0e10cSrcweir             pScrollFill->Show(pHScrollbar->IsVisible(sal_True) && pVScrollbar->IsVisible(sal_True) );
1339*cdf0e10cSrcweir         }
1340*cdf0e10cSrcweir 	}
1341*cdf0e10cSrcweir     return bRet;
1342*cdf0e10cSrcweir }
1343*cdf0e10cSrcweir 
1344*cdf0e10cSrcweir 
1345*cdf0e10cSrcweir void SwView::Move()
1346*cdf0e10cSrcweir {
1347*cdf0e10cSrcweir 	if ( GetWrtShell().IsInSelect() )
1348*cdf0e10cSrcweir 		GetWrtShell().EndSelect();	//#32427#
1349*cdf0e10cSrcweir 	SfxViewShell::Move();
1350*cdf0e10cSrcweir }
1351*cdf0e10cSrcweir 
1352*cdf0e10cSrcweir sal_Bool SwView::HandleWheelCommands( const CommandEvent& rCEvt )
1353*cdf0e10cSrcweir {
1354*cdf0e10cSrcweir 	sal_Bool bOk = sal_False;
1355*cdf0e10cSrcweir 	const CommandWheelData* pWData = rCEvt.GetWheelData();
1356*cdf0e10cSrcweir 	if( pWData && COMMAND_WHEEL_ZOOM == pWData->GetMode() )
1357*cdf0e10cSrcweir 	{
1358*cdf0e10cSrcweir 		sal_uInt16 nFact = pWrtShell->GetViewOptions()->GetZoom();
1359*cdf0e10cSrcweir 		if( 0L > pWData->GetDelta() )
1360*cdf0e10cSrcweir             nFact = static_cast< sal_uInt16 >(Max( 20, nFact - 10 ));
1361*cdf0e10cSrcweir 		else
1362*cdf0e10cSrcweir             nFact = static_cast< sal_uInt16 >(Min( 600, nFact + 10 ));
1363*cdf0e10cSrcweir 
1364*cdf0e10cSrcweir 		SetZoom( SVX_ZOOM_PERCENT, nFact );
1365*cdf0e10cSrcweir 		bOk = sal_True;
1366*cdf0e10cSrcweir 	}
1367*cdf0e10cSrcweir 	else
1368*cdf0e10cSrcweir 	{
1369*cdf0e10cSrcweir 		if (pWData && (COMMAND_WHEEL_SCROLL==pWData->GetMode()) && (((sal_uLong)0xFFFFFFFF) == pWData->GetScrollLines()))
1370*cdf0e10cSrcweir         	{
1371*cdf0e10cSrcweir                         if (pWData->GetDelta()<0)
1372*cdf0e10cSrcweir                                 PhyPageDown();
1373*cdf0e10cSrcweir                         else
1374*cdf0e10cSrcweir                                 PhyPageUp();
1375*cdf0e10cSrcweir                         bOk = sal_True;
1376*cdf0e10cSrcweir                 }
1377*cdf0e10cSrcweir 		else
1378*cdf0e10cSrcweir 			bOk = pEditWin->HandleScrollCommand( rCEvt,
1379*cdf0e10cSrcweir                     		pHScrollbar, pVScrollbar);
1380*cdf0e10cSrcweir 	}
1381*cdf0e10cSrcweir 	return bOk;
1382*cdf0e10cSrcweir }
1383*cdf0e10cSrcweir 
1384*cdf0e10cSrcweir 
1385