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