1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "hintids.hxx"
21 #include <vcl/help.hxx>
22 #include <svx/ruler.hxx>
23 #include <editeng/paperinf.hxx>
24 #include <editeng/lrspitem.hxx>
25 #include <sfx2/bindings.hxx>
28 #include <swmodule.hxx>
29 #include <viewopt.hxx>
36 #include <usrpref.hxx>
37 #include <pagedesc.hxx>
38 #include <workctrl.hxx>
39 #include <crsskip.hxx>
41 #include <PostItMgr.hxx>
43 #include <IDocumentSettingAccess.hxx>
45 #include <basegfx/tools/zoomtools.hxx>
47 //Das SetVisArea der DocShell darf nicht vom InnerResizePixel gerufen werden.
48 //Unsere Einstellungen muessen aber stattfinden.
49 #ifndef WB_RIGHT_ALIGNED
50 #define WB_RIGHT_ALIGNED ((WinBits)0x00008000)
53 static bool bProtectDocShellVisArea
= false;
55 static sal_uInt16 nPgNum
= 0;
57 bool SwView::IsDocumentBorder()
59 return GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
||
60 m_pWrtShell
->GetViewOptions()->getBrowseMode() ||
61 SVX_ZOOM_PAGEWIDTH_NOBORDER
== (SvxZoomType
)m_pWrtShell
->GetViewOptions()->GetZoomType();
64 inline long GetLeftMargin( SwView
&rView
)
66 SvxZoomType eType
= (SvxZoomType
)rView
.GetWrtShell().GetViewOptions()->GetZoomType();
67 long lRet
= rView
.GetWrtShell().GetAnyCurRect(RECT_PAGE_PRT
).Left();
68 return eType
== SVX_ZOOM_PERCENT
? lRet
+ DOCUMENTBORDER
:
69 eType
== SVX_ZOOM_PAGEWIDTH
|| eType
== SVX_ZOOM_PAGEWIDTH_NOBORDER
? 0 :
70 lRet
+ DOCUMENTBORDER
+ nLeftOfst
;
73 static void lcl_GetPos(SwView
* pView
,
75 SwScrollbar
* pScrollbar
,
78 SwWrtShell
&rSh
= pView
->GetWrtShell();
79 const Size
m_aDocSz( rSh
.GetDocSize() );
81 const long lBorder
= bBorder
? DOCUMENTBORDER
: DOCUMENTBORDER
* 2;
82 const bool bHori
= pScrollbar
->IsHoriScroll();
84 const long lPos
= pScrollbar
->GetThumbPos() + (bBorder
? DOCUMENTBORDER
: 0);
86 long lDelta
= lPos
- (bHori
? rSh
.VisArea().Pos().X() : rSh
.VisArea().Pos().Y());
88 const long lSize
= (bHori
? m_aDocSz
.A() : m_aDocSz
.B()) + lBorder
;
89 // sollte rechts oder unten zuviel Wiese sein, dann muss
90 // diese von der VisArea herausgerechnet werden!
91 long nTmp
= pView
->GetVisArea().Right()+lDelta
;
92 if ( bHori
&& nTmp
> lSize
)
93 lDelta
-= nTmp
- lSize
;
94 nTmp
= pView
->GetVisArea().Bottom()+lDelta
;
95 if ( !bHori
&& nTmp
> lSize
)
96 lDelta
-= nTmp
- lSize
;
98 // use a reference to access/moodify the correct coordinate
99 // returned by accessors to non-const object
100 long & rCoord
= bHori
? rPos
.X() : rPos
.Y();
102 if ( bBorder
&& rCoord
< DOCUMENTBORDER
)
103 rCoord
= DOCUMENTBORDER
;
106 /*--------------------------------------------------------------------
107 Beschreibung: Nullpunkt Lineal setzen
108 --------------------------------------------------------------------*/
109 void SwView::InvalidateRulerPos()
111 static sal_uInt16 aInval
[] =
113 SID_ATTR_PARA_LRSPACE
, SID_RULER_BORDERS
, SID_RULER_PAGE_POS
,
114 SID_RULER_LR_MIN_MAX
, SID_ATTR_LONG_ULSPACE
, SID_ATTR_LONG_LRSPACE
,
115 SID_RULER_BORDER_DISTANCE
,
116 SID_ATTR_PARA_LRSPACE_VERTICAL
, SID_RULER_BORDERS_VERTICAL
,
117 SID_RULER_TEXT_RIGHT_TO_LEFT
,
118 SID_RULER_ROWS
, SID_RULER_ROWS_VERTICAL
, FN_STAT_PAGE
,
122 GetViewFrame()->GetBindings().Invalidate(aInval
);
124 OSL_ENSURE(m_pHRuler
, "warum ist das Lineal nicht da?");
125 m_pHRuler
->ForceUpdate();
126 m_pVRuler
->ForceUpdate();
129 /*--------------------------------------------------------------------
130 Beschreibung: begrenzt das Scrollen soweit, dass jeweils nur einen
131 viertel Bildschirm bis vor das Ende des Dokumentes
132 gescrollt werden kann.
133 --------------------------------------------------------------------*/
134 long SwView::SetHScrollMax( long lMax
)
136 const long lBorder
= IsDocumentBorder() ? DOCUMENTBORDER
: DOCUMENTBORDER
* 2;
137 const long lSize
= GetDocSz().Width() + lBorder
- m_aVisArea
.GetWidth();
139 // bei negativen Werten ist das Dokument vollstaendig sichtbar;
140 // in diesem Fall kein Scrollen
141 return std::max( std::min( lMax
, lSize
), 0L );
144 long SwView::SetVScrollMax( long lMax
)
146 const long lBorder
= IsDocumentBorder() ? DOCUMENTBORDER
: DOCUMENTBORDER
* 2;
147 long lSize
= GetDocSz().Height() + lBorder
- m_aVisArea
.GetHeight();
148 return std::max( std::min( lMax
, lSize
), 0L ); // siehe horz.
151 Point
SwView::AlignToPixel(const Point
&rPt
) const
153 return GetEditWin().PixelToLogic( GetEditWin().LogicToPixel( rPt
) );
156 /*--------------------------------------------------------------------
157 Beschreibung: Dokumentgroesse hat sich geaendert
158 --------------------------------------------------------------------*/
159 void SwView::DocSzChgd(const Size
&rSz
)
162 extern int bDocSzUpdated
;
167 if( !m_pWrtShell
|| m_aVisArea
.IsEmpty() ) // keine Shell -> keine Aenderung
169 bDocSzUpdated
= sal_False
;
173 //Wenn Text geloescht worden ist, kann es sein, dass die VisArea hinter
174 //den sichtbaren Bereich verweist
175 Rectangle
aNewVisArea( m_aVisArea
);
176 bool bModified
= false;
177 SwTwips lGreenOffset
= IsDocumentBorder() ? DOCUMENTBORDER
: DOCUMENTBORDER
* 2;
178 SwTwips lTmp
= m_aDocSz
.Width() + lGreenOffset
;
180 if ( aNewVisArea
.Right() >= lTmp
)
182 lTmp
= aNewVisArea
.Right() - lTmp
;
183 aNewVisArea
.Right() -= lTmp
;
184 aNewVisArea
.Left() -= lTmp
;
188 lTmp
= m_aDocSz
.Height() + lGreenOffset
;
189 if ( aNewVisArea
.Bottom() >= lTmp
)
191 lTmp
= aNewVisArea
.Bottom() - lTmp
;
192 aNewVisArea
.Bottom() -= lTmp
;
193 aNewVisArea
.Top() -= lTmp
;
198 SetVisArea( aNewVisArea
, sal_False
);
200 if ( UpdateScrollbars() && !m_bInOuterResizePixel
&& !m_bInInnerResizePixel
&&
201 !GetViewFrame()->GetFrame().IsInPlace())
202 OuterResizePixel( Point(),
203 GetViewFrame()->GetWindow().GetOutputSizePixel() );
206 /*--------------------------------------------------------------------
207 Beschreibung: Visarea neu setzen
208 --------------------------------------------------------------------*/
209 void SwView::SetVisArea( const Rectangle
&rRect
, sal_Bool bUpdateScrollbar
)
211 const Size
aOldSz( m_aVisArea
.GetSize() );
213 const Point
aTopLeft( AlignToPixel( rRect
.TopLeft() ));
214 const Point
aBottomRight( AlignToPixel( rRect
.BottomRight() ));
215 Rectangle
aLR( aTopLeft
, aBottomRight
);
217 if( aLR
== m_aVisArea
)
220 const SwTwips lMin
= IsDocumentBorder() ? DOCUMENTBORDER
: 0;
222 // keine negative Position, keine neg. Groesse
223 if( aLR
.Top() < lMin
)
225 aLR
.Bottom() += lMin
- aLR
.Top();
228 if( aLR
.Left() < lMin
)
230 aLR
.Right() += lMin
- aLR
.Left();
233 if( aLR
.Right() < 0 )
235 if( aLR
.Bottom() < 0 )
238 if( aLR
== m_aVisArea
)
241 const Size
aSize( aLR
.GetSize() );
242 if( aSize
.Width() < 0 || aSize
.Height() < 0 )
245 //Bevor die Daten veraendert werden ggf. ein Update rufen. Dadurch wird
246 //sichergestellt, da? anliegende Paints korrekt in Dokumentkoordinaten
247 //umgerechnet werden.
248 //Vorsichtshalber tun wir das nur wenn an der Shell eine Action laeuft,
249 //denn dann wir nicht wirklich gepaintet sondern die Rechtecke werden
250 //lediglich (in Dokumentkoordinaten) vorgemerkt.
251 if ( m_pWrtShell
&& m_pWrtShell
->ActionPend() )
252 m_pWrtShell
->GetWin()->Update();
256 const sal_Bool bOuterResize
= bUpdateScrollbar
&& UpdateScrollbars();
260 m_pWrtShell
->VisPortChgd( m_aVisArea
);
261 if ( aOldSz
!= m_pWrtShell
->VisArea().SSize() &&
262 ( std::abs(aOldSz
.Width() - m_pWrtShell
->VisArea().Width()) > 2 ||
263 std::abs(aOldSz
.Height() - m_pWrtShell
->VisArea().Height()) > 2 ) )
264 m_pWrtShell
->CheckBrowseView( sal_False
);
267 if ( !bProtectDocShellVisArea
)
269 //Wenn die Groesse der VisArea unveraendert ist, reichen wir die
270 //Groesse der VisArea vom InternalObject weiter. Damit soll der
271 //Transport von Fehlern vermieden werden.
272 Rectangle
aVis( m_aVisArea
);
273 if ( aVis
.GetSize() == aOldSz
)
274 aVis
.SetSize( GetDocShell()->SfxObjectShell::GetVisArea(ASPECT_CONTENT
).GetSize() );
275 // TODO/LATER: why casting?!
276 //GetDocShell()->SfxInPlaceObject::GetVisArea().GetSize() );
278 //Bei embedded immer mit Modify...
279 // TODO/LATER: why casting?!
280 GetDocShell()->SfxObjectShell::SetVisArea( aVis
);
282 if ( GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
283 GetDocShell()->SfxInPlaceObject::SetVisArea( aVis );
285 GetDocShell()->SvEmbeddedObject::SetVisArea( aVis );*/
288 SfxViewShell::VisAreaChanged( m_aVisArea
);
290 InvalidateRulerPos();
292 if ( bOuterResize
&& !m_bInOuterResizePixel
&& !m_bInInnerResizePixel
)
293 OuterResizePixel( Point(),
294 GetViewFrame()->GetWindow().GetOutputSizePixel() );
297 /*--------------------------------------------------------------------
298 Beschreibung: Pos VisArea setzen
299 --------------------------------------------------------------------*/
300 void SwView::SetVisArea( const Point
&rPt
, sal_Bool bUpdateScrollbar
)
302 //einmal alignen, damit Brushes korrekt angesetzt werden.
303 //MA 31. May. 96: Das geht in der BrowseView schief, weil evlt.
304 //nicht das ganze Dokument sichtbar wird. Da der Inhalt in Frames
305 //passgenau ist, kann nicht aligned werden (bessere Idee?!?!)
306 //MA 29. Oct. 96 (fix: Bild.de, 200%) ganz ohne Alignment geht es nicht
307 //mal sehen wie weit wir mit der halben BrushSize kommen.
309 // const long nTmp = GetWrtShell().IsFrameView() ? BRUSH_SIZE/2 : BRUSH_SIZE;
310 const long nTmp
= GetWrtShell().IsFrameView() ? 4 : 8;
311 aPt
= GetEditWin().LogicToPixel( aPt
);
312 aPt
.X() -= aPt
.X() % nTmp
;
313 aPt
.Y() -= aPt
.Y() % nTmp
;
314 aPt
= GetEditWin().PixelToLogic( aPt
);
316 if ( aPt
== m_aVisArea
.TopLeft() )
319 const long lXDiff
= m_aVisArea
.Left() - aPt
.X();
320 const long lYDiff
= m_aVisArea
.Top() - aPt
.Y();
321 SetVisArea( Rectangle( aPt
,
322 Point( m_aVisArea
.Right() - lXDiff
, m_aVisArea
.Bottom() - lYDiff
) ),
326 void SwView::CheckVisArea()
328 m_pHScrollbar
->SetAuto( m_pWrtShell
->GetViewOptions()->getBrowseMode() &&
329 !GetViewFrame()->GetFrame().IsInPlace() );
330 if ( IsDocumentBorder() )
332 if ( m_aVisArea
.Left() != DOCUMENTBORDER
||
333 m_aVisArea
.Top() != DOCUMENTBORDER
)
335 Rectangle
aNewVisArea( m_aVisArea
);
336 aNewVisArea
.Move( DOCUMENTBORDER
- m_aVisArea
.Left(),
337 DOCUMENTBORDER
- m_aVisArea
.Top() );
338 SetVisArea( aNewVisArea
, sal_True
);
343 /*--------------------------------------------------------------------
344 Beschreibung: Sichtbaren Bereich berechnen
346 OUT Point *pPt: neue Position des sichtbaren
348 IN Rectangle &rRect: Rechteck, das sich innerhalb des neuen
349 sichtbaren Bereiches befinden soll
350 sal_uInt16 nRange optional exakte Angabe des Bereiches,
351 um den ggfs. gescrollt werden soll
352 --------------------------------------------------------------------*/
353 void SwView::CalcPt( Point
*pPt
, const Rectangle
&rRect
,
354 sal_uInt16 nRangeX
, sal_uInt16 nRangeY
)
357 const SwTwips lMin
= IsDocumentBorder() ? DOCUMENTBORDER
: 0;
359 long nYScroll
= GetYScroll();
360 long nDesHeight
= rRect
.GetHeight();
361 long nCurHeight
= m_aVisArea
.GetHeight();
362 nYScroll
= std::min(nYScroll
, nCurHeight
- nDesHeight
); // wird es knapp, dann nicht zuviel scrollen
363 if(nDesHeight
> nCurHeight
) // die Hoehe reicht nicht aus, dann interessiert nYScroll nicht mehr
365 pPt
->Y() = rRect
.Top();
366 pPt
->Y() = std::max( lMin
, pPt
->Y() );
368 else if ( rRect
.Top() < m_aVisArea
.Top() ) //Verschiebung nach oben
370 pPt
->Y() = rRect
.Top() - (nRangeY
!= USHRT_MAX
? nRangeY
: nYScroll
);
371 pPt
->Y() = std::max( lMin
, pPt
->Y() );
373 else if( rRect
.Bottom() > m_aVisArea
.Bottom() ) //Verschiebung nach unten
375 pPt
->Y() = rRect
.Bottom() -
376 (m_aVisArea
.GetHeight()) + ( nRangeY
!= USHRT_MAX
?
377 nRangeY
: nYScroll
);
378 pPt
->Y() = SetVScrollMax( pPt
->Y() );
380 long nXScroll
= GetXScroll();
381 if ( rRect
.Right() > m_aVisArea
.Right() ) //Verschiebung nach rechts
383 pPt
->X() = rRect
.Right() -
384 (m_aVisArea
.GetWidth()) +
385 (nRangeX
!= USHRT_MAX
? nRangeX
: nXScroll
);
386 pPt
->X() = SetHScrollMax( pPt
->X() );
388 else if ( rRect
.Left() < m_aVisArea
.Left() ) //Verschiebung nach links
390 pPt
->X() = rRect
.Left() - (nRangeX
!= USHRT_MAX
? nRangeX
: nXScroll
);
391 pPt
->X() = std::max( ::GetLeftMargin( *this ) + nLeftOfst
, pPt
->X() );
392 pPt
->X() = std::min( rRect
.Left() - nScrollX
, pPt
->X() );
393 pPt
->X() = std::max( 0L, pPt
->X() );
397 /*--------------------------------------------------------------------
398 Beschreibung: Scrolling
399 --------------------------------------------------------------------*/
400 sal_Bool
SwView::IsScroll( const Rectangle
&rRect
) const
402 return m_bCenterCrsr
|| m_bTopCrsr
|| !m_aVisArea
.IsInside(rRect
);
405 void SwView::Scroll( const Rectangle
&rRect
, sal_uInt16 nRangeX
, sal_uInt16 nRangeY
)
407 if ( m_aVisArea
.IsEmpty() )
410 Rectangle
aOldVisArea( m_aVisArea
);
413 Window
* pCareWn
= ViewShell::GetCareWin(GetWrtShell());
416 Rectangle
aDlgRect( GetEditWin().PixelToLogic(
417 pCareWn
->GetWindowExtentsRelative( &GetEditWin() ) ) );
418 // Nur, wenn der Dialog nicht rechts oder links der VisArea liegt:
419 if ( aDlgRect
.Left() < m_aVisArea
.Right() &&
420 aDlgRect
.Right() > m_aVisArea
.Left() )
422 // Falls wir nicht zentriert werden sollen, in der VisArea liegen
423 // und nicht vom Dialog ueberdeckt werden ...
424 if ( !m_bCenterCrsr
&& aOldVisArea
.IsInside( rRect
)
425 && ( rRect
.Left() > aDlgRect
.Right()
426 || rRect
.Right() < aDlgRect
.Left()
427 || rRect
.Top() > aDlgRect
.Bottom()
428 || rRect
.Bottom() < aDlgRect
.Top() ) )
431 // Ist oberhalb oder unterhalb der Dialogs mehr Platz?
432 long nTopDiff
= aDlgRect
.Top() - m_aVisArea
.Top();
433 long nBottomDiff
= m_aVisArea
.Bottom() - aDlgRect
.Bottom();
434 if ( nTopDiff
< nBottomDiff
)
436 if ( nBottomDiff
> 0 ) // Ist unterhalb ueberhaupt Platz?
437 { // dann verschieben wir die Oberkante und merken uns dies
438 nDiffY
= aDlgRect
.Bottom() - m_aVisArea
.Top();
439 m_aVisArea
.Top() += nDiffY
;
444 if ( nTopDiff
> 0 ) // Ist oberhalb ueberhaupt Platz?
445 m_aVisArea
.Bottom() = aDlgRect
.Top(); // Unterkante aendern
451 if( !(m_bCenterCrsr
|| m_bTopCrsr
) && m_aVisArea
.IsInside( rRect
) )
453 m_aVisArea
= aOldVisArea
;
456 //falls das Rechteck groesser als der sichtbare Bereich -->
458 Size
aSize( rRect
.GetSize() );
459 const Size
aVisSize( m_aVisArea
.GetSize() );
460 if( !m_aVisArea
.IsEmpty() && (
461 aSize
.Width() + GetXScroll() > aVisSize
.Width() ||
462 aSize
.Height()+ GetYScroll() > aVisSize
.Height() ))
464 Point
aPt( m_aVisArea
.TopLeft() );
465 aSize
.Width() = std::min( aSize
.Width(), aVisSize
.Width() );
466 aSize
.Height()= std::min( aSize
.Height(),aVisSize
.Height());
468 CalcPt( &aPt
, Rectangle( rRect
.TopLeft(), aSize
),
469 static_cast< sal_uInt16
>((aVisSize
.Width() - aSize
.Width()) / 2),
470 static_cast< sal_uInt16
>((aVisSize
.Height()- aSize
.Height())/ 2) );
474 const long nBorder
= IsDocumentBorder() ? DOCUMENTBORDER
: 0;
475 aPt
.Y() = std::min( std::max( nBorder
, rRect
.Top() ),
476 m_aDocSz
.Height() + nBorder
-
477 m_aVisArea
.GetHeight() );
480 m_aVisArea
= aOldVisArea
;
486 Point
aPt( m_aVisArea
.TopLeft() );
487 CalcPt( &aPt
, rRect
, nRangeX
, nRangeY
);
491 const long nBorder
= IsDocumentBorder() ? DOCUMENTBORDER
: 0;
492 aPt
.Y() = std::min( std::max( nBorder
, rRect
.Top() ),
493 m_aDocSz
.Height() + nBorder
-
494 m_aVisArea
.GetHeight() );
498 m_aVisArea
= aOldVisArea
;
504 Point
aPnt( m_aVisArea
.TopLeft() );
505 // ... in Y-Richtung auf jeden Fall
506 aPnt
.Y() += ( rRect
.Top() + rRect
.Bottom()
507 - m_aVisArea
.Top() - m_aVisArea
.Bottom() ) / 2 - nDiffY
;
508 // ... in X-Richtung nur, wenn das Rechteck rechts oder links aus der
509 // VisArea hinausragt.
510 if ( rRect
.Right() > m_aVisArea
.Right() || rRect
.Left() < m_aVisArea
.Left() )
512 aPnt
.X() += ( rRect
.Left() + rRect
.Right()
513 - m_aVisArea
.Left() - m_aVisArea
.Right() ) / 2;
514 aPnt
.X() = SetHScrollMax( aPnt
.X() );
515 const SwTwips lMin
= IsDocumentBorder() ? DOCUMENTBORDER
: 0;
516 aPnt
.X() = std::max( (GetLeftMargin( *this ) - lMin
) + nLeftOfst
, aPnt
.X() );
518 m_aVisArea
= aOldVisArea
;
520 { // Wenn wir nur einem Dialog ausweichen wollen, wollen wir nicht ueber
521 // das Ende des Dokument hinausgehen.
522 aPnt
.Y() = SetVScrollMax( aPnt
.Y() );
527 /*--------------------------------------------------------------------
528 Beschreibung: Seitenweises Scrollen
529 Liefern den Wert, um den bei PageUp / -Down gescrollt werden soll
530 --------------------------------------------------------------------*/
531 sal_Bool
SwView::GetPageScrollUpOffset( SwTwips
&rOff
) const
533 if ( !m_aVisArea
.Top() || !m_aVisArea
.GetHeight() )
535 long nYScrl
= GetYScroll() / 2;
536 rOff
= -(m_aVisArea
.GetHeight() - nYScrl
);
537 //nicht vor den Dokumentanfang scrollen
538 if( m_aVisArea
.Top() - rOff
< 0 )
539 rOff
= rOff
- m_aVisArea
.Top();
540 else if( GetWrtShell().GetCharRect().Top() < (m_aVisArea
.Top() + nYScrl
))
545 sal_Bool
SwView::GetPageScrollDownOffset( SwTwips
&rOff
) const
547 if ( !m_aVisArea
.GetHeight() ||
548 (m_aVisArea
.GetHeight() > m_aDocSz
.Height()) )
550 long nYScrl
= GetYScroll() / 2;
551 rOff
= m_aVisArea
.GetHeight() - nYScrl
;
552 //nicht hinter das Dokumentende scrollen
553 if ( m_aVisArea
.Top() + rOff
> m_aDocSz
.Height() )
554 rOff
= m_aDocSz
.Height() - m_aVisArea
.Bottom();
555 else if( GetWrtShell().GetCharRect().Bottom() >
556 ( m_aVisArea
.Bottom() - nYScrl
))
561 // Seitenweises Blaettern
562 long SwView::PageUp()
564 if (!m_aVisArea
.GetHeight())
567 Point
aPos(m_aVisArea
.TopLeft());
568 aPos
.Y() -= m_aVisArea
.GetHeight() - (GetYScroll() / 2);
569 aPos
.Y() = std::max(0L, aPos
.Y());
574 long SwView::PageDown()
576 if ( !m_aVisArea
.GetHeight() )
578 Point
aPos( m_aVisArea
.TopLeft() );
579 aPos
.Y() += m_aVisArea
.GetHeight() - (GetYScroll() / 2);
580 aPos
.Y() = SetVScrollMax( aPos
.Y() );
585 long SwView::PhyPageUp()
587 //aktuell sichtbare Seite erfragen, nicht formatieren
588 sal_uInt16 nActPage
= m_pWrtShell
->GetNextPrevPageNum( sal_False
);
590 if( USHRT_MAX
!= nActPage
)
592 const Point
aPt( m_aVisArea
.Left(),
593 m_pWrtShell
->GetPagePos( nActPage
).Y() );
594 Point
aAlPt( AlignToPixel( aPt
) );
595 // falls ein Unterschied besteht, wurde abgeschnitten --> dann
596 // einen Pixel addieren, damit kein Rest der Vorgaengerseite
598 if( aPt
.Y() != aAlPt
.Y() )
599 aAlPt
.Y() += 3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height();
605 long SwView::PhyPageDown()
607 //aktuell sichtbare Seite erfragen, nicht formatieren
608 sal_uInt16 nActPage
= m_pWrtShell
->GetNextPrevPageNum( sal_True
);
609 // falls die letzte Dokumentseite sichtbar ist, nichts tun
610 if( USHRT_MAX
!= nActPage
)
612 const Point
aPt( m_aVisArea
.Left(),
613 m_pWrtShell
->GetPagePos( nActPage
).Y() );
614 Point
aAlPt( AlignToPixel( aPt
) );
615 // falls ein Unterschied besteht, wurde abgeschnitten --> dann
616 // einen Pixel addieren, damit kein Rest der Vorgaengerseite sichtbar ist
617 if( aPt
.Y() != aAlPt
.Y() )
618 aAlPt
.Y() += 3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height();
624 long SwView::PageUpCrsr( sal_Bool bSelect
)
628 const sal_uInt16 eType
= m_pWrtShell
->GetFrmType(0,sal_True
);
629 if ( eType
& FRMTYPE_FOOTNOTE
)
631 m_pWrtShell
->MoveCrsr();
632 m_pWrtShell
->GotoFtnAnchor();
633 m_pWrtShell
->Right(CRSR_SKIP_CHARS
, sal_False
, 1, sal_False
);
639 if ( GetPageScrollUpOffset( lOff
) &&
640 (m_pWrtShell
->IsCrsrReadonly() ||
641 !m_pWrtShell
->PageCrsr( lOff
, bSelect
)) &&
644 m_pWrtShell
->ResetCursorStack();
650 long SwView::PageDownCrsr(sal_Bool bSelect
)
653 if ( GetPageScrollDownOffset( lOff
) &&
654 (m_pWrtShell
->IsCrsrReadonly() ||
655 !m_pWrtShell
->PageCrsr( lOff
, bSelect
)) &&
658 m_pWrtShell
->ResetCursorStack();
664 /*------------------------------------------------------------------------
665 Beschreibung: Handler der Scrollbars
666 ------------------------------------------------------------------------*/
667 IMPL_LINK( SwView
, ScrollHdl
, SwScrollbar
*, pScrollbar
)
669 if ( GetWrtShell().ActionPend() )
672 if ( pScrollbar
->GetType() == SCROLL_DRAG
)
673 m_pWrtShell
->EnableSmooth( sal_False
);
675 if(!m_pWrtShell
->GetViewOptions()->getBrowseMode() &&
676 pScrollbar
->GetType() == SCROLL_DRAG
)
678 //Hier wieder auskommentieren wenn das mitscrollen nicht gewuenscht ist.
679 // the end scrollhandler invalidate the FN_STAT_PAGE,
680 // so we dont must do it agin.
681 EndScrollHdl(pScrollbar
);
683 Point
aPos( m_aVisArea
.TopLeft() );
684 lcl_GetPos(this, aPos
, pScrollbar
, IsDocumentBorder());
686 sal_uInt16 nPhNum
= 1;
687 sal_uInt16 nVirtNum
= 1;
690 if(m_pWrtShell
->GetPageNumber( aPos
.Y(), sal_False
, nPhNum
, nVirtNum
, sDisplay
))
694 if( !m_bWheelScrollInProgress
&& m_pWrtShell
->GetPageCnt() > 1 && Help::IsQuickHelpEnabled() )
696 if( !nPgNum
|| nPgNum
!= nPhNum
)
699 aRect
.Left() = pScrollbar
->GetParent()->OutputToScreenPixel(
700 pScrollbar
->GetPosPixel() ).X() -8;
701 aRect
.Top() = pScrollbar
->OutputToScreenPixel(
702 pScrollbar
->GetPointerPosPixel() ).Y();
703 aRect
.Right() = aRect
.Left();
704 aRect
.Bottom() = aRect
.Top();
706 String
sPageStr( GetPageStr( nPhNum
, nVirtNum
, sDisplay
));
707 SwContentAtPos
aCnt( SwContentAtPos::SW_OUTLINE
);
708 m_pWrtShell
->GetContentAtPos( aPos
, aCnt
);
709 if( aCnt
.sStr
.Len() )
711 sPageStr
+= OUString(" - ");
712 sPageStr
.Insert( aCnt
.sStr
, 0, 80 );
713 sPageStr
.SearchAndReplaceAll( '\t', ' ' );
714 sPageStr
.SearchAndReplaceAll( 0x0a, ' ' );
717 Help::ShowQuickHelp( pScrollbar
, aRect
, sPageStr
,
718 QUICKHELP_RIGHT
|QUICKHELP_VCENTER
);
725 EndScrollHdl(pScrollbar
);
727 if ( pScrollbar
->GetType() == SCROLL_DRAG
)
728 m_pWrtShell
->EnableSmooth( sal_True
);
733 /*------------------------------------------------------------------------
734 Beschreibung: Handler der Scrollbars
735 ------------------------------------------------------------------------*/
736 IMPL_LINK( SwView
, EndScrollHdl
, SwScrollbar
*, pScrollbar
)
738 if ( !GetWrtShell().ActionPend() )
743 Help::ShowQuickHelp(pScrollbar
, Rectangle(), aEmptyStr
, 0);
745 Point
aPos( m_aVisArea
.TopLeft() );
746 bool bBorder
= IsDocumentBorder();
747 lcl_GetPos(this, aPos
, pScrollbar
, bBorder
);
748 if ( bBorder
&& aPos
== m_aVisArea
.TopLeft() )
751 SetVisArea( aPos
, sal_False
);
753 GetViewFrame()->GetBindings().Update(FN_STAT_PAGE
);
758 /*--------------------------------------------------------------------
760 berechnet die Groesse von m_aVisArea abhaengig von der Groesse
761 des EditWin auf dem Schirm.
762 --------------------------------------------------------------------*/
763 void SwView::CalcVisArea( const Size
&rOutPixel
)
766 Rectangle
aRect( aTopLeft
, rOutPixel
);
767 aTopLeft
= GetEditWin().PixelToLogic( aTopLeft
);
768 Point
aBottomRight( GetEditWin().PixelToLogic( aRect
.BottomRight() ) );
770 aRect
.Left() = aTopLeft
.X();
771 aRect
.Top() = aTopLeft
.Y();
772 aRect
.Right() = aBottomRight
.X();
773 aRect
.Bottom() = aBottomRight
.Y();
775 //Die Verschiebungen nach rechts und/oder unten koennen jetzt falsch
776 //sein (z.B. Zoom aendern, Viewgroesse aendern.
777 const long lBorder
= IsDocumentBorder() ? DOCUMENTBORDER
: DOCUMENTBORDER
*2;
780 const long lWidth
= GetWrtShell().GetDocSize().Width() + lBorder
;
781 if ( aRect
.Right() > lWidth
)
783 long lDelta
= aRect
.Right() - lWidth
;
784 aRect
.Left() -= lDelta
;
785 aRect
.Right() -= lDelta
;
790 const long lHeight
= GetWrtShell().GetDocSize().Height() + lBorder
;
791 if ( aRect
.Bottom() > lHeight
)
793 long lDelta
= aRect
.Bottom() - lHeight
;
794 aRect
.Top() -= lDelta
;
795 aRect
.Bottom() -= lDelta
;
799 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM
);
800 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
); // for snapping points
803 /*--------------------------------------------------------------------
804 Beschreibung: Bedienelemente neu anordnen
805 --------------------------------------------------------------------*/
806 void SwView::CalcAndSetBorderPixel( SvBorder
&rToFill
, sal_Bool
/*bInner*/ )
808 sal_Bool bRightVRuler
= m_pWrtShell
->GetViewOptions()->IsVRulerRight();
809 if ( m_pVRuler
->IsVisible() )
811 long nWidth
= m_pVRuler
->GetSizePixel().Width();
813 rToFill
.Right() = nWidth
;
815 rToFill
.Left() = nWidth
;
818 OSL_ENSURE(m_pHRuler
, "warum ist das Lineal nicht da?");
819 if ( m_pHRuler
->IsVisible() )
820 rToFill
.Top() = m_pHRuler
->GetSizePixel().Height();
822 const StyleSettings
&rSet
= GetEditWin().GetSettings().GetStyleSettings();
823 const long nTmp
= rSet
.GetScrollBarSize();
824 if( m_pVScrollbar
->IsVisible(sal_True
) )
827 rToFill
.Left() = nTmp
;
829 rToFill
.Right() = nTmp
;
831 if ( m_pHScrollbar
->IsVisible(sal_True
) )
832 rToFill
.Bottom() = nTmp
;
834 SetBorderPixel( rToFill
);
837 void ViewResizePixel( const Window
&rRef
,
841 const sal_Bool
/*bInner*/,
842 SwScrollbar
& rVScrollbar
,
843 SwScrollbar
& rHScrollbar
,
844 ImageButton
* pPageUpBtn
,
845 ImageButton
* pPageDownBtn
,
846 ImageButton
* pNaviBtn
,
847 Window
& rScrollBarBox
,
851 sal_Bool bVRulerRight
)
853 // ViewResizePixel wird auch von der PreView benutzt!!!
855 const sal_Bool bHRuler
= pHRuler
&& pHRuler
->IsVisible();
856 const long nHLinSzHeight
= bHRuler
?
857 pHRuler
->GetSizePixel().Height() : 0;
858 const sal_Bool bVRuler
= pVRuler
&& pVRuler
->IsVisible();
859 const long nVLinSzWidth
= bVRuler
?
860 pVRuler
->GetSizePixel().Width() : 0;
862 long nScrollBarSize
= rRef
.GetSettings().GetStyleSettings().GetScrollBarSize();
863 long nHBSzHeight
= rHScrollbar
.IsVisible(true) ? nScrollBarSize
: 0;
864 long nVBSzWidth
= rVScrollbar
.IsVisible(true) ? nScrollBarSize
: 0;
868 WinBits nStyle
= pVRuler
->GetStyle()&~WB_RIGHT_ALIGNED
;
869 Point
aPos( rOfst
.X(), rOfst
.Y()+nHLinSzHeight
);
872 aPos
.X() += rSize
.Width() - nVLinSzWidth
;
873 nStyle
|= WB_RIGHT_ALIGNED
;
875 Size
aSize( nVLinSzWidth
, rEditSz
.Height() );
877 aSize
.Width() = pVRuler
->GetSizePixel().Width();
878 pVRuler
->SetStyle(nStyle
);
879 pVRuler
->SetPosSizePixel( aPos
, aSize
);
880 if(!pVRuler
->IsVisible())
883 // Lineal braucht ein Resize, sonst funktioniert es nicht im unischtbaren Zustand
886 Size
aSize( rSize
.Width(), nHLinSzHeight
);
887 if ( nVBSzWidth
&& !bVRulerRight
)
888 aSize
.Width() -= nVBSzWidth
;
890 aSize
.Height() = pHRuler
->GetSizePixel().Height();
891 pHRuler
->SetPosSizePixel( rOfst
, aSize
);
892 // VCL ruft an unsichtbaren Fenstern kein Resize
893 // fuer das Lineal ist das aber keine gute Idee
894 if(!pHRuler
->IsVisible())
898 // Scrollbars und SizeBox anordnen
899 Point aScrollFillPos
;
901 Point
aPos( rOfst
.X(),
902 rOfst
.Y()+rSize
.Height()-nHBSzHeight
);
905 aPos
.X() += nVBSzWidth
;
908 Size
aSize( rSize
.Width(), nHBSzHeight
);
910 aSize
.Width() -= nVBSzWidth
;
911 rHScrollbar
.SetPosSizePixel( aPos
, aSize
);
912 aScrollFillPos
.Y() = aPos
.Y();
915 Point
aPos( rOfst
.X()+rSize
.Width()-nVBSzWidth
,
917 Size
aSize( nVBSzWidth
, rSize
.Height() );
920 aPos
.X() = rOfst
.X();
923 aPos
.Y() += nHLinSzHeight
;
924 aSize
.Height() -= nHLinSzHeight
;
928 Size
aImgSz( nVBSzWidth
, nVBSzWidth
);
930 // wenn der Platz fuer Scrollbar und Page-Buttons zu klein wird, dann
931 // werden die Buttons versteckt
932 sal_uInt16 nCnt
= pNaviBtn
? 3 : 2;
933 long nSubSize
= (aImgSz
.Width() * nCnt
);
935 sal_Bool bHidePageButtons
= aSize
.Height() < ((bWebView
? 3 : 2) * nSubSize
);
936 if(!bHidePageButtons
)
937 aSize
.Height() -= nSubSize
;
939 aImgSz
.Width() = 0; // kein Hide, weil das im Update Scrollbar missverstanden wird
942 aSize
.Height() -= nHBSzHeight
;
943 rVScrollbar
.SetPosSizePixel( aPos
, aSize
);
945 aPos
.Y() += aSize
.Height();
946 pPageUpBtn
->SetPosSizePixel( aPos
, aImgSz
);
949 aPos
.Y() += aImgSz
.Height();
950 pNaviBtn
->SetPosSizePixel(aPos
, aImgSz
);
953 aPos
.Y() += aImgSz
.Height();
954 pPageDownBtn
->SetPosSizePixel( aPos
, aImgSz
);
956 aScrollFillPos
.X() = aPos
.X();
959 rScrollBarBox
.SetPosSizePixel( aScrollFillPos
, Size( nHBSzHeight
, nVBSzWidth
) );
962 void SwView::ShowAtResize()
964 m_bShowAtResize
= sal_False
;
965 if ( m_pWrtShell
->GetViewOptions()->IsViewHRuler() )
969 void SwView::InnerResizePixel( const Point
&rOfst
, const Size
&rSize
)
971 Size aObjSize
= GetObjectShell()->GetVisArea().GetSize();
972 if ( aObjSize
.Width() > 0 && aObjSize
.Height() > 0 )
974 SvBorder
aBorder( GetBorderPixel() );
976 aSize
.Width() -= (aBorder
.Left() + aBorder
.Right());
977 aSize
.Height() -= (aBorder
.Top() + aBorder
.Bottom());
978 Size aObjSizePixel
= GetWindow()->LogicToPixel( aObjSize
, MAP_TWIP
);
979 SfxViewShell::SetZoomFactor( Fraction( aSize
.Width(), aObjSizePixel
.Width() ),
980 Fraction( aSize
.Height(), aObjSizePixel
.Height() ) );
983 m_bInInnerResizePixel
= sal_True
;
984 const sal_Bool bHScrollVisible
= m_pHScrollbar
->IsVisible(sal_True
);
985 const sal_Bool bVScrollVisible
= m_pVScrollbar
->IsVisible(sal_True
);
986 sal_Bool bRepeat
= sal_False
;
991 CalcAndSetBorderPixel( aBorder
, sal_True
);
992 if ( GetViewFrame()->GetFrame().IsInPlace() )
994 Size
aViewSize( aSz
);
995 Point
aViewPos( rOfst
);
996 aViewSize
.Height() -= (aBorder
.Top() + aBorder
.Bottom());
997 aViewSize
.Width() -= (aBorder
.Left() + aBorder
.Right());
998 aViewPos
.X() += aBorder
.Left();
999 aViewPos
.Y() += aBorder
.Top();
1000 GetEditWin().SetPosSizePixel( aViewPos
, aViewSize
);
1004 aSz
.Height() += aBorder
.Top() + aBorder
.Bottom();
1005 aSz
.Width() += aBorder
.Left() + aBorder
.Right();
1008 Size
aEditSz( GetEditWin().GetOutputSizePixel() );
1009 ViewResizePixel( GetEditWin(), rOfst
, aSz
, aEditSz
, sal_True
, *m_pVScrollbar
,
1010 *m_pHScrollbar
, m_pPageUpBtn
, m_pPageDownBtn
,
1012 *m_pScrollFill
, m_pVRuler
, m_pHRuler
,
1013 0 != PTR_CAST(SwWebView
, this),
1014 m_pWrtShell
->GetViewOptions()->IsVRulerRight());
1015 if ( m_bShowAtResize
)
1018 if( m_pHRuler
->IsVisible() || m_pVRuler
->IsVisible() )
1020 const Fraction
& rFrac
= GetEditWin().GetMapMode().GetScaleX();
1021 sal_uInt16 nZoom
= 100;
1022 if (0 != rFrac
.GetDenominator())
1023 nZoom
= sal_uInt16(rFrac
.GetNumerator() * 100L / rFrac
.GetDenominator());
1025 const Fraction
aFrac( nZoom
, 100 );
1026 m_pVRuler
->SetZoom( aFrac
);
1027 m_pHRuler
->SetZoom( aFrac
);
1028 InvalidateRulerPos(); //Inhalt invalidieren.
1030 //CursorStack zuruecksetzen, da die Cursorpositionen fuer PageUp/-Down
1031 //nicht mehr zum aktuell sichtbaren Bereich passen
1032 m_pWrtShell
->ResetCursorStack();
1034 //EditWin niemals einstellen!
1036 //VisArea einstellen, aber dort nicht das SetVisArea der DocShell rufen!
1037 bProtectDocShellVisArea
= true;
1038 CalcVisArea( aEditSz
);
1039 //visibility changes of the automatic horizontal scrollbar
1040 //require to repeat the ViewResizePixel() call - but only once!
1042 bRepeat
= sal_False
;
1043 else if(bHScrollVisible
!= m_pHScrollbar
->IsVisible(sal_True
) ||
1044 bVScrollVisible
!= m_pVScrollbar
->IsVisible(sal_True
))
1047 bProtectDocShellVisArea
= false;
1048 m_bInInnerResizePixel
= sal_False
;
1051 void SwView::OuterResizePixel( const Point
&rOfst
, const Size
&rSize
)
1053 // #i16909# return, if no size (caused by minimize window).
1054 if ( m_bInOuterResizePixel
|| ( !rSize
.Width() && !rSize
.Height() ) )
1056 m_bInOuterResizePixel
= sal_True
;
1058 // feststellen, ob Scrollbars angezeigt werden duerfen
1059 sal_Bool bShowH
= sal_True
,
1064 const SwViewOption
*pVOpt
= m_pWrtShell
->GetViewOptions();
1065 if ( !pVOpt
->IsReadonly() || pVOpt
->IsStarOneSetting() )
1067 bShowH
= pVOpt
->IsViewHScrollBar();
1068 bShowV
= pVOpt
->IsViewVScrollBar();
1071 if (!m_bHScrollbarEnabled
)
1073 bHAuto
= bShowH
= false;
1075 if (!m_bVScrollbarEnabled
)
1077 bAuto
= bShowV
= false;
1080 SwDocShell
* pDocSh
= GetDocShell();
1081 sal_Bool bIsPreview
= pDocSh
->IsPreview();
1084 bShowH
= bShowV
= bHAuto
= bAuto
= sal_False
;
1086 if(m_pHScrollbar
->IsVisible(sal_False
) != bShowH
&& !bHAuto
)
1087 ShowHScrollbar(bShowH
);
1088 m_pHScrollbar
->SetAuto( bHAuto
);
1089 if(m_pVScrollbar
->IsVisible(sal_False
) != bShowV
&& !bAuto
)
1090 ShowVScrollbar(bShowV
);
1091 m_pVScrollbar
->SetAuto(bAuto
);
1093 SET_CURR_SHELL( m_pWrtShell
);
1094 sal_Bool bRepeat
= sal_False
;
1097 sal_Bool bUnLockView
= !m_pWrtShell
->IsViewLocked();
1098 m_pWrtShell
->LockView( sal_True
);
1099 m_pWrtShell
->LockPaint();
1103 const sal_Bool bScroll1
= m_pVScrollbar
->IsVisible(sal_True
);
1104 const sal_Bool bScroll2
= m_pHScrollbar
->IsVisible(sal_True
);
1106 CalcAndSetBorderPixel( aBorder
, sal_False
);
1107 const Size
aEditSz( GetEditWin().GetOutputSizePixel() );
1108 ViewResizePixel( GetEditWin(), rOfst
, rSize
, aEditSz
, sal_False
, *m_pVScrollbar
,
1109 *m_pHScrollbar
, m_pPageUpBtn
, m_pPageDownBtn
,
1111 *m_pScrollFill
, m_pVRuler
, m_pHRuler
,
1112 0 != PTR_CAST(SwWebView
, this),
1113 m_pWrtShell
->GetViewOptions()->IsVRulerRight() );
1114 if ( m_bShowAtResize
)
1117 if( m_pHRuler
->IsVisible() || m_pVRuler
->IsVisible() )
1118 InvalidateRulerPos(); //Inhalt invalidieren.
1120 //CursorStack zuruecksetzen, da die Cursorpositionen fuer PageUp/-Down
1121 //nicht mehr zum aktuell sichtbaren Bereich passen
1122 m_pWrtShell
->ResetCursorStack();
1124 OSL_ENSURE( !GetEditWin().IsVisible() ||
1125 (( aEditSz
.Width() > 0 && aEditSz
.Height() > 0 )
1126 || !m_aVisArea
.IsEmpty()), "Small world, isn't it?" );
1128 //EditWin niemals einstellen!
1130 //Die VisArea muss aber natuerlich eingestellt werden.
1131 //jetzt ist auch der richtige Zeitpunkt den Zoom neu zu berechnen wenn
1132 //es kein einfacher Faktor ist.
1133 m_pWrtShell
->StartAction();
1134 CalcVisArea( aEditSz
);
1136 //Damit auch beim outplace editing die Seitenbreite sofort
1138 //TODO/LATER: is that still necessary?!
1140 if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1142 pDocSh->SfxInPlaceObject::GetVisArea() );*/
1143 if ( m_pWrtShell
->GetViewOptions()->GetZoomType() != SVX_ZOOM_PERCENT
&&
1144 !m_pWrtShell
->GetViewOptions()->getBrowseMode() )
1145 _SetZoom( aEditSz
, (SvxZoomType
)m_pWrtShell
->GetViewOptions()->GetZoomType(), 100, sal_True
);
1146 m_pWrtShell
->EndAction();
1148 bRepeat
= bScroll1
!= m_pVScrollbar
->IsVisible(sal_True
);
1150 bRepeat
= bScroll2
!= m_pHScrollbar
->IsVisible(sal_True
);
1152 //Nicht endlosschleifen. Moeglichst dann stoppen wenn die
1153 //(Auto-)Scrollbars sichtbar sind.
1155 ( nCnt
> 10 || ( nCnt
> 3 && bHAuto
&& bAuto
) )
1158 bRepeat
= sal_False
;
1163 if( m_pVScrollbar
->IsVisible(sal_False
) || m_pVScrollbar
->IsAuto())
1165 sal_Bool bShowButtons
= m_pVScrollbar
->IsVisible(sal_True
);
1166 if(m_pPageUpBtn
&& m_pPageUpBtn
->IsVisible() != bShowButtons
)
1168 m_pPageUpBtn
->Show(bShowButtons
);
1170 m_pPageDownBtn
->Show(bShowButtons
);
1172 m_pNaviBtn
->Show(bShowButtons
);
1176 m_pWrtShell
->UnlockPaint();
1178 m_pWrtShell
->LockView( sal_False
);
1180 m_bInOuterResizePixel
= sal_False
;
1184 m_pPostItMgr
->CalcRects();
1185 m_pPostItMgr
->LayoutPostIts();
1189 void SwView::SetZoomFactor( const Fraction
&rX
, const Fraction
&rY
)
1191 const Fraction
&rFrac
= rX
< rY
? rX
: rY
;
1192 SetZoom( SVX_ZOOM_PERCENT
, (short) long(rFrac
* Fraction( 100, 1 )) );
1194 //Um Rundungsfehler zu minimieren lassen wir von der Basisklasse ggf.
1195 //auch die krummen Werte einstellen
1196 SfxViewShell::SetZoomFactor( rX
, rY
);
1199 sal_Bool
SwView::UpdateScrollbars()
1201 sal_Bool bRet
= sal_False
;
1202 if ( !m_aVisArea
.IsEmpty() )
1204 const bool bBorder
= IsDocumentBorder();
1205 Rectangle
aTmpRect( m_aVisArea
);
1208 Point
aPt( DOCUMENTBORDER
, DOCUMENTBORDER
);
1209 aPt
= AlignToPixel( aPt
);
1210 aTmpRect
.Move( -aPt
.X(), -aPt
.Y() );
1213 Size
aTmpSz( m_aDocSz
);
1214 const long lOfst
= bBorder
? 0 : DOCUMENTBORDER
* 2L;
1215 aTmpSz
.Width() += lOfst
; aTmpSz
.Height() += lOfst
;
1218 const sal_Bool bVScrollVisible
= m_pVScrollbar
->IsVisible(sal_True
);
1219 m_pVScrollbar
->DocSzChgd( aTmpSz
);
1220 m_pVScrollbar
->ViewPortChgd( aTmpRect
);
1222 sal_Bool bShowButtons
= m_pVScrollbar
->IsVisible(sal_True
);
1223 if(m_pPageUpBtn
&& m_pPageUpBtn
->IsVisible() != bShowButtons
)
1225 m_pPageUpBtn
->Show(bShowButtons
);
1227 m_pPageDownBtn
->Show(bShowButtons
);
1229 m_pNaviBtn
->Show(bShowButtons
);
1232 if ( bVScrollVisible
!= m_pVScrollbar
->IsVisible(sal_True
) )
1236 const sal_Bool bHScrollVisible
= m_pHScrollbar
->IsVisible(sal_True
);
1237 m_pHScrollbar
->DocSzChgd( aTmpSz
);
1238 m_pHScrollbar
->ViewPortChgd( aTmpRect
);
1239 if ( bHScrollVisible
!= m_pHScrollbar
->IsVisible(sal_True
) )
1241 m_pScrollFill
->Show(m_pHScrollbar
->IsVisible(sal_True
) && m_pVScrollbar
->IsVisible(sal_True
) );
1249 if ( GetWrtShell().IsInSelect() )
1250 GetWrtShell().EndSelect();
1251 SfxViewShell::Move();
1254 sal_Bool
SwView::HandleWheelCommands( const CommandEvent
& rCEvt
)
1256 sal_Bool bOk
= sal_False
;
1257 const CommandWheelData
* pWData
= rCEvt
.GetWheelData();
1258 if (pWData
&& COMMAND_WHEEL_ZOOM
== pWData
->GetMode())
1260 long nFact
= m_pWrtShell
->GetViewOptions()->GetZoom();
1261 if( 0L > pWData
->GetDelta() )
1262 nFact
= std::max( (long) 20, basegfx::zoomtools::zoomOut( nFact
));
1264 nFact
= std::min( (long) 600, basegfx::zoomtools::zoomIn( nFact
));
1266 SetZoom( SVX_ZOOM_PERCENT
, nFact
);
1269 else if (pWData
&& COMMAND_WHEEL_ZOOM_SCALE
== pWData
->GetMode())
1271 int newZoom
= 100 * (m_pWrtShell
->GetViewOptions()->GetZoom() / 100.0) * (pWData
->GetDelta() / 100.0);
1272 SetZoom( SVX_ZOOM_PERCENT
, std::max( 20, std::min( 600, newZoom
) ) );
1277 if (pWData
&& pWData
->GetMode()==COMMAND_WHEEL_SCROLL
)
1279 // This influences whether quick help is shown
1280 m_bWheelScrollInProgress
=true;
1283 if (pWData
&& (COMMAND_WHEEL_SCROLL
==pWData
->GetMode()) && (((sal_uLong
)0xFFFFFFFF) == pWData
->GetScrollLines()))
1285 if (pWData
->GetDelta()<0)
1292 bOk
= m_pEditWin
->HandleScrollCommand(rCEvt
, m_pHScrollbar
, m_pVScrollbar
);
1294 // Restore default state for case when scroll command comes from dragging scrollbar handle
1295 m_bWheelScrollInProgress
=false;
1300 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */