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