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>
50 #include <vcl/uitest/eventdescription.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 
collectUIInformation(const OUString & aFactor)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 
SetZoom(SvxZoomType eZoomType,short nFactor,bool bViewOnly)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 
SetZoom_(const Size & rEditSize,SvxZoomType eZoomType,short nFactor,bool bViewOnly)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 );
212     m_pVRuler->ForceUpdate();
213     m_pHRuler->SetZoom( aFrac );
214     m_pHRuler->ForceUpdate();
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 
SetViewLayout(sal_uInt16 nColumns,bool bBookMode,bool bViewOnly)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 
260     m_pVRuler->ForceUpdate();
261     m_pHRuler->ForceUpdate();
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 
IMPL_LINK(SwView,WindowChildEventListener,VclWindowEvent &,rEvent,void)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 
CreateScrollbar(bool bHori)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 );
307     UpdateScrollbars();
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())
317         InvalidateBorder();
318 
319     if (!m_bShowAtResize)
320         ppScrollbar->ExtendedShow();
321 }
322 
IMPL_LINK(SwView,MoveNavigationHdl,void *,p,void)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)
372                 rSh.MoveTable(GotoNextTable, fnTableStart);
373             else
374                 rSh.MoveTable(GotoPrevTable, fnTableStart);
375         break;
376         case NID_FRM :
377         case NID_GRF:
378         case NID_OLE:
379         {
380             GotoObjFlags eType = GotoObjFlags::FlyFrame;
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 ?
403                         GotoObjFlags::DrawSimple :
404                         GotoObjFlags::DrawControl);
405             if(bSuccess)
406             {
407                 rSh.HideCursor();
408                 rSh.EnterSelFrameMode();
409             }
410         }
411         break;
412         case NID_REG :
413             rSh.EnterStdMode();
414             if(bNext)
415                 rSh.MoveRegion(GotoNextRegion, fnRegionStart);
416             else
417                 rSh.MoveRegion(GotoPrevRegion, fnRegionStart);
418 
419         break;
420         case NID_BKM :
421             rSh.EnterStdMode();
422             GetViewFrame()->GetDispatcher()->Execute(bNext ?
423                                         FN_NEXT_BOOKMARK :
424                                             FN_PREV_BOOKMARK);
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 :
457             rSh.GoNextPrevCursorSetSearchLabel(bNext);
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() :
472                     rSh.GotoPrevFootnoteAnchor();
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             {
494                 if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::MarkType::NAVIGATOR_REMINDER )
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 
591         case NID_TABLE_FORMULA_ERROR:
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 
CreateTab()604 void SwView::CreateTab()
605 {
606     m_pHRuler->SetActive(GetFrame() && IsActive());
607 
608     m_pHRuler->Show();
609     InvalidateBorder();
610 }
611 
KillTab()612 void SwView::KillTab()
613 {
614     m_pHRuler->Hide();
615     InvalidateBorder();
616 }
617 
ChangeTabMetric(FieldUnit eUnit)618 void SwView::ChangeTabMetric( FieldUnit eUnit )
619 {
620     if(m_pHRuler->GetUnit() != eUnit )
621     {
622         m_pHRuler->SetUnit( eUnit );
623         m_pHRuler->Invalidate();
624     }
625 }
626 
ChangeVRulerMetric(FieldUnit eUnit)627 void SwView::ChangeVRulerMetric( FieldUnit eUnit )
628 {
629     if(m_pVRuler->GetUnit() != eUnit)
630     {
631         m_pVRuler->SetUnit( eUnit );
632         m_pVRuler->Invalidate();
633     }
634 }
635 
GetVRulerMetric(FieldUnit & eToFill) const636 void SwView::GetVRulerMetric(FieldUnit& eToFill) const
637 {
638     eToFill = m_pVRuler->GetUnit();
639 }
640 
GetHRulerMetric(FieldUnit & eToFill) const641 void SwView::GetHRulerMetric(FieldUnit& eToFill) const
642 {
643     eToFill = m_pHRuler->GetUnit();
644 }
645 
CreateVRuler()646 void SwView::CreateVRuler()
647 {
648     m_pHRuler->SetBorderPos( m_pVRuler->GetSizePixel().Width()-1 );
649 
650     m_pVRuler->SetActive(GetFrame() && IsActive());
651     m_pVRuler->Show();
652     InvalidateBorder();
653 }
654 
KillVRuler()655 void SwView::KillVRuler()
656 {
657     m_pVRuler->Hide();
658     m_pHRuler->SetBorderPos();
659     InvalidateBorder();
660 }
661 
IMPL_LINK(SwView,ExecRulerClick,Ruler *,pRuler,void)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 
GetMoveType()691 sal_uInt16 SwView::GetMoveType()
692 {
693     return m_nMoveType;
694 }
695 
SetMoveType(sal_uInt16 nSet)696 void SwView::SetMoveType(sal_uInt16 nSet)
697 {
698     m_nMoveType = nSet;
699 }
700 
SetActMark(sal_Int32 nSet)701 void SwView::SetActMark(sal_Int32 nSet)
702 {
703     m_nActMark = nSet;
704 }
705 
ShowHScrollbar(bool bShow)706 void SwView::ShowHScrollbar(bool bShow)
707 {
708     assert(m_pHScrollbar && "Scrollbar invalid");
709     m_pHScrollbar->ExtendedShow(bShow);
710 }
711 
IsHScrollbarVisible() const712 bool SwView::IsHScrollbarVisible()const
713 {
714     assert(m_pHScrollbar && "Scrollbar invalid");
715     return m_pHScrollbar->IsVisible( false ) || m_pHScrollbar->IsAuto();
716 }
717 
ShowVScrollbar(bool bShow)718 void SwView::ShowVScrollbar(bool bShow)
719 {
720     assert(m_pVScrollbar && "Scrollbar invalid");
721     m_pVScrollbar->ExtendedShow(bShow);
722 }
723 
IsVScrollbarVisible() const724 bool SwView::IsVScrollbarVisible()const
725 {
726     assert(m_pVScrollbar && "Scrollbar invalid");
727     return m_pVScrollbar->IsVisible( false );
728 }
729 
EnableHScrollbar(bool bEnable)730 void SwView::EnableHScrollbar(bool bEnable)
731 {
732     if (m_bHScrollbarEnabled != bEnable)
733     {
734         m_bHScrollbarEnabled = bEnable;
735         InvalidateBorder();
736     }
737 }
738 
EnableVScrollbar(bool bEnable)739 void SwView::EnableVScrollbar(bool bEnable)
740 {
741     if (m_bVScrollbarEnabled != bEnable)
742     {
743         m_bVScrollbarEnabled = bEnable;
744         InvalidateBorder();
745     }
746 }
747 
748 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
749