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