LibreOffice Module sw (master)  1
viewport.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <config_features.h>
21 
22 #include <hintids.hxx>
23 
24 #include <vcl/commandevent.hxx>
25 #include <vcl/help.hxx>
26 #include <vcl/settings.hxx>
27 
28 #include <svx/ruler.hxx>
29 #include <editeng/paperinf.hxx>
30 #include <editeng/lrspitem.hxx>
31 #include <sfx2/bindings.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include <svx/svxids.hrc>
34 #include <view.hxx>
35 #include <wrtsh.hxx>
36 #include <swmodule.hxx>
37 #include <viewopt.hxx>
38 #include <frmatr.hxx>
39 #include <docsh.hxx>
40 #include <cmdid.h>
41 #include <edtwin.hxx>
42 #include <scroll.hxx>
43 #include <wview.hxx>
44 #include <usrpref.hxx>
45 #include <pagedesc.hxx>
46 #include <workctrl.hxx>
47 
48 #include <PostItMgr.hxx>
49 
51 
53 #include <comphelper/lok.hxx>
54 #include <vcl/weld.hxx>
55 #include <tools/svborder.hxx>
56 
57 #include "viewfunc.hxx"
58 
59 // The SetVisArea of the DocShell must not be called from InnerResizePixel.
60 // But our adjustments must take place.
61 static bool bProtectDocShellVisArea = false;
62 
63 static sal_uInt16 nPgNum = 0;
64 
66 {
67  if (GetDocShell()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED)
68  return true;
69 
70  if (!m_pWrtShell)
71  return false;
72 
73  return m_pWrtShell->GetViewOptions()->getBrowseMode() ||
74  SvxZoomType::PAGEWIDTH_NOBORDER == m_pWrtShell->GetViewOptions()->GetZoomType();
75 }
76 
77 static long GetLeftMargin( SwView const &rView )
78 {
80  long lRet = rView.GetWrtShell().GetAnyCurRect(CurRectType::PagePrt).Left();
81  return eType == SvxZoomType::PERCENT ? lRet + DOCUMENTBORDER :
82  eType == SvxZoomType::PAGEWIDTH || eType == SvxZoomType::PAGEWIDTH_NOBORDER ? 0 :
83  lRet + DOCUMENTBORDER + nLeftOfst;
84 }
85 
86 static void lcl_GetPos(SwView const * pView,
87  Point& rPos,
88  SwScrollbar const * pScrollbar,
89  bool bBorder)
90 {
91  SwWrtShell &rSh = pView->GetWrtShell();
92  const Size aDocSz( rSh.GetDocSize() );
93 
94  const long lBorder = bBorder ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
95  const bool bHori = pScrollbar->IsHoriScroll();
96 
97  const long lPos = pScrollbar->GetThumbPos() + (bBorder ? DOCUMENTBORDER : 0);
98 
99  long lDelta = lPos - (bHori ? rSh.VisArea().Pos().X() : rSh.VisArea().Pos().Y());
100 
101  const long lSize = (bHori ? aDocSz.Width() : aDocSz.Height()) + lBorder;
102  // Should right or below are too much space,
103  // then they must be subtracted out of the VisArea!
104  long nTmp = pView->GetVisArea().Right()+lDelta;
105  if ( bHori && nTmp > lSize )
106  lDelta -= nTmp - lSize;
107  nTmp = pView->GetVisArea().Bottom()+lDelta;
108  if ( !bHori && nTmp > lSize )
109  lDelta -= nTmp - lSize;
110 
111  bHori ? rPos.AdjustX(lDelta) : rPos.AdjustY(lDelta);
112  if ( bBorder && (bHori ? rPos.X() : rPos.Y()) < DOCUMENTBORDER )
113  bHori ? rPos.setX(DOCUMENTBORDER) : rPos.setY(DOCUMENTBORDER);
114 }
115 
116 // Set zero ruler
117 
119 {
120  static sal_uInt16 aInval[] =
121  {
122  SID_ATTR_PARA_LRSPACE, SID_RULER_BORDERS, SID_RULER_PAGE_POS,
123  SID_RULER_LR_MIN_MAX, SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
124  SID_RULER_BORDER_DISTANCE,
125  SID_ATTR_PARA_LRSPACE_VERTICAL, SID_RULER_BORDERS_VERTICAL,
126  SID_RULER_TEXT_RIGHT_TO_LEFT,
127  SID_RULER_ROWS, SID_RULER_ROWS_VERTICAL, FN_STAT_PAGE,
128  0
129  };
130 
131  GetViewFrame()->GetBindings().Invalidate(aInval);
132 
133  assert(m_pHRuler && "Why is the ruler not there?");
136 }
137 
138 // Limits the scrolling so far that only a quarter of the
139 // screen can be scrolled up before the end of the document.
140 
141 long SwView::SetHScrollMax( long lMax )
142 {
143  const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
144  const long lSize = GetDocSz().Width() + lBorder - m_aVisArea.GetWidth();
145 
146  // At negative values the document is completely visible.
147  // In this case, no scrolling.
148  return std::max( std::min( lMax, lSize ), 0L );
149 }
150 
151 long SwView::SetVScrollMax( long lMax )
152 {
153  const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
154  long lSize = GetDocSz().Height() + lBorder - m_aVisArea.GetHeight();
155  return std::max( std::min( lMax, lSize), 0L ); // see horizontal
156 }
157 
159 {
160  return GetEditWin().PixelToLogic( GetEditWin().LogicToPixel( rPt ) );
161 }
162 
163 // Document size has changed.
164 
165 void SwView::DocSzChgd(const Size &rSz)
166 {
167  m_aDocSz = rSz;
168 
169  if( !m_pWrtShell || m_aVisArea.IsEmpty() ) // no shell -> no change
170  {
171  bDocSzUpdated = false;
172  return;
173  }
174 
175  //If text has been deleted, it may be that the VisArea points behind the visible range.
176  tools::Rectangle aNewVisArea( m_aVisArea );
177  bool bModified = false;
178  SwTwips lGreenOffset = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
179  SwTwips lTmp = m_aDocSz.Width() + lGreenOffset;
180 
181  if ( aNewVisArea.Right() >= lTmp )
182  {
183  lTmp = aNewVisArea.Right() - lTmp;
184  aNewVisArea.AdjustRight( -lTmp );
185  aNewVisArea.AdjustLeft( -lTmp );
186  bModified = true;
187  }
188 
189  lTmp = m_aDocSz.Height() + lGreenOffset;
190  if ( aNewVisArea.Bottom() >= lTmp )
191  {
192  lTmp = aNewVisArea.Bottom() - lTmp;
193  aNewVisArea.AdjustBottom( -lTmp );
194  aNewVisArea.AdjustTop( -lTmp );
195  bModified = true;
196  }
197 
198  if ( bModified )
199  SetVisArea( aNewVisArea, false );
200 
202  !GetViewFrame()->GetFrame().IsInPlace())
204  GetViewFrame()->GetWindow().GetOutputSizePixel() );
205 }
206 
207 // Set VisArea newly
208 
209 void SwView::SetVisArea( const tools::Rectangle &rRect, bool bUpdateScrollbar )
210 {
211  Size aOldSz( m_aVisArea.GetSize() );
213  // If m_pWrtShell's visible area is the whole document, do the same here.
214  aOldSz = m_pWrtShell->VisArea().SSize();
215 
216  if( rRect == m_aVisArea )
217  return;
218 
219  const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
220 
221  // No negative position, no negative size
222  tools::Rectangle aLR = rRect;
223  if( aLR.Top() < lMin )
224  {
225  aLR.AdjustBottom(lMin - aLR.Top() );
226  aLR.SetTop( lMin );
227  }
228  if( aLR.Left() < lMin )
229  {
230  aLR.AdjustRight(lMin - aLR.Left() );
231  aLR.SetLeft( lMin );
232  }
233  if( aLR.Right() < 0 )
234  aLR.SetRight( 0 );
235  if( aLR.Bottom() < 0 )
236  aLR.SetBottom( 0 );
237 
238  if( aLR == m_aVisArea )
239  return;
240 
241  const Size aSize( aLR.GetSize() );
242  if( aSize.Width() < 0 || aSize.Height() < 0 )
243  return;
244 
245  // Before the data can be changed, call an update if necessary. This
246  // ensures that adjacent Paints in document coordinates are converted
247  // correctly.
248  // As a precaution, we do this only when an action is running in the
249  // shell, because then it is not really drawn but the rectangles will
250  // be only marked (in document coordinates).
251  if ( m_pWrtShell && m_pWrtShell->ActionPend() )
252  m_pWrtShell->GetWin()->Update();
253 
254  m_aVisArea = aLR;
255 
256  const bool bOuterResize = bUpdateScrollbar && UpdateScrollbars();
257 
258  if ( m_pWrtShell )
259  {
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->InvalidateLayout( false );
265  }
266 
268  {
269  // If the size of VisArea is unchanged, we extend the size of the VisArea
270  // InternalObject on. By that the transport of errors shall be avoided.
272  if ( aVis.GetSize() == aOldSz )
274  // TODO/LATER: why casting?!
275  //GetDocShell()->SfxInPlaceObject::GetVisArea().GetSize() );
276 
277  // With embedded always with modify...
278  // TODO/LATER: why casting?!
279  GetDocShell()->SfxObjectShell::SetVisArea( aVis );
280  /*
281  if ( GetDocShell()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
282  GetDocShell()->SfxInPlaceObject::SetVisArea( aVis );
283  else
284  GetDocShell()->SvEmbeddedObject::SetVisArea( aVis );*/
285  }
286 
288 
290 
291  if ( bOuterResize && !m_bInOuterResizePixel && !m_bInInnerResizePixel)
293  GetViewFrame()->GetWindow().GetOutputSizePixel() );
294 }
295 
296 // Set Pos VisArea
297 
298 void SwView::SetVisArea( const Point &rPt, bool bUpdateScrollbar )
299 {
300  // Align once, so brushes will be inserted correctly.
301  // This goes wrong in the BrowseView, because the entire document may
302  // not be visible. Since the content in frames is fitting exactly,
303  // align is not possible (better idea?!?!)
304  // (fix: Bild.de, 200%) It does not work completely without alignment
305  // Let's see how far we get with half BrushSize.
306  Point aPt = GetEditWin().LogicToPixel( rPt );
307 #if HAVE_FEATURE_DESKTOP
308  const long nTmp = GetWrtShell().IsFrameView() ? 4 : 8;
309  aPt.AdjustX( -(aPt.X() % nTmp) );
310  aPt.AdjustY( -(aPt.Y() % nTmp) );
311 #endif
312  aPt = GetEditWin().PixelToLogic( aPt );
313 
314  if ( aPt == m_aVisArea.TopLeft() )
315  return;
316 
317  const long lXDiff = m_aVisArea.Left() - aPt.X();
318  const long lYDiff = m_aVisArea.Top() - aPt.Y();
320  Point( m_aVisArea.Right() - lXDiff, m_aVisArea.Bottom() - lYDiff ) ),
321  bUpdateScrollbar);
322 }
323 
325 {
326  m_pHScrollbar->SetAuto( m_pWrtShell->GetViewOptions()->getBrowseMode() &&
327  !GetViewFrame()->GetFrame().IsInPlace() );
328  if ( IsDocumentBorder() )
329  {
330  if ( m_aVisArea.Left() != DOCUMENTBORDER ||
332  {
333  tools::Rectangle aNewVisArea( m_aVisArea );
334  aNewVisArea.Move( DOCUMENTBORDER - m_aVisArea.Left(),
336  SetVisArea( aNewVisArea );
337  }
338  }
339 }
340 
342 
343 // OUT Point *pPt: new position of the visible area
344 
345 // IN Rectangle &rRect: Rectangle, which should be located
346 // within the new visible area.
347 // sal_uInt16 nRange optional accurate indication of the
348 // range by which to scroll if necessary.
349 
350 void SwView::CalcPt( Point *pPt, const tools::Rectangle &rRect,
351  sal_uInt16 nRangeX, sal_uInt16 nRangeY)
352 {
353 
354  const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
355 
356  long nYScroll = GetYScroll();
357  long nDesHeight = rRect.GetHeight();
358  long nCurHeight = m_aVisArea.GetHeight();
359  nYScroll = std::min(nYScroll, nCurHeight - nDesHeight); // If it is scarce, then scroll not too much.
360  if(nDesHeight > nCurHeight) // the height is not sufficient, then nYScroll is no longer of interest
361  {
362  pPt->setY( rRect.Top() );
363  pPt->setY( std::max( lMin, pPt->Y() ) );
364  }
365  else if ( rRect.Top() < m_aVisArea.Top() ) // Upward shift
366  {
367  pPt->setY( rRect.Top() - (nRangeY != USHRT_MAX ? nRangeY : nYScroll) );
368  pPt->setY( std::max( lMin, pPt->Y() ) );
369  }
370  else if( rRect.Bottom() > m_aVisArea.Bottom() ) // Downward shift
371  {
372  pPt->setY( rRect.Bottom() -
373  (m_aVisArea.GetHeight()) + ( nRangeY != USHRT_MAX ?
374  nRangeY : nYScroll ) );
375  pPt->setY( SetVScrollMax( pPt->Y() ) );
376  }
377  long nXScroll = GetXScroll();
378  if ( rRect.Right() > m_aVisArea.Right() ) // Shift right
379  {
380  pPt->setX( rRect.Right() -
381  (m_aVisArea.GetWidth()) +
382  (nRangeX != USHRT_MAX ? nRangeX : nXScroll) );
383  pPt->setX( SetHScrollMax( pPt->X() ) );
384  }
385  else if ( rRect.Left() < m_aVisArea.Left() ) // Shift left
386  {
387  pPt->setX( rRect.Left() - (nRangeX != USHRT_MAX ? nRangeX : nXScroll) );
388  pPt->setX( std::max( ::GetLeftMargin( *this ) + nLeftOfst, pPt->X() ) );
389  pPt->setX( std::min( rRect.Left() - nScrollX, pPt->X() ) );
390  pPt->setX( std::max( 0L, pPt->X() ) );
391  }
392 }
393 
394 // Scrolling
395 
396 bool SwView::IsScroll( const tools::Rectangle &rRect ) const
397 {
398  return m_bCenterCursor || m_bTopCursor || !m_aVisArea.IsInside(rRect);
399 }
400 
401 void SwView::Scroll( const tools::Rectangle &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY )
402 {
403  if ( m_aVisArea.IsEmpty() )
404  return;
405 
406  tools::Rectangle aOldVisArea( m_aVisArea );
407  long nDiffY = 0;
408 
410  if (pCareDialog)
411  {
412  int x, y, width, height;
413  tools::Rectangle aDlgRect;
414  if (pCareDialog->get_extents_relative_to(*GetEditWin().GetFrameWeld(), x, y, width, height))
415  {
416  Point aTopLeft(GetEditWin().GetSystemWindow()->OutputToAbsoluteScreenPixel(Point(x, y)));
417  aTopLeft = GetEditWin().AbsoluteScreenToOutputPixel(aTopLeft);
418  aDlgRect = GetEditWin().PixelToLogic(tools::Rectangle(aTopLeft, Size(width, height)));
419  }
420 
421  // Only if the dialogue is not the VisArea right or left:
422  if ( aDlgRect.Left() < m_aVisArea.Right() &&
423  aDlgRect.Right() > m_aVisArea.Left() )
424  {
425  // If we are not supposed to be centered, lying in the VisArea
426  // and are not covered by the dialogue ...
427  if ( !m_bCenterCursor && aOldVisArea.IsInside( rRect )
428  && ( rRect.Left() > aDlgRect.Right()
429  || rRect.Right() < aDlgRect.Left()
430  || rRect.Top() > aDlgRect.Bottom()
431  || rRect.Bottom() < aDlgRect.Top() ) )
432  return;
433 
434  // Is above or below the dialogue more space?
435  long nTopDiff = aDlgRect.Top() - m_aVisArea.Top();
436  long nBottomDiff = m_aVisArea.Bottom() - aDlgRect.Bottom();
437  if ( nTopDiff < nBottomDiff )
438  {
439  if ( nBottomDiff > 0 ) // Is there room below at all?
440  { // then we move the upper edge and we remember this
441  nDiffY = aDlgRect.Bottom() - m_aVisArea.Top();
442  m_aVisArea.AdjustTop(nDiffY );
443  }
444  }
445  else
446  {
447  if ( nTopDiff > 0 ) // Is there room below at all?
448  m_aVisArea.SetBottom( aDlgRect.Top() ); // Modify the lower edge
449  }
450  }
451  }
452 
453  //s.o. !IsScroll()
454  if( !(m_bCenterCursor || m_bTopCursor) && m_aVisArea.IsInside( rRect ) )
455  {
456  m_aVisArea = aOldVisArea;
457  return;
458  }
459  // If the rectangle is larger than the visible area -->
460  // upper left corner
461  Size aSize( rRect.GetSize() );
462  const Size aVisSize( m_aVisArea.GetSize() );
463  if( !m_aVisArea.IsEmpty() && (
464  aSize.Width() + GetXScroll() > aVisSize.Width() ||
465  aSize.Height()+ GetYScroll() > aVisSize.Height() ))
466  {
467  Point aPt( m_aVisArea.TopLeft() );
468  aSize.setWidth( std::min( aSize.Width(), aVisSize.Width() ) );
469  aSize.setHeight( std::min( aSize.Height(),aVisSize.Height()) );
470 
471  CalcPt( &aPt, tools::Rectangle( rRect.TopLeft(), aSize ),
472  static_cast< sal_uInt16 >((aVisSize.Width() - aSize.Width()) / 2),
473  static_cast< sal_uInt16 >((aVisSize.Height()- aSize.Height())/ 2) );
474 
475  if( m_bTopCursor )
476  {
477  const long nBorder = IsDocumentBorder() ? DOCUMENTBORDER : 0;
478  aPt.setY( std::min( std::max( nBorder, rRect.Top() ),
479  m_aDocSz.Height() + nBorder -
480  m_aVisArea.GetHeight() ) );
481  }
482  aPt.AdjustY( -nDiffY );
483  m_aVisArea = aOldVisArea;
484  SetVisArea( aPt );
485  return;
486  }
487  if( !m_bCenterCursor )
488  {
489  Point aPt( m_aVisArea.TopLeft() );
490  CalcPt( &aPt, rRect, nRangeX, nRangeY );
491 
492  if( m_bTopCursor )
493  {
494  const long nBorder = IsDocumentBorder() ? DOCUMENTBORDER : 0;
495  aPt.setY( std::min( std::max( nBorder, rRect.Top() ),
496  m_aDocSz.Height() + nBorder -
497  m_aVisArea.GetHeight() ) );
498  }
499 
500  aPt.AdjustY( -nDiffY );
501  m_aVisArea = aOldVisArea;
502  SetVisArea( aPt );
503  return;
504  }
505 
506  //Center cursor
507  Point aPnt( m_aVisArea.TopLeft() );
508  // ... in Y-direction in any case
509  aPnt.AdjustY(( rRect.Top() + rRect.Bottom()
510  - m_aVisArea.Top() - m_aVisArea.Bottom() ) / 2 - nDiffY );
511  // ... in X-direction, only if the rectangle protrudes over the right or left of the VisArea.
512  if ( rRect.Right() > m_aVisArea.Right() || rRect.Left() < m_aVisArea.Left() )
513  {
514  aPnt.AdjustX(( rRect.Left() + rRect.Right()
515  - m_aVisArea.Left() - m_aVisArea.Right() ) / 2 );
516  aPnt.setX( SetHScrollMax( aPnt.X() ) );
517  const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
518  aPnt.setX( std::max( (GetLeftMargin( *this ) - lMin) + nLeftOfst, aPnt.X() ) );
519  }
520  m_aVisArea = aOldVisArea;
521  if (pCareDialog)
522  {
523  // If we want to avoid only a dialogue, we do
524  // not want to go beyond the end of the document.
525  aPnt.setY( SetVScrollMax( aPnt.Y() ) );
526  }
527  SetVisArea( aPnt );
528 }
529 
531 // Returns the value by which to be scrolled with PageUp / Down
532 
534 {
535  // in the LOK case, force the value set by the API
537  {
538  rOff = -m_nLOKPageUpDownOffset;
539  return true;
540  }
541 
542  if ( !m_aVisArea.Top() || !m_aVisArea.GetHeight() )
543  return false;
544  long nYScrl = GetYScroll() / 2;
545  rOff = -(m_aVisArea.GetHeight() - nYScrl);
546  // Do not scroll before the beginning of the document.
547  if( m_aVisArea.Top() - rOff < 0 )
548  rOff = rOff - m_aVisArea.Top();
549  else if( GetWrtShell().GetCharRect().Top() < (m_aVisArea.Top() + nYScrl))
550  rOff += nYScrl;
551 
552  return true;
553 }
554 
556 {
557  // in the LOK case, force the value set by the API
559  {
560  rOff = m_nLOKPageUpDownOffset;
561  return true;
562  }
563 
564  if ( !m_aVisArea.GetHeight() ||
566  return false;
567  long nYScrl = GetYScroll() / 2;
568  rOff = m_aVisArea.GetHeight() - nYScrl;
569  // Do not scroll past the end of the document.
570  if ( m_aVisArea.Top() + rOff > m_aDocSz.Height() )
571  rOff = m_aDocSz.Height() - m_aVisArea.Bottom();
572  else if( GetWrtShell().GetCharRect().Bottom() >
573  ( m_aVisArea.Bottom() - nYScrl ))
574  rOff -= nYScrl;
575 
576  return rOff > 0;
577 }
578 
579 // Scroll page by page
581 {
582  if (!m_aVisArea.GetHeight())
583  return false;
584 
585  Point aPos(m_aVisArea.TopLeft());
586  aPos.AdjustY( -(m_aVisArea.GetHeight() - (GetYScroll() / 2)) );
587  aPos.setY( std::max(0L, aPos.Y()) );
588  SetVisArea( aPos );
589  return true;
590 }
591 
593 {
594  if ( !m_aVisArea.GetHeight() )
595  return false;
596  Point aPos( m_aVisArea.TopLeft() );
597  aPos.AdjustY(m_aVisArea.GetHeight() - (GetYScroll() / 2) );
598  aPos.setY( SetVScrollMax( aPos.Y() ) );
599  SetVisArea( aPos );
600  return true;
601 }
602 
604 {
605  // Check for the currently visible page, do not format
606  sal_uInt16 nActPage = m_pWrtShell->GetNextPrevPageNum( false );
607 
608  if( USHRT_MAX != nActPage )
609  {
610  const Point aPt( m_aVisArea.Left(),
611  m_pWrtShell->GetPagePos( nActPage ).Y() );
612  Point aAlPt( AlignToPixel( aPt ) );
613  // If there is a difference, has been truncated --> then add one pixel,
614  // so that no residue of the previous page is visible.
615  if( aPt.Y() != aAlPt.Y() )
616  aAlPt.AdjustY(3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height() );
617  SetVisArea( aAlPt );
618  }
619 }
620 
622 {
623  // Check for the currently visible page, do not format
624  sal_uInt16 nActPage = m_pWrtShell->GetNextPrevPageNum();
625  // If the last page of the document is visible, do nothing.
626  if( USHRT_MAX != nActPage )
627  {
628  const Point aPt( m_aVisArea.Left(),
629  m_pWrtShell->GetPagePos( nActPage ).Y() );
630  Point aAlPt( AlignToPixel( aPt ) );
631  // If there is a difference, has been truncated --> then add one pixel,
632  // so that no residue of the previous page is visible.
633  if( aPt.Y() != aAlPt.Y() )
634  aAlPt.AdjustY(3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height() );
635  SetVisArea( aAlPt );
636  }
637 }
638 
639 bool SwView::PageUpCursor( bool bSelect )
640 {
641  if ( !bSelect )
642  {
643  const FrameTypeFlags eType = m_pWrtShell->GetFrameType(nullptr,true);
644  if ( eType & FrameTypeFlags::FOOTNOTE )
645  {
646  m_pWrtShell->MoveCursor();
647  m_pWrtShell->GotoFootnoteAnchor();
648  m_pWrtShell->Right(CRSR_SKIP_CHARS, false, 1, false );
649  return true;
650  }
651  }
652 
653  SwTwips lOff = 0;
654  if ( GetPageScrollUpOffset( lOff ) &&
655  (m_pWrtShell->IsCursorReadonly() ||
656  !m_pWrtShell->PageCursor( lOff, bSelect )) &&
657  PageUp() )
658  {
659  m_pWrtShell->ResetCursorStack();
660  return true;
661  }
662  return false;
663 }
664 
665 bool SwView::PageDownCursor(bool bSelect)
666 {
667  SwTwips lOff = 0;
668  if ( GetPageScrollDownOffset( lOff ) &&
669  (m_pWrtShell->IsCursorReadonly() ||
670  !m_pWrtShell->PageCursor( lOff, bSelect )) &&
671  PageDown() )
672  {
673  m_pWrtShell->ResetCursorStack();
674  return true;
675  }
676  return false;
677 }
678 
679 // Handler of the scrollbars
680 
681 IMPL_LINK( SwView, ScrollHdl, ScrollBar *, p, void )
682 {
683  SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
684  if ( GetWrtShell().ActionPend() )
685  return;
686 
687  if ( pScrollbar->GetType() == ScrollType::Drag )
688  m_pWrtShell->EnableSmooth( false );
689 
690  if(!m_pWrtShell->GetViewOptions()->getBrowseMode() &&
691  pScrollbar->GetType() == ScrollType::Drag)
692  {
693  // Here comment out again if it is not desired to scroll together:
694  // The end scrollhandler invalidate the FN_STAT_PAGE,
695  // so we don't must do it again.
696  EndScrollHdl(pScrollbar);
697 
698  if ( !m_bWheelScrollInProgress && Help::IsQuickHelpEnabled() &&
699  m_pWrtShell->GetViewOptions()->IsShowScrollBarTips())
700  {
701 
702  Point aPos( m_aVisArea.TopLeft() );
703  lcl_GetPos(this, aPos, pScrollbar, IsDocumentBorder());
704 
705  sal_uInt16 nPhNum = 1;
706  sal_uInt16 nVirtNum = 1;
707 
708  OUString sDisplay;
709  if(m_pWrtShell->GetPageNumber( aPos.Y(), false, nPhNum, nVirtNum, sDisplay ))
710  {
711  // The end scrollhandler invalidate the FN_STAT_PAGE,
712  // so we don't must do it again.
713  // if(!GetViewFrame()->GetFrame().IsInPlace())
714  // S F X_BINDINGS().Update(FN_STAT_PAGE);
715 
716  //QuickHelp:
717  if( m_pWrtShell->GetPageCnt() > 1 )
718  {
719  tools::Rectangle aRect;
720  aRect.SetLeft( pScrollbar->GetParent()->OutputToScreenPixel(
721  pScrollbar->GetPosPixel() ).X() -8 );
722  aRect.SetTop( pScrollbar->OutputToScreenPixel(
723  pScrollbar->GetPointerPosPixel() ).Y() );
724  aRect.SetRight( aRect.Left() );
725  aRect.SetBottom( aRect.Top() );
726 
727  OUString sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay ));
729  bool bSuccess = m_pWrtShell->GetContentAtPos(aPos, aCnt);
730  if (bSuccess && !aCnt.sStr.isEmpty())
731  {
732  sPageStr += " - ";
733  sal_Int32 nChunkLen = std::min<sal_Int32>(aCnt.sStr.getLength(), 80);
734  OUString sChunk = aCnt.sStr.copy(0, nChunkLen);
735  sPageStr = sChunk + sPageStr;
736  sPageStr = sPageStr.replace('\t', ' ');
737  sPageStr = sPageStr.replace(0x0a, ' ');
738  }
739  nPgNum = nPhNum;
740  }
741  }
742  }
743  }
744  else
745  EndScrollHdl(pScrollbar);
746 
747  if ( pScrollbar->GetType() == ScrollType::Drag )
748  m_pWrtShell->EnableSmooth( true );
749 }
750 
751 // Handler of the scrollbars
752 
753 IMPL_LINK( SwView, EndScrollHdl, ScrollBar *, p, void )
754 {
755  SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
756  if ( !GetWrtShell().ActionPend() )
757  {
758  if(nPgNum)
759  {
760  nPgNum = 0;
761  Help::ShowQuickHelp(pScrollbar, tools::Rectangle(), OUString());
762  }
763  Point aPos( m_aVisArea.TopLeft() );
764  bool bBorder = IsDocumentBorder();
765  lcl_GetPos(this, aPos, pScrollbar, bBorder);
766  if ( bBorder && aPos == m_aVisArea.TopLeft() )
767  UpdateScrollbars();
768  else
769  SetVisArea( aPos, false );
770 
771  GetViewFrame()->GetBindings().Update(FN_STAT_PAGE);
772  }
773 }
774 
775 // Calculates the size of the m_aVisArea in dependency of the size of
776 // EditWin on the screen.
777 
778 void SwView::CalcVisArea( const Size &rOutPixel )
779 {
780  Point aTopLeft;
781  tools::Rectangle aRect( aTopLeft, rOutPixel );
782  aTopLeft = GetEditWin().PixelToLogic( aTopLeft );
783  Point aBottomRight( GetEditWin().PixelToLogic( aRect.BottomRight() ) );
784 
785  aRect.SetLeft( aTopLeft.X() );
786  aRect.SetTop( aTopLeft.Y() );
787  aRect.SetRight( aBottomRight.X() );
788  aRect.SetBottom( aBottomRight.Y() );
789 
790  // The shifts to the right and/or below can now be incorrect
791  // (e.g. change zoom level, change view size).
792  const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
793  if ( aRect.Left() )
794  {
795  const long lWidth = GetWrtShell().GetDocSize().Width() + lBorder;
796  if ( aRect.Right() > lWidth )
797  {
798  long lDelta = aRect.Right() - lWidth;
799  aRect.AdjustLeft( -lDelta );
800  aRect.AdjustRight( -lDelta );
801  }
802  }
803  if ( aRect.Top() )
804  {
805  const long lHeight = GetWrtShell().GetDocSize().Height() + lBorder;
806  if ( aRect.Bottom() > lHeight )
807  {
808  long lDelta = aRect.Bottom() - lHeight;
809  aRect.AdjustTop( -lDelta );
810  aRect.AdjustBottom( -lDelta );
811  }
812  }
813  SetVisArea( aRect );
814  GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
815  GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); // for snapping points
816 }
817 
818 // Rearrange control elements
819 
821 {
822  bool bRightVRuler = m_pWrtShell->GetViewOptions()->IsVRulerRight();
823  if ( m_pVRuler->IsVisible() )
824  {
825  long nWidth = m_pVRuler->GetSizePixel().Width();
826  if(bRightVRuler)
827  rToFill.Right() = nWidth;
828  else
829  rToFill.Left() = nWidth;
830  }
831 
832  OSL_ENSURE(m_pHRuler, "Why is the ruler not present?");
833  if ( m_pHRuler->IsVisible() )
834  rToFill.Top() = m_pHRuler->GetSizePixel().Height();
835 
837  const long nTmp = rSet.GetScrollBarSize();
838  if( m_pVScrollbar->IsVisible(true) )
839  {
840  if(bRightVRuler)
841  rToFill.Left() = nTmp;
842  else
843  rToFill.Right() = nTmp;
844  }
845  if ( m_pHScrollbar->IsVisible(true) )
846  rToFill.Bottom() = nTmp;
847 
848  SetBorderPixel( rToFill );
849 }
850 
852  const Point &rOfst,
853  const Size &rSize,
854  const Size &rEditSz,
855  SwScrollbar& rVScrollbar,
856  SwScrollbar& rHScrollbar,
857  vcl::Window& rScrollBarBox,
858  SvxRuler* pVRuler,
859  SvxRuler* pHRuler,
860  bool bVRulerRight )
861 {
862 // ViewResizePixel is also used by Preview!!!
863 
864  const bool bHRuler = pHRuler && pHRuler->IsVisible();
865  const long nHLinSzHeight = bHRuler ?
866  pHRuler->GetSizePixel().Height() : 0;
867  const bool bVRuler = pVRuler && pVRuler->IsVisible();
868  const long nVLinSzWidth = bVRuler ?
869  pVRuler->GetSizePixel().Width() : 0;
870 
872  const long nHBSzHeight = rHScrollbar.IsVisible(true) ? nScrollBarSize : 0;
873  const long nVBSzWidth = rVScrollbar.IsVisible(true) ? nScrollBarSize : 0;
874 
875  if(pVRuler)
876  {
877  WinBits nStyle = pVRuler->GetStyle()&~WB_RIGHT_ALIGNED;
878  Point aPos( rOfst.X(), rOfst.Y()+nHLinSzHeight );
879  if(bVRulerRight)
880  {
881  aPos.AdjustX(rSize.Width() - nVLinSzWidth );
882  nStyle |= WB_RIGHT_ALIGNED;
883  }
884  Size aSize( nVLinSzWidth, rEditSz.Height() );
885  if(!aSize.Width())
886  aSize.setWidth( pVRuler->GetSizePixel().Width() );
887  pVRuler->SetStyle(nStyle);
888  pVRuler->SetPosSizePixel( aPos, aSize );
889  if(!pVRuler->IsVisible())
890  pVRuler->Resize();
891  }
892  // Ruler needs a resize, otherwise it will not work in the invisible condition
893  if(pHRuler)
894  {
895  Size aSize( rSize.Width(), nHLinSzHeight );
896  if ( nVBSzWidth && !bVRulerRight)
897  aSize.AdjustWidth( -nVBSzWidth );
898  if(!aSize.Height())
899  aSize.setHeight( pHRuler->GetSizePixel().Height() );
900  pHRuler->SetPosSizePixel( rOfst, aSize );
901  // VCL calls no resize on invisible windows
902  // but that is not a good idea for the ruler
903  if(!pHRuler->IsVisible())
904  pHRuler->Resize();
905  }
906 
907  // Arrange scrollbars and SizeBox
908  Point aScrollFillPos;
909  {
910  Point aPos( rOfst.X(),
911  rOfst.Y()+rSize.Height()-nHBSzHeight );
912  if(bVRulerRight)
913  {
914  aPos.AdjustX(nVBSzWidth );
915  }
916 
917  Size aSize( rSize.Width(), nHBSzHeight );
918  if ( nVBSzWidth )
919  aSize.AdjustWidth( -nVBSzWidth );
920  rHScrollbar.SetPosSizePixel( aPos, aSize );
921  aScrollFillPos.setY( aPos.Y() );
922  }
923  {
924  Point aPos( rOfst.X()+rSize.Width()-nVBSzWidth,
925  rOfst.Y() );
926  Size aSize( nVBSzWidth, rSize.Height() );
927  if(bVRulerRight)
928  {
929  aPos.setX( rOfst.X() );
930  if(bHRuler)
931  {
932  aPos.AdjustY(nHLinSzHeight );
933  aSize.AdjustHeight( -nHLinSzHeight );
934  }
935  }
936 
937  if ( nHBSzHeight )
938  aSize.AdjustHeight( -nHBSzHeight );
939  rVScrollbar.SetPosSizePixel( aPos, aSize );
940 
941  aPos.AdjustY(aSize.Height() );
942 
943  aScrollFillPos.setX( aPos.X() );
944  }
945 
946  rScrollBarBox.SetPosSizePixel(aScrollFillPos, Size(nVBSzWidth, nHBSzHeight));
947 }
948 
950 {
951  m_bShowAtResize = false;
952  if ( m_pWrtShell->GetViewOptions()->IsViewHRuler() )
953  m_pHRuler->Show();
954 }
955 
956 void SwView::InnerResizePixel( const Point &rOfst, const Size &rSize, bool )
957 {
958  Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
959  if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
960  {
961  SvBorder aBorder( GetBorderPixel() );
962  Size aSize( rSize );
963  aSize.AdjustWidth( -(aBorder.Left() + aBorder.Right()) );
964  aSize.AdjustHeight( -(aBorder.Top() + aBorder.Bottom()) );
965  Size aObjSizePixel = GetWindow()->LogicToPixel(aObjSize, MapMode(MapUnit::MapTwip));
966  SfxViewShell::SetZoomFactor( Fraction( aSize.Width(), aObjSizePixel.Width() ),
967  Fraction( aSize.Height(), aObjSizePixel.Height() ) );
968  }
969 
970  m_bInInnerResizePixel = true;
971  const bool bHScrollVisible = m_pHScrollbar->IsVisible(true);
972  const bool bVScrollVisible = m_pVScrollbar->IsVisible(true);
973  bool bRepeat = false;
974  do
975  {
976  Size aSz( rSize );
977  SvBorder aBorder;
978  CalcAndSetBorderPixel( aBorder );
979  if ( GetViewFrame()->GetFrame().IsInPlace() )
980  {
981  Size aViewSize( aSz );
982  Point aViewPos( rOfst );
983  aViewSize.AdjustHeight( -(aBorder.Top() + aBorder.Bottom()) );
984  aViewSize.AdjustWidth( -(aBorder.Left() + aBorder.Right()) );
985  aViewPos.AdjustX(aBorder.Left() );
986  aViewPos.AdjustY(aBorder.Top() );
987  GetEditWin().SetPosSizePixel( aViewPos, aViewSize );
988  }
989  else
990  {
991  aSz.AdjustHeight(aBorder.Top() + aBorder.Bottom() );
992  aSz.AdjustWidth(aBorder.Left() + aBorder.Right() );
993  }
994 
995  Size aEditSz( GetEditWin().GetOutputSizePixel() );
996  ViewResizePixel( GetEditWin(), rOfst, aSz, aEditSz, *m_pVScrollbar,
998  m_pWrtShell->GetViewOptions()->IsVRulerRight());
999  if ( m_bShowAtResize )
1000  ShowAtResize();
1001 
1002  if( m_pHRuler->IsVisible() || m_pVRuler->IsVisible() )
1003  {
1004  const Fraction& rFrac = GetEditWin().GetMapMode().GetScaleX();
1005  long nZoom = 100;
1006  if (rFrac.IsValid())
1007  nZoom = long(rFrac * 100);
1008 
1009  const Fraction aFrac( nZoom, 100 );
1010  m_pVRuler->SetZoom( aFrac );
1011  m_pHRuler->SetZoom( aFrac );
1012  InvalidateRulerPos(); // Invalidate content.
1013  }
1014  // Reset the cursor stack because the cursor positions for PageUp/Down
1015  // no longer fit the currently visible area.
1016  m_pWrtShell->ResetCursorStack();
1017 
1018  // EditWin never set!
1019 
1020  // Set VisArea, but do not call the SetVisArea of the Docshell there!
1021  bProtectDocShellVisArea = true;
1022  CalcVisArea( aEditSz );
1023  // Visibility changes of the automatic horizontal scrollbar
1024  // require to repeat the ViewResizePixel() call - but only once!
1025  if(bRepeat)
1026  bRepeat = false;
1027  else if(bHScrollVisible != m_pHScrollbar->IsVisible(true) ||
1028  bVScrollVisible != m_pVScrollbar->IsVisible(true))
1029  bRepeat = true;
1030  }while( bRepeat );
1031  bProtectDocShellVisArea = false;
1032  m_bInInnerResizePixel = false;
1033 }
1034 
1035 void SwView::OuterResizePixel( const Point &rOfst, const Size &rSize )
1036 {
1037  // #i16909# return, if no size (caused by minimize window).
1038  if ( m_bInOuterResizePixel || ( !rSize.Width() && !rSize.Height() ) )
1039  return;
1040  m_bInOuterResizePixel = true;
1041 
1042  // Determine whether scroll bars may be displayed.
1043  bool bShowH = true,
1044  bShowV = true,
1045  bAuto = true,
1046  bHAuto = true;
1047 
1048  const SwViewOption *pVOpt = m_pWrtShell->GetViewOptions();
1049  if ( !pVOpt->IsReadonly() || pVOpt->IsStarOneSetting() )
1050  {
1051  bShowH = pVOpt->IsViewHScrollBar();
1052  bShowV = pVOpt->IsViewVScrollBar();
1053  }
1054 
1055  if (!m_bHScrollbarEnabled)
1056  {
1057  bHAuto = bShowH = false;
1058  }
1059  if (!m_bVScrollbarEnabled)
1060  {
1061  bAuto = bShowV = false;
1062  }
1063 
1064  SwDocShell* pDocSh = GetDocShell();
1065  bool bIsPreview = pDocSh->IsPreview();
1066  if( bIsPreview )
1067  {
1068  bShowH = bShowV = bHAuto = bAuto = false;
1069  }
1070  if(m_pHScrollbar->IsVisible(false) != bShowH && !bHAuto)
1071  ShowHScrollbar(bShowH);
1072  m_pHScrollbar->SetAuto( bHAuto );
1073  if(m_pVScrollbar->IsVisible(false) != bShowV && !bAuto)
1074  ShowVScrollbar(bShowV);
1075  m_pVScrollbar->SetAuto(bAuto);
1076 
1077  SET_CURR_SHELL( m_pWrtShell.get() );
1078  bool bRepeat = false;
1079  long nCnt = 0;
1080 
1081  bool bUnLockView = !m_pWrtShell->IsViewLocked();
1082  m_pWrtShell->LockView( true );
1083  m_pWrtShell->LockPaint();
1084 
1085  do {
1086  ++nCnt;
1087  const bool bScroll1 = m_pVScrollbar->IsVisible(true);
1088  const bool bScroll2 = m_pHScrollbar->IsVisible(true);
1089  SvBorder aBorder;
1090  CalcAndSetBorderPixel( aBorder );
1091  const Size aEditSz( GetEditWin().GetOutputSizePixel() );
1092  ViewResizePixel( GetEditWin(), rOfst, rSize, aEditSz, *m_pVScrollbar,
1094  m_pWrtShell->GetViewOptions()->IsVRulerRight() );
1095  if ( m_bShowAtResize )
1096  ShowAtResize();
1097 
1098  if( m_pHRuler->IsVisible() || m_pVRuler->IsVisible() )
1099  InvalidateRulerPos(); // Invalidate content.
1100 
1101  // Reset the cursor stack because the cursor positions for PageUp/Down
1102  // no longer fit the currently visible area.
1103  m_pWrtShell->ResetCursorStack();
1104 
1105  OSL_ENSURE( !GetEditWin().IsVisible() ||
1106  (( aEditSz.Width() > 0 && aEditSz.Height() > 0 )
1107  || !m_aVisArea.IsEmpty()), "Small world, isn't it?" );
1108 
1109  // Never set EditWin!
1110 
1111  // Of course the VisArea must also be set.
1112  // Now is the right time to re-calculate the zoom if it is not a simple factor.
1113  m_pWrtShell->StartAction();
1114  CalcVisArea( aEditSz );
1115 
1116  //Thus also in the outplace editing the page width will be adjusted immediately.
1117  //TODO/LATER: is that still necessary?!
1118  /*
1119  if ( pDocSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
1120  pDocSh->SetVisArea(
1121  pDocSh->SfxInPlaceObject::GetVisArea() );*/
1122  if ( m_pWrtShell->GetViewOptions()->GetZoomType() != SvxZoomType::PERCENT &&
1123  !m_pWrtShell->GetViewOptions()->getBrowseMode() )
1124  SetZoom_( aEditSz, m_pWrtShell->GetViewOptions()->GetZoomType(), 100, true );
1125  m_pWrtShell->EndAction();
1126 
1127  bRepeat = bScroll1 != m_pVScrollbar->IsVisible(true);
1128  if ( !bRepeat )
1129  bRepeat = bScroll2 != m_pHScrollbar->IsVisible(true);
1130 
1131  // Do no infinite loops.
1132  // If possible stop when the (auto-) scroll bars are visible.
1133  if ( bRepeat &&
1134  ( nCnt > 10 || ( nCnt > 3 && bHAuto && bAuto ) )
1135  )
1136  {
1137  bRepeat = false;
1138  }
1139 
1140  } while ( bRepeat );
1141 
1142  m_pWrtShell->UnlockPaint();
1143  if( bUnLockView )
1144  m_pWrtShell->LockView( false );
1145 
1146  m_bInOuterResizePixel = false;
1147 
1148  if ( m_pPostItMgr )
1149  {
1150  m_pPostItMgr->CalcRects();
1151  m_pPostItMgr->LayoutPostIts();
1152  }
1153 }
1154 
1155 void SwView::SetZoomFactor( const Fraction &rX, const Fraction &rY )
1156 {
1157  const Fraction &rFrac = rX < rY ? rX : rY;
1158  SetZoom( SvxZoomType::PERCENT, static_cast<short>(long(rFrac * Fraction( 100, 1 ))) );
1159 
1160  // To minimize rounding errors we also adjust the odd values
1161  // of the base class if necessary.
1162  SfxViewShell::SetZoomFactor( rX, rY );
1163 }
1164 
1166 {
1167  bool bRet = false;
1168  if ( !m_aVisArea.IsEmpty() )
1169  {
1170  const bool bBorder = IsDocumentBorder();
1171  tools::Rectangle aTmpRect( m_aVisArea );
1172  if ( bBorder )
1173  {
1175  aPt = AlignToPixel( aPt );
1176  aTmpRect.Move( -aPt.X(), -aPt.Y() );
1177  }
1178 
1179  Size aTmpSz( m_aDocSz );
1180  const long lOfst = bBorder ? 0 : DOCUMENTBORDER * 2;
1181  aTmpSz.AdjustWidth(lOfst ); aTmpSz.AdjustHeight(lOfst );
1182 
1183  {
1184  const bool bVScrollVisible = m_pVScrollbar->IsVisible(true);
1185  m_pVScrollbar->DocSzChgd( aTmpSz );
1186  m_pVScrollbar->ViewPortChgd( aTmpRect );
1187  if ( bVScrollVisible != m_pVScrollbar->IsVisible(true) )
1188  bRet = true;
1189  }
1190  {
1191  const bool bHScrollVisible = m_pHScrollbar->IsVisible(true);
1192  m_pHScrollbar->DocSzChgd( aTmpSz );
1193  m_pHScrollbar->ViewPortChgd( aTmpRect );
1194  if ( bHScrollVisible != m_pHScrollbar->IsVisible(true) )
1195  bRet = true;
1197  }
1198  }
1199  return bRet;
1200 }
1201 
1203 {
1204  if ( GetWrtShell().IsInSelect() )
1205  GetWrtShell().EndSelect();
1207 }
1208 
1210 {
1211  bool bOk = false;
1212  const CommandWheelData* pWData = rCEvt.GetWheelData();
1213  if (pWData && CommandWheelMode::ZOOM == pWData->GetMode())
1214  {
1215  long nFact = m_pWrtShell->GetViewOptions()->GetZoom();
1216  if( 0L > pWData->GetDelta() )
1217  nFact = std::max( long(20), basegfx::zoomtools::zoomOut( nFact ));
1218  else
1219  nFact = std::min( long(600), basegfx::zoomtools::zoomIn( nFact ));
1220 
1221  SetZoom( SvxZoomType::PERCENT, nFact );
1222  bOk = true;
1223  }
1224  else
1225  {
1226  if (pWData && pWData->GetMode()==CommandWheelMode::SCROLL)
1227  {
1228  // This influences whether quick help is shown
1230  }
1231 
1232  if (pWData && (CommandWheelMode::SCROLL==pWData->GetMode()) &&
1234  {
1235  if (pWData->GetDelta()<0)
1236  PhyPageDown();
1237  else
1238  PhyPageUp();
1239  bOk = true;
1240  }
1241  else
1243 
1244  // Restore default state for case when scroll command comes from dragging scrollbar handle
1246  }
1247  return bOk;
1248 }
1249 
1250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Point TopLeft() const
SfxViewFrame * GetViewFrame() const
const Fraction & GetScaleX() const
long Width() const
virtual bool get_extents_relative_to(Widget &rRelative, int &x, int &y, int &width, int &height)=0
long GetWidth() const
Point GetPointerPosPixel()
void ViewResizePixel(const vcl::RenderContext &rRef, const Point &rOfst, const Size &rSize, const Size &rEditSz, SwScrollbar &rVScrollbar, SwScrollbar &rHScrollbar, vcl::Window &rScrollBarBox, SvxRuler *pVRuler, SvxRuler *pHRuler, bool bVRulerRight)
Definition: viewport.cxx:851
long GetHeight() const
SAL_DLLPRIVATE void PhyPageUp()
Definition: viewport.cxx:603
SAL_DLLPRIVATE Point AlignToPixel(const Point &rPt) const
Definition: viewport.cxx:158
SfxViewFrame * GetFrame() const
long AdjustWidth(long n)
long zoomIn(long nCurrent)
long AdjustX(long nHorzMove)
std::unique_ptr< SwPostItMgr > m_pPostItMgr
Definition: view.hxx:210
SAL_DLLPRIVATE bool PageUp()
Definition: viewport.cxx:580
std::unique_ptr< SwWrtShell > m_pWrtShell
Definition: view.hxx:183
long Height() const
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:92
VclPtr< SvxRuler > m_pHRuler
Definition: view.hxx:200
long AdjustLeft(long nHorzMoveDelta)
Point AbsoluteScreenToOutputPixel(const Point &rPos) const
const StyleSettings & GetStyleSettings() const
long GetThumbPos() const
Size m_aDocSz
Definition: view.hxx:179
const MapMode & GetMapMode() const
long SwTwips
Definition: swtypes.hxx:49
SwEditWin & GetEditWin()
Definition: view.hxx:403
void Pos(const Point &rNew)
Definition: swrect.hxx:167
SAL_DLLPRIVATE bool GetPageScrollDownOffset(SwTwips &rOff) const
Definition: viewport.cxx:555
#define FN_STAT_PAGE
Definition: cmdid.h:804
const CommandWheelData * GetWheelData() const
void Invalidate(sal_uInt16 nId)
long & Left()
SAL_DLLPRIVATE bool PageUpCursor(bool bSelect)
Definition: viewport.cxx:639
float x
bool HandleScrollCommand(const CommandEvent &rCmd, ScrollBar *pHScrl, ScrollBar *pVScrl)
long AdjustHeight(long n)
long & Bottom()
void Scroll(const tools::Rectangle &rRect, sal_uInt16 nRangeX=USHRT_MAX, sal_uInt16 nRangeY=USHRT_MAX)
Definition: viewport.cxx:401
SAL_DLLPRIVATE bool PageDownCursor(bool bSelect)
Definition: viewport.cxx:665
void ViewPortChgd(const tools::Rectangle &rRectangle)
Definition: scroll.cxx:55
void SetBorderPixel(const SvBorder &rBorder)
void SetVisArea(const tools::Rectangle &, bool bUpdateScrollbar=true)
Definition: viewport.cxx:209
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
long AdjustBottom(long nVertMoveDelta)
void Move(long nHorzMoveDelta, long nVertMoveDelta)
SvxZoomType GetZoomType() const
Definition: viewopt.hxx:500
bool IsEmpty() const
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
const long nScrollX
Definition: view.hxx:79
sal_Int64 WinBits
bool IsReadonly() const
Definition: viewopt.hxx:417
long Right() const
bool m_bVScrollbarEnabled
Definition: view.hxx:195
bool IsVisible(bool bReal) const
Definition: scroll.hxx:39
void setX(long nX)
#define X
bool bDocSzUpdated
Definition: view.cxx:133
SfxFrame & GetFrame() const
bool IsHoriScroll() const
Definition: scroll.hxx:46
OUString sStr
Definition: crsrsh.hxx:107
bool IsViewVScrollBar() const
Definition: viewopt.hxx:473
long Top() const
SAL_DLLPRIVATE void SetZoom_(const Size &rEditSz, SvxZoomType eZoomType, short nFactor, bool bViewOnly)
Definition: viewmdi.cxx:93
void setY(long nY)
void DocSzChgd(const Size &rNewSize)
Definition: viewport.cxx:165
VclPtr< SwEditWin > m_pEditWin
Definition: view.hxx:182
static weld::Window * GetCareDialog(SwViewShell const &rVSh)
Definition: viewsh.hxx:441
float y
double GetScrollLines() const
Point BottomRight() const
void EndSelect()
Definition: select.cxx:426
SAL_DLLPRIVATE void PhyPageDown()
Definition: viewport.cxx:621
virtual SAL_DLLPRIVATE void Move() override
Definition: viewport.cxx:1202
ScrollType GetType() const
Rect of current PrtArea of page.
void SetTop(long v)
long GetXScroll() const
Definition: view.hxx:677
const SwRect & VisArea() const
Definition: viewsh.cxx:570
bool m_bTopCursor
Definition: view.hxx:229
long AdjustY(long nVertMove)
VclPtr< vcl::Window > m_pScrollFill
Definition: view.hxx:197
void setY(long y)
SAL_DLLPRIVATE bool GetPageScrollUpOffset(SwTwips &rOff) const
Scroll page by page.
Definition: viewport.cxx:533
const long nLeftOfst
Definition: view.hxx:78
void SetAuto(bool bSet)
Definition: scroll.cxx:92
static bool IsQuickHelpEnabled()
void SetSize(const Size &rSize)
SfxBindings & GetBindings()
CommandWheelMode GetMode() const
Size GetDocSize() const
Definition: viewsh.cxx:2099
bool IsPreview() const
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
void SetRight(long v)
static long GetLeftMargin(SwView const &rView)
Definition: viewport.cxx:77
SwTwips m_nLOKPageUpDownOffset
LibreOfficeKit has to force the page size for PgUp/PgDown functionality based on the user's view...
Definition: view.hxx:254
SAL_DLLPRIVATE void ShowAtResize()
Definition: viewport.cxx:949
SAL_DLLPRIVATE void CalcAndSetBorderPixel(SvBorder &rToFill)
Definition: viewport.cxx:820
long Bottom() const
long const nBorder
void ShowVScrollbar(bool bShow)
Definition: viewmdi.cxx:679
#define SET_CURR_SHELL(shell)
Definition: swtypes.hxx:101
bool IsInside(const Point &rPOINT) const
static bool bProtectDocShellVisArea
Definition: viewport.cxx:61
const AllSettings & GetSettings() const
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override
Definition: viewport.cxx:956
IMPL_LINK(SwView, ScrollHdl, ScrollBar *, p, void)
Definition: viewport.cxx:681
const tools::Rectangle & GetVisArea() const
SAL_DLLPRIVATE bool PageDown()
Definition: viewport.cxx:592
DocumentType const eType
bool m_bWheelScrollInProgress
Definition: view.hxx:227
#define ASPECT_CONTENT
#define COMMAND_WHEEL_PAGESCROLL
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
vcl::Window * GetParent() const
bool IsFrameView() const
Definition: viewsh.hxx:493
VclPtr< SvxRuler > m_pVRuler
Definition: view.hxx:200
long X() const
static sal_uInt16 nPgNum
Definition: viewport.cxx:63
SAL_DLLPRIVATE void CalcVisArea(const Size &rPixelSz)
Definition: viewport.cxx:778
Size GetSize() const
#define Y
SwDocShell * GetDocShell()
Definition: view.cxx:1115
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override
Definition: viewport.cxx:1035
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
long SetVScrollMax(long lMax)
Definition: viewport.cxx:151
void ShowHScrollbar(bool bShow)
Definition: viewmdi.cxx:667
constexpr sal_uInt16 nScrollBarSize
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
static void lcl_GetPos(SwView const *pView, Point &rPos, SwScrollbar const *pScrollbar, bool bBorder)
Definition: viewport.cxx:86
const Size & GetDocSz() const
Definition: view.hxx:440
void Left(const long nLeft)
Definition: swrect.hxx:193
void SetZoom(SvxZoomType eZoomType, short nFactor=100, bool bViewOnly=false)
Definition: viewmdi.cxx:82
tools::Rectangle m_aVisArea
Definition: view.hxx:180
VclPtr< SwScrollbar > m_pVScrollbar
Definition: view.hxx:191
bool m_bInOuterResizePixel
Definition: view.hxx:229
long AdjustRight(long nHorzMoveDelta)
weld::Window * GetFrameWeld() const
long GetDelta() const
long & Right()
bool IsInPlace() const
bool m_bShowAtResize
Definition: view.hxx:229
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:426
long zoomOut(long nCurrent)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
bool IsStarOneSetting() const
Definition: viewopt.hxx:586
#define WB_RIGHT_ALIGNED
const SvBorder & GetBorderPixel() const
SAL_DLLPRIVATE void CalcPt(Point *pPt, const tools::Rectangle &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY)
Calculate the visible range.
Definition: viewport.cxx:350
void SetBottom(long v)
VclPtr< SwScrollbar > m_pHScrollbar
Definition: view.hxx:191
long AdjustTop(long nVertMoveDelta)
long SetHScrollMax(long lMax)
Definition: viewport.cxx:141
bool IsDocumentBorder()
Definition: viewport.cxx:65
vcl::Window * GetWindow() const
void InvalidateRulerPos()
Definition: viewport.cxx:118
long Left() const
const tools::Rectangle & GetVisArea() const
Definition: view.hxx:413
void DocSzChgd(const Size &rNewSize)
Definition: scroll.cxx:44
virtual SfxObjectShell * GetObjectShell() override
long GetYScroll() const
Definition: view.hxx:682
bool m_bCenterCursor
Definition: view.hxx:229
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
void VisAreaChanged()
void SetLeft(long v)
virtual void SetZoomFactor(const Fraction &rX, const Fraction &) override
Definition: viewport.cxx:1155
SAL_DLLPRIVATE bool UpdateScrollbars()
Definition: viewport.cxx:1165
bool HandleWheelCommands(const CommandEvent &)
Definition: viewport.cxx:1209
bool m_bInInnerResizePixel
Definition: view.hxx:229
Point OutputToScreenPixel(const Point &rPos) const
SvxZoomType
bool IsValid() const
virtual void Move()
long GetScrollBarSize() const
void ForceUpdate()
#define DOCUMENTBORDER
Definition: swtypes.hxx:82
bool IsViewHScrollBar() const
Definition: viewopt.hxx:481
bool m_bHScrollbarEnabled
Definition: view.hxx:194
void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: scroll.cxx:83
void setWidth(long nWidth)
long & Top()
Definition: view.hxx:146
long Y() const
virtual tools::Rectangle GetVisArea(sal_uInt16 nAspect) const
virtual void SetZoomFactor(const Fraction &rZoomX, const Fraction &rZoomY)
bool IsScroll(const tools::Rectangle &rRect) const
Definition: viewport.cxx:396
void CheckVisArea()
Definition: viewport.cxx:324
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)