LibreOffice Module sw (master) 1
viewmdi.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 <sfx2/dispatch.hxx>
21#include <sfx2/viewfrm.hxx>
22#include <svx/ruler.hxx>
23#include <editeng/lrspitem.hxx>
24#include <o3tl/safeint.hxx>
25#include <svl/srchitem.hxx>
26#include <svl/stritem.hxx>
27#include <sfx2/request.hxx>
28#include <swmodule.hxx>
29#include <view.hxx>
30#include <wrtsh.hxx>
31#include <viewopt.hxx>
32#include <frmatr.hxx>
33#include <edtwin.hxx>
34#include <pagedesc.hxx>
35#include <IMark.hxx>
36#include <fldbas.hxx>
37#include <workctrl.hxx>
38#include <usrpref.hxx>
39#include <scroll.hxx>
40#include <wview.hxx>
41
42#include <cmdid.h>
43
44#include <PostItMgr.hxx>
45#include <AnnotationWin.hxx>
46
47#include <svx/srchdlg.hxx>
48#include <svx/svdview.hxx>
49
50#include <vcl/uitest/logger.hxx>
52
53sal_uInt16 SwView::s_nMoveType = NID_PGE;
54sal_Int32 SwView::s_nActMark = 0;
55
56using namespace ::com::sun::star::uno;
57
58namespace {
59
60void collectUIInformation(const OUString& aFactor)
61{
62 EventDescription aDescription;
63 aDescription.aID = "writer_edit";
64 aDescription.aParameters = {{"ZOOM", aFactor}};
65 aDescription.aAction = "SET";
66 aDescription.aKeyWord = "SwEditWinUIObject";
67 aDescription.aParent = "MainWindow";
68 UITestLogger::getInstance().logEvent(aDescription);
69}
70
71}
72
73void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, bool bViewOnly )
74{
75 bool const bCursorIsVisible(m_pWrtShell->IsCursorVisible());
76 SetZoom_( GetEditWin().GetOutputSizePixel(), eZoomType, nFactor, bViewOnly );
77 // fdo#40465 force the cursor to stay in view whilst zooming
78 if (bCursorIsVisible)
79 m_pWrtShell->ShowCursor();
80
81 Invalidate(SID_ZOOM_IN);
82 Invalidate(SID_ZOOM_OUT);
83
84 collectUIInformation(OUString::number(nFactor));
85}
86
87void SwView::SetZoom_( const Size &rEditSize, SvxZoomType eZoomType,
88 short nFactor, bool bViewOnly )
89{
90 bool bUnLockView = !m_pWrtShell->IsViewLocked();
91 m_pWrtShell->LockView( true );
93
94 { // start of SwActContext scope
95 SwActContext aActContext(m_pWrtShell.get());
96
97 tools::Long nFac = nFactor;
98
99 const bool bWeb = dynamic_cast< const SwWebView *>( this ) != nullptr;
100 SwMasterUsrPref *pUsrPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(bWeb));
101
102 const SwPageDesc &rDesc = m_pWrtShell->GetPageDesc( m_pWrtShell->GetCurPageDesc() );
103 const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace();
104 const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
105 tools::Long lLeftMargin = 0;
106
107 if( eZoomType != SvxZoomType::PERCENT )
108 {
109 const bool bAutomaticViewLayout = 0 == pOpt->GetViewLayoutColumns();
110
111 const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( CurRectType::PageCalc ) );
112 const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( CurRectType::PagesArea ) );
113 Size aPageSize( aPageRect.SSize() );
114 Size aRootSize( aRootRect.SSize() );
115
116 //mod #i6193# added sidebar width
117 SwPostItMgr* pPostItMgr = GetPostItMgr();
118 if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes())
119 aPageSize.AdjustWidth(pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() );
120
121 const MapMode aTmpMap( MapUnit::MapTwip );
122 const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
123
124 if( SvxZoomType::OPTIMAL == eZoomType )
125 {
126 // unclear if this is useful for OPTIMAL, or completely useless?
127 if( UseOnPage::Mirror == rDesc.GetUseOn() ) // mirrored pages
128 {
129 const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
130 aPageSize.AdjustWidth(std::abs( rLeftLRSpace.GetLeft() - rLRSpace.GetLeft() ) );
131 }
132
133 if (!pPostItMgr->HasNotes() || !pPostItMgr->ShowNotes())
134 aPageSize.AdjustWidth( -( rLRSpace.GetLeft() + rLRSpace.GetRight() + nLeftOfst * 2 ) );
135 lLeftMargin = rLRSpace.GetLeft() + DOCUMENTBORDER + nLeftOfst;
136 nFac = aWindowSize.Width() * 100 / aPageSize.Width();
137 }
138 else if(SvxZoomType::WHOLEPAGE == eZoomType || SvxZoomType::PAGEWIDTH == eZoomType )
139 {
140 const tools::Long nOf = DOCUMENTBORDER * 2;
141 tools::Long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
142 nTmpWidth += nOf;
143 aPageSize.AdjustHeight(nOf );
144 nFac = aWindowSize.Width() * 100 / nTmpWidth;
145
146 if ( SvxZoomType::WHOLEPAGE == eZoomType )
147 {
148 tools::Long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
149 nFac = std::min( nFac, nVisPercent );
150 }
151 }
152 else
153 {
154 const tools::Long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
155 nFac = aWindowSize.Width() * 100 / nTmpWidth;
156 }
157 }
158
159 nFac = std::max( tools::Long( MINZOOM ), nFac );
160 const sal_uInt16 nZoomFac = o3tl::narrowing<sal_uInt16>(nFac);
161
162 SwViewOption aOpt( *pOpt );
163 if ( !GetViewFrame().GetFrame().IsInPlace() )
164 {
165 //Update MasterUsrPrefs and after that update the ViewOptions of the current View.
166 if ( !bViewOnly &&
167 (nZoomFac != pUsrPref->GetZoom() ||
168 eZoomType != pUsrPref->GetZoomType()) )
169 {
170 pUsrPref->SetZoom(nZoomFac);
171 pUsrPref->SetZoomType(eZoomType);
172 SW_MOD()->ApplyUsrPref(*pUsrPref, nullptr);
173 pUsrPref->SetModified();
174 }
175 if ( pOpt->GetZoom() != nZoomFac )
176 {
177 aOpt.SetZoom(nZoomFac);
178 aOpt.SetReadonly(pOpt->IsReadonly());
179 m_pWrtShell->ApplyViewOptions( aOpt );
180 }
181 if ( eZoomType != SvxZoomType::PERCENT )
182 {
183 Point aPos;
184
185 if ( eZoomType == SvxZoomType::WHOLEPAGE )
186 aPos.setY( m_pWrtShell->GetAnyCurRect(CurRectType::Page).Top() - DOCUMENTBORDER );
187 else
188 {
189 // Make sure that the cursor is in the visible range, so that
190 // the scrolling will be performed only once.
191 aPos.setX( lLeftMargin );
192 const SwRect &rCharRect = m_pWrtShell->GetCharRect();
193 if ( rCharRect.Top() > GetVisArea().Bottom() ||
194 rCharRect.Bottom() < aPos.Y() )
195 aPos.setY( rCharRect.Top() - rCharRect.Height() );
196 else
197 aPos.setY( GetVisArea().Top() );
198 }
199 SetVisArea( aPos );
200 }
201 // Compromise solution - Under certain circumstances SetZoom is called
202 // in CalcVisAreas again and thus be set wrong values.
203 const_cast<SwViewOption*>(m_pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
204 CalcVisArea( rEditSize ); // for the recalculation of the viewable area
205 }
206 else if ( nZoomFac != pOpt->GetZoom() )
207 {
208 aOpt.SetZoom( nZoomFac );
209 m_pWrtShell->ApplyViewOptions( aOpt );
210 }
211
212 const Fraction aFrac( nFac, 100 );
213 m_pVRuler->SetZoom( aFrac );
214 m_pVRuler->ForceUpdate();
215 m_pHRuler->SetZoom( aFrac );
216 m_pHRuler->ForceUpdate();
217 const_cast<SwViewOption*>(m_pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
218 } // end of SwActContext scope
219
220 m_pWrtShell->UnlockPaint();
221 if( bUnLockView )
222 m_pWrtShell->LockView( false );
223}
224
225void SwView::SetViewLayout( sal_uInt16 nColumns, bool bBookMode, bool bViewOnly )
226{
227 const bool bUnLockView = !m_pWrtShell->IsViewLocked();
228 m_pWrtShell->LockView( true );
230
231 {
232
233 SwActContext aActContext(m_pWrtShell.get());
234
235 if ( !GetViewFrame().GetFrame().IsInPlace() && !bViewOnly )
236 {
237 const bool bWeb = dynamic_cast< const SwWebView *>( this ) != nullptr;
238 SwMasterUsrPref *pUsrPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(bWeb));
239
240 // Update MasterUsrPrefs and after that update the ViewOptions of the current View.
241 if ( nColumns != pUsrPref->GetViewLayoutColumns() ||
242 bBookMode != pUsrPref->IsViewLayoutBookMode() )
243 {
244 pUsrPref->SetViewLayoutColumns(nColumns);
245 pUsrPref->SetViewLayoutBookMode(bBookMode);
246 SW_MOD()->ApplyUsrPref(*pUsrPref, nullptr);
247 pUsrPref->SetModified();
248 }
249 }
250
251 const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
252
253 if ( nColumns != pOpt->GetViewLayoutColumns() ||
254 bBookMode != pOpt->IsViewLayoutBookMode() )
255 {
256 SwViewOption aOpt( *pOpt );
257 aOpt.SetViewLayoutColumns( nColumns );
258 aOpt.SetViewLayoutBookMode( bBookMode );
259 m_pWrtShell->ApplyViewOptions( aOpt );
260 }
261
262 m_pVRuler->ForceUpdate();
263 m_pHRuler->ForceUpdate();
264
265 }
266
267 m_pWrtShell->UnlockPaint();
268 if( bUnLockView )
269 m_pWrtShell->LockView( false );
270
272 rBnd.Invalidate( SID_ATTR_VIEWLAYOUT );
273 rBnd.Invalidate( SID_ATTR_ZOOMSLIDER);
274}
275
276// Scrollbar - Handler
277
278IMPL_LINK( SwView, WindowChildEventListener, VclWindowEvent&, rEvent, void )
279{
280 OSL_ENSURE( rEvent.GetWindow(), "Window???" );
281 vcl::Window* pChildWin = static_cast< vcl::Window* >( rEvent.GetData() );
282
283 switch ( rEvent.GetId() )
284 {
285 case VclEventId::WindowHide:
286 if( pChildWin == m_pHScrollbar )
287 ShowHScrollbar( false );
288 else if( pChildWin == m_pVScrollbar )
289 ShowVScrollbar( false );
290 break;
291 case VclEventId::WindowShow:
292 if( pChildWin == m_pHScrollbar )
293 ShowHScrollbar( true );
294 else if( pChildWin == m_pVScrollbar )
295 ShowVScrollbar( true );
296 break;
297 default: break;
298 }
299}
300
301void SwView::CreateScrollbar( bool bHori )
302{
304 VclPtr<SwScrollbar>& ppScrollbar = bHori ? m_pHScrollbar : m_pVScrollbar;
305
306 assert(!ppScrollbar); //check beforehand!
307
308 ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori );
310 if(bHori)
311 ppScrollbar->SetScrollHdl( LINK( this, SwView, HoriScrollHdl ));
312 else
313 ppScrollbar->SetScrollHdl( LINK( this, SwView, VertScrollHdl ));
314
315 if(GetWindow())
317
318 if (!m_bShowAtResize)
319 ppScrollbar->ExtendedShow();
320}
321
322IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void )
323{
324 bool* pbNext = static_cast<bool*>(p);
325 if ( !pbNext )
326 return;
327 const bool bNext = *pbNext;
328 SwWrtShell& rSh = GetWrtShell();
329 if ( NID_SRCH_REP != s_nMoveType)
330 {
331 if ( rSh.GetDrawView()->IsTextEdit() )
332 rSh.EndTextEdit();
333 if ( IsDrawMode() )
334 LeaveDrawCreate();
335 }
336 if ( NID_POSTIT != s_nMoveType && m_pPostItMgr )
337 {
338 sw::annotation::SwAnnotationWin* pActiveSidebarWin = m_pPostItMgr->GetActiveSidebarWin();
339 if (pActiveSidebarWin)
340 pActiveSidebarWin->SwitchToFieldPos();
341 }
342 if (NID_RECENCY != s_nMoveType && NID_PGE != s_nMoveType && NID_SRCH_REP != s_nMoveType)
343 rSh.addCurrentPosition();
344 switch( s_nMoveType )
345 {
346 case NID_PGE:
347 {
348 tools::Long nYPos;
349 SwVisiblePageNumbers aVisiblePageNumbers;
350 rSh.GetFirstLastVisPageNumbers(aVisiblePageNumbers);
351 if ((bNext && aVisiblePageNumbers.nLastPhy + 1 > rSh.GetPageCnt()) ||
352 (!bNext && aVisiblePageNumbers.nFirstPhy == 1))
353 {
354 nYPos = rSh.GetPagePos(bNext ? 1 : rSh.GetPageCnt()).Y();
355 SvxSearchDialogWrapper::SetSearchLabel(bNext ? SearchLabel::EndWrapped :
356 SearchLabel::StartWrapped);
357 }
358 else
359 {
360 auto nPage = bNext ? aVisiblePageNumbers.nLastPhy + 1 :
361 aVisiblePageNumbers.nFirstPhy - 1;
362 nYPos = rSh.GetPagePos(nPage).Y();
363 SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Empty);
364 }
365 const Point aPt(GetVisArea().Left(), nYPos);
366 Point aAlPt(AlignToPixel(aPt));
367 // If there is a difference, has been truncated --> then add one pixel,
368 // so that no residue of the previous page is visible.
369 if(aPt.Y() != aAlPt.Y())
370 aAlPt.AdjustY(3 * GetEditWin().PixelToLogic(Size(0, 1)).Height());
371 SetVisArea(aAlPt);
372 }
373 break;
374 case NID_TBL :
375 rSh.EnterStdMode();
376 if(bNext)
378 else
380 break;
381 case NID_FRM :
382 case NID_GRF:
383 case NID_OLE:
384 {
386 if(s_nMoveType == NID_GRF)
388 else if(s_nMoveType == NID_OLE)
390 bool bSuccess = bNext ?
391 rSh.GotoNextFly(eType) :
392 rSh.GotoPrevFly(eType);
393 if(bSuccess)
394 {
395 rSh.HideCursor();
396 rSh.EnterSelFrameMode();
397 }
398 }
399 break;
400 case NID_CTRL:
401 if (!rSh.GetView().IsDesignMode())
402 rSh.GetView().GetFormShell()->SetDesignMode(true);
403 [[fallthrough]];
404 case NID_DRW:
405 {
406 bool bSuccess = rSh.GotoObj(bNext,
407 s_nMoveType == NID_DRW ?
410 if(bSuccess)
411 {
412 rSh.HideCursor();
413 rSh.EnterSelFrameMode();
414 }
415 }
416 break;
417 case NID_REG :
418 rSh.EnterStdMode();
419 if(bNext)
421 else
423
424 break;
425 case NID_BKM :
426 rSh.EnterStdMode();
427 GetViewFrame().GetDispatcher()->Execute(bNext ?
430 break;
431 case NID_FIELD:
432 {
433 rSh.EnterStdMode();
434 rSh.StartAction();
435 SearchLabel eSearchLabel = SearchLabel::Empty;
436 if (!rSh.MoveFieldType(nullptr, bNext, SwFieldIds::Unknown))
437 {
438 // no field found in the move direction
439 // wrap and try again
440 SwShellCursor* pCursor = rSh.GetCursor_();
441 SwCursorSaveState aSaveState(*pCursor);
442 rSh.SttEndDoc(bNext);
443 // document might have a field at the start of the document
444 SwField* pField = rSh.GetCurField();
445 if ((bNext && pField && pField->GetTypeId() != SwFieldTypesEnum::Postit) ||
446 rSh.MoveFieldType(nullptr, bNext, SwFieldIds::Unknown))
447 {
448 eSearchLabel = bNext ? SearchLabel::EndWrapped : SearchLabel::StartWrapped;
449 }
450 else
451 {
452 // no visible fields found
453 pCursor->RestoreSavePos();
454 eSearchLabel = SearchLabel::NavElementNotFound;
455 }
456 }
458 rSh.EndAction();
459 }
460 break;
461 case NID_FIELD_BYTYPE:
462 {
463 // see: SwFieldMgr::GoNextPrev
464 SwField* pCurField = rSh.GetCurField(true);
465 if (!pCurField)
466 break;
467 rSh.EnterStdMode();
468 SwFieldType* pTyp = nullptr;
469 const SwFieldTypesEnum nTypeId = pCurField->GetTypeId();
470 if (SwFieldTypesEnum::SetInput == nTypeId || SwFieldTypesEnum::UserInput == nTypeId)
471 pTyp = rSh.GetFieldType(0, SwFieldIds::Input);
472 else
473 pTyp = pCurField->GetTyp();
474 if (pTyp)
475 {
476 if (pTyp->Which() == SwFieldIds::Database)
477 rSh.MoveFieldType(nullptr, bNext, SwFieldIds::Database);
478 else
479 rSh.MoveFieldType(pTyp, bNext);
480 }
481 }
482 break;
483 case NID_OUTL:
484 rSh.EnterStdMode();
485 bNext ? rSh.GotoNextOutline() : rSh.GotoPrevOutline();
486 break;
487 case NID_SEL :
489 break;
490 case NID_FTN:
491 {
492 bool bFrameTypeFootnote(rSh.GetFrameType(nullptr, false) & FrameTypeFlags::FOOTNOTE);
493
494 if (bFrameTypeFootnote)
495 {
496 rSh.LockView(true);
497 rSh.GotoFootnoteAnchor();
498 }
499
500 rSh.EnterStdMode();
501 bNext ?
504
505 if (bFrameTypeFootnote)
506 {
507 rSh.LockView(false);
508 rSh.GotoFootnoteText();
509 }
510 }
511 break;
512 case NID_MARK:
513 {
514 // unselect
515 rSh.MoveCursor();
516 rSh.EnterStdMode();
517
518 // collect and sort navigator reminder names
519 IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
520 std::vector< OUString > vNavMarkNames;
522 ppMark != pMarkAccess->getAllMarksEnd();
523 ++ppMark)
524 {
526 vNavMarkNames.push_back((*ppMark)->GetName());
527 }
528 std::sort(vNavMarkNames.begin(), vNavMarkNames.end());
529
530 // move
531 if(!vNavMarkNames.empty())
532 {
533 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
534
535 if(bNext)
536 {
537 s_nActMark++;
538 if (s_nActMark >= MAX_MARKS || s_nActMark >= static_cast<sal_Int32>(vNavMarkNames.size()))
539 {
540 s_nActMark = 0;
541 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::ReminderEndWrapped );
542 }
543 }
544 else
545 {
546 s_nActMark--;
547 if (s_nActMark < 0 || o3tl::make_unsigned(s_nActMark) >= vNavMarkNames.size())
548 {
549 s_nActMark = vNavMarkNames.size()-1;
550 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::ReminderStartWrapped );
551 }
552 }
553 rSh.GotoMark(vNavMarkNames[s_nActMark]);
554 }
555 else
556 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
557 }
558 break;
559
560 case NID_POSTIT:
561 {
562 if (m_pPostItMgr->HasNotes())
563 {
564 rSh.EnterStdMode();
565 m_pPostItMgr->AssureStdModeAtShell();
566 m_pPostItMgr->SetActiveSidebarWin(nullptr);
567 GetEditWin().GrabFocus();
568 SwShellCursor* pCursor = rSh.GetCursor_();
569 SwCursorSaveState aSaveState(*pCursor);
570 SwFieldType* pFieldType = rSh.GetFieldType(0, SwFieldIds::Postit);
571 bool bWrapped = false;
572 bool bFound = false;
573 rSh.StartAction();
574 while (!bFound)
575 {
576 if (!rSh.MoveFieldType(pFieldType, bNext))
577 {
578 if (bWrapped)
579 break;
580 bWrapped = true;
581 rSh.SttEndDoc(bNext);
582 continue;
583 }
584 do
585 {
586 auto pAnnotationWin = m_pPostItMgr->GetAnnotationWin(
588 if (pAnnotationWin && pAnnotationWin->IsVisible())
589 bFound = true;
590 } while (!bFound && rSh.MoveFieldType(pFieldType, bNext));
591 }
592 if (!bFound)
593 {
594 pCursor->RestoreSavePos();
595 SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
596 }
597 rSh.EndAction();
598 if (bFound)
599 {
600 GetViewFrame().GetDispatcher()->Execute(FN_POSTIT);
601 if (bWrapped)
602 SvxSearchDialogWrapper::SetSearchLabel(bNext ? SearchLabel::EndWrapped :
603 SearchLabel::StartWrapped);
604 else
605 SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Empty);
606 }
607 }
608 else
609 SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
610 }
611 break;
612
613 case NID_SRCH_REP:
614 if(s_pSrchItem)
615 {
616 bool bBackward = s_pSrchItem->GetBackward();
617 if (rSh.HasSelection() && bNext != rSh.IsCursorPtAtEnd())
618 rSh.SwapPam();
619 s_pSrchItem->SetBackward(!bNext);
620 SfxRequest aReq(FN_REPEAT_SEARCH, SfxCallMode::SLOT, GetPool());
621 ExecSearch(aReq);
622 s_pSrchItem->SetBackward(bBackward);
623 }
624 break;
625 case NID_INDEX_ENTRY:
626 rSh.GotoNxtPrvTOXMark(bNext);
627 break;
628
630 rSh.GotoNxtPrvTableFormula( bNext );
631 break;
632
634 rSh.GotoNxtPrvTableFormula( bNext, true );
635 break;
636
637 case NID_RECENCY :
638 rSh.EnterStdMode();
639 bNext ? rSh.GetNavigationMgr().goForward() : rSh.GetNavigationMgr().goBack();
640 break;
641 }
642 if (NID_POSTIT != s_nMoveType)
643 m_pEditWin->GrabFocus();
644 delete pbNext;
645}
646
648{
649 m_pHRuler->SetActive(GetFrame() && IsActive());
650
651 m_pHRuler->Show();
653}
654
656{
657 m_pHRuler->Hide();
659}
660
662{
663 if(m_pHRuler->GetUnit() != eUnit )
664 {
665 m_pHRuler->SetUnit( eUnit );
666 m_pHRuler->Invalidate();
667 }
668}
669
671{
672 if(m_pVRuler->GetUnit() != eUnit)
673 {
674 m_pVRuler->SetUnit( eUnit );
675 m_pVRuler->Invalidate();
676 }
677}
678
680{
681 eToFill = m_pVRuler->GetUnit();
682}
683
685{
686 eToFill = m_pHRuler->GetUnit();
687}
688
690{
691 m_pHRuler->SetBorderPos( m_pVRuler->GetSizePixel().Width()-1 );
692
693 m_pVRuler->SetActive(GetFrame() && IsActive());
694 m_pVRuler->Show();
696}
697
699{
700 m_pVRuler->Hide();
701 m_pHRuler->SetBorderPos();
703}
704
705IMPL_LINK( SwView, ExecRulerClick, Ruler *, pRuler, void )
706{
707 OUString sDefPage;
708 TypedWhichId<SfxStringItem> nDefDlg = SID_PARA_DLG;
709 switch( pRuler->GetClickType() )
710 {
711 case RulerType::DontKnow:
712 case RulerType::Outside:
713 sDefPage="labelTP_BORDER";
714 break;
715 case RulerType::Indent:
716 sDefPage="labelTP_PARA_STD";
717 break;
718 case RulerType::Margin1:
719 case RulerType::Margin2:
720 nDefDlg= FN_FORMAT_PAGE_DLG;
721 sDefPage = "page";
722 break;
723 default:
724 sDefPage = "labelTP_TABULATOR";
725
726 }
727
728 SfxStringItem aDefPage(nDefDlg, sDefPage);
729 GetViewFrame().GetDispatcher()->ExecuteList(nDefDlg,
730 SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
731 { &aDefPage });
732}
733
735{
736 return s_nMoveType;
737}
738
739void SwView::SetMoveType(sal_uInt16 nSet)
740{
741 s_nMoveType = nSet;
742}
743
744void SwView::SetActMark(sal_Int32 nSet)
745{
746 s_nActMark = nSet;
747}
748
750{
751 assert(m_pHScrollbar && "Scrollbar invalid");
752 m_pHScrollbar->ExtendedShow(bShow);
753}
754
756{
757 assert(m_pHScrollbar && "Scrollbar invalid");
758 return m_pHScrollbar->IsScrollbarVisible(false) || m_pHScrollbar->IsAuto();
759}
760
762{
763 assert(m_pVScrollbar && "Scrollbar invalid");
764 m_pVScrollbar->ExtendedShow(bShow);
765}
766
768{
769 assert(m_pVScrollbar && "Scrollbar invalid");
770 return m_pVScrollbar->IsScrollbarVisible(false);
771}
772
773void SwView::EnableHScrollbar(bool bEnable)
774{
775 if (m_bHScrollbarEnabled != bEnable)
776 {
777 m_bHScrollbarEnabled = bEnable;
779 }
780}
781
782void SwView::EnableVScrollbar(bool bEnable)
783{
784 if (m_bVScrollbarEnabled != bEnable)
785 {
786 m_bVScrollbarEnabled = bEnable;
788 }
789}
790
791/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetDesignMode(bool _bDesignMode)
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
Provides access to the marks of a document.
virtual const_iterator_t getAllMarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of marks.
virtual const_iterator_t getAllMarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of marks.
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:502
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
virtual bool IsTextEdit() const final override
void Invalidate(sal_uInt16 nId)
SfxViewFrame * GetFrame() const
virtual void Invalidate(sal_uInt16 nId=0)
virtual bool IsDesignMode() const
bool IsActive() const
vcl::Window & GetWindow() const
SfxBindings & GetBindings()
void InvalidateBorder()
SfxViewFrame & GetViewFrame() const
vcl::Window * GetWindow() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
tools::Long GetRight() const
tools::Long GetLeft() const
static void SetSearchLabel(const SearchLabel &rSL)
Class for automated call of Start- and EndAction().
Definition: editsh.hxx:1040
A helper class to save cursor state (position).
Definition: swcrsr.hxx:233
bool GotoNextOutline()
jump to next node with outline num.
Definition: crstrvl.cxx:1192
bool GotoPrevOutline()
jump to previous node with outline num.
Definition: crstrvl.cxx:1257
void StartAction()
Definition: crsrsh.cxx:226
bool GotoNextFootnoteAnchor()
Definition: trvlfnfl.cxx:339
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:343
void SwapPam()
Definition: crsrsh.cxx:1262
const SwPostItField * GetPostItFieldAtCursor() const
Definition: crstrvl.cxx:2107
void HideCursor()
Definition: crsrsh.cxx:2731
bool SttEndDoc(bool bStt)
Definition: crsrsh.cxx:579
bool MoveRegion(SwWhichRegion, SwMoveFnCollection const &)
Definition: trvlreg.cxx:236
bool MoveTable(SwWhichTable, SwMoveFnCollection const &)
Definition: trvltbl.cxx:679
bool GotoNxtPrvTOXMark(bool bNext=true)
jump to next/previous index marker
Definition: crstrvl.cxx:498
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:1073
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
bool GotoFootnoteText()
jump from content to footnote
Definition: trvlfnfl.cxx:89
bool GotoPrevFootnoteAnchor()
Definition: trvlfnfl.cxx:344
void GoNextPrevCursorSetSearchLabel(const bool bNext)
Definition: crsrsh.cxx:1694
bool GotoNxtPrvTableFormula(bool bNext=true, bool bOnlyErrors=false)
Jump to next/previous table formula Optionally it is possible to also jump to broken formulas.
Definition: crstrvl.cxx:383
bool IsCursorPtAtEnd() const
Definition: crsrsh.hxx:920
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
Definition: crstrvl.cxx:674
sal_uInt16 GetPageCnt()
Definition: crsrsh.cxx:1591
void RestoreSavePos()
Restore cursor state to the one saved by SwCursorSaveState.
Definition: swcrsr.cxx:2339
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
Definition: edfld.cxx:64
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:237
bool GotoNextFly(GotoObjFlags eType=GotoObjFlags::FlyAny)
Independent selecting of flys.
Definition: fesh.hxx:416
bool GotoObj(bool bNext, GotoObjFlags eType=GotoObjFlags::DrawAny)
Definition: feshview.cxx:1630
bool GotoPrevFly(GotoObjFlags eType=GotoObjFlags::FlyAny)
Definition: fesh.hxx:418
void EndTextEdit()
Deletes object if required.
Definition: feshview.cxx:1193
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
SwFieldIds Which() const
Definition: fldbas.hxx:276
Base class of all fields.
Definition: fldbas.hxx:296
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:270
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:98
void SetModified()
Definition: usrpref.hxx:157
void goBack()
Definition: navmgr.cxx:98
void goForward()
Definition: navmgr.cxx:144
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
UseOnPage GetUseOn() const
Definition: pagedesc.hxx:353
SwFrameFormat & GetLeft()
Definition: pagedesc.hxx:239
bool HasNotes() const
Definition: PostItMgr.cxx:2116
bool ShowNotes() const
Definition: PostItMgr.cxx:2110
tools::ULong GetSidebarWidth(bool bPx=false) const
Definition: PostItMgr.cxx:2121
tools::ULong GetSidebarBorderWidth(bool bPx=false) const
Definition: PostItMgr.cxx:2147
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Height(tools::Long nNew)
Definition: swrect.hxx:193
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
void SSize(const Size &rNew)
Definition: swrect.hxx:180
Represents the current text cursor of one opened edit window.
Definition: viscrs.hxx:140
bool IsReadonly() const
Definition: viewopt.hxx:627
bool IsViewLayoutBookMode() const
Definition: viewopt.hxx:643
SvxZoomType GetZoomType() const
Definition: viewopt.hxx:710
sal_uInt16 GetZoom() const
Definition: viewopt.hxx:669
void SetZoomType(SvxZoomType eZoom_)
Definition: viewopt.hxx:736
void SetZoom(sal_uInt16 n)
Definition: viewopt.hxx:670
sal_uInt16 GetViewLayoutColumns() const
Definition: viewopt.hxx:645
void SetReadonly(bool bSet)
Definition: viewopt.hxx:628
void SetViewLayoutColumns(sal_uInt16 nNew)
Definition: viewopt.hxx:646
void SetViewLayoutBookMode(bool bNew)
Definition: viewopt.hxx:644
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2821
void LockView(bool b)
Definition: viewsh.hxx:491
Point GetPagePos(sal_uInt16 nPageNum) const
Definition: viewsh.cxx:699
void GetFirstLastVisPageNumbers(SwVisiblePageNumbers &rVisiblePageNumbers)
Definition: viewsh.cxx:2776
SdrView * GetDrawView()
Definition: vnew.cxx:386
Definition: view.hxx:146
void GetHRulerMetric(FieldUnit &rToFill) const
Definition: viewmdi.cxx:684
SAL_DLLPRIVATE bool UpdateScrollbars()
Definition: viewport.cxx:1147
VclPtr< SwScrollbar > m_pHScrollbar
Definition: view.hxx:202
bool m_bShowAtResize
Definition: view.hxx:252
void CreateVRuler()
Definition: viewmdi.cxx:689
static void SetActMark(sal_Int32 nSet)
Definition: viewmdi.cxx:744
static sal_uInt16 s_nMoveType
Definition: view.hxx:167
void EnableVScrollbar(bool bEnable)
Definition: viewmdi.cxx:782
std::unique_ptr< SwWrtShell > m_pWrtShell
Definition: view.hxx:194
void GetVRulerMetric(FieldUnit &rToFill) const
Definition: viewmdi.cxx:679
VclPtr< SwScrollbar > m_pVScrollbar
Definition: view.hxx:203
virtual FmFormShell * GetFormShell() override
Definition: view.hxx:589
bool m_bVScrollbarEnabled
Definition: view.hxx:206
VclPtr< SvxRuler > m_pHRuler
Definition: view.hxx:208
VclPtr< SvxRuler > m_pVRuler
Definition: view.hxx:209
void CreateTab()
Definition: viewmdi.cxx:647
void SetViewLayout(sal_uInt16 nColumns, bool bBookMode, bool bViewOnly=false)
Definition: viewmdi.cxx:225
void ShowHScrollbar(bool bShow)
Definition: viewmdi.cxx:749
void EnableHScrollbar(bool bEnable)
Definition: viewmdi.cxx:773
const tools::Rectangle & GetVisArea() const
Definition: view.hxx:436
bool IsHScrollbarVisible() const
Definition: viewmdi.cxx:755
SwPostItMgr * GetPostItMgr()
Definition: view.hxx:650
void ChangeVRulerMetric(FieldUnit eUnit)
Definition: viewmdi.cxx:670
static sal_Int32 s_nActMark
Definition: view.hxx:168
bool IsVScrollbarVisible() const
Definition: viewmdi.cxx:767
SwEditWin & GetEditWin()
Definition: view.hxx:426
void KillTab()
Definition: viewmdi.cxx:655
SAL_DLLPRIVATE void CreateScrollbar(bool bHori)
Definition: viewmdi.cxx:301
void SetVisArea(const tools::Rectangle &, bool bUpdateScrollbar=true)
Definition: viewport.cxx:198
void KillVRuler()
Definition: viewmdi.cxx:698
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
static sal_uInt16 GetMoveType()
Definition: viewmdi.cxx:734
void ShowVScrollbar(bool bShow)
Definition: viewmdi.cxx:761
bool m_bHScrollbarEnabled
Definition: view.hxx:205
static void SetMoveType(sal_uInt16 nSet)
Definition: viewmdi.cxx:739
void SetZoom(SvxZoomType eZoomType, short nFactor=100, bool bViewOnly=false)
Definition: viewmdi.cxx:73
void ChangeTabMetric(FieldUnit eUnit)
Definition: viewmdi.cxx:661
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void EnterSelFrameMode(const Point *pStartDrag=nullptr)
Definition: select.cxx:711
void addCurrentPosition()
Definition: wrtsh1.cxx:1869
void GotoMark(const ::sw::mark::IMark *const pMark)
Definition: wrtsh3.cxx:272
void EnterStdMode()
Definition: select.cxx:560
SwNavigationMgr & GetNavigationMgr()
Definition: wrtsh.hxx:485
void GotoFootnoteAnchor(const SwTextFootnote &rTextFootnote)
Definition: move.cxx:747
bool HasSelection() const
Definition: wrtsh.hxx:147
void MoveCursor(bool bWithSelect=false)
Definition: move.cxx:74
const SwView & GetView() const
Definition: wrtsh.hxx:443
static UITestLogger & getInstance()
void logEvent(const EventDescription &rDescription)
static VclPtr< reference_type > Create(Arg &&... arg)
#define FN_REPEAT_SEARCH
Definition: cmdid.h:112
#define FN_POSTIT
Definition: cmdid.h:233
#define FN_PREV_BOOKMARK
Definition: cmdid.h:123
#define FN_FORMAT_PAGE_DLG
Definition: cmdid.h:350
#define FN_NEXT_BOOKMARK
Definition: cmdid.h:122
GotoObjFlags
values can be combined via logical or
Definition: fesh.hxx:88
@ Page
Rect of current page.
@ PageCalc
... page will be formatted if required.
@ PagesArea
Rect covering the pages area.
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:98
@ Database
For old documents the Field-Which IDs must be preserved !!!
FieldUnit
DocumentType eType
void * p
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
long Long
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
SwNodeOffset abs(const SwNodeOffset &a)
Definition: nodeoffset.hxx:34
SwMoveFnCollection const & fnTableStart
Definition: paminit.cxx:54
SwMoveFnCollection const & fnRegionStart
Definition: paminit.cxx:57
SearchLabel
std::map< OUString, OUString > aParameters
sal_uInt16 nLastPhy
Definition: viewsh.hxx:103
sal_uInt16 nFirstPhy
Definition: viewsh.hxx:103
#define SW_MOD()
Definition: swmodule.hxx:254
constexpr SwTwips DOCUMENTBORDER
Definition: swtypes.hxx:79
Left
bool GotoNextRegion(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosRegion, bool bInReadOnly)
Definition: trvlreg.cxx:106
bool GotoPrevRegion(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosRegion, bool bInReadOnly)
Definition: trvlreg.cxx:31
bool GotoNextTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
Definition: trvltbl.cxx:560
bool GotoPrevTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
Definition: trvltbl.cxx:481
#define MAX_MARKS
Definition: view.hxx:84
#define MINZOOM
Definition: view.hxx:81
const tools::Long nLeftOfst
Definition: view.hxx:77
IMPL_LINK(SwView, WindowChildEventListener, VclWindowEvent &, rEvent, void)
Definition: viewmdi.cxx:278
#define NID_SEL
Definition: workctrl.hxx:45
#define NID_TABLE_FORMULA
Definition: workctrl.hxx:51
#define NID_MARK
Definition: workctrl.hxx:47
#define NID_POSTIT
Definition: workctrl.hxx:48
#define NID_TABLE_FORMULA_ERROR
Definition: workctrl.hxx:52
#define NID_OUTL
Definition: workctrl.hxx:44
#define NID_BKM
Definition: workctrl.hxx:41
#define NID_CTRL
Definition: workctrl.hxx:39
#define NID_FIELD_BYTYPE
Definition: workctrl.hxx:55
#define NID_TBL
Definition: workctrl.hxx:35
#define NID_GRF
Definition: workctrl.hxx:42
#define NID_REG
Definition: workctrl.hxx:40
#define NID_DRW
Definition: workctrl.hxx:38
#define NID_PGE
Definition: workctrl.hxx:37
#define NID_FTN
Definition: workctrl.hxx:46
#define NID_RECENCY
Definition: workctrl.hxx:53
#define NID_OLE
Definition: workctrl.hxx:43
#define NID_FRM
Definition: workctrl.hxx:36
#define NID_INDEX_ENTRY
Definition: workctrl.hxx:50
#define NID_FIELD
Definition: workctrl.hxx:54
#define NID_SRCH_REP
Definition: workctrl.hxx:49
SvxZoomType