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
47
48// The SetVisArea of the DocShell must not be called from InnerResizePixel.
49// But our adjustments must take place.
50static bool bProtectDocShellVisArea = false;
51
52static 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
66static tools::Long GetLeftMargin( SwView const &rView )
67{
70 return eType == SvxZoomType::PERCENT ? lRet + DOCUMENTBORDER :
71 eType == SvxZoomType::PAGEWIDTH || eType == SvxZoomType::PAGEWIDTH_NOBORDER ? 0 :
73}
74
75static void lcl_GetPos(SwView const * pView,
76 Point& rPos,
77 const weld::Scrollbar& rScrollbar,
78 bool bHori,
79 bool bBorder)
80{
81 SwWrtShell &rSh = pView->GetWrtShell();
82 const Size aDocSz( rSh.GetDocSize() );
83
84 const tools::Long lBorder = bBorder ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
85
86 const tools::Long lPos = rScrollbar.adjustment_get_value() + (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
121
122 assert(m_pHRuler && "Why is the ruler not there?");
123 m_pHRuler->ForceUpdate();
124 m_pVRuler->ForceUpdate();
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{
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{
143 tools::Long lSize = GetDocSz().Height() + lBorder - m_aVisArea.GetHeight();
144 return std::clamp( lSize, tools::Long(0), lMax ); // see horizontal
145}
146
148{
149 return GetEditWin().PixelToLogic( GetEditWin().LogicToPixel( rPt ) );
150}
151
152// Document size has changed.
153
154void 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
198void 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
287void 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 = 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 (GetWrtShell().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
342void 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
388bool SwView::IsScroll( const tools::Rectangle &rRect ) const
389{
390 return m_bCenterCursor || m_bTopCursor || !m_aVisArea.Contains(rRect);
391}
392
393void 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.Contains( 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.Contains( 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() ),
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() ),
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 {
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 {
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
631bool SwView::PageUpCursor( bool bSelect )
632{
633 if ( !bSelect )
634 {
635 const FrameTypeFlags eType = m_pWrtShell->GetFrameType(nullptr,true);
637 {
638 m_pWrtShell->MoveCursor();
639 m_pWrtShell->GotoFootnoteAnchor();
640 m_pWrtShell->Right(SwCursorSkipMode::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
657bool 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
671static void HideQuickHelp(vcl::Window* pParent) { Help::ShowQuickHelp(pParent, {}, {}); }
672
673// Handler of the scrollbars
674IMPL_LINK(SwView, VertScrollHdl, weld::Scrollbar&, rScrollbar, void)
675{
676 if ( GetWrtShell().ActionPend() )
677 return;
678
679 if (rScrollbar.get_scroll_type() == ScrollType::Drag)
680 m_pWrtShell->EnableSmooth( false );
681
682 bool bHidePending = nPgNum != 0;
683 nPgNum = 0; // avoid flicker from hiding then showing help window again
684 EndScrollHdl(rScrollbar, false);
685
686 if (!m_pWrtShell->GetViewOptions()->getBrowseMode() &&
687 rScrollbar.get_scroll_type() == ScrollType::Drag)
688 {
689 if ( !m_bWheelScrollInProgress && Help::IsQuickHelpEnabled() &&
690 m_pWrtShell->GetViewOptions()->IsShowScrollBarTips())
691 {
692
693 Point aPos( m_aVisArea.TopLeft() );
694 lcl_GetPos(this, aPos, rScrollbar, false, IsDocumentBorder());
695
696 sal_uInt16 nPhNum = 1;
697 sal_uInt16 nVirtNum = 1;
698
699 OUString sDisplay;
700 if(m_pWrtShell->GetPageNumber( aPos.Y(), false, nPhNum, nVirtNum, sDisplay ))
701 {
702 //QuickHelp:
703 if( m_pWrtShell->GetPageCnt() > 1 )
704 {
705 tools::Rectangle aRect;
706 aRect.SetLeft( m_pVScrollbar->GetParent()->OutputToScreenPixel(
707 m_pVScrollbar->GetPosPixel() ).X() -8 );
708 aRect.SetTop( m_pVScrollbar->OutputToScreenPixel(
709 m_pVScrollbar->GetPointerPosPixel() ).Y() );
710 aRect.SetRight( aRect.Left() );
711 aRect.SetBottom( aRect.Top() );
712
713 OUString sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay ));
715 bool bSuccess = m_pWrtShell->GetContentAtPos(aPos, aCnt);
716 if (bSuccess && !aCnt.sStr.isEmpty())
717 {
718 sal_Int32 nChunkLen = std::min<sal_Int32>(aCnt.sStr.getLength(), 80);
719 std::u16string_view sChunk = aCnt.sStr.subView(0, nChunkLen);
720 sPageStr = sPageStr + " - " + sChunk;
721 sPageStr = sPageStr.replace('\t', ' ').replace(0x0a, ' ');
722 }
723
724 Help::ShowQuickHelp(m_pVScrollbar, aRect, sPageStr,
725 QuickHelpFlags::Right|QuickHelpFlags::VCenter);
726 bHidePending = false;
727 nPgNum = nPhNum;
728 }
729 }
730 }
731 }
732
733 if (bHidePending)
734 HideQuickHelp(m_pVScrollbar);
735
736 if (rScrollbar.get_scroll_type() == ScrollType::Drag)
737 m_pWrtShell->EnableSmooth( true );
738}
739
740// Handler of the scrollbars
741void SwView::EndScrollHdl(weld::Scrollbar& rScrollbar, bool bHorizontal)
742{
743 if ( GetWrtShell().ActionPend() )
744 return;
745
746 if(nPgNum)
747 {
748 nPgNum = 0;
750 }
751 Point aPos( m_aVisArea.TopLeft() );
752 bool bBorder = IsDocumentBorder();
753 lcl_GetPos(this, aPos, rScrollbar, bHorizontal, bBorder);
754 if ( bBorder && aPos == m_aVisArea.TopLeft() )
756 else
757 SetVisArea( aPos, false );
758
760}
761
762IMPL_LINK(SwView, HoriScrollHdl, weld::Scrollbar&, rScrollBar, void)
763{
764 EndScrollHdl(rScrollBar, true);
765}
766
767// Calculates the size of the m_aVisArea in dependency of the size of
768// EditWin on the screen.
769
770void SwView::CalcVisArea( const Size &rOutPixel )
771{
772 Point aTopLeft;
773 tools::Rectangle aRect( aTopLeft, rOutPixel );
774 aRect = GetEditWin().PixelToLogic(aRect);
775
776 // The shifts to the right and/or below can now be incorrect
777 // (e.g. change zoom level, change view size).
779 if ( aRect.Left() )
780 {
781 const tools::Long lWidth = GetWrtShell().GetDocSize().Width() + lBorder;
782 if ( aRect.Right() > lWidth )
783 {
784 tools::Long lDelta = aRect.Right() - lWidth;
785 aRect.AdjustLeft( -lDelta );
786 aRect.AdjustRight( -lDelta );
787 }
788 }
789 if ( aRect.Top() )
790 {
791 const tools::Long lHeight = GetWrtShell().GetDocSize().Height() + lBorder;
792 if ( aRect.Bottom() > lHeight )
793 {
794 tools::Long lDelta = aRect.Bottom() - lHeight;
795 aRect.AdjustTop( -lDelta );
796 aRect.AdjustBottom( -lDelta );
797 }
798 }
799 SetVisArea( aRect );
800 GetViewFrame().GetBindings().Invalidate( SID_ATTR_ZOOM );
801 GetViewFrame().GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); // for snapping points
802}
803
804// Rearrange control elements
805
807{
808 bool bRightVRuler = m_pWrtShell->GetViewOptions()->IsVRulerRight();
809 if ( m_pVRuler->IsVisible() )
810 {
811 tools::Long nWidth = m_pVRuler->GetSizePixel().Width();
812 if(bRightVRuler)
813 rToFill.Right() = nWidth;
814 else
815 rToFill.Left() = nWidth;
816 }
817
818 OSL_ENSURE(m_pHRuler, "Why is the ruler not present?");
819 if ( m_pHRuler->IsVisible() )
820 rToFill.Top() = m_pHRuler->GetSizePixel().Height();
821
823 const tools::Long nTmp = rSet.GetScrollBarSize();
824 if( m_pVScrollbar->IsScrollbarVisible(true) )
825 {
826 if(bRightVRuler)
827 rToFill.Left() = nTmp;
828 else
829 rToFill.Right() = nTmp;
830 }
831 if ( m_pHScrollbar->IsScrollbarVisible(true) )
832 rToFill.Bottom() = nTmp;
833
834 SetBorderPixel( rToFill );
835}
836
838 const Point &rOfst,
839 const Size &rSize,
840 const Size &rEditSz,
841 SwScrollbar& rVScrollbar,
842 SwScrollbar& rHScrollbar,
843 SvxRuler* pVRuler,
844 SvxRuler* pHRuler,
845 bool bVRulerRight )
846{
847// ViewResizePixel is also used by Preview!!!
848
849 const bool bHRuler = pHRuler && pHRuler->IsVisible();
850 const tools::Long nHLinSzHeight = bHRuler ?
851 pHRuler->GetSizePixel().Height() : 0;
852 const bool bVRuler = pVRuler && pVRuler->IsVisible();
853 const tools::Long nVLinSzWidth = bVRuler ?
854 pVRuler->GetSizePixel().Width() : 0;
855
856 const tools::Long nScrollBarSize = rRef.GetSettings().GetStyleSettings().GetScrollBarSize();
857 const tools::Long nHBSzHeight = rHScrollbar.IsScrollbarVisible(true) ? nScrollBarSize : 0;
858 const tools::Long nVBSzWidth = rVScrollbar.IsScrollbarVisible(true) ? nScrollBarSize : 0;
859
860 if(pVRuler)
861 {
862 WinBits nStyle = pVRuler->GetStyle()&~WB_RIGHT_ALIGNED;
863 Point aPos( rOfst.X(), rOfst.Y()+nHLinSzHeight );
864 if(bVRulerRight)
865 {
866 aPos.AdjustX(rSize.Width() - nVLinSzWidth );
867 nStyle |= WB_RIGHT_ALIGNED;
868 }
869 Size aSize( nVLinSzWidth, rEditSz.Height() );
870 if(!aSize.Width())
871 aSize.setWidth( pVRuler->GetSizePixel().Width() );
872 pVRuler->SetStyle(nStyle);
873 pVRuler->SetPosSizePixel( aPos, aSize );
874 if(!pVRuler->IsVisible())
875 pVRuler->Resize();
876 }
877 // Ruler needs a resize, otherwise it will not work in the invisible condition
878 if(pHRuler)
879 {
880 Size aSize( rSize.Width(), nHLinSzHeight );
881 if ( nVBSzWidth && !bVRulerRight)
882 aSize.AdjustWidth( -nVBSzWidth );
883 if(!aSize.Height())
884 aSize.setHeight( pHRuler->GetSizePixel().Height() );
885 pHRuler->SetPosSizePixel( rOfst, aSize );
886 // VCL calls no resize on invisible windows
887 // but that is not a good idea for the ruler
888 if(!pHRuler->IsVisible())
889 pHRuler->Resize();
890 }
891
892 // Arrange scrollbars and SizeBox
893 Point aScrollFillPos;
894 {
895 Point aPos( rOfst.X(),
896 rOfst.Y()+rSize.Height()-nHBSzHeight );
897 if(bVRulerRight)
898 {
899 aPos.AdjustX(nVBSzWidth );
900 }
901
902 Size aSize( rSize.Width(), nHBSzHeight );
903 if ( nVBSzWidth )
904 aSize.AdjustWidth( -nVBSzWidth );
905 rHScrollbar.SetPosSizePixel( aPos, aSize );
906 aScrollFillPos.setY( aPos.Y() );
907 }
908 {
909 Point aPos( rOfst.X()+rSize.Width()-nVBSzWidth,
910 rOfst.Y() );
911 Size aSize( nVBSzWidth, rSize.Height() );
912 if(bVRulerRight)
913 {
914 aPos.setX( rOfst.X() );
915 if(bHRuler)
916 {
917 aPos.AdjustY(nHLinSzHeight );
918 aSize.AdjustHeight( -nHLinSzHeight );
919 }
920 }
921
922 if ( nHBSzHeight )
923 aSize.AdjustHeight( -nHBSzHeight );
924 rVScrollbar.SetPosSizePixel( aPos, aSize );
925
926 aPos.AdjustY(aSize.Height() );
927
928 aScrollFillPos.setX( aPos.X() );
929 }
930}
931
933{
934 m_bShowAtResize = false;
935 if ( m_pWrtShell->GetViewOptions()->IsViewHRuler() )
936 m_pHRuler->Show();
937}
938
939void SwView::InnerResizePixel( const Point &rOfst, const Size &rSize, bool )
940{
941 Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
942 if ( !aObjSize.IsEmpty() )
943 {
944 SvBorder aBorder( GetBorderPixel() );
945 Size aSize( rSize );
946 aSize.AdjustWidth( -(aBorder.Left() + aBorder.Right()) );
947 aSize.AdjustHeight( -(aBorder.Top() + aBorder.Bottom()) );
948 Size aObjSizePixel = GetWindow()->LogicToPixel(aObjSize, MapMode(MapUnit::MapTwip));
949 SfxViewShell::SetZoomFactor( Fraction( aSize.Width(), aObjSizePixel.Width() ),
950 Fraction( aSize.Height(), aObjSizePixel.Height() ) );
951 }
952
954 const bool bHScrollVisible = m_pHScrollbar->IsScrollbarVisible(true);
955 const bool bVScrollVisible = m_pVScrollbar->IsScrollbarVisible(true);
956 bool bRepeat = false;
957 do
958 {
959 Size aSz( rSize );
960 SvBorder aBorder;
961 CalcAndSetBorderPixel( aBorder );
962 if ( GetViewFrame().GetFrame().IsInPlace() )
963 {
964 Size aViewSize( aSz );
965 Point aViewPos( rOfst );
966 aViewSize.AdjustHeight( -(aBorder.Top() + aBorder.Bottom()) );
967 aViewSize.AdjustWidth( -(aBorder.Left() + aBorder.Right()) );
968 aViewPos.AdjustX(aBorder.Left() );
969 aViewPos.AdjustY(aBorder.Top() );
970 GetEditWin().SetPosSizePixel( aViewPos, aViewSize );
971 }
972 else
973 {
974 aSz.AdjustHeight(aBorder.Top() + aBorder.Bottom() );
975 aSz.AdjustWidth(aBorder.Left() + aBorder.Right() );
976 }
977
978 Size aEditSz( GetEditWin().GetOutputSizePixel() );
979 ViewResizePixel( *GetEditWin().GetOutDev(), rOfst, aSz, aEditSz, *m_pVScrollbar,
981 m_pWrtShell->GetViewOptions()->IsVRulerRight());
982 if ( m_bShowAtResize )
983 ShowAtResize();
984
985 if( m_pHRuler->IsVisible() || m_pVRuler->IsVisible() )
986 {
987 const Fraction& rFrac = GetEditWin().GetMapMode().GetScaleX();
988 tools::Long nZoom = 100;
989 if (rFrac.IsValid())
990 nZoom = tools::Long(rFrac * 100);
991
992 const Fraction aFrac( nZoom, 100 );
993 m_pVRuler->SetZoom( aFrac );
994 m_pHRuler->SetZoom( aFrac );
995 InvalidateRulerPos(); // Invalidate content.
996 }
997 // Reset the cursor stack because the cursor positions for PageUp/Down
998 // no longer fit the currently visible area.
999 m_pWrtShell->ResetCursorStack();
1000
1001 // EditWin never set!
1002
1003 // Set VisArea, but do not call the SetVisArea of the Docshell there!
1005 CalcVisArea( aEditSz );
1006 // Visibility changes of the automatic horizontal scrollbar
1007 // require to repeat the ViewResizePixel() call - but only once!
1008 if(bRepeat)
1009 bRepeat = false;
1010 else if(bHScrollVisible != m_pHScrollbar->IsScrollbarVisible(true) ||
1011 bVScrollVisible != m_pVScrollbar->IsScrollbarVisible(true))
1012 bRepeat = true;
1013 }while( bRepeat );
1015 m_bInInnerResizePixel = false;
1016}
1017
1018void SwView::OuterResizePixel( const Point &rOfst, const Size &rSize )
1019{
1020 // #i16909# return, if no size (caused by minimize window).
1021 if ( m_bInOuterResizePixel || ( !rSize.Width() && !rSize.Height() ) )
1022 return;
1023 m_bInOuterResizePixel = true;
1024
1025 // Determine whether scroll bars may be displayed.
1026 bool bShowH = true,
1027 bShowV = true,
1028 bAuto = true,
1029 bHAuto = true;
1030
1031 const SwViewOption *pVOpt = m_pWrtShell->GetViewOptions();
1032 if ( !pVOpt->IsReadonly() || pVOpt->IsStarOneSetting() )
1033 {
1034 bShowH = pVOpt->IsViewHScrollBar();
1035 bShowV = pVOpt->IsViewVScrollBar();
1036 }
1037
1039 {
1040 bHAuto = bShowH = false;
1041 }
1043 {
1044 bAuto = bShowV = false;
1045 }
1046
1047 SwDocShell* pDocSh = GetDocShell();
1048 bool bIsPreview = pDocSh->IsPreview();
1049 if( bIsPreview )
1050 {
1051 bShowH = bShowV = bHAuto = bAuto = false;
1052 }
1053 if(m_pHScrollbar->IsScrollbarVisible(false) != bShowH && !bHAuto)
1054 ShowHScrollbar(bShowH);
1055 m_pHScrollbar->SetAuto( bHAuto );
1056 if(m_pVScrollbar->IsScrollbarVisible(false) != bShowV && !bAuto)
1057 ShowVScrollbar(bShowV);
1058 m_pVScrollbar->SetAuto(bAuto);
1059
1060 CurrShell aCurr( m_pWrtShell.get() );
1061 bool bRepeat = false;
1062 tools::Long nCnt = 0;
1063
1064 bool bUnLockView = !m_pWrtShell->IsViewLocked();
1065 m_pWrtShell->LockView( true );
1067
1068 do {
1069 ++nCnt;
1070 const bool bScroll1 = m_pVScrollbar->IsScrollbarVisible(true);
1071 const bool bScroll2 = m_pHScrollbar->IsScrollbarVisible(true);
1072 SvBorder aBorder;
1073 CalcAndSetBorderPixel( aBorder );
1074 const Size aEditSz( GetEditWin().GetOutputSizePixel() );
1075 ViewResizePixel( *GetEditWin().GetOutDev(), rOfst, rSize, aEditSz, *m_pVScrollbar,
1077 m_pWrtShell->GetViewOptions()->IsVRulerRight() );
1078 if ( m_bShowAtResize )
1079 ShowAtResize();
1080
1081 if( m_pHRuler->IsVisible() || m_pVRuler->IsVisible() )
1082 InvalidateRulerPos(); // Invalidate content.
1083
1084 // Reset the cursor stack because the cursor positions for PageUp/Down
1085 // no longer fit the currently visible area.
1086 m_pWrtShell->ResetCursorStack();
1087
1088 OSL_ENSURE( !GetEditWin().IsVisible() ||
1089 !aEditSz.IsEmpty() || !m_aVisArea.IsEmpty(), "Small world, isn't it?" );
1090
1091 // Never set EditWin!
1092
1093 // Of course the VisArea must also be set.
1094 // Now is the right time to re-calculate the zoom if it is not a simple factor.
1095 m_pWrtShell->StartAction();
1096 CalcVisArea( aEditSz );
1097
1098 //Thus also in the outplace editing the page width will be adjusted immediately.
1099 //TODO/LATER: is that still necessary?!
1100 /*
1101 if ( pDocSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
1102 pDocSh->SetVisArea(
1103 pDocSh->SfxInPlaceObject::GetVisArea() );*/
1104 if ( m_pWrtShell->GetViewOptions()->GetZoomType() != SvxZoomType::PERCENT &&
1105 !m_pWrtShell->GetViewOptions()->getBrowseMode() )
1106 SetZoom_( aEditSz, m_pWrtShell->GetViewOptions()->GetZoomType(), 100, true );
1107 m_pWrtShell->EndAction();
1108
1109 bRepeat = bScroll1 != m_pVScrollbar->IsScrollbarVisible(true);
1110 if ( !bRepeat )
1111 bRepeat = bScroll2 != m_pHScrollbar->IsScrollbarVisible(true);
1112
1113 // Do no infinite loops.
1114 // If possible stop when the (auto-) scroll bars are visible.
1115 if ( bRepeat &&
1116 ( nCnt > 10 || ( nCnt > 3 && bHAuto && bAuto ) )
1117 )
1118 {
1119 bRepeat = false;
1120 }
1121
1122 } while ( bRepeat );
1123
1124 m_pWrtShell->UnlockPaint();
1125 if( bUnLockView )
1126 m_pWrtShell->LockView( false );
1127
1128 m_bInOuterResizePixel = false;
1129
1130 if ( m_pPostItMgr )
1131 {
1132 m_pPostItMgr->CalcRects();
1133 m_pPostItMgr->LayoutPostIts();
1134 }
1135}
1136
1137void SwView::SetZoomFactor( const Fraction &rX, const Fraction &rY )
1138{
1139 const Fraction &rFrac = rX < rY ? rX : rY;
1140 SetZoom( SvxZoomType::PERCENT, static_cast<short>(tools::Long(rFrac * Fraction( 100, 1 ))) );
1141
1142 // To minimize rounding errors we also adjust the odd values
1143 // of the base class if necessary.
1145}
1146
1148{
1149 bool bRet = false;
1150 if ( !m_aVisArea.IsEmpty() )
1151 {
1152 const bool bBorder = IsDocumentBorder();
1153 tools::Rectangle aTmpRect( m_aVisArea );
1154 if ( bBorder )
1155 {
1157 aPt = AlignToPixel( aPt );
1158 aTmpRect.Move( -aPt.X(), -aPt.Y() );
1159 }
1160
1161 Size aTmpSz( m_aDocSz );
1162 const tools::Long lOfst = bBorder ? 0 : DOCUMENTBORDER * 2;
1163 aTmpSz.AdjustWidth(lOfst ); aTmpSz.AdjustHeight(lOfst );
1164
1165 {
1166 const bool bVScrollVisible = m_pVScrollbar->IsScrollbarVisible(true);
1167 m_pVScrollbar->DocSzChgd( aTmpSz );
1168 m_pVScrollbar->ViewPortChgd( aTmpRect );
1169 if ( bVScrollVisible != m_pVScrollbar->IsScrollbarVisible(true) )
1170 bRet = true;
1171 }
1172 {
1173 const bool bHScrollVisible = m_pHScrollbar->IsScrollbarVisible(true);
1174 m_pHScrollbar->DocSzChgd( aTmpSz );
1175 m_pHScrollbar->ViewPortChgd( aTmpRect );
1176 if ( bHScrollVisible != m_pHScrollbar->IsScrollbarVisible(true) )
1177 bRet = true;
1178 }
1179 }
1180 return bRet;
1181}
1182
1184{
1185 if ( GetWrtShell().IsInSelect() )
1188}
1189
1191{
1192 bool bOk = false;
1193 const CommandWheelData* pWData = rCEvt.GetWheelData();
1194 if (pWData && CommandWheelMode::ZOOM == pWData->GetMode())
1195 {
1196 sal_uInt16 nFact = m_pWrtShell->GetViewOptions()->GetZoom();
1197 if( 0L > pWData->GetDelta() )
1198 nFact = std::max(MIN_ZOOM_PERCENT, basegfx::zoomtools::zoomOut( nFact ));
1199 else
1201
1202 SetZoom( SvxZoomType::PERCENT, nFact );
1203 bOk = true;
1204 }
1205 else
1206 {
1207 if (pWData && pWData->GetMode()==CommandWheelMode::SCROLL)
1208 {
1209 // This influences whether quick help is shown
1211 }
1212
1213 if (pWData && (CommandWheelMode::SCROLL==pWData->GetMode()) &&
1215 {
1216 if (pWData->GetDelta()<0)
1217 PhyPageDown();
1218 else
1219 PhyPageUp();
1220 bOk = true;
1221 }
1222 else
1223 bOk = m_pEditWin->HandleScrollCommand(rCEvt, m_pHScrollbar, m_pVScrollbar);
1224
1225 // Restore default state for case when scroll command comes from dragging scrollbar handle
1227 }
1228 return bOk;
1229}
1230
1232{
1234
1235 if (pData->meEventType == GestureEventZoomType::Begin)
1236 {
1237 m_fLastZoomScale = pData->mfScaleDelta;
1238 return true;
1239 }
1240
1241 if (pData->meEventType == GestureEventZoomType::Update)
1242 {
1243 double deltaBetweenEvents = (pData->mfScaleDelta - m_fLastZoomScale) / m_fLastZoomScale;
1244 m_fLastZoomScale = pData->mfScaleDelta;
1245
1246 // Accumulate fractional zoom to avoid small zoom changes from being ignored
1247 m_fAccumulatedZoom += deltaBetweenEvents;
1248 int nZoomChangePercent = m_fAccumulatedZoom * 100;
1249 m_fAccumulatedZoom -= nZoomChangePercent / 100.0;
1250
1251 sal_uInt16 nFact = m_pWrtShell->GetViewOptions()->GetZoom();
1252 nFact += nZoomChangePercent;
1253 nFact = std::clamp<sal_uInt16>(nFact, MIN_ZOOM_PERCENT, MAX_ZOOM_PERCENT);
1254 SetZoom(SvxZoomType::PERCENT, nFact);
1255
1256 return true;
1257 }
1258 return true;
1259}
1260
1261/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const StyleSettings & GetStyleSettings() const
const CommandGestureZoomData * GetGestureZoomData() const
const CommandWheelData * GetWheelData() const
tools::Long GetDelta() const
double GetScrollLines() const
CommandWheelMode GetMode() const
bool IsValid() const
static bool IsQuickHelpEnabled()
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
const Fraction & GetScaleX() const
const AllSettings & GetSettings() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
void Update(sal_uInt16 nId)
void Invalidate(sal_uInt16 nId)
virtual tools::Rectangle GetVisArea(sal_uInt16 nAspect) const
const tools::Rectangle & GetVisArea() const
bool IsPreview() const
SfxViewFrame * GetFrame() const
SfxBindings & GetBindings()
weld::Window * GetFrameWeld() const
virtual void Move()
void SetBorderPixel(const SvBorder &rBorder)
virtual void SetZoomFactor(const Fraction &rZoomX, const Fraction &rZoomY)
SfxViewFrame & GetViewFrame() const
void VisAreaChanged()
const SvBorder & GetBorderPixel() const
virtual SfxObjectShell * GetObjectShell() override
vcl::Window * GetWindow() const
bool IsEmpty() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
sal_Int32 GetScrollBarSize() const
tools::Long & Left()
tools::Long & Top()
tools::Long & Right()
tools::Long & Bottom()
const SwRect & GetCharRect() const
Definition: crsrsh.hxx:536
SwFrameControlsManager & GetFrameControlsManager()
Definition: edtwin.cxx:6832
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
void HideControls(FrameControlType eType)
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void Pos(const Point &rNew)
Definition: swrect.hxx:171
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: scroll.cxx:79
bool IsScrollbarVisible(bool bReal) const
Definition: scroll.hxx:35
bool IsReadonly() const
Definition: viewopt.hxx:627
SvxZoomType GetZoomType() const
Definition: viewopt.hxx:710
bool IsViewHScrollBar() const
Definition: viewopt.hxx:691
bool IsViewVScrollBar() const
Definition: viewopt.hxx:683
bool IsStarOneSetting() const
Definition: viewopt.hxx:796
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:452
Size GetDocSize() const
Definition: viewsh.cxx:2190
const SwRect & VisArea() const
Definition: viewsh.cxx:642
static weld::Window * GetCareDialog(SwViewShell const &rVSh)
Definition: viewsh.hxx:467
Definition: view.hxx:146
SAL_DLLPRIVATE bool UpdateScrollbars()
Definition: viewport.cxx:1147
VclPtr< SwScrollbar > m_pHScrollbar
Definition: view.hxx:202
SAL_DLLPRIVATE void ShowAtResize()
Definition: viewport.cxx:932
bool m_bWheelScrollInProgress
Definition: view.hxx:237
bool m_bShowAtResize
Definition: view.hxx:252
SAL_DLLPRIVATE bool PageDownCursor(bool bSelect)
Definition: viewport.cxx:657
SAL_DLLPRIVATE bool GetPageScrollUpOffset(SwTwips &rOff) const
Scroll page by page.
Definition: viewport.cxx:525
double m_fAccumulatedZoom
Definition: view.hxx:239
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override
Definition: viewport.cxx:1018
SwWrtShell & GetWrtShell() const
Definition: view.hxx:423
static constexpr sal_uInt16 MIN_ZOOM_PERCENT
Definition: view.hxx:276
void Scroll(const tools::Rectangle &rRect, sal_uInt16 nRangeX=USHRT_MAX, sal_uInt16 nRangeY=USHRT_MAX)
Definition: viewport.cxx:393
virtual SAL_DLLPRIVATE void Move() override
Definition: viewport.cxx:1183
SAL_DLLPRIVATE bool PageDown()
Definition: viewport.cxx:584
bool HandleWheelCommands(const CommandEvent &)
Definition: viewport.cxx:1190
std::unique_ptr< SwWrtShell > m_pWrtShell
Definition: view.hxx:194
bool m_bTopCursor
Definition: view.hxx:242
std::unique_ptr< SwPostItMgr > m_pPostItMgr
Definition: view.hxx:219
VclPtr< SwScrollbar > m_pVScrollbar
Definition: view.hxx:203
static constexpr sal_uInt16 MAX_ZOOM_PERCENT
Definition: view.hxx:275
SAL_DLLPRIVATE void CalcPt(Point *pPt, const tools::Rectangle &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY)
Calculate the visible range.
Definition: viewport.cxx:342
tools::Rectangle m_aVisArea
Definition: view.hxx:191
double m_fLastZoomScale
Definition: view.hxx:238
tools::Long SetHScrollMax(tools::Long lMax)
Definition: viewport.cxx:130
bool m_bInOuterResizePixel
Definition: view.hxx:253
bool m_bVScrollbarEnabled
Definition: view.hxx:206
VclPtr< SvxRuler > m_pHRuler
Definition: view.hxx:208
bool HandleGestureZoomCommand(const CommandEvent &)
Definition: viewport.cxx:1231
bool IsDocumentBorder()
Definition: viewport.cxx:54
VclPtr< SvxRuler > m_pVRuler
Definition: view.hxx:209
tools::Long GetXScroll() const
Definition: view.hxx:721
VclPtr< SwEditWin > m_pEditWin
Definition: view.hxx:193
void ShowHScrollbar(bool bShow)
Definition: viewmdi.cxx:749
const tools::Rectangle & GetVisArea() const
Definition: view.hxx:436
bool m_bInInnerResizePixel
Definition: view.hxx:254
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override
Definition: viewport.cxx:939
SAL_DLLPRIVATE bool PageUp()
Definition: viewport.cxx:572
const Size & GetDocSz() const
Definition: view.hxx:463
tools::Long SetVScrollMax(tools::Long lMax)
Definition: viewport.cxx:140
virtual void SetZoomFactor(const Fraction &rX, const Fraction &) override
Definition: viewport.cxx:1137
bool m_bCenterCursor
Definition: view.hxx:241
SAL_DLLPRIVATE void PhyPageUp()
Definition: viewport.cxx:595
Size m_aDocSz
Definition: view.hxx:190
SAL_DLLPRIVATE bool PageUpCursor(bool bSelect)
Definition: viewport.cxx:631
SwTwips m_nLOKPageUpDownOffset
LibreOfficeKit has to force the page size for PgUp/PgDown functionality based on the user's view,...
Definition: view.hxx:267
SwEditWin & GetEditWin()
Definition: view.hxx:426
void CheckVisArea()
Definition: viewport.cxx:316
bool IsScroll(const tools::Rectangle &rRect) const
Definition: viewport.cxx:388
SwDocShell * GetDocShell()
Definition: view.cxx:1193
void DocSzChgd(const Size &rNewSize)
Definition: viewport.cxx:154
SAL_DLLPRIVATE void CalcAndSetBorderPixel(SvBorder &rToFill)
Definition: viewport.cxx:806
tools::Long GetYScroll() const
Definition: view.hxx:726
void SetVisArea(const tools::Rectangle &, bool bUpdateScrollbar=true)
Definition: viewport.cxx:198
SAL_DLLPRIVATE void EndScrollHdl(weld::Scrollbar &rScrollbar, bool bHorizontal)
Definition: viewport.cxx:741
void InvalidateRulerPos()
Definition: viewport.cxx:107
SAL_DLLPRIVATE void CalcVisArea(const Size &rPixelSz)
Definition: viewport.cxx:770
SAL_DLLPRIVATE void SetZoom_(const Size &rEditSz, SvxZoomType eZoomType, short nFactor, bool bViewOnly)
Definition: viewmdi.cxx:87
SAL_DLLPRIVATE bool GetPageScrollDownOffset(SwTwips &rOff) const
Definition: viewport.cxx:547
void ShowVScrollbar(bool bShow)
Definition: viewmdi.cxx:761
SAL_DLLPRIVATE Point AlignToPixel(const Point &rPt) const
Definition: viewport.cxx:147
bool m_bHScrollbarEnabled
Definition: view.hxx:205
SAL_DLLPRIVATE void PhyPageDown()
Definition: viewport.cxx:613
void SetZoom(SvxZoomType eZoomType, short nFactor=100, bool bViewOnly=false)
Definition: viewmdi.cxx:73
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void EndSelect()
Definition: select.cxx:434
constexpr tools::Long GetWidth() const
bool Contains(const Point &rPOINT) const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
void SetSize(const Size &)
constexpr Point TopLeft() const
constexpr void SetRight(tools::Long v)
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
Point AbsoluteScreenToOutputPixel(const Point &rPos) const
Point LogicToPixel(const Point &rLogicPt) const
const AllSettings & GetSettings() const
const MapMode & GetMapMode() const
Point PixelToLogic(const Point &rDevicePt) const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
virtual int adjustment_get_value() const=0
virtual bool get_extents_relative_to(const Widget &rRelative, int &x, int &y, int &width, int &height) const=0
#define FN_STAT_PAGE
Definition: cmdid.h:864
#define COMMAND_WHEEL_PAGESCROLL
float y
float x
@ PagePrt
Rect of current PrtArea of page.
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:63
DocumentType eType
const char sDisplay[]
std::unique_ptr< sal_Int32[]> pData
tools::Long const nBorder
sal_uInt16 zoomIn(sal_uInt16 nCurrent)
sal_uInt16 zoomOut(sal_uInt16 nCurrent)
long Long
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
SwNodeOffset abs(const SwNodeOffset &a)
Definition: nodeoffset.hxx:34
#define ASPECT_CONTENT
constexpr WinBits WB_RIGHT_ALIGNED
static SfxItemSet & rSet
OUString sStr
Definition: crsrsh.hxx:114
tools::Long SwTwips
Definition: swtypes.hxx:51
constexpr SwTwips DOCUMENTBORDER
Definition: swtypes.hxx:79
bool bDocSzUpdated
Definition: view.cxx:125
const tools::Long nScrollX
Definition: view.hxx:78
const tools::Long nLeftOfst
Definition: view.hxx:77
static tools::Long GetLeftMargin(SwView const &rView)
Definition: viewport.cxx:66
static void lcl_GetPos(SwView const *pView, Point &rPos, const weld::Scrollbar &rScrollbar, bool bHori, bool bBorder)
Definition: viewport.cxx:75
IMPL_LINK(SwView, VertScrollHdl, weld::Scrollbar &, rScrollbar, void)
Definition: viewport.cxx:674
static bool bProtectDocShellVisArea
Definition: viewport.cxx:50
static sal_uInt16 nPgNum
Definition: viewport.cxx:52
static void HideQuickHelp(vcl::Window *pParent)
Definition: viewport.cxx:671
void ViewResizePixel(const vcl::RenderContext &rRef, const Point &rOfst, const Size &rSize, const Size &rEditSz, SwScrollbar &rVScrollbar, SwScrollbar &rHScrollbar, SvxRuler *pVRuler, SvxRuler *pHRuler, bool bVRulerRight)
Definition: viewport.cxx:837
sal_Int64 WinBits
SvxZoomType