Line data Source code
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 :
21 : #include <string>
22 :
23 : #include "hintids.hxx"
24 : #include <vcl/svapp.hxx>
25 : #include <sfx2/dispatch.hxx>
26 : #include <svx/ruler.hxx>
27 : #include <editeng/lrspitem.hxx>
28 : #include <svl/srchitem.hxx>
29 : #include <sfx2/request.hxx>
30 : #include <swmodule.hxx>
31 : #include <view.hxx>
32 : #include <wrtsh.hxx>
33 : #include <docsh.hxx>
34 : #include <viewopt.hxx>
35 : #include <frmatr.hxx>
36 : #include <wdocsh.hxx>
37 : #include <uitool.hxx>
38 : #include <edtwin.hxx>
39 : #include <pagedesc.hxx>
40 : #include <IMark.hxx>
41 : #include <fldbas.hxx>
42 : #include <workctrl.hxx>
43 : #include <usrpref.hxx>
44 : #include <scroll.hxx>
45 : #include <wview.hxx>
46 :
47 : #include <cmdid.h>
48 : #include <view.hrc>
49 : #include <ribbar.hrc>
50 : #include <helpid.h>
51 : #include <globals.hrc>
52 :
53 : #include <IDocumentSettingAccess.hxx>
54 : #include <PostItMgr.hxx>
55 :
56 : sal_uInt16 SwView::m_nMoveType = NID_PGE;
57 : sal_Int32 SwView::m_nActMark = 0;
58 :
59 :
60 : #define VIEW_IMAGECOLOR COL_LIGHTBLUE
61 :
62 : using namespace ::com::sun::star::uno;
63 : using namespace ::com::sun::star::frame;
64 :
65 84 : void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, sal_Bool bViewOnly )
66 : {
67 84 : bool const bCrsrIsVisible(m_pWrtShell->IsCrsrVisible());
68 84 : _SetZoom( GetEditWin().GetOutputSizePixel(), eZoomType, nFactor, bViewOnly );
69 : // fdo#40465 force the cursor to stay in view whilst zooming
70 84 : if (bCrsrIsVisible)
71 45 : m_pWrtShell->ShowCrsr();
72 84 : }
73 :
74 85 : void SwView::_SetZoom( const Size &rEditSize, SvxZoomType eZoomType,
75 : short nFactor, sal_Bool bViewOnly )
76 : {
77 85 : sal_Bool bUnLockView = !m_pWrtShell->IsViewLocked();
78 85 : m_pWrtShell->LockView( sal_True );
79 85 : m_pWrtShell->LockPaint();
80 :
81 : {
82 85 : SwActContext aActContext(m_pWrtShell);
83 :
84 85 : long nFac = nFactor;
85 :
86 85 : sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
87 85 : SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb);
88 :
89 85 : const SwPageDesc &rDesc = m_pWrtShell->GetPageDesc( m_pWrtShell->GetCurPageDesc() );
90 85 : const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace();
91 85 : const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
92 85 : long lLeftMargin = 0;
93 :
94 85 : if( eZoomType != SVX_ZOOM_PERCENT )
95 : {
96 6 : const bool bAutomaticViewLayout = 0 == pOpt->GetViewLayoutColumns();
97 :
98 6 : const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
99 6 : const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) );
100 6 : Size aPageSize( aPageRect.SSize() );
101 6 : Size aRootSize( aRootRect.SSize() );
102 :
103 : //mod #i6193# added sidebar width
104 6 : SwPostItMgr* pPostItMgr = GetPostItMgr();
105 6 : if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes())
106 0 : aPageSize.Width() += pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth();
107 :
108 6 : const MapMode aTmpMap( MAP_TWIP );
109 6 : const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
110 :
111 6 : if( nsUseOnPage::PD_MIRROR == rDesc.GetUseOn() ) // gespiegelte Seiten
112 : {
113 0 : const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
114 0 : aPageSize.Width() += std::abs( long(rLeftLRSpace.GetLeft()) - long(rLRSpace.GetLeft()) );
115 : }
116 :
117 6 : if( SVX_ZOOM_OPTIMAL == eZoomType )
118 : {
119 0 : if (!pPostItMgr->HasNotes() || !pPostItMgr->ShowNotes())
120 0 : aPageSize.Width() -= ( rLRSpace.GetLeft() + rLRSpace.GetRight() + nLeftOfst * 2 );
121 0 : lLeftMargin = long(rLRSpace.GetLeft()) + DOCUMENTBORDER + nLeftOfst;
122 0 : nFac = aWindowSize.Width() * 100 / aPageSize.Width();
123 : }
124 6 : else if(SVX_ZOOM_WHOLEPAGE == eZoomType || SVX_ZOOM_PAGEWIDTH == eZoomType )
125 : {
126 2 : const long nOf = DOCUMENTBORDER * 2L;
127 2 : long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
128 2 : nTmpWidth += nOf;
129 2 : aPageSize.Height() += nOf;
130 2 : nFac = aWindowSize.Width() * 100 / nTmpWidth;
131 :
132 2 : if ( SVX_ZOOM_WHOLEPAGE == eZoomType )
133 : {
134 0 : long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
135 0 : nFac = std::min( nFac, nVisPercent );
136 2 : }
137 : }
138 : else
139 : {
140 4 : const long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
141 4 : nFac = aWindowSize.Width() * 100 / nTmpWidth;
142 6 : }
143 : }
144 :
145 85 : nFac = std::max( long( MINZOOM ), nFac );
146 :
147 170 : SwViewOption aOpt( *pOpt );
148 85 : if ( !GetViewFrame()->GetFrame().IsInPlace() )
149 : {
150 : //MasterUsrPrefs updaten UND DANACH die ViewOptions der aktuellen
151 : //View updaten.
152 85 : if ( !bViewOnly &&
153 0 : (sal_uInt16(nFac) != pUsrPref->GetZoom() ||
154 0 : sal_uInt8 (eZoomType) != pUsrPref->GetZoomType()) )
155 : {
156 0 : pUsrPref->SetZoom ( sal_uInt16(nFac) );
157 0 : pUsrPref->SetZoomType( eZoomType );
158 0 : SW_MOD()->ApplyUsrPref( *pUsrPref,
159 : bViewOnly ? this: 0,
160 0 : bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 );
161 0 : pUsrPref->SetModified();
162 : }
163 85 : if ( pOpt->GetZoom() != (sal_uInt16) nFac )
164 : {
165 80 : aOpt.SetZoom ( sal_uInt16(nFac) );
166 80 : aOpt.SetReadonly(pOpt->IsReadonly());
167 80 : m_pWrtShell->ApplyViewOptions( aOpt );
168 : }
169 85 : if ( eZoomType != SVX_ZOOM_PERCENT )
170 : {
171 6 : Point aPos;
172 :
173 6 : if ( eZoomType == SVX_ZOOM_WHOLEPAGE )
174 0 : aPos.Y() = m_pWrtShell->GetAnyCurRect(RECT_PAGE).Top() - DOCUMENTBORDER;
175 : else
176 : {
177 : //sicherstellen, dass sich der Cursor im sichtbaren
178 : //Bereich befindet, damit nur 1x gescrollt wird
179 6 : aPos.X() = lLeftMargin;
180 6 : const SwRect &rCharRect = m_pWrtShell->GetCharRect();
181 12 : if ( rCharRect.Top() > GetVisArea().Bottom() ||
182 6 : rCharRect.Bottom() < aPos.Y() )
183 0 : aPos.Y() = rCharRect.Top() - rCharRect.Height();
184 : else
185 6 : aPos.Y() = GetVisArea().Top();
186 : }
187 6 : SetVisArea( aPos );
188 : }
189 : // OS: Notloesung - in CalcVisArea wird u.U. wieder SetZoom gerufen und
190 : // dann werden falsche Werte eingestellt
191 85 : ((SwViewOption*)m_pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
192 85 : CalcVisArea( rEditSize ); //fuer das Neuberechnen des sichtbaren Bereiches
193 : }
194 0 : else if ( sal_uInt16(nFac) != pOpt->GetZoom() )
195 : {
196 0 : aOpt.SetZoom ( sal_uInt16(nFac) );
197 0 : m_pWrtShell->ApplyViewOptions( aOpt );
198 : }
199 :
200 85 : const Fraction aFrac( nFac, 100 );
201 85 : m_pVRuler->SetZoom( aFrac );
202 85 : m_pVRuler->ForceUpdate();
203 85 : m_pHRuler->SetZoom( aFrac );
204 85 : m_pHRuler->ForceUpdate();
205 170 : ((SwViewOption*)m_pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
206 : }
207 85 : m_pWrtShell->UnlockPaint();
208 85 : if( bUnLockView )
209 84 : m_pWrtShell->LockView( sal_False );
210 85 : }
211 :
212 2 : void SwView::SetViewLayout( sal_uInt16 nColumns, bool bBookMode, sal_Bool bViewOnly )
213 : {
214 2 : const sal_Bool bUnLockView = !m_pWrtShell->IsViewLocked();
215 2 : m_pWrtShell->LockView( sal_True );
216 2 : m_pWrtShell->LockPaint();
217 :
218 : {
219 :
220 2 : SwActContext aActContext(m_pWrtShell);
221 :
222 2 : if ( !GetViewFrame()->GetFrame().IsInPlace() && !bViewOnly )
223 : {
224 0 : const sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
225 0 : SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb);
226 :
227 : //MasterUsrPrefs updaten UND DANACH die ViewOptions der aktuellen
228 : //View updaten.
229 0 : if ( nColumns != pUsrPref->GetViewLayoutColumns() ||
230 0 : bBookMode != pUsrPref->IsViewLayoutBookMode() )
231 : {
232 0 : pUsrPref->SetViewLayoutColumns( nColumns );
233 0 : pUsrPref->SetViewLayoutBookMode( bBookMode );
234 0 : SW_MOD()->ApplyUsrPref( *pUsrPref,
235 : bViewOnly ? this: 0,
236 0 : bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 );
237 0 : pUsrPref->SetModified();
238 : }
239 : }
240 :
241 2 : const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
242 :
243 2 : if ( nColumns != pOpt->GetViewLayoutColumns() ||
244 0 : bBookMode != pOpt->IsViewLayoutBookMode() )
245 : {
246 2 : SwViewOption aOpt( *pOpt );
247 2 : aOpt.SetViewLayoutColumns( nColumns );
248 2 : aOpt.SetViewLayoutBookMode( bBookMode );
249 2 : m_pWrtShell->ApplyViewOptions( aOpt );
250 : }
251 :
252 2 : m_pVRuler->ForceUpdate();
253 2 : m_pHRuler->ForceUpdate();
254 :
255 : }
256 :
257 2 : m_pWrtShell->UnlockPaint();
258 2 : if( bUnLockView )
259 2 : m_pWrtShell->LockView( sal_False );
260 :
261 2 : SfxBindings& rBnd = GetViewFrame()->GetBindings();
262 2 : rBnd.Invalidate( SID_ATTR_VIEWLAYOUT );
263 2 : rBnd.Invalidate( SID_ATTR_ZOOMSLIDER);
264 2 : }
265 :
266 : /*
267 : * Scrollbar - Handler
268 : */
269 124410 : IMPL_LINK( SwView, WindowChildEventListener, VclSimpleEvent*, pEvent )
270 : {
271 : OSL_ENSURE( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
272 62205 : if ( pEvent && pEvent->ISA( VclWindowEvent ) )
273 : {
274 62205 : VclWindowEvent *pVclEvent = static_cast< VclWindowEvent * >( pEvent );
275 : OSL_ENSURE( pVclEvent->GetWindow(), "Window???" );
276 62205 : Window* pChildWin = static_cast< Window* >( pVclEvent->GetData() );
277 :
278 62205 : switch ( pVclEvent->GetId() )
279 : {
280 : case VCLEVENT_WINDOW_HIDE:
281 802 : if( pChildWin == m_pHScrollbar )
282 21 : ShowHScrollbar( sal_False );
283 781 : else if( pChildWin == m_pVScrollbar )
284 11 : ShowVScrollbar( sal_False );
285 802 : break;
286 : case VCLEVENT_WINDOW_SHOW:
287 14836 : if( pChildWin == m_pHScrollbar )
288 769 : ShowHScrollbar( sal_True );
289 14067 : else if( pChildWin == m_pVScrollbar )
290 777 : ShowVScrollbar( sal_True );
291 14836 : break;
292 : }
293 : }
294 :
295 62205 : return 0;
296 : }
297 :
298 1586 : int SwView::_CreateScrollbar( sal_Bool bHori )
299 : {
300 1586 : Window *pMDI = &GetViewFrame()->GetWindow();
301 1586 : SwScrollbar** ppScrollbar = bHori ? &m_pHScrollbar : &m_pVScrollbar;
302 :
303 : OSL_ENSURE( !*ppScrollbar, "vorher abpruefen!" );
304 :
305 1586 : if( !bHori )
306 793 : CreatePageButtons( !m_bShowAtResize );
307 :
308 1586 : *ppScrollbar = new SwScrollbar( pMDI, bHori );
309 1586 : UpdateScrollbars();
310 1586 : if(bHori)
311 793 : (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, EndScrollHdl ));
312 : else
313 793 : (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, ScrollHdl ));
314 1586 : (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl ));
315 :
316 1586 : (*ppScrollbar)->EnableDrag( sal_True );
317 :
318 1586 : if(GetWindow())
319 0 : InvalidateBorder();
320 :
321 : // Scrollbar muss nochmals getestet werden, da im InvalidateBorder u.U. der
322 : // Scrollbar wieder geloescht wurde
323 1586 : if ( !m_bShowAtResize && (*ppScrollbar))
324 0 : (*ppScrollbar)->ExtendedShow();
325 :
326 1586 : return 1;
327 : }
328 :
329 793 : void SwView::CreatePageButtons(sal_Bool bShow)
330 : {
331 793 : Window *pMDI = &GetViewFrame()->GetWindow();
332 793 : m_pPageUpBtn = new SwHlpImageButton(pMDI, SW_RES( BTN_PAGEUP ), sal_True );
333 793 : m_pPageUpBtn->SetHelpId(HID_SCRL_PAGEUP);
334 793 : m_pPageDownBtn = new SwHlpImageButton(pMDI, SW_RES( BTN_PAGEDOWN ), sal_False );
335 793 : m_pPageDownBtn->SetHelpId(HID_SCRL_PAGEDOWN);
336 793 : Reference< XFrame > xFrame = GetViewFrame()->GetFrame().GetFrameInterface();
337 793 : m_pNaviBtn = new SwNaviImageButton(pMDI, xFrame );
338 793 : m_pNaviBtn->SetHelpId(HID_SCRL_NAVI);
339 793 : Link aLk( LINK( this, SwView, BtnPage ) );
340 793 : m_pPageUpBtn->SetClickHdl( aLk );
341 793 : m_pPageDownBtn->SetClickHdl( aLk );
342 793 : if(m_nMoveType != NID_PGE)
343 : {
344 0 : Color aColor(VIEW_IMAGECOLOR);
345 0 : SetImageButtonColor(aColor);
346 : }
347 :
348 793 : if(bShow)
349 : {
350 0 : m_pPageUpBtn->Show();
351 0 : m_pPageDownBtn->Show();
352 0 : m_pNaviBtn->Show();
353 793 : }
354 793 : };
355 :
356 : /*
357 : * Button-Handler
358 : */
359 0 : IMPL_LINK( SwView, BtnPage, Button *, pButton )
360 : {
361 : // #i75416# move the execution of the search to an asynchronously called static link
362 0 : bool* pbNext = new bool( (pButton == m_pPageDownBtn) );
363 0 : Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext );
364 0 : return 0;
365 : }
366 :
367 0 : IMPL_STATIC_LINK( SwView, MoveNavigationHdl, bool *, pbNext )
368 : {
369 0 : if ( !pbNext )
370 0 : return 0;
371 0 : bool bNext = *pbNext;
372 0 : SwWrtShell& rSh = pThis->GetWrtShell();
373 0 : switch( m_nMoveType )
374 : {
375 : case NID_PGE:
376 0 : bNext ? pThis->PhyPageDown() : pThis->PhyPageUp();
377 0 : break;
378 : case NID_TBL :
379 0 : rSh.EnterStdMode();
380 0 : if(bNext)
381 0 : rSh.MoveTable(fnTableNext, fnTableStart);
382 : else
383 0 : rSh.MoveTable(fnTablePrev, fnTableStart);
384 0 : break;
385 : case NID_FRM :
386 : case NID_GRF:
387 : case NID_OLE:
388 : {
389 0 : sal_uInt16 eType = GOTOOBJ_FLY_FRM;
390 0 : if(m_nMoveType == NID_GRF)
391 0 : eType = GOTOOBJ_FLY_GRF;
392 0 : else if(m_nMoveType == NID_OLE)
393 0 : eType = GOTOOBJ_FLY_OLE;
394 : sal_Bool bSuccess = bNext ?
395 0 : rSh.GotoNextFly(eType) :
396 0 : rSh.GotoPrevFly(eType);
397 0 : if(bSuccess)
398 : {
399 0 : rSh.HideCrsr();
400 0 : rSh.EnterSelFrmMode();
401 : }
402 : }
403 0 : break;
404 : case NID_DRW :
405 : case NID_CTRL:
406 : rSh.GotoObj(bNext,
407 0 : m_nMoveType == NID_DRW ?
408 : GOTOOBJ_DRAW_SIMPLE :
409 0 : GOTOOBJ_DRAW_CONTROL);
410 0 : break;
411 : case NID_REG :
412 0 : rSh.EnterStdMode();
413 0 : if(bNext)
414 0 : rSh.MoveRegion(fnRegionNext, fnRegionStart);
415 : else
416 0 : rSh.MoveRegion(fnRegionPrev, fnRegionStart);
417 :
418 0 : break;
419 : case NID_BKM :
420 0 : rSh.EnterStdMode();
421 : pThis->GetViewFrame()->GetDispatcher()->Execute(bNext ?
422 : FN_NEXT_BOOKMARK :
423 0 : FN_PREV_BOOKMARK);
424 0 : break;
425 : case NID_OUTL:
426 0 : rSh.EnterStdMode();
427 0 : bNext ? rSh.GotoNextOutline() : rSh.GotoPrevOutline();
428 0 : break;
429 : case NID_SEL :
430 0 : bNext ? rSh.GoNextCrsr() : rSh.GoPrevCrsr();
431 0 : break;
432 : case NID_FTN:
433 0 : rSh.EnterStdMode();
434 : bNext ?
435 0 : rSh.GotoNextFtnAnchor() :
436 0 : rSh.GotoPrevFtnAnchor();
437 0 : break;
438 : case NID_MARK:
439 : {
440 : // unselect
441 0 : rSh.MoveCrsr();
442 0 : rSh.EnterStdMode();
443 :
444 : // collect navigator reminders
445 0 : IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
446 0 : ::std::vector< const ::sw::mark::IMark* > vNavMarks;
447 0 : for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
448 0 : ppMark != pMarkAccess->getMarksEnd();
449 : ppMark++)
450 : {
451 0 : if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER )
452 0 : vNavMarks.push_back(ppMark->get());
453 : }
454 :
455 : // move
456 0 : if(!vNavMarks.empty())
457 : {
458 0 : if(bNext)
459 : {
460 0 : m_nActMark++;
461 0 : if (m_nActMark >= MAX_MARKS || m_nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
462 0 : m_nActMark = 0;
463 : }
464 : else
465 : {
466 0 : m_nActMark--;
467 0 : if (m_nActMark < 0 || m_nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
468 0 : m_nActMark = vNavMarks.size()-1;
469 : }
470 0 : rSh.GotoMark(vNavMarks[m_nActMark]);
471 0 : }
472 : }
473 0 : break;
474 : case NID_POSTIT:
475 : {
476 0 : sw::sidebarwindows::SwSidebarWin* pPostIt = pThis->GetPostItMgr()->GetActiveSidebarWin();
477 0 : if (pPostIt)
478 0 : pThis->GetPostItMgr()->SetActiveSidebarWin(0);
479 0 : SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD);
480 0 : if (rSh.MoveFldType(pFldType, bNext))
481 0 : pThis->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
482 : else
483 : //first/last item
484 0 : pThis->GetPostItMgr()->SetActiveSidebarWin(pPostIt);
485 : }
486 0 : break;
487 : case NID_SRCH_REP:
488 0 : if(m_pSrchItem)
489 : {
490 0 : sal_Bool bBackward = m_pSrchItem->GetBackward();
491 0 : if(rSh.HasSelection() && !bNext == rSh.IsCrsrPtAtEnd())
492 0 : rSh.SwapPam();
493 0 : m_pSrchItem->SetBackward(!bNext);
494 0 : SfxRequest aReq(FN_REPEAT_SEARCH, SFX_CALLMODE_SLOT, pThis->GetPool());
495 0 : pThis->ExecSearch(aReq);
496 0 : m_pSrchItem->SetBackward(bBackward);
497 : }
498 0 : break;
499 : case NID_INDEX_ENTRY:
500 0 : rSh.GotoNxtPrvTOXMark(bNext);
501 0 : break;
502 :
503 : case NID_TABLE_FORMULA:
504 0 : rSh.GotoNxtPrvTblFormula( bNext );
505 0 : break;
506 :
507 : case NID_TABLE_FORMULA_ERROR:
508 0 : rSh.GotoNxtPrvTblFormula( bNext, sal_True );
509 0 : break;
510 : }
511 0 : pThis->m_pEditWin->GrabFocus();
512 0 : delete pbNext;
513 0 : return 0;
514 : }
515 :
516 845 : int SwView::CreateTab()
517 : {
518 845 : m_pHRuler->SetActive(GetFrame() && IsActive());
519 :
520 845 : m_pHRuler->Show();
521 845 : InvalidateBorder();
522 845 : return 1;
523 : }
524 :
525 58 : int SwView::KillTab()
526 : {
527 58 : m_pHRuler->Hide();
528 58 : InvalidateBorder();
529 58 : return 1;
530 : }
531 :
532 0 : void SwView::ChangeTabMetric( FieldUnit eUnit )
533 : {
534 0 : if(m_pHRuler->GetUnit() != eUnit )
535 : {
536 0 : m_pHRuler->SetUnit( eUnit );
537 0 : m_pHRuler->Invalidate();
538 : }
539 0 : }
540 :
541 0 : void SwView::ChangeVRulerMetric( FieldUnit eUnit )
542 : {
543 0 : if(m_pVRuler->GetUnit() != eUnit)
544 : {
545 0 : m_pVRuler->SetUnit( eUnit );
546 0 : m_pVRuler->Invalidate();
547 : }
548 0 : }
549 :
550 1 : void SwView::GetVRulerMetric(FieldUnit& eToFill) const
551 : {
552 1 : eToFill = m_pVRuler->GetUnit();
553 1 : }
554 :
555 1 : void SwView::GetHRulerMetric(FieldUnit& eToFill) const
556 : {
557 1 : eToFill = m_pHRuler->GetUnit();
558 1 : }
559 :
560 840 : int SwView::CreateVRuler()
561 : {
562 840 : m_pHRuler->SetBorderPos( m_pVRuler->GetSizePixel().Width()-1 );
563 :
564 840 : m_pVRuler->SetActive(GetFrame() && IsActive());
565 840 : m_pVRuler->Show();
566 840 : InvalidateBorder();
567 840 : return 1;
568 : }
569 :
570 61 : int SwView::KillVRuler()
571 : {
572 61 : m_pVRuler->Hide();
573 61 : m_pHRuler->SetBorderPos( 0 );
574 61 : InvalidateBorder();
575 61 : return 1;
576 : }
577 :
578 0 : IMPL_LINK( SwView, ExecRulerClick, Ruler *, pRuler )
579 : {
580 0 : sal_uInt16 nDefPage = 0;
581 0 : switch( pRuler->GetClickType() )
582 : {
583 : case RULER_TYPE_DONTKNOW:
584 : case RULER_TYPE_OUTSIDE:
585 : case RULER_TYPE_INDENT:
586 : case RULER_TYPE_MARGIN1:
587 : case RULER_TYPE_MARGIN2:
588 0 : nDefPage = TP_PARA_STD;
589 0 : break;
590 : default:
591 0 : nDefPage = TP_TABULATOR;
592 :
593 : }
594 :
595 0 : SfxUInt16Item aDefPage(SID_PARA_DLG, nDefPage);
596 : GetViewFrame()->GetDispatcher()->Execute( SID_PARA_DLG,
597 : SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
598 0 : &aDefPage, 0L );
599 0 : return 0;
600 : }
601 :
602 0 : sal_uInt16 SwView::GetMoveType()
603 : {
604 0 : return m_nMoveType;
605 : }
606 :
607 0 : void SwView::SetMoveType(sal_uInt16 nSet)
608 : {
609 0 : sal_Bool bLastPage = m_nMoveType == NID_PGE;
610 0 : m_nMoveType = nSet;
611 0 : sal_Bool bNewPage = m_nMoveType == NID_PGE;
612 0 : if(bNewPage != bLastPage)
613 : {
614 0 : Color aColor(bNewPage ? COL_BLACK : VIEW_IMAGECOLOR);
615 0 : const TypeId aTypeId = TYPE(SwView);
616 0 : SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
617 0 : while( pView )
618 : {
619 0 : pView->SetImageButtonColor(aColor);
620 0 : pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
621 : }
622 : }
623 0 : }
624 :
625 0 : void SwView::SetActMark(sal_Int32 nSet)
626 : {
627 0 : m_nActMark = nSet;
628 0 : }
629 :
630 0 : void SwView::SetImageButtonColor(Color& rColor)
631 : {
632 0 : if(m_pPageUpBtn)
633 : {
634 0 : m_pPageUpBtn->SetControlForeground(rColor);
635 0 : m_pPageDownBtn->SetControlForeground(rColor);
636 : }
637 0 : }
638 :
639 1582 : void SwView::ShowHScrollbar(sal_Bool bShow)
640 : {
641 : OSL_ENSURE(m_pHScrollbar, "Scrollbar invalid");
642 1582 : m_pHScrollbar->ExtendedShow(bShow);
643 1582 : }
644 :
645 0 : sal_Bool SwView::IsHScrollbarVisible()const
646 : {
647 : OSL_ENSURE(m_pHScrollbar, "Scrollbar invalid");
648 0 : return m_pHScrollbar->IsVisible( sal_False ) || m_pHScrollbar->IsAuto();
649 : }
650 :
651 1582 : void SwView::ShowVScrollbar(sal_Bool bShow)
652 : {
653 : OSL_ENSURE(m_pVScrollbar, "Scrollbar invalid");
654 1582 : m_pVScrollbar->ExtendedShow(bShow);
655 1582 : m_pPageUpBtn->Show(bShow);
656 1582 : m_pPageDownBtn->Show(bShow);
657 1582 : m_pNaviBtn->Show(bShow);
658 1582 : }
659 :
660 0 : sal_Bool SwView::IsVScrollbarVisible()const
661 : {
662 : OSL_ENSURE(m_pVScrollbar, "Scrollbar invalid");
663 0 : return m_pVScrollbar->IsVisible( sal_False );
664 : }
665 :
666 3 : void SwView::EnableHScrollbar(bool bEnable)
667 : {
668 3 : if (m_bHScrollbarEnabled != bEnable)
669 : {
670 2 : m_bHScrollbarEnabled = bEnable;
671 2 : InvalidateBorder();
672 : }
673 3 : }
674 :
675 3 : void SwView::EnableVScrollbar(bool bEnable)
676 : {
677 3 : if (m_bVScrollbarEnabled != bEnable)
678 : {
679 3 : m_bVScrollbarEnabled = bEnable;
680 3 : InvalidateBorder();
681 : }
682 102 : }
683 :
684 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|