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