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 <string>
21
22 #include <hintids.hxx>
23 #include <vcl/svapp.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <sfx2/viewfrm.hxx>
26 #include <svx/ruler.hxx>
27 #include <editeng/lrspitem.hxx>
28 #include <svl/srchitem.hxx>
29 #include <svl/stritem.hxx>
30 #include <sfx2/request.hxx>
31 #include <swmodule.hxx>
32 #include <view.hxx>
33 #include <wrtsh.hxx>
34 #include <docsh.hxx>
35 #include <viewopt.hxx>
36 #include <frmatr.hxx>
37 #include <wdocsh.hxx>
38 #include <uitool.hxx>
39 #include <edtwin.hxx>
40 #include <pagedesc.hxx>
41 #include <IMark.hxx>
42 #include <fldbas.hxx>
43 #include <workctrl.hxx>
44 #include <usrpref.hxx>
45 #include <scroll.hxx>
46 #include <wview.hxx>
47
48 #include <cmdid.h>
49 #include <globals.hrc>
50
51 #include <IDocumentSettingAccess.hxx>
52 #include <PostItMgr.hxx>
53 #include <AnnotationWin.hxx>
54
55 #include <svx/srchdlg.hxx>
56 #include <svx/svdview.hxx>
57 #include <svx/svxids.hrc>
58
59 #include <vcl/uitest/logger.hxx>
60 #include <vcl/uitest/eventdescription.hxx>
61
62 sal_uInt16 SwView::m_nMoveType = NID_PGE;
63 sal_Int32 SwView::m_nActMark = 0;
64
65 using namespace ::com::sun::star::uno;
66
67 namespace {
68
collectUIInformation(const OUString & aFactor)69 void collectUIInformation(const OUString& aFactor)
70 {
71 EventDescription aDescription;
72 aDescription.aID = "writer_edit";
73 aDescription.aParameters = {{"ZOOM", aFactor}};
74 aDescription.aAction = "SET";
75 aDescription.aKeyWord = "SwEditWinUIObject";
76 aDescription.aParent = "MainWindow";
77 UITestLogger::getInstance().logEvent(aDescription);
78 }
79
80 }
81
SetZoom(SvxZoomType eZoomType,short nFactor,bool bViewOnly)82 void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, bool bViewOnly )
83 {
84 bool const bCursorIsVisible(m_pWrtShell->IsCursorVisible());
85 SetZoom_( GetEditWin().GetOutputSizePixel(), eZoomType, nFactor, bViewOnly );
86 // fdo#40465 force the cursor to stay in view whilst zooming
87 if (bCursorIsVisible)
88 m_pWrtShell->ShowCursor();
89
90 collectUIInformation(OUString::number(nFactor));
91 }
92
SetZoom_(const Size & rEditSize,SvxZoomType eZoomType,short nFactor,bool bViewOnly)93 void SwView::SetZoom_( const Size &rEditSize, SvxZoomType eZoomType,
94 short nFactor, bool bViewOnly )
95 {
96 bool bUnLockView = !m_pWrtShell->IsViewLocked();
97 m_pWrtShell->LockView( true );
98 m_pWrtShell->LockPaint();
99
100 { // start of SwActContext scope
101 SwActContext aActContext(m_pWrtShell.get());
102
103 long nFac = nFactor;
104
105 const bool bWeb = dynamic_cast< const SwWebView *>( this ) != nullptr;
106 SwMasterUsrPref *pUsrPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(bWeb));
107
108 const SwPageDesc &rDesc = m_pWrtShell->GetPageDesc( m_pWrtShell->GetCurPageDesc() );
109 const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace();
110 const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
111 long lLeftMargin = 0;
112
113 if( eZoomType != SvxZoomType::PERCENT )
114 {
115 const bool bAutomaticViewLayout = 0 == pOpt->GetViewLayoutColumns();
116
117 const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( CurRectType::PageCalc ) );
118 const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( CurRectType::PagesArea ) );
119 Size aPageSize( aPageRect.SSize() );
120 Size aRootSize( aRootRect.SSize() );
121
122 //mod #i6193# added sidebar width
123 SwPostItMgr* pPostItMgr = GetPostItMgr();
124 if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes())
125 aPageSize.AdjustWidth(pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() );
126
127 const MapMode aTmpMap( MapUnit::MapTwip );
128 const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
129
130 if( UseOnPage::Mirror == rDesc.GetUseOn() ) // mirrored pages
131 {
132 const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
133 aPageSize.AdjustWidth(std::abs( rLeftLRSpace.GetLeft() - rLRSpace.GetLeft() ) );
134 }
135
136 if( SvxZoomType::OPTIMAL == eZoomType )
137 {
138 if (!pPostItMgr->HasNotes() || !pPostItMgr->ShowNotes())
139 aPageSize.AdjustWidth( -( rLRSpace.GetLeft() + rLRSpace.GetRight() + nLeftOfst * 2 ) );
140 lLeftMargin = rLRSpace.GetLeft() + DOCUMENTBORDER + nLeftOfst;
141 nFac = aWindowSize.Width() * 100 / aPageSize.Width();
142 }
143 else if(SvxZoomType::WHOLEPAGE == eZoomType || SvxZoomType::PAGEWIDTH == eZoomType )
144 {
145 const long nOf = DOCUMENTBORDER * 2;
146 long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
147 nTmpWidth += nOf;
148 aPageSize.AdjustHeight(nOf );
149 nFac = aWindowSize.Width() * 100 / nTmpWidth;
150
151 if ( SvxZoomType::WHOLEPAGE == eZoomType )
152 {
153 long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
154 nFac = std::min( nFac, nVisPercent );
155 }
156 }
157 else
158 {
159 const long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
160 nFac = aWindowSize.Width() * 100 / nTmpWidth;
161 }
162 }
163
164 nFac = std::max( long( MINZOOM ), nFac );
165 const sal_uInt16 nZoomFac = static_cast<sal_uInt16>(nFac);
166
167 SwViewOption aOpt( *pOpt );
168 if ( !GetViewFrame()->GetFrame().IsInPlace() )
169 {
170 //Update MasterUsrPrefs and after that update the ViewOptions of the current View.
171 if ( !bViewOnly &&
172 (nZoomFac != pUsrPref->GetZoom() ||
173 eZoomType != pUsrPref->GetZoomType()) )
174 {
175 pUsrPref->SetZoom(nZoomFac);
176 pUsrPref->SetZoomType(eZoomType);
177 SW_MOD()->ApplyUsrPref(*pUsrPref, nullptr);
178 pUsrPref->SetModified();
179 }
180 if ( pOpt->GetZoom() != nZoomFac )
181 {
182 aOpt.SetZoom(nZoomFac);
183 aOpt.SetReadonly(pOpt->IsReadonly());
184 m_pWrtShell->ApplyViewOptions( aOpt );
185 }
186 if ( eZoomType != SvxZoomType::PERCENT )
187 {
188 Point aPos;
189
190 if ( eZoomType == SvxZoomType::WHOLEPAGE )
191 aPos.setY( m_pWrtShell->GetAnyCurRect(CurRectType::Page).Top() - DOCUMENTBORDER );
192 else
193 {
194 // Make sure that the cursor is in the visible range, so that
195 // the scrolling will be performed only once.
196 aPos.setX( lLeftMargin );
197 const SwRect &rCharRect = m_pWrtShell->GetCharRect();
198 if ( rCharRect.Top() > GetVisArea().Bottom() ||
199 rCharRect.Bottom() < aPos.Y() )
200 aPos.setY( rCharRect.Top() - rCharRect.Height() );
201 else
202 aPos.setY( GetVisArea().Top() );
203 }
204 SetVisArea( aPos );
205 }
206 // Compromise solution - Under certain circumstances SetZoom is called
207 // in CalcVisAreas again and thus be set wrong values.
208 const_cast<SwViewOption*>(m_pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
209 CalcVisArea( rEditSize ); // for the recalculation of the viewable area
210 }
211 else if ( nZoomFac != pOpt->GetZoom() )
212 {
213 aOpt.SetZoom( nZoomFac );
214 m_pWrtShell->ApplyViewOptions( aOpt );
215 }
216
217 const Fraction aFrac( nFac, 100 );
218 m_pVRuler->SetZoom( aFrac );
219 m_pVRuler->ForceUpdate();
220 m_pHRuler->SetZoom( aFrac );
221 m_pHRuler->ForceUpdate();
222 const_cast<SwViewOption*>(m_pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
223 } // end of SwActContext scope
224
225 m_pWrtShell->UnlockPaint();
226 if( bUnLockView )
227 m_pWrtShell->LockView( false );
228 }
229
SetViewLayout(sal_uInt16 nColumns,bool bBookMode,bool bViewOnly)230 void SwView::SetViewLayout( sal_uInt16 nColumns, bool bBookMode, bool bViewOnly )
231 {
232 const bool bUnLockView = !m_pWrtShell->IsViewLocked();
233 m_pWrtShell->LockView( true );
234 m_pWrtShell->LockPaint();
235
236 {
237
238 SwActContext aActContext(m_pWrtShell.get());
239
240 if ( !GetViewFrame()->GetFrame().IsInPlace() && !bViewOnly )
241 {
242 const bool bWeb = dynamic_cast< const SwWebView *>( this ) != nullptr;
243 SwMasterUsrPref *pUsrPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(bWeb));
244
245 // Update MasterUsrPrefs and after that update the ViewOptions of the current View.
246 if ( nColumns != pUsrPref->GetViewLayoutColumns() ||
247 bBookMode != pUsrPref->IsViewLayoutBookMode() )
248 {
249 pUsrPref->SetViewLayoutColumns(nColumns);
250 pUsrPref->SetViewLayoutBookMode(bBookMode);
251 SW_MOD()->ApplyUsrPref(*pUsrPref, nullptr);
252 pUsrPref->SetModified();
253 }
254 }
255
256 const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
257
258 if ( nColumns != pOpt->GetViewLayoutColumns() ||
259 bBookMode != pOpt->IsViewLayoutBookMode() )
260 {
261 SwViewOption aOpt( *pOpt );
262 aOpt.SetViewLayoutColumns( nColumns );
263 aOpt.SetViewLayoutBookMode( bBookMode );
264 m_pWrtShell->ApplyViewOptions( aOpt );
265 }
266
267 m_pVRuler->ForceUpdate();
268 m_pHRuler->ForceUpdate();
269
270 }
271
272 m_pWrtShell->UnlockPaint();
273 if( bUnLockView )
274 m_pWrtShell->LockView( false );
275
276 SfxBindings& rBnd = GetViewFrame()->GetBindings();
277 rBnd.Invalidate( SID_ATTR_VIEWLAYOUT );
278 rBnd.Invalidate( SID_ATTR_ZOOMSLIDER);
279 }
280
281 // Scrollbar - Handler
282
IMPL_LINK(SwView,WindowChildEventListener,VclWindowEvent &,rEvent,void)283 IMPL_LINK( SwView, WindowChildEventListener, VclWindowEvent&, rEvent, void )
284 {
285 OSL_ENSURE( rEvent.GetWindow(), "Window???" );
286 vcl::Window* pChildWin = static_cast< vcl::Window* >( rEvent.GetData() );
287
288 switch ( rEvent.GetId() )
289 {
290 case VclEventId::WindowHide:
291 if( pChildWin == m_pHScrollbar )
292 ShowHScrollbar( false );
293 else if( pChildWin == m_pVScrollbar )
294 ShowVScrollbar( false );
295 break;
296 case VclEventId::WindowShow:
297 if( pChildWin == m_pHScrollbar )
298 ShowHScrollbar( true );
299 else if( pChildWin == m_pVScrollbar )
300 ShowVScrollbar( true );
301 break;
302 default: break;
303 }
304 }
305
CreateScrollbar(bool bHori)306 void SwView::CreateScrollbar( bool bHori )
307 {
308 vcl::Window *pMDI = &GetViewFrame()->GetWindow();
309 VclPtr<SwScrollbar>& ppScrollbar = bHori ? m_pHScrollbar : m_pVScrollbar;
310
311 assert(!ppScrollbar.get()); //check beforehand!
312
313 ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori );
314 UpdateScrollbars();
315 if(bHori)
316 ppScrollbar->SetScrollHdl( LINK( this, SwView, EndScrollHdl ));
317 else
318 ppScrollbar->SetScrollHdl( LINK( this, SwView, ScrollHdl ));
319 ppScrollbar->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl ));
320
321 ppScrollbar->EnableDrag();
322
323 if(GetWindow())
324 InvalidateBorder();
325
326 if (!m_bShowAtResize)
327 ppScrollbar->ExtendedShow();
328 }
329
IMPL_LINK(SwView,MoveNavigationHdl,void *,p,void)330 IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void )
331 {
332 bool* pbNext = static_cast<bool*>(p);
333 if ( !pbNext )
334 return;
335 const bool bNext = *pbNext;
336 SwWrtShell& rSh = GetWrtShell();
337 if ( NID_SRCH_REP != m_nMoveType)
338 {
339 if ( rSh.GetDrawView()->IsTextEdit() )
340 rSh.EndTextEdit();
341 if ( IsDrawMode() )
342 LeaveDrawCreate();
343 }
344 if ( NID_POSTIT != m_nMoveType && m_pPostItMgr )
345 {
346 sw::annotation::SwAnnotationWin* pActiveSidebarWin = m_pPostItMgr->GetActiveSidebarWin();
347 if (pActiveSidebarWin)
348 pActiveSidebarWin->SwitchToFieldPos();
349 }
350 switch( m_nMoveType )
351 {
352 case NID_PGE:
353 if ( bNext )
354 {
355 if ( USHRT_MAX == rSh.GetNextPrevPageNum( true ) )
356 {
357 rSh.GotoPage( 1, true );
358 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
359 }
360 else
361 {
362 PhyPageDown();
363 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
364 }
365 }
366 else
367 {
368 if ( USHRT_MAX == rSh.GetNextPrevPageNum( false ) )
369 {
370 rSh.GotoPage( rSh.GetPageCnt(), true );
371 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
372 }
373 else
374 {
375 PhyPageUp();
376 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
377 }
378 }
379 break;
380 case NID_TBL :
381 rSh.EnterStdMode();
382 if(bNext)
383 rSh.MoveTable(GotoNextTable, fnTableStart);
384 else
385 rSh.MoveTable(GotoPrevTable, fnTableStart);
386 break;
387 case NID_FRM :
388 case NID_GRF:
389 case NID_OLE:
390 {
391 GotoObjFlags eType = GotoObjFlags::FlyFrame;
392 if(m_nMoveType == NID_GRF)
393 eType = GotoObjFlags::FlyGrf;
394 else if(m_nMoveType == NID_OLE)
395 eType = GotoObjFlags::FlyOLE;
396 bool bSuccess = bNext ?
397 rSh.GotoNextFly(eType) :
398 rSh.GotoPrevFly(eType);
399 if(bSuccess)
400 {
401 rSh.HideCursor();
402 rSh.EnterSelFrameMode();
403 }
404 }
405 break;
406 case NID_CTRL:
407 if (!rSh.GetView().IsDesignMode())
408 rSh.GetView().GetFormShell()->SetDesignMode(true);
409 [[fallthrough]];
410 case NID_DRW:
411 {
412 bool bSuccess = rSh.GotoObj(bNext,
413 m_nMoveType == NID_DRW ?
414 GotoObjFlags::DrawSimple :
415 GotoObjFlags::DrawControl);
416 if(bSuccess)
417 {
418 rSh.HideCursor();
419 rSh.EnterSelFrameMode();
420 }
421 }
422 break;
423 case NID_REG :
424 rSh.EnterStdMode();
425 if(bNext)
426 rSh.MoveRegion(GotoNextRegion, fnRegionStart);
427 else
428 rSh.MoveRegion(GotoPrevRegion, fnRegionStart);
429
430 break;
431 case NID_BKM :
432 rSh.EnterStdMode();
433 GetViewFrame()->GetDispatcher()->Execute(bNext ?
434 FN_NEXT_BOOKMARK :
435 FN_PREV_BOOKMARK);
436 break;
437 case NID_OUTL:
438 rSh.EnterStdMode();
439 bNext ? rSh.GotoNextOutline() : rSh.GotoPrevOutline();
440 break;
441 case NID_SEL :
442 rSh.GoNextPrevCursorSetSearchLabel(bNext);
443 break;
444 case NID_FTN:
445 {
446 bool bFrameTypeFootnote(rSh.GetFrameType(nullptr, false) & FrameTypeFlags::FOOTNOTE);
447
448 if (bFrameTypeFootnote)
449 {
450 rSh.LockView(true);
451 rSh.GotoFootnoteAnchor();
452 }
453
454 rSh.EnterStdMode();
455 bNext ?
456 rSh.GotoNextFootnoteAnchor() :
457 rSh.GotoPrevFootnoteAnchor();
458
459 if (bFrameTypeFootnote)
460 {
461 rSh.LockView(false);
462 rSh.GotoFootnoteText();
463 }
464 }
465 break;
466 case NID_MARK:
467 {
468 // unselect
469 rSh.MoveCursor();
470 rSh.EnterStdMode();
471
472 // collect navigator reminders
473 IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
474 std::vector< const ::sw::mark::IMark* > vNavMarks;
475 for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
476 ppMark != pMarkAccess->getAllMarksEnd();
477 ++ppMark)
478 {
479 if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::MarkType::NAVIGATOR_REMINDER )
480 vNavMarks.push_back(*ppMark);
481 }
482
483 // move
484 if(!vNavMarks.empty())
485 {
486 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
487
488 if(bNext)
489 {
490 m_nActMark++;
491 if (m_nActMark >= MAX_MARKS || m_nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
492 {
493 m_nActMark = 0;
494 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
495 }
496 }
497 else
498 {
499 m_nActMark--;
500 if (m_nActMark < 0 || m_nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
501 {
502 m_nActMark = vNavMarks.size()-1;
503 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
504 }
505 }
506 rSh.GotoMark(vNavMarks[m_nActMark]);
507 }
508 else
509 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
510 }
511 break;
512
513 case NID_POSTIT:
514 {
515 if ( m_pPostItMgr->HasNotes() )
516 {
517 rSh.EnterStdMode();
518 sw::annotation::SwAnnotationWin* pPostIt = GetPostItMgr()->GetActiveSidebarWin();
519 if (pPostIt)
520 GetPostItMgr()->SetActiveSidebarWin(nullptr);
521 SwFieldType* pFieldType = rSh.GetFieldType(0, SwFieldIds::Postit);
522 if ( !rSh.MoveFieldType( pFieldType, bNext ) )
523 {
524 bNext ? (*(m_pPostItMgr->begin()))->pPostIt->GotoPos() :
525 (*(m_pPostItMgr->end()-1))->pPostIt->GotoPos();
526 SvxSearchDialogWrapper::SetSearchLabel( bNext ? SearchLabel::EndWrapped : SearchLabel::StartWrapped );
527 }
528 else
529 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
530 GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
531 }
532 else
533 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
534 }
535 break;
536
537 case NID_SRCH_REP:
538 if(s_pSrchItem)
539 {
540 bool bBackward = s_pSrchItem->GetBackward();
541 if (rSh.HasSelection() && bNext != rSh.IsCursorPtAtEnd())
542 rSh.SwapPam();
543 s_pSrchItem->SetBackward(!bNext);
544 SfxRequest aReq(FN_REPEAT_SEARCH, SfxCallMode::SLOT, GetPool());
545 ExecSearch(aReq);
546 s_pSrchItem->SetBackward(bBackward);
547 }
548 break;
549 case NID_INDEX_ENTRY:
550 rSh.GotoNxtPrvTOXMark(bNext);
551 break;
552
553 case NID_TABLE_FORMULA:
554 rSh.GotoNxtPrvTableFormula( bNext );
555 break;
556
557 case NID_TABLE_FORMULA_ERROR:
558 rSh.GotoNxtPrvTableFormula( bNext, true );
559 break;
560 }
561 m_pEditWin->GrabFocus();
562 delete pbNext;
563 }
564
CreateTab()565 void SwView::CreateTab()
566 {
567 m_pHRuler->SetActive(GetFrame() && IsActive());
568
569 m_pHRuler->Show();
570 InvalidateBorder();
571 }
572
KillTab()573 void SwView::KillTab()
574 {
575 m_pHRuler->Hide();
576 InvalidateBorder();
577 }
578
ChangeTabMetric(FieldUnit eUnit)579 void SwView::ChangeTabMetric( FieldUnit eUnit )
580 {
581 if(m_pHRuler->GetUnit() != eUnit )
582 {
583 m_pHRuler->SetUnit( eUnit );
584 m_pHRuler->Invalidate();
585 }
586 }
587
ChangeVRulerMetric(FieldUnit eUnit)588 void SwView::ChangeVRulerMetric( FieldUnit eUnit )
589 {
590 if(m_pVRuler->GetUnit() != eUnit)
591 {
592 m_pVRuler->SetUnit( eUnit );
593 m_pVRuler->Invalidate();
594 }
595 }
596
GetVRulerMetric(FieldUnit & eToFill) const597 void SwView::GetVRulerMetric(FieldUnit& eToFill) const
598 {
599 eToFill = m_pVRuler->GetUnit();
600 }
601
GetHRulerMetric(FieldUnit & eToFill) const602 void SwView::GetHRulerMetric(FieldUnit& eToFill) const
603 {
604 eToFill = m_pHRuler->GetUnit();
605 }
606
CreateVRuler()607 void SwView::CreateVRuler()
608 {
609 m_pHRuler->SetBorderPos( m_pVRuler->GetSizePixel().Width()-1 );
610
611 m_pVRuler->SetActive(GetFrame() && IsActive());
612 m_pVRuler->Show();
613 InvalidateBorder();
614 }
615
KillVRuler()616 void SwView::KillVRuler()
617 {
618 m_pVRuler->Hide();
619 m_pHRuler->SetBorderPos();
620 InvalidateBorder();
621 }
622
IMPL_LINK(SwView,ExecRulerClick,Ruler *,pRuler,void)623 IMPL_LINK( SwView, ExecRulerClick, Ruler *, pRuler, void )
624 {
625 OUString sDefPage;
626 sal_uInt16 nDefDlg = SID_PARA_DLG;
627 switch( pRuler->GetClickType() )
628 {
629 case RulerType::DontKnow:
630 case RulerType::Outside:
631 sDefPage="labelTP_BORDER";
632 break;
633 case RulerType::Indent:
634 sDefPage="labelTP_PARA_STD";
635 break;
636 case RulerType::Margin1:
637 case RulerType::Margin2:
638 nDefDlg= FN_FORMAT_PAGE_DLG;
639 sDefPage = "page";
640 break;
641 default:
642 sDefPage = "labelTP_TABULATOR";
643
644 }
645
646 SfxStringItem aDefPage(nDefDlg, sDefPage);
647 GetViewFrame()->GetDispatcher()->ExecuteList(nDefDlg,
648 SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
649 { &aDefPage });
650 }
651
GetMoveType()652 sal_uInt16 SwView::GetMoveType()
653 {
654 return m_nMoveType;
655 }
656
SetMoveType(sal_uInt16 nSet)657 void SwView::SetMoveType(sal_uInt16 nSet)
658 {
659 m_nMoveType = nSet;
660 }
661
SetActMark(sal_Int32 nSet)662 void SwView::SetActMark(sal_Int32 nSet)
663 {
664 m_nActMark = nSet;
665 }
666
ShowHScrollbar(bool bShow)667 void SwView::ShowHScrollbar(bool bShow)
668 {
669 assert(m_pHScrollbar && "Scrollbar invalid");
670 m_pHScrollbar->ExtendedShow(bShow);
671 }
672
IsHScrollbarVisible() const673 bool SwView::IsHScrollbarVisible()const
674 {
675 assert(m_pHScrollbar && "Scrollbar invalid");
676 return m_pHScrollbar->IsVisible( false ) || m_pHScrollbar->IsAuto();
677 }
678
ShowVScrollbar(bool bShow)679 void SwView::ShowVScrollbar(bool bShow)
680 {
681 assert(m_pVScrollbar && "Scrollbar invalid");
682 m_pVScrollbar->ExtendedShow(bShow);
683 }
684
IsVScrollbarVisible() const685 bool SwView::IsVScrollbarVisible()const
686 {
687 assert(m_pVScrollbar && "Scrollbar invalid");
688 return m_pVScrollbar->IsVisible( false );
689 }
690
EnableHScrollbar(bool bEnable)691 void SwView::EnableHScrollbar(bool bEnable)
692 {
693 if (m_bHScrollbarEnabled != bEnable)
694 {
695 m_bHScrollbarEnabled = bEnable;
696 InvalidateBorder();
697 }
698 }
699
EnableVScrollbar(bool bEnable)700 void SwView::EnableVScrollbar(bool bEnable)
701 {
702 if (m_bVScrollbarEnabled != bEnable)
703 {
704 m_bVScrollbarEnabled = bEnable;
705 InvalidateBorder();
706 }
707 }
708
709 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
710