1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 33*cdf0e10cSrcweir #include <wrtsh.hxx> 34*cdf0e10cSrcweir #ifndef _VIEW_HXX 35*cdf0e10cSrcweir #include <view.hxx> 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir #include <viewopt.hxx> 38*cdf0e10cSrcweir #include <crsskip.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir /* Immer: 41*cdf0e10cSrcweir - Zuruecksetzen des Cursorstacks 42*cdf0e10cSrcweir - Timer nachtriggern 43*cdf0e10cSrcweir - gfs. GCAttr 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir bei Selektion 46*cdf0e10cSrcweir - SttSelect() 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir sonst 49*cdf0e10cSrcweir - EndSelect() 50*cdf0e10cSrcweir */ 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir const long nReadOnlyScrollOfst = 10; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir class ShellMoveCrsr 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir SwWrtShell* pSh; 57*cdf0e10cSrcweir sal_Bool bAct; 58*cdf0e10cSrcweir public: 59*cdf0e10cSrcweir inline ShellMoveCrsr( SwWrtShell* pWrtSh, sal_Bool bSel ) 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir bAct = !pWrtSh->ActionPend() && (pWrtSh->GetFrmType(0,sal_False) & FRMTYPE_FLY_ANY); 62*cdf0e10cSrcweir ( pSh = pWrtSh )->MoveCrsr( sal_Bool(bSel) ); 63*cdf0e10cSrcweir pWrtSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_HYPERLINK_GETLINK); 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir inline ~ShellMoveCrsr() 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir if( bAct ) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir //Die Action wird fuer das Scrollen in "einabsaetzigen" Rahmen mit 70*cdf0e10cSrcweir //fester Hoehe gebraucht. 71*cdf0e10cSrcweir pSh->StartAllAction(); 72*cdf0e10cSrcweir pSh->EndAllAction(); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir }; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir void SwWrtShell::MoveCrsr( sal_Bool bWithSelect ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir ResetCursorStack(); 80*cdf0e10cSrcweir if ( IsGCAttr() ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir GCAttr(); 83*cdf0e10cSrcweir ClearGCAttr(); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir if ( bWithSelect ) 86*cdf0e10cSrcweir SttSelect(); 87*cdf0e10cSrcweir else 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir EndSelect(); 90*cdf0e10cSrcweir (this->*fnKillSel)( 0, sal_False ); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir sal_Bool SwWrtShell::SimpleMove( FNSimpleMove FnSimpleMove, sal_Bool bSelect ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir sal_Bool nRet; 97*cdf0e10cSrcweir if( bSelect ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir SttCrsrMove(); 100*cdf0e10cSrcweir MoveCrsr( sal_True ); 101*cdf0e10cSrcweir nRet = (this->*FnSimpleMove)(); 102*cdf0e10cSrcweir EndCrsrMove(); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir else if( 0 != ( nRet = (this->*FnSimpleMove)() ) ) 105*cdf0e10cSrcweir MoveCrsr( sal_False ); 106*cdf0e10cSrcweir return nRet; 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir sal_Bool SwWrtShell::Left( sal_uInt16 nMode, sal_Bool bSelect, 111*cdf0e10cSrcweir sal_uInt16 nCount, sal_Bool bBasicCall, sal_Bool bVisual ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly()) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir Point aTmp( VisArea().Pos() ); 116*cdf0e10cSrcweir aTmp.X() -= VisArea().Width() * nReadOnlyScrollOfst / 100; 117*cdf0e10cSrcweir rView.SetVisArea( aTmp ); 118*cdf0e10cSrcweir return sal_True; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir else 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 123*cdf0e10cSrcweir return SwCrsrShell::Left( nCount, nMode, bVisual ); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir sal_Bool SwWrtShell::Right( sal_uInt16 nMode, sal_Bool bSelect, 130*cdf0e10cSrcweir sal_uInt16 nCount, sal_Bool bBasicCall, sal_Bool bVisual ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly() ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir Point aTmp( VisArea().Pos() ); 135*cdf0e10cSrcweir aTmp.X() += VisArea().Width() * nReadOnlyScrollOfst / 100; 136*cdf0e10cSrcweir aTmp.X() = rView.SetHScrollMax( aTmp.X() ); 137*cdf0e10cSrcweir rView.SetVisArea( aTmp ); 138*cdf0e10cSrcweir return sal_True; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir else 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 143*cdf0e10cSrcweir return SwCrsrShell::Right( nCount, nMode, bVisual ); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir sal_Bool SwWrtShell::Up( sal_Bool bSelect, sal_uInt16 nCount, sal_Bool bBasicCall ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly()) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir Point aTmp( VisArea().Pos() ); 154*cdf0e10cSrcweir aTmp.Y() -= VisArea().Height() * nReadOnlyScrollOfst / 100; 155*cdf0e10cSrcweir rView.SetVisArea( aTmp ); 156*cdf0e10cSrcweir return sal_True; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir else 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 161*cdf0e10cSrcweir return SwCrsrShell::Up( nCount ); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir sal_Bool SwWrtShell::Down( sal_Bool bSelect, sal_uInt16 nCount, sal_Bool bBasicCall ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly()) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir Point aTmp( VisArea().Pos() ); 172*cdf0e10cSrcweir aTmp.Y() += VisArea().Height() * nReadOnlyScrollOfst / 100; 173*cdf0e10cSrcweir aTmp.Y() = rView.SetVScrollMax( aTmp.Y() ); 174*cdf0e10cSrcweir rView.SetVisArea( aTmp ); 175*cdf0e10cSrcweir return sal_True; 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir else 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 180*cdf0e10cSrcweir return SwCrsrShell::Down( nCount ); 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir sal_Bool SwWrtShell::LeftMargin( sal_Bool bSelect, sal_Bool bBasicCall ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir Point aTmp( VisArea().Pos() ); 191*cdf0e10cSrcweir aTmp.X() = DOCUMENTBORDER; 192*cdf0e10cSrcweir rView.SetVisArea( aTmp ); 193*cdf0e10cSrcweir return sal_True; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir else 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 198*cdf0e10cSrcweir return SwCrsrShell::LeftMargin(); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir sal_Bool SwWrtShell::RightMargin( sal_Bool bSelect, sal_Bool bBasicCall ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir Point aTmp( VisArea().Pos() ); 209*cdf0e10cSrcweir aTmp.X() = GetDocSize().Width() - VisArea().Width() + DOCUMENTBORDER; 210*cdf0e10cSrcweir if( DOCUMENTBORDER > aTmp.X() ) 211*cdf0e10cSrcweir aTmp.X() = DOCUMENTBORDER; 212*cdf0e10cSrcweir rView.SetVisArea( aTmp ); 213*cdf0e10cSrcweir return sal_True; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir else 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 218*cdf0e10cSrcweir return SwCrsrShell::RightMargin(bBasicCall); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir sal_Bool SwWrtShell::GoStart( sal_Bool bKeepArea, sal_Bool *pMoveTable, 225*cdf0e10cSrcweir sal_Bool bSelect, sal_Bool bDontMoveRegion ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir if ( IsCrsrInTbl() ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir const sal_Bool bBoxSelection = HasBoxSelection(); 230*cdf0e10cSrcweir if( !bBlockMode ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir if ( !bSelect ) 233*cdf0e10cSrcweir EnterStdMode(); 234*cdf0e10cSrcweir else 235*cdf0e10cSrcweir SttSelect(); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir // Tabellenzelle? 238*cdf0e10cSrcweir if ( !bBoxSelection && (MoveSection( fnSectionCurr, fnSectionStart) 239*cdf0e10cSrcweir || bDontMoveRegion)) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir if ( pMoveTable ) 242*cdf0e10cSrcweir *pMoveTable = sal_False; 243*cdf0e10cSrcweir return sal_True; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir if( MoveTable( fnTableCurr, fnTableStart ) || bDontMoveRegion ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir if ( pMoveTable ) 248*cdf0e10cSrcweir *pMoveTable = sal_True; 249*cdf0e10cSrcweir return sal_True; 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir else if( bBoxSelection && pMoveTable ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir // JP 09.01.96: wir haben eine Boxselektion (oder leere Zelle) 254*cdf0e10cSrcweir // und wollen selektieren (pMoveTable wird im 255*cdf0e10cSrcweir // SelAll gesetzt). Dann darf die Tabelle nicht 256*cdf0e10cSrcweir // verlassen werden; sonst ist keine Selektion der 257*cdf0e10cSrcweir // gesamten Tabelle moeglich! 258*cdf0e10cSrcweir *pMoveTable = sal_True; 259*cdf0e10cSrcweir return sal_True; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir if( !bBlockMode ) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir if ( !bSelect ) 266*cdf0e10cSrcweir EnterStdMode(); 267*cdf0e10cSrcweir else 268*cdf0e10cSrcweir SttSelect(); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir const sal_uInt16 nFrmType = GetFrmType(0,sal_False); 271*cdf0e10cSrcweir if ( FRMTYPE_FLY_ANY & nFrmType ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir if( MoveSection( fnSectionCurr, fnSectionStart ) ) 274*cdf0e10cSrcweir return sal_True; 275*cdf0e10cSrcweir else if ( FRMTYPE_FLY_FREE & nFrmType || bDontMoveRegion ) 276*cdf0e10cSrcweir return sal_False; 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir if(( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE ) & nFrmType ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir if ( MoveSection( fnSectionCurr, fnSectionStart ) ) 281*cdf0e10cSrcweir return sal_True; 282*cdf0e10cSrcweir else if ( bKeepArea ) 283*cdf0e10cSrcweir return sal_True; 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir // Bereiche ??? 286*cdf0e10cSrcweir return SwCrsrShell::MoveRegion( fnRegionCurrAndSkip, fnRegionStart ) || 287*cdf0e10cSrcweir SwCrsrShell::SttEndDoc(sal_True); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir sal_Bool SwWrtShell::GoEnd(sal_Bool bKeepArea, sal_Bool *pMoveTable) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir if ( pMoveTable && *pMoveTable ) 295*cdf0e10cSrcweir return MoveTable( fnTableCurr, fnTableEnd ); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir if ( IsCrsrInTbl() ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir if ( MoveSection( fnSectionCurr, fnSectionEnd ) || 300*cdf0e10cSrcweir MoveTable( fnTableCurr, fnTableEnd ) ) 301*cdf0e10cSrcweir return sal_True; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir else 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir const sal_uInt16 nFrmType = GetFrmType(0,sal_False); 306*cdf0e10cSrcweir if ( FRMTYPE_FLY_ANY & nFrmType ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir if ( MoveSection( fnSectionCurr, fnSectionEnd ) ) 309*cdf0e10cSrcweir return sal_True; 310*cdf0e10cSrcweir else if ( FRMTYPE_FLY_FREE & nFrmType ) 311*cdf0e10cSrcweir return sal_False; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir if(( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE ) & nFrmType ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir if ( MoveSection( fnSectionCurr, fnSectionEnd) ) 316*cdf0e10cSrcweir return sal_True; 317*cdf0e10cSrcweir else if ( bKeepArea ) 318*cdf0e10cSrcweir return sal_True; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir // Bereiche ??? 322*cdf0e10cSrcweir return SwCrsrShell::MoveRegion( fnRegionCurrAndSkip, fnRegionEnd ) || 323*cdf0e10cSrcweir SwCrsrShell::SttEndDoc(sal_False); 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir sal_Bool SwWrtShell::SttDoc( sal_Bool bSelect ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 331*cdf0e10cSrcweir return GoStart(sal_False, 0, bSelect ); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir sal_Bool SwWrtShell::EndDoc( sal_Bool bSelect) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 339*cdf0e10cSrcweir return GoEnd(); 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir sal_Bool SwWrtShell::SttNxtPg( sal_Bool bSelect ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 346*cdf0e10cSrcweir return MovePage( fnPageNext, fnPageStart ); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir sal_Bool SwWrtShell::SttPrvPg( sal_Bool bSelect ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 354*cdf0e10cSrcweir return MovePage( fnPagePrev, fnPageStart ); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir sal_Bool SwWrtShell::EndNxtPg( sal_Bool bSelect ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 362*cdf0e10cSrcweir return MovePage( fnPageNext, fnPageEnd ); 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir sal_Bool SwWrtShell::EndPrvPg( sal_Bool bSelect ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 370*cdf0e10cSrcweir return MovePage( fnPagePrev, fnPageEnd ); 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir sal_Bool SwWrtShell::SttPg( sal_Bool bSelect ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 378*cdf0e10cSrcweir return MovePage( fnPageCurr, fnPageStart ); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir sal_Bool SwWrtShell::EndPg( sal_Bool bSelect ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 386*cdf0e10cSrcweir return MovePage( fnPageCurr, fnPageEnd ); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir sal_Bool SwWrtShell::SttPara( sal_Bool bSelect ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 394*cdf0e10cSrcweir return MovePara( fnParaCurr, fnParaStart ); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir sal_Bool SwWrtShell::EndPara( sal_Bool bSelect ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 402*cdf0e10cSrcweir return MovePara(fnParaCurr,fnParaEnd); 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir /*------------------------------------------------------------------------ 407*cdf0e10cSrcweir Beschreibung: Spaltenweises Springen 408*cdf0e10cSrcweir Parameter: mit oder ohne SSelection 409*cdf0e10cSrcweir Return: Erfolg oder Misserfolg 410*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir sal_Bool SwWrtShell::StartOfColumn( sal_Bool bSelect ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect); 417*cdf0e10cSrcweir return MoveColumn(fnColumnCurr, fnColumnStart); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir sal_Bool SwWrtShell::EndOfColumn( sal_Bool bSelect ) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect); 425*cdf0e10cSrcweir return MoveColumn(fnColumnCurr, fnColumnEnd); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir sal_Bool SwWrtShell::StartOfNextColumn( sal_Bool bSelect ) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect); 433*cdf0e10cSrcweir return MoveColumn( fnColumnNext, fnColumnStart); 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir sal_Bool SwWrtShell::EndOfNextColumn( sal_Bool bSelect ) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect); 441*cdf0e10cSrcweir return MoveColumn(fnColumnNext, fnColumnEnd); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir sal_Bool SwWrtShell::StartOfPrevColumn( sal_Bool bSelect ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect); 449*cdf0e10cSrcweir return MoveColumn(fnColumnPrev, fnColumnStart); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir sal_Bool SwWrtShell::EndOfPrevColumn( sal_Bool bSelect ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect); 457*cdf0e10cSrcweir return MoveColumn(fnColumnPrev, fnColumnEnd); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir sal_Bool SwWrtShell::PushCrsr(SwTwips lOffset, sal_Bool bSelect) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir sal_Bool bDiff = sal_False; 465*cdf0e10cSrcweir SwRect aOldRect( GetCharRect() ), aTmpArea( VisArea() ); 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir //bDestOnStack besagt, ob ich den Cursor nicht an die aktuelle Position 468*cdf0e10cSrcweir //setzen konnte, da in diesem Bereich kein Inhalt vorhanden ist. 469*cdf0e10cSrcweir if( !bDestOnStack ) 470*cdf0e10cSrcweir { 471*cdf0e10cSrcweir Point aPt( aOldRect.Center() ); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir if( !IsCrsrVisible() ) 474*cdf0e10cSrcweir // set CrsrPos to top-/bottom left pos. So the pagescroll is not 475*cdf0e10cSrcweir // be dependent on the current cursor, but on the visarea. 476*cdf0e10cSrcweir aPt.Y() = aTmpArea.Top() + aTmpArea.Height() / 2; 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir aPt.Y() += lOffset; 479*cdf0e10cSrcweir aDest = GetCntntPos(aPt,lOffset > 0); 480*cdf0e10cSrcweir aDest.X() = aPt.X(); 481*cdf0e10cSrcweir bDestOnStack = sal_True; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir //falls wir eine Rahmenselektion hatten, muss diese nach dem 485*cdf0e10cSrcweir //fnSetCrsr entfernt werden und damit wir da wieder hinkommen 486*cdf0e10cSrcweir //auf dem Stack gemerkt werden. 487*cdf0e10cSrcweir sal_Bool bIsFrmSel = sal_False; 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir sal_Bool bIsObjSel = sal_False; 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir //Zielposition liegt jetzt innerhalb des sichtbaren Bereiches --> 492*cdf0e10cSrcweir //Cursor an die Zielposition setzen; merken, dass keine Ziel- 493*cdf0e10cSrcweir //position mehr auf dem Stack steht. 494*cdf0e10cSrcweir //Der neue sichtbare Bereich wird zuvor ermittelt. 495*cdf0e10cSrcweir aTmpArea.Pos().Y() += lOffset; 496*cdf0e10cSrcweir if( aTmpArea.IsInside(aDest) ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir if( bSelect ) 499*cdf0e10cSrcweir SttSelect(); 500*cdf0e10cSrcweir else 501*cdf0e10cSrcweir EndSelect(); 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir bIsFrmSel = IsFrmSelected(); 504*cdf0e10cSrcweir bIsObjSel = 0 != IsObjSelected(); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir // Rahmenselektion aufheben 507*cdf0e10cSrcweir if( bIsFrmSel || bIsObjSel ) 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir UnSelectFrm(); 510*cdf0e10cSrcweir LeaveSelFrmMode(); 511*cdf0e10cSrcweir if ( bIsObjSel ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir GetView().SetDrawFuncPtr( NULL ); 514*cdf0e10cSrcweir GetView().LeaveDrawCreate(); 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir CallChgLnk(); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir (this->*fnSetCrsr)( &aDest, sal_True ); 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir bDiff = aOldRect != GetCharRect(); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir if( bIsFrmSel ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir // CallChgLnk(); 527*cdf0e10cSrcweir // bei Frames immer nur die obere Ecke nehmen, damit dieser 528*cdf0e10cSrcweir // wieder selektiert werden kann 529*cdf0e10cSrcweir aOldRect.SSize( 5, 5 ); 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir // Zuruecksetzen des Dest. SPoint Flags 533*cdf0e10cSrcweir bDestOnStack = sal_False; 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir // Position auf den Stack; bDiff besagt, ob ein Unterschied zwischen 537*cdf0e10cSrcweir // der alten und der neuen Cursorposition besteht. 538*cdf0e10cSrcweir pCrsrStack = new CrsrStack( bDiff, bIsFrmSel, aOldRect.Center(), 539*cdf0e10cSrcweir lOffset, pCrsrStack ); 540*cdf0e10cSrcweir return !bDestOnStack && bDiff; 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir sal_Bool SwWrtShell::PopCrsr(sal_Bool bUpdate, sal_Bool bSelect) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir if( 0 == pCrsrStack) 548*cdf0e10cSrcweir return sal_False; 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir const sal_Bool bValidPos = pCrsrStack->bValidCurPos; 551*cdf0e10cSrcweir if( bUpdate && bValidPos ) 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir // falls ein Vorgaenger auf dem Stack steht, dessen Flag fuer eine 554*cdf0e10cSrcweir // gueltige Position verwenden. 555*cdf0e10cSrcweir SwRect aTmpArea(VisArea()); 556*cdf0e10cSrcweir aTmpArea.Pos().Y() -= pCrsrStack->lOffset; 557*cdf0e10cSrcweir if( aTmpArea.IsInside( pCrsrStack->aDocPos ) ) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir if( bSelect ) 560*cdf0e10cSrcweir SttSelect(); 561*cdf0e10cSrcweir else 562*cdf0e10cSrcweir EndSelect(); 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir (this->*fnSetCrsr)(&pCrsrStack->aDocPos, !pCrsrStack->bIsFrmSel); 565*cdf0e10cSrcweir if( pCrsrStack->bIsFrmSel && IsObjSelectable(pCrsrStack->aDocPos)) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir HideCrsr(); 568*cdf0e10cSrcweir SelectObj( pCrsrStack->aDocPos ); 569*cdf0e10cSrcweir EnterSelFrmMode( &pCrsrStack->aDocPos ); 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir // Falls eine Verschiebung zwischen dem sichtbaren Bereich 573*cdf0e10cSrcweir // und der gemerkten Cursorpositionen auftritt, werden 574*cdf0e10cSrcweir // alle gemerkten Positionen weggeschmissen 575*cdf0e10cSrcweir else 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir _ResetCursorStack(); 578*cdf0e10cSrcweir return sal_False; 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir CrsrStack *pTmp = pCrsrStack; 582*cdf0e10cSrcweir pCrsrStack = pCrsrStack->pNext; 583*cdf0e10cSrcweir delete pTmp; 584*cdf0e10cSrcweir if( 0 == pCrsrStack ) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir ePageMove = MV_NO; 587*cdf0e10cSrcweir bDestOnStack = sal_False; 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir return bValidPos; 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir /* 593*cdf0e10cSrcweir * Zuruecksetzen aller gepushten Cursorpositionen; dieser werden nicht 594*cdf0e10cSrcweir * zur Anzeige gebracht ( --> Kein Start-/EndAction!!) 595*cdf0e10cSrcweir */ 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir void SwWrtShell::_ResetCursorStack() 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir CrsrStack *pTmp = pCrsrStack; 602*cdf0e10cSrcweir while(pCrsrStack) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir pTmp = pCrsrStack->pNext; 605*cdf0e10cSrcweir delete pCrsrStack; 606*cdf0e10cSrcweir pCrsrStack = pTmp; 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir ePageMove = MV_NO; 609*cdf0e10cSrcweir bDestOnStack = sal_False; 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir /************** 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir falls kein Stack existiert --> Selektionen aufheben 614*cdf0e10cSrcweir falls Stack && Richtungswechsel 615*cdf0e10cSrcweir --> Cursor poppen und return 616*cdf0e10cSrcweir sonst 617*cdf0e10cSrcweir --> Cursor pushen 618*cdf0e10cSrcweir Cursor umsetzen 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir ***************/ 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir sal_Bool SwWrtShell::PageCrsr(SwTwips lOffset, sal_Bool bSelect) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir // nichts tun, wenn ein Offset von 0 angegeben wurde 627*cdf0e10cSrcweir if(!lOffset) return sal_False; 628*cdf0e10cSrcweir // Diente mal dazu, eine Neuformatierung fuer das Layout 629*cdf0e10cSrcweir // zu erzwingen. 630*cdf0e10cSrcweir // Hat so nicht funktioniert, da der Cursor nicht gesetzt 631*cdf0e10cSrcweir // wurde, da dies innerhalb einer Start- / EndActionklammerung 632*cdf0e10cSrcweir // nicht geschieht. 633*cdf0e10cSrcweir // Da am Ende nur ViewShell::EndAction() gerufen wird, 634*cdf0e10cSrcweir // findet auch hier keine Aktualisierung der Anzeige 635*cdf0e10cSrcweir // der Cursorposition statt. 636*cdf0e10cSrcweir // Die CrsrShell- Actionklammerung kann nicht verwendet werden, 637*cdf0e10cSrcweir // da sie immer zu einer Anzeige des Cursors fuehrt, also auch, 638*cdf0e10cSrcweir // wenn nach dem Blaettern in einen Bereich ohne gueltige Position 639*cdf0e10cSrcweir // geblaettert wurde. 640*cdf0e10cSrcweir // ViewShell::StartAction(); 641*cdf0e10cSrcweir PageMove eDir = lOffset > 0? MV_PAGE_DOWN: MV_PAGE_UP; 642*cdf0e10cSrcweir // Richtungswechsel und Stack vorhanden 643*cdf0e10cSrcweir if( eDir != ePageMove && ePageMove != MV_NO && PopCrsr( sal_True, bSelect )) 644*cdf0e10cSrcweir return sal_True; 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir const sal_Bool bRet = PushCrsr(lOffset, bSelect); 647*cdf0e10cSrcweir ePageMove = eDir; 648*cdf0e10cSrcweir return bRet; 649*cdf0e10cSrcweir } 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir sal_Bool SwWrtShell::GotoPage(sal_uInt16 nPage, sal_Bool bRecord) 654*cdf0e10cSrcweir { 655*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, sal_False); 656*cdf0e10cSrcweir if( SwCrsrShell::GotoPage(nPage) && bRecord) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir if(IsSelFrmMode()) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir UnSelectFrm(); 661*cdf0e10cSrcweir LeaveSelFrmMode(); 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir return sal_True; 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir return sal_False; 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark, sal_Bool bSelect, sal_Bool bStart ) 671*cdf0e10cSrcweir { 672*cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect ); 673*cdf0e10cSrcweir return SwCrsrShell::GotoMark( pMark, bStart ); 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir sal_Bool SwWrtShell::SelectTxtAttr( sal_uInt16 nWhich, const SwTxtAttr* pAttr ) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir sal_Bool bRet; 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir MV_KONTEXT(this); 683*cdf0e10cSrcweir SttSelect(); 684*cdf0e10cSrcweir bRet = SwCrsrShell::SelectTxtAttr( nWhich, sal_False, pAttr ); 685*cdf0e10cSrcweir } 686*cdf0e10cSrcweir EndSelect(); 687*cdf0e10cSrcweir return bRet; 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir 692