Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <wrtsh.hxx>
30 : : #include <crsskip.hxx>
31 : :
32 : :
33 : : /*
34 : : * private Methoden, die den Cursor ueber Suchen bewegen. Das
35 : : * Aufheben der Selektion muss auf der Ebene darueber erfolgen.
36 : : */
37 : :
38 : : /*
39 : : * Der Anfang eines Wortes ist das Folgen eines nicht-
40 : : * Trennzeichens auf Trennzeichen. Ferner das Folgen von
41 : : * nicht-Satztrennern auf Satztrenner. Der Absatzanfang ist
42 : : * ebenfalls Wortanfang.
43 : : */
44 : :
45 : :
46 : 0 : sal_Bool SwWrtShell::_SttWrd()
47 : : {
48 [ # # ]: 0 : if ( IsSttPara() )
49 : 0 : return 1;
50 : : /*
51 : : * temporaeren Cursor ohne Selektion erzeugen
52 : : */
53 : 0 : Push();
54 : 0 : ClearMark();
55 [ # # ]: 0 : if( !GoStartWord() )
56 : : // nicht gefunden --> an den Absatzanfang
57 : 0 : SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
58 : 0 : ClearMark();
59 : : // falls vorher Mark gesetzt war, zusammenfassen
60 : 0 : Combine();
61 : 0 : return 1;
62 : : }
63 : : /*
64 : : * Das Ende eines Wortes ist das Folgen von Trennzeichen auf
65 : : * nicht-Trennzeichen. Unter dem Ende eines Wortes wird
66 : : * ebenfalls die Folge von Worttrennzeichen auf Interpunktions-
67 : : * zeichen verstanden. Das Absatzende ist ebenfalls Wortende.
68 : : */
69 : :
70 : :
71 : :
72 : 0 : sal_Bool SwWrtShell::_EndWrd()
73 : : {
74 [ # # ]: 0 : if ( IsEndWrd() )
75 : 0 : return 1;
76 : : // temporaeren Cursor ohne Selektion erzeugen
77 : 0 : Push();
78 : 0 : ClearMark();
79 [ # # ]: 0 : if( !GoEndWord() )
80 : : // nicht gefunden --> an das Absatz Ende
81 : 0 : SwCrsrShell::MovePara(fnParaCurr, fnParaEnd);
82 : 0 : ClearMark();
83 : : // falls vorher Mark gesetzt war, zusammenfassen
84 : 0 : Combine();
85 : 0 : return 1;
86 : : }
87 : :
88 : :
89 : :
90 : 0 : sal_Bool SwWrtShell::_NxtWrd()
91 : : {
92 : 0 : sal_Bool bRet = sal_False;
93 [ # # ]: 0 : while( IsEndPara() ) // wenn schon am Ende, dann naechsten ???
94 : : {
95 [ # # ]: 0 : if(!SwCrsrShell::Right(1,CRSR_SKIP_CHARS)) // Document - Ende ??
96 : : {
97 : 0 : Pop( sal_False );
98 : 0 : return bRet;
99 : : }
100 : 0 : bRet = IsStartWord();
101 : : }
102 : 0 : Push();
103 : 0 : ClearMark();
104 [ # # ]: 0 : while( !bRet )
105 : : {
106 [ # # ]: 0 : if( !GoNextWord() )
107 : : {
108 [ # # ]: 0 : if( (!IsEndPara() && !SwCrsrShell::MovePara( fnParaCurr, fnParaEnd ) )
[ # # # # ]
[ # # ]
109 : 0 : || !SwCrsrShell::Right(1,CRSR_SKIP_CHARS) )
110 : 0 : break;
111 : 0 : bRet = IsStartWord();
112 : : }
113 : : else
114 : 0 : bRet = sal_True;
115 : : }
116 : 0 : ClearMark();
117 : 0 : Combine();
118 : 0 : return bRet;
119 : : }
120 : :
121 : 0 : sal_Bool SwWrtShell::_PrvWrd()
122 : : {
123 : 0 : sal_Bool bRet = sal_False;
124 [ # # ]: 0 : while( IsSttPara() )
125 : : { // wenn schon am Anfang, dann naechsten ???
126 [ # # ]: 0 : if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS))
127 : : { // Document - Anfang ??
128 : 0 : Pop( sal_False );
129 : 0 : return bRet;
130 : : }
131 : 0 : bRet = IsStartWord();
132 : : }
133 : 0 : Push();
134 : 0 : ClearMark();
135 [ # # ]: 0 : while( !bRet )
136 : : {
137 [ # # ]: 0 : if( !GoPrevWord() )
138 : : {
139 [ # # ]: 0 : if( (!IsSttPara() && !SwCrsrShell::MovePara( fnParaCurr, fnParaStart ) )
[ # # # # ]
[ # # ]
140 : 0 : || !SwCrsrShell::Left(1,CRSR_SKIP_CHARS) )
141 : 0 : break;
142 : 0 : bRet = IsStartWord();
143 : : }
144 : : else
145 : 0 : bRet = sal_True;
146 : : }
147 : 0 : ClearMark();
148 : 0 : Combine();
149 : 0 : return bRet;
150 : : }
151 : :
152 : : // #i92468#
153 : : // method code of <SwWrtShell::_NxtWrd()> before fix for issue i72162
154 : 0 : sal_Bool SwWrtShell::_NxtWrdForDelete()
155 : : {
156 [ # # ]: 0 : if ( IsEndPara() )
157 : : {
158 [ # # ]: 0 : if ( !SwCrsrShell::Right(1,CRSR_SKIP_CHARS) )
159 : : {
160 : 0 : Pop( sal_False );
161 : 0 : return sal_False;
162 : : }
163 : 0 : return sal_True;
164 : : }
165 : 0 : Push();
166 : 0 : ClearMark();
167 [ # # ]: 0 : if ( !GoNextWord() )
168 : : {
169 : 0 : SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
170 : : }
171 : 0 : ClearMark();
172 : 0 : Combine();
173 : 0 : return sal_True;
174 : : }
175 : :
176 : : // method code of <SwWrtShell::_PrvWrd()> before fix for issue i72162
177 : 0 : sal_Bool SwWrtShell::_PrvWrdForDelete()
178 : : {
179 [ # # ]: 0 : if ( IsSttPara() )
180 : : {
181 [ # # ]: 0 : if ( !SwCrsrShell::Left(1,CRSR_SKIP_CHARS) )
182 : : {
183 : 0 : Pop( sal_False );
184 : 0 : return sal_False;
185 : : }
186 : 0 : return sal_True;
187 : : }
188 : 0 : Push();
189 : 0 : ClearMark();
190 [ # # ]: 0 : if( !GoPrevWord() )
191 : : {
192 : 0 : SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
193 : : }
194 : 0 : ClearMark();
195 : 0 : Combine();
196 : 0 : return sal_True;
197 : : }
198 : :
199 : 0 : sal_Bool SwWrtShell::_FwdSentence()
200 : : {
201 : 0 : Push();
202 : 0 : ClearMark();
203 [ # # ]: 0 : if(!SwCrsrShell::Right(1,CRSR_SKIP_CHARS))
204 : : {
205 : 0 : Pop(sal_False);
206 : 0 : return 0;
207 : : }
208 [ # # ][ # # ]: 0 : if( !GoNextSentence() && !IsEndPara() )
[ # # ]
209 : 0 : SwCrsrShell::MovePara(fnParaCurr, fnParaEnd);
210 : :
211 : 0 : ClearMark();
212 : 0 : Combine();
213 : 0 : return 1;
214 : : }
215 : :
216 : 0 : sal_Bool SwWrtShell::_BwdSentence()
217 : : {
218 : 0 : Push();
219 : 0 : ClearMark();
220 [ # # ]: 0 : if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS))
221 : : {
222 : 0 : Pop(sal_False);
223 : 0 : return 0;
224 : : }
225 [ # # ][ # # ]: 0 : if( !GoStartSentence() && !IsSttPara() )
[ # # ]
226 : : // nicht gefunden --> an den Absatz Anfang
227 : 0 : SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
228 : 0 : ClearMark();
229 : 0 : Combine();
230 : 0 : return 1;
231 : : }
232 : :
233 : 0 : sal_Bool SwWrtShell::_FwdPara()
234 : : {
235 : 0 : Push();
236 : 0 : ClearMark();
237 : 0 : sal_Bool bRet = SwCrsrShell::MovePara(fnParaNext, fnParaStart);
238 : :
239 : 0 : ClearMark();
240 : 0 : Combine();
241 : 0 : return bRet;
242 : : }
243 : :
244 : :
245 : 0 : sal_Bool SwWrtShell::_BwdPara()
246 : : {
247 : 0 : Push();
248 : 0 : ClearMark();
249 : :
250 : 0 : sal_Bool bRet = SwCrsrShell::MovePara(fnParaPrev, fnParaStart);
251 [ # # ][ # # ]: 0 : if ( !bRet && !IsSttOfPara() )
[ # # ]
252 : : {
253 : 0 : SttPara();
254 : : }
255 : :
256 : 0 : ClearMark();
257 : 0 : Combine();
258 : 0 : return bRet;
259 : : }
260 : :
261 : :
262 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|