nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / uibase / wrtsh / wrtsh4.cxx
blob8009ce98037b646ee071807c6c800b89425540ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <wrtsh.hxx>
22 // Private methods, which move the cursor over search.
23 // The removal of the selection must be made on the level above.
25 // The beginning of a word is the follow of a
26 // non-delimiter to delimiter. Furthermore, the follow of
27 // non-sentence separators on sentence separator.
28 // The begin of paragraph is also the word beginning.
30 void SwWrtShell::SttWrd()
32 if ( IsSttPara() )
33 return;
34 // Create temporary cursor without selection.
35 Push();
36 ClearMark();
37 if( !GoStartWord() )
38 // not found --> go to the beginning of the paragraph.
39 SwCursorShell::MovePara( GoCurrPara, fnParaStart );
40 ClearMark();
41 // If Mark was previously set, summarize.
42 Combine();
45 // The end of a word is the follow of separator to nonseparator.
46 // The end of a word is also the sequence of word separators to
47 // punctuation marks.
48 // The end of a paragraph is also the end of a word.
50 void SwWrtShell::EndWrd()
52 if ( IsEndWrd() )
53 return;
54 // Create temporary cursor without selection.
55 Push();
56 ClearMark();
57 if( !GoEndWord() )
58 // not found --> go to the end of the paragraph.
59 SwCursorShell::MovePara(GoCurrPara, fnParaEnd);
60 ClearMark();
61 // If Mark was previously set, summarize.
62 Combine();
65 bool SwWrtShell::NxtWrd_()
67 bool bRet = false;
68 while( IsEndPara() ) // If already at the end, then the next???
70 if(!SwCursorShell::Right(1,CRSR_SKIP_CHARS)) // Document - end ??
72 Pop(SwCursorShell::PopMode::DeleteCurrent);
73 return bRet;
75 bRet = IsStartWord();
77 Push();
78 ClearMark();
79 while( !bRet )
81 if( !GoNextWord() )
83 if( (!IsEndPara() && !SwCursorShell::MovePara( GoCurrPara, fnParaEnd ) )
84 || !SwCursorShell::Right(1,CRSR_SKIP_CHARS) )
85 break;
86 bRet = IsStartWord();
88 else
89 bRet = true;
91 ClearMark();
92 Combine();
93 return bRet;
96 bool SwWrtShell::PrvWrd_()
98 bool bRet = false;
99 while( IsSttPara() )
100 { // if already at the beginning, then the next???
101 if(!SwCursorShell::Left(1,CRSR_SKIP_CHARS))
102 { // Document - beginning ??
103 Pop(SwCursorShell::PopMode::DeleteCurrent);
104 return bRet;
106 bRet = IsStartWord() || IsEndPara();
108 Push();
109 ClearMark();
110 while( !bRet )
112 if( !GoPrevWord() )
114 if( (!IsSttPara() && !SwCursorShell::MovePara( GoCurrPara, fnParaStart ) )
115 || !SwCursorShell::Left(1,CRSR_SKIP_CHARS) )
116 break;
117 bRet = IsStartWord();
119 else
120 bRet = true;
122 ClearMark();
123 Combine();
124 return bRet;
127 // #i92468#
128 // method code of <SwWrtShell::NxtWrd_()> before fix for issue i72162
129 bool SwWrtShell::NxtWrdForDelete()
131 if ( IsEndPara() )
133 if ( !SwCursorShell::Right(1,CRSR_SKIP_CHARS) )
135 Pop(SwCursorShell::PopMode::DeleteCurrent);
136 return false;
138 return true;
140 Push();
141 ClearMark();
142 if ( !GoNextWord() )
144 SwCursorShell::MovePara( GoCurrPara, fnParaEnd );
146 ClearMark();
147 Combine();
148 return true;
151 // method code of <SwWrtShell::PrvWrd_()> before fix for issue i72162
152 bool SwWrtShell::PrvWrdForDelete()
154 if ( IsSttPara() )
156 if ( !SwCursorShell::Left(1,CRSR_SKIP_CHARS) )
158 Pop(SwCursorShell::PopMode::DeleteCurrent);
159 return false;
161 return true;
163 Push();
164 ClearMark();
165 if( !GoPrevWord() )
167 SwCursorShell::MovePara( GoCurrPara, fnParaStart );
169 ClearMark();
170 Combine();
171 return true;
174 bool SwWrtShell::FwdSentence_()
176 Push();
177 ClearMark();
178 if(!SwCursorShell::Right(1,CRSR_SKIP_CHARS))
180 Pop(SwCursorShell::PopMode::DeleteCurrent);
181 return false;
183 if( !GoNextSentence() && !IsEndPara() )
184 SwCursorShell::MovePara(GoCurrPara, fnParaEnd);
186 ClearMark();
187 Combine();
188 return true;
191 bool SwWrtShell::BwdSentence_()
193 Push();
194 ClearMark();
195 if(!SwCursorShell::Left(1,CRSR_SKIP_CHARS))
197 Pop(SwCursorShell::PopMode::DeleteCurrent);
198 return false;
200 if( !GoStartSentence() && !IsSttPara() )
201 // not found --> go to the beginning of the paragraph
202 SwCursorShell::MovePara( GoCurrPara, fnParaStart );
203 ClearMark();
204 Combine();
205 return true;
208 bool SwWrtShell::FwdPara_()
210 Push();
211 ClearMark();
212 bool bRet = SwCursorShell::MovePara(GoNextPara, fnParaStart);
214 ClearMark();
215 Combine();
216 return bRet;
219 bool SwWrtShell::BwdPara_()
221 Push();
222 ClearMark();
224 bool bRet = SwCursorShell::MovePara(GoPrevPara, fnParaStart);
225 if ( !bRet && !IsSttOfPara() )
227 SttPara();
230 ClearMark();
231 Combine();
232 return bRet;
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */