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