xref: /aoo42x/main/sw/source/ui/wrtsh/wrtsh4.cxx (revision e789bd50)
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
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
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.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew 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 
_SttWrd()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 
_EndWrd()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 
_NxtWrd()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 
_PrvWrd()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
_NxtWrdForDelete()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
_PrvWrdForDelete()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 
_FwdSentence()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 
_BwdSentence()219cdf0e10cSrcweir sal_Bool SwWrtShell::_BwdSentence()
220cdf0e10cSrcweir {
221*e789bd50SOliver-Rainer Wittmann     Push();
222*e789bd50SOliver-Rainer Wittmann     ClearMark();
223*e789bd50SOliver-Rainer Wittmann     if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS))
224*e789bd50SOliver-Rainer Wittmann     {
225*e789bd50SOliver-Rainer Wittmann         Pop(sal_False);
226*e789bd50SOliver-Rainer Wittmann         return sal_False;
227*e789bd50SOliver-Rainer Wittmann     }
228*e789bd50SOliver-Rainer Wittmann     if(IsSttPara())
229*e789bd50SOliver-Rainer Wittmann     {
230*e789bd50SOliver-Rainer Wittmann         Pop();
231*e789bd50SOliver-Rainer Wittmann         return sal_True;
232*e789bd50SOliver-Rainer Wittmann     }
233*e789bd50SOliver-Rainer Wittmann     if( !GoPrevSentence()  && !IsSttPara() )
234*e789bd50SOliver-Rainer Wittmann         // nicht gefunden --> an den Absatz Anfang
235*e789bd50SOliver-Rainer Wittmann             SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
236*e789bd50SOliver-Rainer Wittmann     ClearMark();
237*e789bd50SOliver-Rainer Wittmann     Combine();
238*e789bd50SOliver-Rainer Wittmann 
239*e789bd50SOliver-Rainer Wittmann     return sal_True;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 
_FwdPara()243cdf0e10cSrcweir sal_Bool SwWrtShell::_FwdPara()
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	Push();
246cdf0e10cSrcweir 	ClearMark();
247cdf0e10cSrcweir     // --> OD 2009-01-06 #i81824#
248cdf0e10cSrcweir     // going right and back again left not needed and causes too much
249cdf0e10cSrcweir     // accessibility events due to the cursor movements.
250cdf0e10cSrcweir //    if(!SwCrsrShell::Right(1,CRSR_SKIP_CHARS))
251cdf0e10cSrcweir //    {
252cdf0e10cSrcweir //        Pop(sal_False);
253cdf0e10cSrcweir //        return 0;
254cdf0e10cSrcweir //    }
255cdf0e10cSrcweir //    SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
256cdf0e10cSrcweir     // <--
257cdf0e10cSrcweir 	sal_Bool bRet = SwCrsrShell::MovePara(fnParaNext, fnParaStart);
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	ClearMark();
260cdf0e10cSrcweir 	Combine();
261cdf0e10cSrcweir 	return bRet;
262cdf0e10cSrcweir }
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 
_BwdPara()265cdf0e10cSrcweir sal_Bool SwWrtShell::_BwdPara()
266cdf0e10cSrcweir {
267cdf0e10cSrcweir 	Push();
268cdf0e10cSrcweir 	ClearMark();
269cdf0e10cSrcweir     // --> OD 2009-01-06 #i81824#
270cdf0e10cSrcweir     // going left and back again right not needed and causes too much
271cdf0e10cSrcweir     // accessibility events due to the cursor movements.
272cdf0e10cSrcweir //    if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS))
273cdf0e10cSrcweir //    {
274cdf0e10cSrcweir //        Pop(sal_False);
275cdf0e10cSrcweir //        return 0;
276cdf0e10cSrcweir //    }
277cdf0e10cSrcweir //    SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
278cdf0e10cSrcweir     // <--
279cdf0e10cSrcweir     // --> OD 2009-01-06 #i81824#
280cdf0e10cSrcweir     // going to start of paragraph only needed, if move to previous paragraph
281cdf0e10cSrcweir     // does not happen. Otherwise, useless accessibility events are triggered
282cdf0e10cSrcweir     // due to cursor movements.
283cdf0e10cSrcweir //    if(!IsSttOfPara())
284cdf0e10cSrcweir //        SttPara();
285cdf0e10cSrcweir 	sal_Bool bRet = SwCrsrShell::MovePara(fnParaPrev, fnParaStart);
286cdf0e10cSrcweir     if ( !bRet && !IsSttOfPara() )
287cdf0e10cSrcweir     {
288cdf0e10cSrcweir         SttPara();
289cdf0e10cSrcweir     }
290cdf0e10cSrcweir     // <--
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 	ClearMark();
293cdf0e10cSrcweir 	Combine();
294cdf0e10cSrcweir 	return bRet;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 
298