1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "hintids.hxx" 32cdf0e10cSrcweir #include <vcl/svapp.hxx> 33cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 34cdf0e10cSrcweir #include <svx/ruler.hxx> 35cdf0e10cSrcweir #include <editeng/lrspitem.hxx> 36cdf0e10cSrcweir #include <svl/srchitem.hxx> 37cdf0e10cSrcweir #include <sfx2/request.hxx> 38cdf0e10cSrcweir #include <swmodule.hxx> 39cdf0e10cSrcweir #ifndef _VIEW_HXX 40cdf0e10cSrcweir #include <view.hxx> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #include <wrtsh.hxx> 43cdf0e10cSrcweir #ifndef _DOCSH_HXX 44cdf0e10cSrcweir #include <docsh.hxx> 45cdf0e10cSrcweir #endif 46cdf0e10cSrcweir #include <viewopt.hxx> 47cdf0e10cSrcweir #include <frmatr.hxx> 48cdf0e10cSrcweir #ifndef _WDOCSH_HXX 49cdf0e10cSrcweir #include <wdocsh.hxx> 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir #include <uitool.hxx> 52cdf0e10cSrcweir #include <edtwin.hxx> 53cdf0e10cSrcweir #include <pagedesc.hxx> 54cdf0e10cSrcweir #include <IMark.hxx> 55cdf0e10cSrcweir #include <fldbas.hxx> 56cdf0e10cSrcweir #include <workctrl.hxx> 57cdf0e10cSrcweir #include <usrpref.hxx> 58cdf0e10cSrcweir #include <scroll.hxx> 59cdf0e10cSrcweir #ifndef _WVIEW_HXX 60cdf0e10cSrcweir #include <wview.hxx> 61cdf0e10cSrcweir #endif 62cdf0e10cSrcweir 63cdf0e10cSrcweir #ifndef _CMDID_H 64cdf0e10cSrcweir #include <cmdid.h> 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir #ifndef _VIEW_HRC 67cdf0e10cSrcweir #include <view.hrc> 68cdf0e10cSrcweir #endif 69cdf0e10cSrcweir #ifndef _RIBBAR_HRC 70cdf0e10cSrcweir #include <ribbar.hrc> 71cdf0e10cSrcweir #endif 72cdf0e10cSrcweir #ifndef _HELPID_H 73cdf0e10cSrcweir #include <helpid.h> 74cdf0e10cSrcweir #endif 75cdf0e10cSrcweir #ifndef _GLOBALS_HRC 76cdf0e10cSrcweir #include <globals.hrc> 77cdf0e10cSrcweir #endif 78cdf0e10cSrcweir 79cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx> 80cdf0e10cSrcweir #include <PostItMgr.hxx> 81cdf0e10cSrcweir 82cdf0e10cSrcweir sal_uInt16 SwView::nMoveType = NID_PGE; 83cdf0e10cSrcweir sal_Int32 SwView::nActMark = 0; 84cdf0e10cSrcweir 85cdf0e10cSrcweir 86cdf0e10cSrcweir #define VIEW_IMAGECOLOR COL_LIGHTBLUE 87cdf0e10cSrcweir 88cdf0e10cSrcweir using namespace ::com::sun::star::uno; 89cdf0e10cSrcweir using namespace ::com::sun::star::frame; 90cdf0e10cSrcweir 91cdf0e10cSrcweir void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, sal_Bool bViewOnly ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir _SetZoom( GetEditWin().GetOutputSizePixel(), eZoomType, nFactor, bViewOnly ); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir void SwView::_SetZoom( const Size &rEditSize, SvxZoomType eZoomType, 97cdf0e10cSrcweir short nFactor, sal_Bool bViewOnly ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir sal_Bool bUnLockView = !pWrtShell->IsViewLocked(); 100cdf0e10cSrcweir pWrtShell->LockView( sal_True ); 101cdf0e10cSrcweir pWrtShell->LockPaint(); 102cdf0e10cSrcweir 103cdf0e10cSrcweir { 104cdf0e10cSrcweir ACT_KONTEXT(pWrtShell); 105cdf0e10cSrcweir 106cdf0e10cSrcweir long nFac = nFactor; 107cdf0e10cSrcweir 108cdf0e10cSrcweir sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this); 109cdf0e10cSrcweir SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb); 110cdf0e10cSrcweir 111cdf0e10cSrcweir const SwPageDesc &rDesc = pWrtShell->GetPageDesc( pWrtShell->GetCurPageDesc() ); 112cdf0e10cSrcweir const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace(); 113cdf0e10cSrcweir const SwViewOption *pOpt = pWrtShell->GetViewOptions(); 114cdf0e10cSrcweir long lLeftMargin = 0; 115cdf0e10cSrcweir 116cdf0e10cSrcweir if( eZoomType != SVX_ZOOM_PERCENT ) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir const bool bAutomaticViewLayout = 0 == pOpt->GetViewLayoutColumns(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir const SwRect aPageRect( pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) ); 121cdf0e10cSrcweir const SwRect aRootRect( pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) ); 122cdf0e10cSrcweir Size aPageSize( aPageRect.SSize() ); 123cdf0e10cSrcweir Size aRootSize( aRootRect.SSize() ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir //mod #i6193# added sidebar width 126cdf0e10cSrcweir SwPostItMgr* pPostItMgr = GetPostItMgr(); 127cdf0e10cSrcweir if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes()) 128cdf0e10cSrcweir aPageSize.Width() += pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir const MapMode aTmpMap( MAP_TWIP ); 131cdf0e10cSrcweir const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir if( nsUseOnPage::PD_MIRROR == rDesc.GetUseOn() ) // gespiegelte Seiten 134cdf0e10cSrcweir { 135cdf0e10cSrcweir const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace(); 136cdf0e10cSrcweir aPageSize.Width() += Abs( long(rLeftLRSpace.GetLeft()) - long(rLRSpace.GetLeft()) ); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir if( SVX_ZOOM_OPTIMAL == eZoomType ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes()) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir lLeftMargin = long(rLRSpace.GetLeft()) + aPageRect.Left() + nLeftOfst; 144cdf0e10cSrcweir } 145cdf0e10cSrcweir else 146cdf0e10cSrcweir { 147cdf0e10cSrcweir aPageSize.Width() -= ( rLRSpace.GetLeft() + rLRSpace.GetRight() + nLeftOfst * 2 ); 148cdf0e10cSrcweir lLeftMargin = long(rLRSpace.GetLeft()) + aPageRect.Left() + nLeftOfst; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir nFac = aWindowSize.Width() * 100 / aPageSize.Width(); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir else if(SVX_ZOOM_WHOLEPAGE == eZoomType || SVX_ZOOM_PAGEWIDTH == eZoomType ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir const long nOf = DOCUMENTBORDER * 2L; 155cdf0e10cSrcweir long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width(); 156cdf0e10cSrcweir nTmpWidth += nOf; 157cdf0e10cSrcweir aPageSize.Height() += nOf; 158cdf0e10cSrcweir nFac = aWindowSize.Width() * 100 / nTmpWidth; 159cdf0e10cSrcweir 160cdf0e10cSrcweir if ( SVX_ZOOM_WHOLEPAGE == eZoomType ) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height(); 163cdf0e10cSrcweir nFac = Min( nFac, nVisPercent ); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir } 166cdf0e10cSrcweir else /*if( SVX_ZOOM_PAGEWIDTH_NOBORDER == eZoomType )*/ 167cdf0e10cSrcweir { 168cdf0e10cSrcweir const long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width(); 169cdf0e10cSrcweir nFac = aWindowSize.Width() * 100 / nTmpWidth; 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir nFac = Max( long( MINZOOM ), nFac ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir SwViewOption aOpt( *pOpt ); 176cdf0e10cSrcweir if ( !GetViewFrame()->GetFrame().IsInPlace() ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir //MasterUsrPrefs updaten UND DANACH die ViewOptions der aktuellen 179cdf0e10cSrcweir //View updaten. 180cdf0e10cSrcweir if ( !bViewOnly && 181cdf0e10cSrcweir (sal_uInt16(nFac) != pUsrPref->GetZoom() || 182cdf0e10cSrcweir sal_uInt8 (eZoomType) != pUsrPref->GetZoomType()) ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir pUsrPref->SetZoom ( sal_uInt16(nFac) ); 185cdf0e10cSrcweir pUsrPref->SetZoomType( eZoomType ); 186cdf0e10cSrcweir SW_MOD()->ApplyUsrPref( *pUsrPref, 187cdf0e10cSrcweir bViewOnly ? this: 0, 188cdf0e10cSrcweir bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 ); 189cdf0e10cSrcweir pUsrPref->SetModified(); 190cdf0e10cSrcweir } 191cdf0e10cSrcweir if ( pOpt->GetZoom() != (sal_uInt16) nFac ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir aOpt.SetZoom ( sal_uInt16(nFac) ); 194cdf0e10cSrcweir aOpt.SetReadonly(pOpt->IsReadonly()); 195cdf0e10cSrcweir pWrtShell->ApplyViewOptions( aOpt ); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir if ( eZoomType != SVX_ZOOM_PERCENT ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir Point aPos; 200cdf0e10cSrcweir 201cdf0e10cSrcweir if ( eZoomType == SVX_ZOOM_WHOLEPAGE ) 202cdf0e10cSrcweir aPos.Y() = pWrtShell->GetAnyCurRect(RECT_PAGE).Top() - DOCUMENTBORDER; 203cdf0e10cSrcweir else 204cdf0e10cSrcweir { 205cdf0e10cSrcweir //sicherstellen, dass sich der Cursor im sichtbaren 206cdf0e10cSrcweir //Bereich befindet, damit nur 1x gescrollt wird 207cdf0e10cSrcweir aPos.X() = lLeftMargin; 208cdf0e10cSrcweir const SwRect &rCharRect = pWrtShell->GetCharRect(); 209cdf0e10cSrcweir if ( rCharRect.Top() > GetVisArea().Bottom() || 210cdf0e10cSrcweir rCharRect.Bottom() < aPos.Y() ) 211cdf0e10cSrcweir aPos.Y() = rCharRect.Top() - rCharRect.Height(); 212cdf0e10cSrcweir else 213cdf0e10cSrcweir aPos.Y() = GetVisArea().Top(); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir SetVisArea( aPos ); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir // OS: Notloesung - in CalcVisArea wird u.U. wieder SetZoom gerufen und 218cdf0e10cSrcweir // dann werden falsche Werte eingestellt 219cdf0e10cSrcweir ((SwViewOption*)pWrtShell->GetViewOptions())->SetZoomType( eZoomType ); 220cdf0e10cSrcweir CalcVisArea( rEditSize ); //fuer das Neuberechnen des sichtbaren Bereiches 221cdf0e10cSrcweir } 222cdf0e10cSrcweir else if ( sal_uInt16(nFac) != pOpt->GetZoom() ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir aOpt.SetZoom ( sal_uInt16(nFac) ); 225cdf0e10cSrcweir pWrtShell->ApplyViewOptions( aOpt ); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir 228cdf0e10cSrcweir const Fraction aFrac( nFac, 100 ); 229cdf0e10cSrcweir pVRuler->SetZoom( aFrac ); 230cdf0e10cSrcweir pVRuler->ForceUpdate(); 231cdf0e10cSrcweir pHRuler->SetZoom( aFrac ); 232cdf0e10cSrcweir pHRuler->ForceUpdate(); 233cdf0e10cSrcweir ((SwViewOption*)pWrtShell->GetViewOptions())->SetZoomType( eZoomType ); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir pWrtShell->UnlockPaint(); 236cdf0e10cSrcweir if( bUnLockView ) 237cdf0e10cSrcweir pWrtShell->LockView( sal_False ); 238cdf0e10cSrcweir 239cdf0e10cSrcweir // if ( mpPostItMgr ) 240cdf0e10cSrcweir // { 241cdf0e10cSrcweir // mpPostItMgr->Rescale(); 242cdf0e10cSrcweir // mpPostItMgr->CalcRects(); 243cdf0e10cSrcweir // mpPostItMgr->LayoutPostIts(); 244cdf0e10cSrcweir // } 245cdf0e10cSrcweir 246cdf0e10cSrcweir // eZoom = eZoomType; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir void SwView::SetViewLayout( sal_uInt16 nColumns, bool bBookMode, sal_Bool bViewOnly ) 250cdf0e10cSrcweir { 251cdf0e10cSrcweir const sal_Bool bUnLockView = !pWrtShell->IsViewLocked(); 252cdf0e10cSrcweir pWrtShell->LockView( sal_True ); 253cdf0e10cSrcweir pWrtShell->LockPaint(); 254cdf0e10cSrcweir 255cdf0e10cSrcweir { 256cdf0e10cSrcweir 257cdf0e10cSrcweir ACT_KONTEXT(pWrtShell); 258cdf0e10cSrcweir 259cdf0e10cSrcweir if ( !GetViewFrame()->GetFrame().IsInPlace() && !bViewOnly ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir const sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this); 262cdf0e10cSrcweir SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb); 263cdf0e10cSrcweir 264cdf0e10cSrcweir //MasterUsrPrefs updaten UND DANACH die ViewOptions der aktuellen 265cdf0e10cSrcweir //View updaten. 266cdf0e10cSrcweir if ( nColumns != pUsrPref->GetViewLayoutColumns() || 267cdf0e10cSrcweir bBookMode != pUsrPref->IsViewLayoutBookMode() ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir pUsrPref->SetViewLayoutColumns( nColumns ); 270cdf0e10cSrcweir pUsrPref->SetViewLayoutBookMode( bBookMode ); 271cdf0e10cSrcweir SW_MOD()->ApplyUsrPref( *pUsrPref, 272cdf0e10cSrcweir bViewOnly ? this: 0, 273cdf0e10cSrcweir bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 ); 274cdf0e10cSrcweir pUsrPref->SetModified(); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir const SwViewOption *pOpt = pWrtShell->GetViewOptions(); 279cdf0e10cSrcweir 280cdf0e10cSrcweir if ( nColumns != pOpt->GetViewLayoutColumns() || 281cdf0e10cSrcweir bBookMode != pOpt->IsViewLayoutBookMode() ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir SwViewOption aOpt( *pOpt ); 284cdf0e10cSrcweir aOpt.SetViewLayoutColumns( nColumns ); 285cdf0e10cSrcweir aOpt.SetViewLayoutBookMode( bBookMode ); 286cdf0e10cSrcweir pWrtShell->ApplyViewOptions( aOpt ); 287cdf0e10cSrcweir } 288cdf0e10cSrcweir 289cdf0e10cSrcweir pVRuler->ForceUpdate(); 290cdf0e10cSrcweir pHRuler->ForceUpdate(); 291cdf0e10cSrcweir 292cdf0e10cSrcweir } 293cdf0e10cSrcweir 294cdf0e10cSrcweir pWrtShell->UnlockPaint(); 295cdf0e10cSrcweir if( bUnLockView ) 296cdf0e10cSrcweir pWrtShell->LockView( sal_False ); 297cdf0e10cSrcweir 298cdf0e10cSrcweir SfxBindings& rBnd = GetViewFrame()->GetBindings(); 299cdf0e10cSrcweir rBnd.Invalidate( SID_ATTR_VIEWLAYOUT ); 300cdf0e10cSrcweir rBnd.Invalidate( SID_ATTR_ZOOMSLIDER); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir /* 304cdf0e10cSrcweir * Scrollbar - Handler 305cdf0e10cSrcweir */ 306cdf0e10cSrcweir 307cdf0e10cSrcweir int SwView::_CreateScrollbar( sal_Bool bHori ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir Window *pMDI = &GetViewFrame()->GetWindow(); 310cdf0e10cSrcweir SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar; 311cdf0e10cSrcweir 312cdf0e10cSrcweir ASSERT( !*ppScrollbar, "vorher abpruefen!" ) 313cdf0e10cSrcweir 314cdf0e10cSrcweir if( !bHori ) 315cdf0e10cSrcweir CreatePageButtons( !bShowAtResize ); 316cdf0e10cSrcweir 317cdf0e10cSrcweir *ppScrollbar = new SwScrollbar( pMDI, bHori ); 318cdf0e10cSrcweir UpdateScrollbars(); 319cdf0e10cSrcweir if(bHori) 320cdf0e10cSrcweir (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, EndScrollHdl )); 321cdf0e10cSrcweir else 322cdf0e10cSrcweir (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, ScrollHdl )); 323cdf0e10cSrcweir (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl )); 324cdf0e10cSrcweir 325cdf0e10cSrcweir (*ppScrollbar)->EnableDrag( sal_True ); 326cdf0e10cSrcweir 327cdf0e10cSrcweir if(GetWindow()) 328cdf0e10cSrcweir InvalidateBorder(); 329cdf0e10cSrcweir 330cdf0e10cSrcweir // Scrollbar muss nochmals getestet werden, da im InvalidateBorder u.U. der 331cdf0e10cSrcweir // Scrollbar wieder geloescht wurde 332cdf0e10cSrcweir if ( !bShowAtResize && (*ppScrollbar)) 333cdf0e10cSrcweir (*ppScrollbar)->ExtendedShow(); 334cdf0e10cSrcweir 335cdf0e10cSrcweir return 1; 336cdf0e10cSrcweir } 337cdf0e10cSrcweir 338cdf0e10cSrcweir void SwView::CreatePageButtons(sal_Bool bShow) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir Window *pMDI = &GetViewFrame()->GetWindow(); 341cdf0e10cSrcweir pPageUpBtn = new SwHlpImageButton(pMDI, SW_RES( BTN_PAGEUP ), sal_True ); 342cdf0e10cSrcweir pPageUpBtn->SetHelpId(HID_SCRL_PAGEUP); 343cdf0e10cSrcweir pPageDownBtn = new SwHlpImageButton(pMDI, SW_RES( BTN_PAGEDOWN ), sal_False ); 344cdf0e10cSrcweir pPageDownBtn->SetHelpId(HID_SCRL_PAGEDOWN); 345cdf0e10cSrcweir Reference< XFrame > xFrame = GetViewFrame()->GetFrame().GetFrameInterface(); 346cdf0e10cSrcweir pNaviBtn = new SwNaviImageButton(pMDI, xFrame ); 347cdf0e10cSrcweir pNaviBtn->SetHelpId(HID_SCRL_NAVI); 348cdf0e10cSrcweir Link aLk( LINK( this, SwView, BtnPage ) ); 349cdf0e10cSrcweir pPageUpBtn->SetClickHdl( aLk ); 350cdf0e10cSrcweir pPageDownBtn->SetClickHdl( aLk ); 351cdf0e10cSrcweir if(nMoveType != NID_PGE) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir Color aColor(VIEW_IMAGECOLOR); 354cdf0e10cSrcweir SetImageButtonColor(aColor); 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir if(bShow) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir pPageUpBtn->Show(); 360cdf0e10cSrcweir pPageDownBtn->Show(); 361cdf0e10cSrcweir pNaviBtn->Show(); 362cdf0e10cSrcweir } 363cdf0e10cSrcweir }; 364cdf0e10cSrcweir 365cdf0e10cSrcweir /* 366cdf0e10cSrcweir * Button-Handler 367cdf0e10cSrcweir */ 368cdf0e10cSrcweir IMPL_LINK( SwView, BtnPage, Button *, pButton ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir // #i75416# move the execution of the search to an asynchronously called static link 371cdf0e10cSrcweir bool* pbNext = new bool( (pButton == pPageDownBtn) ); 372cdf0e10cSrcweir Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext ); 373cdf0e10cSrcweir return 0; 374cdf0e10cSrcweir } 375cdf0e10cSrcweir /*-----------------20.06.97 10:46------------------- 376cdf0e10cSrcweir 377cdf0e10cSrcweir --------------------------------------------------*/ 378cdf0e10cSrcweir IMPL_STATIC_LINK( SwView, MoveNavigationHdl, bool *, pbNext ) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir if ( !pbNext ) 381cdf0e10cSrcweir return 0; 382cdf0e10cSrcweir bool bNext = *pbNext; 383cdf0e10cSrcweir SwWrtShell& rSh = pThis->GetWrtShell(); 384cdf0e10cSrcweir switch( nMoveType ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir case NID_PGE: 387cdf0e10cSrcweir bNext ? pThis->PhyPageDown() : pThis->PhyPageUp(); 388cdf0e10cSrcweir break; 389cdf0e10cSrcweir case NID_TBL : 390cdf0e10cSrcweir rSh.EnterStdMode(); 391cdf0e10cSrcweir if(bNext) 392cdf0e10cSrcweir rSh.MoveTable(fnTableNext, fnTableStart); 393cdf0e10cSrcweir else 394cdf0e10cSrcweir rSh.MoveTable(fnTablePrev, fnTableStart); 395cdf0e10cSrcweir break; 396cdf0e10cSrcweir case NID_FRM : 397cdf0e10cSrcweir case NID_GRF: 398cdf0e10cSrcweir case NID_OLE: 399cdf0e10cSrcweir { 400cdf0e10cSrcweir sal_uInt16 eType = GOTOOBJ_FLY_FRM; 401cdf0e10cSrcweir if(nMoveType == NID_GRF) 402cdf0e10cSrcweir eType = GOTOOBJ_FLY_GRF; 403cdf0e10cSrcweir else if(nMoveType == NID_OLE) 404cdf0e10cSrcweir eType = GOTOOBJ_FLY_OLE; 405cdf0e10cSrcweir sal_Bool bSuccess = bNext ? 406cdf0e10cSrcweir rSh.GotoNextFly(eType) : 407cdf0e10cSrcweir rSh.GotoPrevFly(eType); 408cdf0e10cSrcweir if(bSuccess) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir rSh.HideCrsr(); 411cdf0e10cSrcweir rSh.EnterSelFrmMode(); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir } 414cdf0e10cSrcweir break; 415cdf0e10cSrcweir case NID_DRW : 416cdf0e10cSrcweir case NID_CTRL: 417cdf0e10cSrcweir rSh.GotoObj(bNext, 418cdf0e10cSrcweir nMoveType == NID_DRW ? 419cdf0e10cSrcweir GOTOOBJ_DRAW_SIMPLE : 420cdf0e10cSrcweir GOTOOBJ_DRAW_CONTROL); 421cdf0e10cSrcweir break; 422cdf0e10cSrcweir case NID_REG : 423cdf0e10cSrcweir rSh.EnterStdMode(); 424cdf0e10cSrcweir if(bNext) 425cdf0e10cSrcweir rSh.MoveRegion(fnRegionNext, fnRegionStart); 426cdf0e10cSrcweir else 427cdf0e10cSrcweir rSh.MoveRegion(fnRegionPrev, fnRegionStart); 428cdf0e10cSrcweir 429cdf0e10cSrcweir break; 430cdf0e10cSrcweir case NID_BKM : 431cdf0e10cSrcweir rSh.EnterStdMode(); 432cdf0e10cSrcweir pThis->GetViewFrame()->GetDispatcher()->Execute(bNext ? 433cdf0e10cSrcweir FN_NEXT_BOOKMARK : 434cdf0e10cSrcweir FN_PREV_BOOKMARK); 435cdf0e10cSrcweir break; 436cdf0e10cSrcweir case NID_OUTL: 437cdf0e10cSrcweir rSh.EnterStdMode(); 438cdf0e10cSrcweir bNext ? rSh.GotoNextOutline() : rSh.GotoPrevOutline(); 439cdf0e10cSrcweir break; 440cdf0e10cSrcweir case NID_SEL : 441cdf0e10cSrcweir bNext ? rSh.GoNextCrsr() : rSh.GoPrevCrsr(); 442cdf0e10cSrcweir break; 443cdf0e10cSrcweir case NID_FTN: 444cdf0e10cSrcweir rSh.EnterStdMode(); 445cdf0e10cSrcweir bNext ? 446cdf0e10cSrcweir rSh.GotoNextFtnAnchor() : 447cdf0e10cSrcweir rSh.GotoPrevFtnAnchor(); 448cdf0e10cSrcweir break; 449cdf0e10cSrcweir case NID_MARK: 450cdf0e10cSrcweir { 451cdf0e10cSrcweir // unselect 452cdf0e10cSrcweir rSh.MoveCrsr(); 453cdf0e10cSrcweir rSh.EnterStdMode(); 454cdf0e10cSrcweir 455cdf0e10cSrcweir // collect navigator reminders 456cdf0e10cSrcweir IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); 457cdf0e10cSrcweir ::std::vector< const ::sw::mark::IMark* > vNavMarks; 458cdf0e10cSrcweir for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); 459cdf0e10cSrcweir ppMark != pMarkAccess->getMarksEnd(); 460cdf0e10cSrcweir ppMark++) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER ) 463cdf0e10cSrcweir vNavMarks.push_back(ppMark->get()); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir 466cdf0e10cSrcweir // move 467cdf0e10cSrcweir if(vNavMarks.size()) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir if(bNext) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir nActMark++; 472cdf0e10cSrcweir if (nActMark >= MAX_MARKS || nActMark >= static_cast<sal_Int32>(vNavMarks.size())) 473cdf0e10cSrcweir nActMark = 0; 474cdf0e10cSrcweir } 475cdf0e10cSrcweir else 476cdf0e10cSrcweir { 477cdf0e10cSrcweir nActMark--; 478cdf0e10cSrcweir if (nActMark < 0 || nActMark >= static_cast<sal_Int32>(vNavMarks.size())) 479cdf0e10cSrcweir nActMark = vNavMarks.size()-1; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir rSh.GotoMark(vNavMarks[nActMark]); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir } 484cdf0e10cSrcweir break; 485cdf0e10cSrcweir case NID_POSTIT: 486cdf0e10cSrcweir { 487cdf0e10cSrcweir sw::sidebarwindows::SwSidebarWin* pPostIt = pThis->GetPostItMgr()->GetActiveSidebarWin(); 488cdf0e10cSrcweir if (pPostIt) 489cdf0e10cSrcweir pThis->GetPostItMgr()->SetActiveSidebarWin(0); 490cdf0e10cSrcweir SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD); 491cdf0e10cSrcweir if (rSh.MoveFldType(pFldType, bNext)) 492cdf0e10cSrcweir pThis->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT); 493cdf0e10cSrcweir else 494cdf0e10cSrcweir //first/last item 495cdf0e10cSrcweir pThis->GetPostItMgr()->SetActiveSidebarWin(pPostIt); 496cdf0e10cSrcweir } 497cdf0e10cSrcweir break; 498cdf0e10cSrcweir case NID_SRCH_REP: 499cdf0e10cSrcweir if(pSrchItem) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir sal_Bool bBackward = pSrchItem->GetBackward(); 502cdf0e10cSrcweir if(rSh.HasSelection() && !bNext == rSh.IsCrsrPtAtEnd()) 503cdf0e10cSrcweir rSh.SwapPam(); 504cdf0e10cSrcweir pSrchItem->SetBackward(!bNext); 505cdf0e10cSrcweir SfxRequest aReq(FN_REPEAT_SEARCH, SFX_CALLMODE_SLOT, pThis->GetPool()); 506cdf0e10cSrcweir pThis->ExecSearch(aReq); 507cdf0e10cSrcweir pSrchItem->SetBackward(bBackward); 508cdf0e10cSrcweir } 509cdf0e10cSrcweir break; 510cdf0e10cSrcweir case NID_INDEX_ENTRY: 511cdf0e10cSrcweir rSh.GotoNxtPrvTOXMark(bNext); 512cdf0e10cSrcweir break; 513cdf0e10cSrcweir 514cdf0e10cSrcweir case NID_TABLE_FORMULA: 515cdf0e10cSrcweir rSh.GotoNxtPrvTblFormula( bNext ); 516cdf0e10cSrcweir break; 517cdf0e10cSrcweir 518cdf0e10cSrcweir case NID_TABLE_FORMULA_ERROR: 519cdf0e10cSrcweir rSh.GotoNxtPrvTblFormula( bNext, sal_True ); 520cdf0e10cSrcweir break; 521cdf0e10cSrcweir } 522cdf0e10cSrcweir pThis->pEditWin->GrabFocus(); 523cdf0e10cSrcweir delete pbNext; 524cdf0e10cSrcweir return 0; 525cdf0e10cSrcweir } 526cdf0e10cSrcweir 527cdf0e10cSrcweir /************************************************************************* 528cdf0e10cSrcweir |* 529cdf0e10cSrcweir |* SwView::CreateTab() 530cdf0e10cSrcweir |* 531cdf0e10cSrcweir |* Beschreibung 532cdf0e10cSrcweir |* Ersterstellung VB 29.05.91 533cdf0e10cSrcweir |* Letzte Aenderung OS 09.05.96 534cdf0e10cSrcweir |* 535cdf0e10cSrcweir *************************************************************************/ 536cdf0e10cSrcweir 537cdf0e10cSrcweir int SwView::CreateTab() 538cdf0e10cSrcweir { 539cdf0e10cSrcweir pHRuler->SetActive(GetFrame() && IsActive()); 540cdf0e10cSrcweir 541cdf0e10cSrcweir pHRuler->Show(); 542cdf0e10cSrcweir InvalidateBorder(); 543cdf0e10cSrcweir return 1; 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir /************************************************************************* 547cdf0e10cSrcweir |* 548cdf0e10cSrcweir |* SwView::KillTab() 549cdf0e10cSrcweir |* 550cdf0e10cSrcweir |* Beschreibung 551cdf0e10cSrcweir |* Ersterstellung VB 29.05.91 552cdf0e10cSrcweir |* Letzte Aenderung OS 09.05.96 553cdf0e10cSrcweir |* 554cdf0e10cSrcweir *************************************************************************/ 555cdf0e10cSrcweir 556cdf0e10cSrcweir int SwView::KillTab() 557cdf0e10cSrcweir { 558cdf0e10cSrcweir pHRuler->Hide(); 559cdf0e10cSrcweir InvalidateBorder(); 560cdf0e10cSrcweir return 1; 561cdf0e10cSrcweir } 562cdf0e10cSrcweir 563cdf0e10cSrcweir void SwView::ChangeTabMetric( FieldUnit eUnit ) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir if(pHRuler->GetUnit() != eUnit ) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir pHRuler->SetUnit( eUnit ); 568cdf0e10cSrcweir pHRuler->Invalidate(); 569cdf0e10cSrcweir } 570cdf0e10cSrcweir } 571cdf0e10cSrcweir 572cdf0e10cSrcweir void SwView::ChangeVLinealMetric( FieldUnit eUnit ) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir if(pVRuler->GetUnit() != eUnit) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir pVRuler->SetUnit( eUnit ); 577cdf0e10cSrcweir pVRuler->Invalidate(); 578cdf0e10cSrcweir } 579cdf0e10cSrcweir } 580cdf0e10cSrcweir /* -----------------------------07.04.01 17:09-------------------------------- 581cdf0e10cSrcweir 582cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 583cdf0e10cSrcweir void SwView::GetVLinealMetric(FieldUnit& eToFill) const 584cdf0e10cSrcweir { 585cdf0e10cSrcweir eToFill = pVRuler->GetUnit(); 586cdf0e10cSrcweir } 587cdf0e10cSrcweir /* -----------------------------07.04.01 17:09-------------------------------- 588cdf0e10cSrcweir 589cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 590cdf0e10cSrcweir void SwView::GetHLinealMetric(FieldUnit& eToFill) const 591cdf0e10cSrcweir { 592cdf0e10cSrcweir eToFill = pHRuler->GetUnit(); 593cdf0e10cSrcweir } 594cdf0e10cSrcweir /************************************************************************* 595cdf0e10cSrcweir |* 596cdf0e10cSrcweir |* SwView::CreateVLineal() 597cdf0e10cSrcweir |* 598cdf0e10cSrcweir |* Beschreibung 599cdf0e10cSrcweir |* Ersterstellung VB 29.05.91 600cdf0e10cSrcweir |* 601cdf0e10cSrcweir *************************************************************************/ 602cdf0e10cSrcweir 603cdf0e10cSrcweir int SwView::CreateVLineal() 604cdf0e10cSrcweir { 605cdf0e10cSrcweir pHRuler->SetBorderPos( pVRuler->GetSizePixel().Width()-1 ); 606cdf0e10cSrcweir 607cdf0e10cSrcweir pVRuler->SetActive(GetFrame() && IsActive()); 608cdf0e10cSrcweir pVRuler->Show(); 609cdf0e10cSrcweir InvalidateBorder(); 610cdf0e10cSrcweir return 1; 611cdf0e10cSrcweir } 612cdf0e10cSrcweir 613cdf0e10cSrcweir /************************************************************************* 614cdf0e10cSrcweir |* 615cdf0e10cSrcweir |* SwView::KillVLineal() 616cdf0e10cSrcweir |* 617cdf0e10cSrcweir |* Beschreibung 618cdf0e10cSrcweir |* Ersterstellung VB 29.05.91 619cdf0e10cSrcweir |* 620cdf0e10cSrcweir *************************************************************************/ 621cdf0e10cSrcweir 622cdf0e10cSrcweir int SwView::KillVLineal() 623cdf0e10cSrcweir { 624cdf0e10cSrcweir pVRuler->Hide(); 625cdf0e10cSrcweir pHRuler->SetBorderPos( 0 ); 626cdf0e10cSrcweir InvalidateBorder(); 627cdf0e10cSrcweir return 1; 628cdf0e10cSrcweir } 629cdf0e10cSrcweir /************************************************************************* 630cdf0e10cSrcweir |* 631cdf0e10cSrcweir |* SwView::ExecRulerClick() 632cdf0e10cSrcweir |* 633cdf0e10cSrcweir |* Beschreibung 634cdf0e10cSrcweir |* Ersterstellung OS 15.06.95 635cdf0e10cSrcweir |* Letzte Aenderung 636cdf0e10cSrcweir |* 637cdf0e10cSrcweir *************************************************************************/ 638cdf0e10cSrcweir 639cdf0e10cSrcweir IMPL_LINK( SwView, ExecRulerClick, Ruler *, pRuler ) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir sal_uInt16 nDefPage = 0; 642cdf0e10cSrcweir switch( pRuler->GetClickType() ) 643cdf0e10cSrcweir { 644cdf0e10cSrcweir case RULER_TYPE_DONTKNOW: 645cdf0e10cSrcweir case RULER_TYPE_OUTSIDE: 646cdf0e10cSrcweir case RULER_TYPE_INDENT: 647cdf0e10cSrcweir case RULER_TYPE_MARGIN1: 648cdf0e10cSrcweir case RULER_TYPE_MARGIN2: 649cdf0e10cSrcweir nDefPage = TP_PARA_STD; 650cdf0e10cSrcweir break; 651cdf0e10cSrcweir default: 652cdf0e10cSrcweir nDefPage = TP_TABULATOR; 653cdf0e10cSrcweir 654cdf0e10cSrcweir } 655cdf0e10cSrcweir 656cdf0e10cSrcweir SfxUInt16Item aDefPage(SID_PARA_DLG, nDefPage); 657cdf0e10cSrcweir GetViewFrame()->GetDispatcher()->Execute( SID_PARA_DLG, 658cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, 659cdf0e10cSrcweir &aDefPage, 0L ); 660cdf0e10cSrcweir return 0; 661cdf0e10cSrcweir } 662cdf0e10cSrcweir 663cdf0e10cSrcweir 664cdf0e10cSrcweir /*-----------------20.02.97 09:11------------------- 665cdf0e10cSrcweir 666cdf0e10cSrcweir --------------------------------------------------*/ 667cdf0e10cSrcweir 668cdf0e10cSrcweir sal_uInt16 SwView::GetMoveType() 669cdf0e10cSrcweir { 670cdf0e10cSrcweir return nMoveType; 671cdf0e10cSrcweir } 672cdf0e10cSrcweir /*-----------------20.02.97 09:11------------------- 673cdf0e10cSrcweir 674cdf0e10cSrcweir --------------------------------------------------*/ 675cdf0e10cSrcweir 676cdf0e10cSrcweir void SwView::SetMoveType(sal_uInt16 nSet) 677cdf0e10cSrcweir { 678cdf0e10cSrcweir sal_Bool bLastPage = nMoveType == NID_PGE; 679cdf0e10cSrcweir nMoveType = nSet; 680cdf0e10cSrcweir sal_Bool bNewPage = nMoveType == NID_PGE; 681cdf0e10cSrcweir if(bNewPage != bLastPage) 682cdf0e10cSrcweir { 683cdf0e10cSrcweir Color aColor(bNewPage ? COL_BLACK : VIEW_IMAGECOLOR); 684cdf0e10cSrcweir const TypeId aTypeId = TYPE(SwView); 685cdf0e10cSrcweir SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId); 686cdf0e10cSrcweir while( pView ) 687cdf0e10cSrcweir { 688cdf0e10cSrcweir pView->SetImageButtonColor(aColor); 689cdf0e10cSrcweir pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId); 690cdf0e10cSrcweir } 691cdf0e10cSrcweir } 692cdf0e10cSrcweir } 693cdf0e10cSrcweir 694cdf0e10cSrcweir /*-----------------20.06.97 11:18------------------- 695cdf0e10cSrcweir 696cdf0e10cSrcweir --------------------------------------------------*/ 697cdf0e10cSrcweir void SwView::SetActMark(sal_Int32 nSet) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir nActMark = nSet; 700cdf0e10cSrcweir } 701cdf0e10cSrcweir 702cdf0e10cSrcweir /*-----------------15.03.97 10:53------------------- 703cdf0e10cSrcweir 704cdf0e10cSrcweir --------------------------------------------------*/ 705cdf0e10cSrcweir 706cdf0e10cSrcweir void SwView::SetImageButtonColor(Color& rColor) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir if(pPageUpBtn) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir pPageUpBtn->SetControlForeground(rColor); 711cdf0e10cSrcweir pPageDownBtn->SetControlForeground(rColor); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir } 714cdf0e10cSrcweir /* -----------------------------2002/06/26 13:57------------------------------ 715cdf0e10cSrcweir 716cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 717cdf0e10cSrcweir void SwView::ShowHScrollbar(sal_Bool bShow) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir DBG_ASSERT(pHScrollbar, "Scrollbar invalid"); 720cdf0e10cSrcweir pHScrollbar->ExtendedShow(bShow); 721cdf0e10cSrcweir } 722cdf0e10cSrcweir /* -----------------------------2002/06/26 13:57------------------------------ 723cdf0e10cSrcweir 724cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 725cdf0e10cSrcweir sal_Bool SwView::IsHScrollbarVisible()const 726cdf0e10cSrcweir { 727cdf0e10cSrcweir DBG_ASSERT(pHScrollbar, "Scrollbar invalid"); 728cdf0e10cSrcweir return pHScrollbar->IsVisible( sal_False ) || pHScrollbar->IsAuto(); 729cdf0e10cSrcweir } 730cdf0e10cSrcweir /* -----------------------------2002/06/26 13:57------------------------------ 731cdf0e10cSrcweir 732cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 733cdf0e10cSrcweir void SwView::ShowVScrollbar(sal_Bool bShow) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir DBG_ASSERT(pVScrollbar, "Scrollbar invalid"); 736cdf0e10cSrcweir pVScrollbar->ExtendedShow(bShow); 737cdf0e10cSrcweir pPageUpBtn->Show(bShow); 738cdf0e10cSrcweir pPageDownBtn->Show(bShow); 739cdf0e10cSrcweir pNaviBtn->Show(bShow); 740cdf0e10cSrcweir } 741cdf0e10cSrcweir /* -----------------------------2002/06/26 13:57------------------------------ 742cdf0e10cSrcweir 743cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 744cdf0e10cSrcweir sal_Bool SwView::IsVScrollbarVisible()const 745cdf0e10cSrcweir { 746cdf0e10cSrcweir DBG_ASSERT(pVScrollbar, "Scrollbar invalid"); 747cdf0e10cSrcweir return pVScrollbar->IsVisible( sal_False ); 748cdf0e10cSrcweir } 749cdf0e10cSrcweir 750cdf0e10cSrcweir 751