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 10*efeef26fSAndrew Rist * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*efeef26fSAndrew Rist * 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. 19*efeef26fSAndrew Rist * 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 #include <wrtsh.hxx> 29cdf0e10cSrcweir #include <crsskip.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir 32cdf0e10cSrcweir /* 33cdf0e10cSrcweir * private Methoden, die den Cursor ueber Suchen bewegen. Das 34cdf0e10cSrcweir * Aufheben der Selektion muss auf der Ebene darueber erfolgen. 35cdf0e10cSrcweir */ 36cdf0e10cSrcweir 37cdf0e10cSrcweir /* 38cdf0e10cSrcweir * Der Anfang eines Wortes ist das Folgen eines nicht- 39cdf0e10cSrcweir * Trennzeichens auf Trennzeichen. Ferner das Folgen von 40cdf0e10cSrcweir * nicht-Satztrennern auf Satztrenner. Der Absatzanfang ist 41cdf0e10cSrcweir * ebenfalls Wortanfang. 42cdf0e10cSrcweir */ 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir sal_Bool SwWrtShell::_SttWrd() 46cdf0e10cSrcweir { 47cdf0e10cSrcweir if ( IsSttPara() ) 48cdf0e10cSrcweir return 1; 49cdf0e10cSrcweir /* 50cdf0e10cSrcweir * temporaeren Cursor ohne Selektion erzeugen 51cdf0e10cSrcweir */ 52cdf0e10cSrcweir Push(); 53cdf0e10cSrcweir ClearMark(); 54cdf0e10cSrcweir if( !GoStartWord() ) 55cdf0e10cSrcweir // nicht gefunden --> an den Absatzanfang 56cdf0e10cSrcweir SwCrsrShell::MovePara( fnParaCurr, fnParaStart ); 57cdf0e10cSrcweir ClearMark(); 58cdf0e10cSrcweir // falls vorher Mark gesetzt war, zusammenfassen 59cdf0e10cSrcweir Combine(); 60cdf0e10cSrcweir return 1; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir /* 63cdf0e10cSrcweir * Das Ende eines Wortes ist das Folgen von Trennzeichen auf 64cdf0e10cSrcweir * nicht-Trennzeichen. Unter dem Ende eines Wortes wird 65cdf0e10cSrcweir * ebenfalls die Folge von Worttrennzeichen auf Interpunktions- 66cdf0e10cSrcweir * zeichen verstanden. Das Absatzende ist ebenfalls Wortende. 67cdf0e10cSrcweir */ 68cdf0e10cSrcweir 69cdf0e10cSrcweir 70cdf0e10cSrcweir 71cdf0e10cSrcweir sal_Bool SwWrtShell::_EndWrd() 72cdf0e10cSrcweir { 73cdf0e10cSrcweir if ( IsEndWrd() ) 74cdf0e10cSrcweir return 1; 75cdf0e10cSrcweir // temporaeren Cursor ohne Selektion erzeugen 76cdf0e10cSrcweir Push(); 77cdf0e10cSrcweir ClearMark(); 78cdf0e10cSrcweir if( !GoEndWord() ) 79cdf0e10cSrcweir // nicht gefunden --> an das Absatz Ende 80cdf0e10cSrcweir SwCrsrShell::MovePara(fnParaCurr, fnParaEnd); 81cdf0e10cSrcweir ClearMark(); 82cdf0e10cSrcweir // falls vorher Mark gesetzt war, zusammenfassen 83cdf0e10cSrcweir Combine(); 84cdf0e10cSrcweir return 1; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir sal_Bool SwWrtShell::_NxtWrd() 90cdf0e10cSrcweir { 91cdf0e10cSrcweir sal_Bool bRet = sal_False; 92cdf0e10cSrcweir while( IsEndPara() ) // wenn schon am Ende, dann naechsten ??? 93cdf0e10cSrcweir { 94cdf0e10cSrcweir if(!SwCrsrShell::Right(1,CRSR_SKIP_CHARS)) // Document - Ende ?? 95cdf0e10cSrcweir { 96cdf0e10cSrcweir Pop( sal_False ); 97cdf0e10cSrcweir return bRet; 98cdf0e10cSrcweir } 99cdf0e10cSrcweir bRet = IsStartWord(); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir Push(); 102cdf0e10cSrcweir ClearMark(); 103cdf0e10cSrcweir while( !bRet ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir if( !GoNextWord() ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir if( (!IsEndPara() && !SwCrsrShell::MovePara( fnParaCurr, fnParaEnd ) ) 108cdf0e10cSrcweir || !SwCrsrShell::Right(1,CRSR_SKIP_CHARS) ) 109cdf0e10cSrcweir break; 110cdf0e10cSrcweir bRet = IsStartWord(); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir else 113cdf0e10cSrcweir bRet = sal_True; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir ClearMark(); 116cdf0e10cSrcweir Combine(); 117cdf0e10cSrcweir return bRet; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir sal_Bool SwWrtShell::_PrvWrd() 121cdf0e10cSrcweir { 122cdf0e10cSrcweir sal_Bool bRet = sal_False; 123cdf0e10cSrcweir while( IsSttPara() ) 124cdf0e10cSrcweir { // wenn schon am Anfang, dann naechsten ??? 125cdf0e10cSrcweir if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS)) 126cdf0e10cSrcweir { // Document - Anfang ?? 127cdf0e10cSrcweir Pop( sal_False ); 128cdf0e10cSrcweir return bRet; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir bRet = IsStartWord(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir Push(); 133cdf0e10cSrcweir ClearMark(); 134cdf0e10cSrcweir while( !bRet ) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir if( !GoPrevWord() ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir if( (!IsSttPara() && !SwCrsrShell::MovePara( fnParaCurr, fnParaStart ) ) 139cdf0e10cSrcweir || !SwCrsrShell::Left(1,CRSR_SKIP_CHARS) ) 140cdf0e10cSrcweir break; 141cdf0e10cSrcweir bRet = IsStartWord(); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir else 144cdf0e10cSrcweir bRet = sal_True; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir ClearMark(); 147cdf0e10cSrcweir Combine(); 148cdf0e10cSrcweir return bRet; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir // --> OD 2008-08-06 #i92468# 152cdf0e10cSrcweir // method code of <SwWrtShell::_NxtWrd()> before fix for issue i72162 153cdf0e10cSrcweir sal_Bool SwWrtShell::_NxtWrdForDelete() 154cdf0e10cSrcweir { 155cdf0e10cSrcweir if ( IsEndPara() ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir if ( !SwCrsrShell::Right(1,CRSR_SKIP_CHARS) ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir Pop( sal_False ); 160cdf0e10cSrcweir return sal_False; 161cdf0e10cSrcweir } 162cdf0e10cSrcweir return sal_True; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir Push(); 165cdf0e10cSrcweir ClearMark(); 166cdf0e10cSrcweir if ( !GoNextWord() ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir SwCrsrShell::MovePara( fnParaCurr, fnParaEnd ); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir ClearMark(); 171cdf0e10cSrcweir Combine(); 172cdf0e10cSrcweir return sal_True; 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir // method code of <SwWrtShell::_PrvWrd()> before fix for issue i72162 176cdf0e10cSrcweir sal_Bool SwWrtShell::_PrvWrdForDelete() 177cdf0e10cSrcweir { 178cdf0e10cSrcweir if ( IsSttPara() ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir if ( !SwCrsrShell::Left(1,CRSR_SKIP_CHARS) ) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir Pop( sal_False ); 183cdf0e10cSrcweir return sal_False; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir return sal_True; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir Push(); 188cdf0e10cSrcweir ClearMark(); 189cdf0e10cSrcweir if( !GoPrevWord() ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir SwCrsrShell::MovePara( fnParaCurr, fnParaStart ); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir ClearMark(); 194cdf0e10cSrcweir Combine(); 195cdf0e10cSrcweir return sal_True; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir // <-- 198cdf0e10cSrcweir 199cdf0e10cSrcweir 200cdf0e10cSrcweir sal_Bool SwWrtShell::_FwdSentence() 201cdf0e10cSrcweir { 202cdf0e10cSrcweir Push(); 203cdf0e10cSrcweir ClearMark(); 204cdf0e10cSrcweir if(!SwCrsrShell::Right(1,CRSR_SKIP_CHARS)) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir Pop(sal_False); 207cdf0e10cSrcweir return 0; 208cdf0e10cSrcweir } 209cdf0e10cSrcweir if( !GoNextSentence() && !IsEndPara() ) 210cdf0e10cSrcweir SwCrsrShell::MovePara(fnParaCurr, fnParaEnd); 211cdf0e10cSrcweir 212cdf0e10cSrcweir ClearMark(); 213cdf0e10cSrcweir Combine(); 214cdf0e10cSrcweir return 1; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir 218cdf0e10cSrcweir 219cdf0e10cSrcweir sal_Bool SwWrtShell::_BwdSentence() 220cdf0e10cSrcweir { 221cdf0e10cSrcweir Push(); 222cdf0e10cSrcweir ClearMark(); 223cdf0e10cSrcweir if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS)) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir Pop(sal_False); 226cdf0e10cSrcweir return 0; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir if(IsSttPara()) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir Pop(); 231cdf0e10cSrcweir return 1; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir if( !GoPrevSentence() && !IsSttPara() ) 234cdf0e10cSrcweir // nicht gefunden --> an den Absatz Anfang 235cdf0e10cSrcweir SwCrsrShell::MovePara( fnParaCurr, fnParaStart ); 236cdf0e10cSrcweir ClearMark(); 237cdf0e10cSrcweir Combine(); 238cdf0e10cSrcweir return 1; 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir 242cdf0e10cSrcweir sal_Bool SwWrtShell::_FwdPara() 243cdf0e10cSrcweir { 244cdf0e10cSrcweir Push(); 245cdf0e10cSrcweir ClearMark(); 246cdf0e10cSrcweir // --> OD 2009-01-06 #i81824# 247cdf0e10cSrcweir // going right and back again left not needed and causes too much 248cdf0e10cSrcweir // accessibility events due to the cursor movements. 249cdf0e10cSrcweir // if(!SwCrsrShell::Right(1,CRSR_SKIP_CHARS)) 250cdf0e10cSrcweir // { 251cdf0e10cSrcweir // Pop(sal_False); 252cdf0e10cSrcweir // return 0; 253cdf0e10cSrcweir // } 254cdf0e10cSrcweir // SwCrsrShell::Left(1,CRSR_SKIP_CHARS); 255cdf0e10cSrcweir // <-- 256cdf0e10cSrcweir sal_Bool bRet = SwCrsrShell::MovePara(fnParaNext, fnParaStart); 257cdf0e10cSrcweir 258cdf0e10cSrcweir ClearMark(); 259cdf0e10cSrcweir Combine(); 260cdf0e10cSrcweir return bRet; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir 264cdf0e10cSrcweir sal_Bool SwWrtShell::_BwdPara() 265cdf0e10cSrcweir { 266cdf0e10cSrcweir Push(); 267cdf0e10cSrcweir ClearMark(); 268cdf0e10cSrcweir // --> OD 2009-01-06 #i81824# 269cdf0e10cSrcweir // going left and back again right not needed and causes too much 270cdf0e10cSrcweir // accessibility events due to the cursor movements. 271cdf0e10cSrcweir // if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS)) 272cdf0e10cSrcweir // { 273cdf0e10cSrcweir // Pop(sal_False); 274cdf0e10cSrcweir // return 0; 275cdf0e10cSrcweir // } 276cdf0e10cSrcweir // SwCrsrShell::Right(1,CRSR_SKIP_CHARS); 277cdf0e10cSrcweir // <-- 278cdf0e10cSrcweir // --> OD 2009-01-06 #i81824# 279cdf0e10cSrcweir // going to start of paragraph only needed, if move to previous paragraph 280cdf0e10cSrcweir // does not happen. Otherwise, useless accessibility events are triggered 281cdf0e10cSrcweir // due to cursor movements. 282cdf0e10cSrcweir // if(!IsSttOfPara()) 283cdf0e10cSrcweir // SttPara(); 284cdf0e10cSrcweir sal_Bool bRet = SwCrsrShell::MovePara(fnParaPrev, fnParaStart); 285cdf0e10cSrcweir if ( !bRet && !IsSttOfPara() ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir SttPara(); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir // <-- 290cdf0e10cSrcweir 291cdf0e10cSrcweir ClearMark(); 292cdf0e10cSrcweir Combine(); 293cdf0e10cSrcweir return bRet; 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir 297