Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / uiview / viewmdi.cxx
blobf07c25e2dfc110060e99732163690fa4c7bfea49
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
42 #include <cmdid.h>
44 #include <PostItMgr.hxx>
45 #include <AnnotationWin.hxx>
47 #include <svx/srchdlg.hxx>
48 #include <svx/svdview.hxx>
50 #include <vcl/uitest/logger.hxx>
51 #include <vcl/uitest/eventdescription.hxx>
53 sal_uInt16 SwView::s_nMoveType = NID_PGE;
54 sal_Int32 SwView::s_nActMark = 0;
56 using namespace ::com::sun::star::uno;
58 namespace {
60 void collectUIInformation(const OUString& aFactor)
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);
73 void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, bool bViewOnly )
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();
81 Invalidate(SID_ZOOM_IN);
82 Invalidate(SID_ZOOM_OUT);
84 collectUIInformation(OUString::number(nFactor));
87 void SwView::SetZoom_( const Size &rEditSize, SvxZoomType eZoomType,
88 short nFactor, bool bViewOnly )
90 bool bUnLockView = !m_pWrtShell->IsViewLocked();
91 m_pWrtShell->LockView( true );
92 m_pWrtShell->LockPaint(LockPaintReason::SetZoom);
94 { // start of SwActContext scope
95 SwActContext aActContext(m_pWrtShell.get());
97 tools::Long nFac = nFactor;
99 const bool bWeb = dynamic_cast< const SwWebView *>( this ) != nullptr;
100 SwMasterUsrPref *pUsrPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(bWeb));
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;
107 if( eZoomType != SvxZoomType::PERCENT )
109 const bool bAutomaticViewLayout = 0 == pOpt->GetViewLayoutColumns();
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() );
116 //mod #i6193# added sidebar width
117 SwPostItMgr* pPostItMgr = GetPostItMgr();
118 if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes())
119 aPageSize.AdjustWidth(pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() );
121 const MapMode aTmpMap( MapUnit::MapTwip );
122 const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
124 if( SvxZoomType::OPTIMAL == eZoomType )
126 // unclear if this is useful for OPTIMAL, or completely useless?
127 if( UseOnPage::Mirror == rDesc.GetUseOn() ) // mirrored pages
129 const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
130 aPageSize.AdjustWidth(std::abs( rLeftLRSpace.GetLeft() - rLRSpace.GetLeft() ) );
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();
138 else if(SvxZoomType::WHOLEPAGE == eZoomType || SvxZoomType::PAGEWIDTH == eZoomType )
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;
146 if ( SvxZoomType::WHOLEPAGE == eZoomType )
148 tools::Long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
149 nFac = std::min( nFac, nVisPercent );
152 else
154 const tools::Long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
155 nFac = aWindowSize.Width() * 100 / nTmpWidth;
159 nFac = std::max( tools::Long( MINZOOM ), nFac );
160 const sal_uInt16 nZoomFac = o3tl::narrowing<sal_uInt16>(nFac);
162 SwViewOption aOpt( *pOpt );
163 if ( !GetViewFrame().GetFrame().IsInPlace() )
165 //Update MasterUsrPrefs and after that update the ViewOptions of the current View.
166 if ( !bViewOnly &&
167 (nZoomFac != pUsrPref->GetZoom() ||
168 eZoomType != pUsrPref->GetZoomType()) )
170 pUsrPref->SetZoom(nZoomFac);
171 pUsrPref->SetZoomType(eZoomType);
172 SW_MOD()->ApplyUsrPref(*pUsrPref, nullptr);
173 pUsrPref->SetModified();
175 if ( pOpt->GetZoom() != nZoomFac )
177 aOpt.SetZoom(nZoomFac);
178 aOpt.SetReadonly(pOpt->IsReadonly());
179 m_pWrtShell->ApplyViewOptions( aOpt );
181 if ( eZoomType != SvxZoomType::PERCENT )
183 Point aPos;
185 if ( eZoomType == SvxZoomType::WHOLEPAGE )
186 aPos.setY( m_pWrtShell->GetAnyCurRect(CurRectType::Page).Top() - DOCUMENTBORDER );
187 else
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() );
199 SetVisArea( aPos );
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
206 else if ( nZoomFac != pOpt->GetZoom() )
208 aOpt.SetZoom( nZoomFac );
209 m_pWrtShell->ApplyViewOptions( aOpt );
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
220 m_pWrtShell->UnlockPaint();
221 if( bUnLockView )
222 m_pWrtShell->LockView( false );
225 void SwView::SetViewLayout( sal_uInt16 nColumns, bool bBookMode, bool bViewOnly )
227 const bool bUnLockView = !m_pWrtShell->IsViewLocked();
228 m_pWrtShell->LockView( true );
229 m_pWrtShell->LockPaint(LockPaintReason::ViewLayout);
233 SwActContext aActContext(m_pWrtShell.get());
235 if ( !GetViewFrame().GetFrame().IsInPlace() && !bViewOnly )
237 const bool bWeb = dynamic_cast< const SwWebView *>( this ) != nullptr;
238 SwMasterUsrPref *pUsrPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(bWeb));
240 // Update MasterUsrPrefs and after that update the ViewOptions of the current View.
241 if ( nColumns != pUsrPref->GetViewLayoutColumns() ||
242 bBookMode != pUsrPref->IsViewLayoutBookMode() )
244 pUsrPref->SetViewLayoutColumns(nColumns);
245 pUsrPref->SetViewLayoutBookMode(bBookMode);
246 SW_MOD()->ApplyUsrPref(*pUsrPref, nullptr);
247 pUsrPref->SetModified();
251 const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
253 if ( nColumns != pOpt->GetViewLayoutColumns() ||
254 bBookMode != pOpt->IsViewLayoutBookMode() )
256 SwViewOption aOpt( *pOpt );
257 aOpt.SetViewLayoutColumns( nColumns );
258 aOpt.SetViewLayoutBookMode( bBookMode );
259 m_pWrtShell->ApplyViewOptions( aOpt );
262 m_pVRuler->ForceUpdate();
263 m_pHRuler->ForceUpdate();
267 m_pWrtShell->UnlockPaint();
268 if( bUnLockView )
269 m_pWrtShell->LockView( false );
271 SfxBindings& rBnd = GetViewFrame().GetBindings();
272 rBnd.Invalidate( SID_ATTR_VIEWLAYOUT );
273 rBnd.Invalidate( SID_ATTR_ZOOMSLIDER);
276 // Scrollbar - Handler
278 IMPL_LINK( SwView, WindowChildEventListener, VclWindowEvent&, rEvent, void )
280 OSL_ENSURE( rEvent.GetWindow(), "Window???" );
281 vcl::Window* pChildWin = static_cast< vcl::Window* >( rEvent.GetData() );
283 switch ( rEvent.GetId() )
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;
301 void SwView::CreateScrollbar( bool bHori )
303 vcl::Window *pMDI = &GetViewFrame().GetWindow();
304 VclPtr<SwScrollbar>& ppScrollbar = bHori ? m_pHScrollbar : m_pVScrollbar;
306 assert(!ppScrollbar); //check beforehand!
308 ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori );
309 UpdateScrollbars();
310 if(bHori)
311 ppScrollbar->SetScrollHdl( LINK( this, SwView, HoriScrollHdl ));
312 else
313 ppScrollbar->SetScrollHdl( LINK( this, SwView, VertScrollHdl ));
315 if(GetWindow())
316 InvalidateBorder();
318 if (!m_bShowAtResize)
319 ppScrollbar->ExtendedShow();
322 IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void )
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)
331 if ( rSh.GetDrawView()->IsTextEdit() )
332 rSh.EndTextEdit();
333 if ( IsDrawMode() )
334 LeaveDrawCreate();
336 if ( NID_POSTIT != s_nMoveType && m_pPostItMgr )
338 sw::annotation::SwAnnotationWin* pActiveSidebarWin = m_pPostItMgr->GetActiveSidebarWin();
339 if (pActiveSidebarWin)
340 pActiveSidebarWin->SwitchToFieldPos();
342 if (NID_RECENCY != s_nMoveType && NID_PGE != s_nMoveType && NID_SRCH_REP != s_nMoveType)
343 rSh.addCurrentPosition();
344 switch( s_nMoveType )
346 case NID_PGE:
348 tools::Long nYPos;
349 SwVisiblePageNumbers aVisiblePageNumbers;
350 rSh.GetFirstLastVisPageNumbers(aVisiblePageNumbers);
351 if ((bNext && aVisiblePageNumbers.nLastPhy + 1 > rSh.GetPageCnt()) ||
352 (!bNext && aVisiblePageNumbers.nFirstPhy == 1))
354 nYPos = rSh.GetPagePos(bNext ? 1 : rSh.GetPageCnt()).Y();
355 SvxSearchDialogWrapper::SetSearchLabel(bNext ? SearchLabel::EndWrapped :
356 SearchLabel::StartWrapped);
358 else
360 auto nPage = bNext ? aVisiblePageNumbers.nLastPhy + 1 :
361 aVisiblePageNumbers.nFirstPhy - 1;
362 nYPos = rSh.GetPagePos(nPage).Y();
363 SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Empty);
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);
373 break;
374 case NID_TBL :
375 rSh.EnterStdMode();
376 if(bNext)
377 rSh.MoveTable(GotoNextTable, fnTableStart);
378 else
379 rSh.MoveTable(GotoPrevTable, fnTableStart);
380 break;
381 case NID_FRM :
382 case NID_GRF:
383 case NID_OLE:
385 GotoObjFlags eType = GotoObjFlags::FlyFrame;
386 if(s_nMoveType == NID_GRF)
387 eType = GotoObjFlags::FlyGrf;
388 else if(s_nMoveType == NID_OLE)
389 eType = GotoObjFlags::FlyOLE;
390 bool bSuccess = bNext ?
391 rSh.GotoNextFly(eType) :
392 rSh.GotoPrevFly(eType);
393 if(bSuccess)
395 rSh.HideCursor();
396 rSh.EnterSelFrameMode();
399 break;
400 case NID_CTRL:
401 if (!rSh.GetView().IsDesignMode())
402 rSh.GetView().GetFormShell()->SetDesignMode(true);
403 [[fallthrough]];
404 case NID_DRW:
406 bool bSuccess = rSh.GotoObj(bNext,
407 s_nMoveType == NID_DRW ?
408 GotoObjFlags::DrawSimple :
409 GotoObjFlags::DrawControl);
410 if(bSuccess)
412 rSh.HideCursor();
413 rSh.EnterSelFrameMode();
416 break;
417 case NID_REG :
418 rSh.EnterStdMode();
419 if(bNext)
420 rSh.MoveRegion(GotoNextRegion, fnRegionStart);
421 else
422 rSh.MoveRegion(GotoPrevRegion, fnRegionStart);
424 break;
425 case NID_BKM :
426 rSh.EnterStdMode();
427 GetViewFrame().GetDispatcher()->Execute(bNext ?
428 FN_NEXT_BOOKMARK :
429 FN_PREV_BOOKMARK);
430 break;
431 case NID_FIELD:
433 rSh.EnterStdMode();
434 rSh.StartAction();
435 SearchLabel eSearchLabel = SearchLabel::Empty;
436 if (!rSh.MoveFieldType(nullptr, bNext, SwFieldIds::Unknown))
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))
448 eSearchLabel = bNext ? SearchLabel::EndWrapped : SearchLabel::StartWrapped;
450 else
452 // no visible fields found
453 pCursor->RestoreSavePos();
454 eSearchLabel = SearchLabel::NavElementNotFound;
457 SvxSearchDialogWrapper::SetSearchLabel(eSearchLabel);
458 rSh.EndAction();
460 break;
461 case NID_FIELD_BYTYPE:
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)
476 if (pTyp->Which() == SwFieldIds::Database)
477 rSh.MoveFieldType(nullptr, bNext, SwFieldIds::Database);
478 else
479 rSh.MoveFieldType(pTyp, bNext);
482 break;
483 case NID_OUTL:
484 rSh.EnterStdMode();
485 bNext ? rSh.GotoNextOutline() : rSh.GotoPrevOutline();
486 break;
487 case NID_SEL :
488 rSh.GoNextPrevCursorSetSearchLabel(bNext);
489 break;
490 case NID_FTN:
492 bool bFrameTypeFootnote(rSh.GetFrameType(nullptr, false) & FrameTypeFlags::FOOTNOTE);
494 if (bFrameTypeFootnote)
496 rSh.LockView(true);
497 rSh.GotoFootnoteAnchor();
500 rSh.EnterStdMode();
501 bNext ?
502 rSh.GotoNextFootnoteAnchor() :
503 rSh.GotoPrevFootnoteAnchor();
505 if (bFrameTypeFootnote)
507 rSh.LockView(false);
508 rSh.GotoFootnoteText();
511 break;
512 case NID_MARK:
514 // unselect
515 rSh.MoveCursor();
516 rSh.EnterStdMode();
518 // collect and sort navigator reminder names
519 IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
520 std::vector< OUString > vNavMarkNames;
521 for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
522 ppMark != pMarkAccess->getAllMarksEnd();
523 ++ppMark)
525 if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::MarkType::NAVIGATOR_REMINDER )
526 vNavMarkNames.push_back((*ppMark)->GetName());
528 std::sort(vNavMarkNames.begin(), vNavMarkNames.end());
530 // move
531 if(!vNavMarkNames.empty())
533 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
535 if(bNext)
537 s_nActMark++;
538 if (s_nActMark >= MAX_MARKS || s_nActMark >= static_cast<sal_Int32>(vNavMarkNames.size()))
540 s_nActMark = 0;
541 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::ReminderEndWrapped );
544 else
546 s_nActMark--;
547 if (s_nActMark < 0 || o3tl::make_unsigned(s_nActMark) >= vNavMarkNames.size())
549 s_nActMark = vNavMarkNames.size()-1;
550 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::ReminderStartWrapped );
553 rSh.GotoMark(vNavMarkNames[s_nActMark]);
555 else
556 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
558 break;
560 case NID_POSTIT:
562 if (m_pPostItMgr->HasNotes())
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)
576 if (!rSh.MoveFieldType(pFieldType, bNext))
578 if (bWrapped)
579 break;
580 bWrapped = true;
581 rSh.SttEndDoc(bNext);
582 continue;
586 auto pAnnotationWin = m_pPostItMgr->GetAnnotationWin(
587 rSh.GetPostItFieldAtCursor());
588 if (pAnnotationWin && pAnnotationWin->IsVisible())
589 bFound = true;
590 } while (!bFound && rSh.MoveFieldType(pFieldType, bNext));
592 if (!bFound)
594 pCursor->RestoreSavePos();
595 SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
597 rSh.EndAction();
598 if (bFound)
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);
608 else
609 SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
611 break;
613 case NID_SRCH_REP:
614 if(s_pSrchItem)
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);
624 break;
625 case NID_INDEX_ENTRY:
626 rSh.GotoNxtPrvTOXMark(bNext);
627 break;
629 case NID_TABLE_FORMULA:
630 rSh.GotoNxtPrvTableFormula( bNext );
631 break;
633 case NID_TABLE_FORMULA_ERROR:
634 rSh.GotoNxtPrvTableFormula( bNext, true );
635 break;
637 case NID_RECENCY :
638 rSh.EnterStdMode();
639 bNext ? rSh.GetNavigationMgr().goForward() : rSh.GetNavigationMgr().goBack();
640 break;
642 if (NID_POSTIT != s_nMoveType)
643 m_pEditWin->GrabFocus();
644 delete pbNext;
647 void SwView::CreateTab()
649 m_pHRuler->SetActive(GetFrame() && IsActive());
651 m_pHRuler->Show();
652 InvalidateBorder();
655 void SwView::KillTab()
657 m_pHRuler->Hide();
658 InvalidateBorder();
661 void SwView::ChangeTabMetric( FieldUnit eUnit )
663 if(m_pHRuler->GetUnit() != eUnit )
665 m_pHRuler->SetUnit( eUnit );
666 m_pHRuler->Invalidate();
670 void SwView::ChangeVRulerMetric( FieldUnit eUnit )
672 if(m_pVRuler->GetUnit() != eUnit)
674 m_pVRuler->SetUnit( eUnit );
675 m_pVRuler->Invalidate();
679 void SwView::GetVRulerMetric(FieldUnit& eToFill) const
681 eToFill = m_pVRuler->GetUnit();
684 void SwView::GetHRulerMetric(FieldUnit& eToFill) const
686 eToFill = m_pHRuler->GetUnit();
689 void SwView::CreateVRuler()
691 m_pHRuler->SetBorderPos( m_pVRuler->GetSizePixel().Width()-1 );
693 m_pVRuler->SetActive(GetFrame() && IsActive());
694 m_pVRuler->Show();
695 InvalidateBorder();
698 void SwView::KillVRuler()
700 m_pVRuler->Hide();
701 m_pHRuler->SetBorderPos();
702 InvalidateBorder();
705 IMPL_LINK( SwView, ExecRulerClick, Ruler *, pRuler, void )
707 OUString sDefPage;
708 TypedWhichId<SfxStringItem> nDefDlg = SID_PARA_DLG;
709 switch( pRuler->GetClickType() )
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";
728 SfxStringItem aDefPage(nDefDlg, sDefPage);
729 GetViewFrame().GetDispatcher()->ExecuteList(nDefDlg,
730 SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
731 { &aDefPage });
734 sal_uInt16 SwView::GetMoveType()
736 return s_nMoveType;
739 void SwView::SetMoveType(sal_uInt16 nSet)
741 s_nMoveType = nSet;
744 void SwView::SetActMark(sal_Int32 nSet)
746 s_nActMark = nSet;
749 void SwView::ShowHScrollbar(bool bShow)
751 assert(m_pHScrollbar && "Scrollbar invalid");
752 m_pHScrollbar->ExtendedShow(bShow);
755 bool SwView::IsHScrollbarVisible()const
757 assert(m_pHScrollbar && "Scrollbar invalid");
758 return m_pHScrollbar->IsScrollbarVisible(false) || m_pHScrollbar->IsAuto();
761 void SwView::ShowVScrollbar(bool bShow)
763 assert(m_pVScrollbar && "Scrollbar invalid");
764 m_pVScrollbar->ExtendedShow(bShow);
767 bool SwView::IsVScrollbarVisible()const
769 assert(m_pVScrollbar && "Scrollbar invalid");
770 return m_pVScrollbar->IsScrollbarVisible(false);
773 void SwView::EnableHScrollbar(bool bEnable)
775 if (m_bHScrollbarEnabled != bEnable)
777 m_bHScrollbarEnabled = bEnable;
778 InvalidateBorder();
782 void SwView::EnableVScrollbar(bool bEnable)
784 if (m_bVScrollbarEnabled != bEnable)
786 m_bVScrollbarEnabled = bEnable;
787 InvalidateBorder();
791 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */