/src/libreoffice/sw/source/uibase/wrtsh/wrtsh4.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <wrtsh.hxx> |
21 | | |
22 | | #include <LibreOfficeKit/LibreOfficeKitEnums.h> |
23 | | |
24 | | // Private methods, which move the cursor over search. |
25 | | // The removal of the selection must be made on the level above. |
26 | | |
27 | | // The beginning of a word is the follow of a |
28 | | // non-delimiter to delimiter. Furthermore, the follow of |
29 | | // non-sentence separators on sentence separator. |
30 | | // The begin of paragraph is also the word beginning. |
31 | | |
32 | | void SwWrtShell::SttWrd() |
33 | 0 | { |
34 | 0 | if ( IsSttPara() ) |
35 | 0 | return; |
36 | | // Create temporary cursor without selection. |
37 | 0 | Push(); |
38 | 0 | ClearMark(); |
39 | 0 | if( !GoStartWord() ) |
40 | | // not found --> go to the beginning of the paragraph. |
41 | 0 | SwCursorShell::MovePara( GoCurrPara, fnParaStart ); |
42 | 0 | ClearMark(); |
43 | | // If Mark was previously set, summarize. |
44 | 0 | Combine(); |
45 | 0 | } |
46 | | |
47 | | // The end of a word is the follow of separator to nonseparator. |
48 | | // The end of a word is also the sequence of word separators to |
49 | | // punctuation marks. |
50 | | // The end of a paragraph is also the end of a word. |
51 | | |
52 | | void SwWrtShell::EndWrd() |
53 | 0 | { |
54 | 0 | if ( IsEndWrd() ) |
55 | 0 | return; |
56 | | // Create temporary cursor without selection. |
57 | 0 | Push(); |
58 | 0 | ClearMark(); |
59 | 0 | if( !GoEndWord() ) |
60 | | // not found --> go to the end of the paragraph. |
61 | 0 | SwCursorShell::MovePara(GoCurrPara, fnParaEnd); |
62 | 0 | ClearMark(); |
63 | | // If Mark was previously set, summarize. |
64 | 0 | Combine(); |
65 | 0 | } |
66 | | |
67 | | bool SwWrtShell::NxtWrd_() |
68 | 0 | { |
69 | 0 | bool bRet = false; |
70 | 0 | while( IsEndPara() ) // If already at the end, then the next??? |
71 | 0 | { |
72 | 0 | if(!SwCursorShell::Right(1,SwCursorSkipMode::Chars)) // Document - end ?? |
73 | 0 | { |
74 | 0 | Pop(SwCursorShell::PopMode::DeleteCurrent); |
75 | 0 | return bRet; |
76 | 0 | } |
77 | 0 | bRet = IsStartWord(); |
78 | 0 | } |
79 | 0 | Push(); |
80 | 0 | ClearMark(); |
81 | 0 | while( !bRet ) |
82 | 0 | { |
83 | 0 | if( !GoNextWord() ) |
84 | 0 | { |
85 | 0 | if( (!IsEndPara() && !SwCursorShell::MovePara( GoCurrPara, fnParaEnd ) ) |
86 | 0 | || !SwCursorShell::Right(1,SwCursorSkipMode::Chars) ) |
87 | 0 | break; |
88 | 0 | bRet = IsStartWord(); |
89 | 0 | } |
90 | 0 | else |
91 | 0 | bRet = true; |
92 | 0 | } |
93 | 0 | ClearMark(); |
94 | 0 | Combine(); |
95 | 0 | return bRet; |
96 | 0 | } |
97 | | |
98 | | bool SwWrtShell::PrvWrd_() |
99 | 0 | { |
100 | 0 | bool bRet = false; |
101 | 0 | while( IsSttPara() ) |
102 | 0 | { // if already at the beginning, then the next??? |
103 | 0 | if(!SwCursorShell::Left(1,SwCursorSkipMode::Chars)) |
104 | 0 | { // Document - beginning ?? |
105 | 0 | Pop(SwCursorShell::PopMode::DeleteCurrent); |
106 | 0 | return bRet; |
107 | 0 | } |
108 | 0 | bRet = IsStartWord() || IsEndPara(); |
109 | 0 | } |
110 | 0 | Push(); |
111 | 0 | ClearMark(); |
112 | 0 | while( !bRet ) |
113 | 0 | { |
114 | 0 | if( !GoPrevWord() ) |
115 | 0 | { |
116 | 0 | if( (!IsSttPara() && !SwCursorShell::MovePara( GoCurrPara, fnParaStart ) ) |
117 | 0 | || !SwCursorShell::Left(1,SwCursorSkipMode::Chars) ) |
118 | 0 | break; |
119 | 0 | bRet = IsStartWord(); |
120 | 0 | } |
121 | 0 | else |
122 | 0 | bRet = true; |
123 | 0 | } |
124 | 0 | ClearMark(); |
125 | 0 | Combine(); |
126 | 0 | return bRet; |
127 | 0 | } |
128 | | |
129 | | // #i92468# |
130 | | // method code of <SwWrtShell::NxtWrd_()> before fix for issue i72162 |
131 | | bool SwWrtShell::NxtWrdForDelete() |
132 | 0 | { |
133 | 0 | if ( IsEndPara() ) |
134 | 0 | { |
135 | 0 | if ( !SwCursorShell::Right(1,SwCursorSkipMode::Chars) ) |
136 | 0 | { |
137 | 0 | Pop(SwCursorShell::PopMode::DeleteCurrent); |
138 | 0 | return false; |
139 | 0 | } |
140 | 0 | return true; |
141 | 0 | } |
142 | 0 | Push(); |
143 | 0 | ClearMark(); |
144 | 0 | if ( !GoNextWord() ) |
145 | 0 | { |
146 | 0 | SwCursorShell::MovePara( GoCurrPara, fnParaEnd ); |
147 | 0 | } |
148 | 0 | ClearMark(); |
149 | 0 | Combine(); |
150 | 0 | return true; |
151 | 0 | } |
152 | | |
153 | | // method code of <SwWrtShell::PrvWrd_()> before fix for issue i72162 |
154 | | bool SwWrtShell::PrvWrdForDelete() |
155 | 0 | { |
156 | 0 | if ( IsSttPara() ) |
157 | 0 | { |
158 | 0 | if ( !SwCursorShell::Left(1,SwCursorSkipMode::Chars) ) |
159 | 0 | { |
160 | 0 | Pop(SwCursorShell::PopMode::DeleteCurrent); |
161 | 0 | return false; |
162 | 0 | } |
163 | 0 | return true; |
164 | 0 | } |
165 | 0 | Push(); |
166 | 0 | ClearMark(); |
167 | 0 | if( !GoPrevWord() ) |
168 | 0 | { |
169 | 0 | SwCursorShell::MovePara( GoCurrPara, fnParaStart ); |
170 | 0 | } |
171 | 0 | ClearMark(); |
172 | 0 | Combine(); |
173 | 0 | return true; |
174 | 0 | } |
175 | | |
176 | | bool SwWrtShell::FwdSentence_() |
177 | 0 | { |
178 | 0 | Push(); |
179 | 0 | ClearMark(); |
180 | 0 | if(!SwCursorShell::Right(1,SwCursorSkipMode::Chars)) |
181 | 0 | { |
182 | 0 | Pop(SwCursorShell::PopMode::DeleteCurrent); |
183 | 0 | return false; |
184 | 0 | } |
185 | 0 | if( !GoNextSentence() && !IsEndPara() ) |
186 | 0 | SwCursorShell::MovePara(GoCurrPara, fnParaEnd); |
187 | |
|
188 | 0 | ClearMark(); |
189 | 0 | Combine(); |
190 | 0 | return true; |
191 | 0 | } |
192 | | |
193 | | bool SwWrtShell::BwdSentence_() |
194 | 0 | { |
195 | 0 | Push(); |
196 | 0 | ClearMark(); |
197 | 0 | if(!SwCursorShell::Left(1,SwCursorSkipMode::Chars)) |
198 | 0 | { |
199 | 0 | Pop(SwCursorShell::PopMode::DeleteCurrent); |
200 | 0 | return false; |
201 | 0 | } |
202 | 0 | if( !GoStartSentence() && !IsSttPara() ) |
203 | | // not found --> go to the beginning of the paragraph |
204 | 0 | SwCursorShell::MovePara( GoCurrPara, fnParaStart ); |
205 | 0 | ClearMark(); |
206 | 0 | Combine(); |
207 | 0 | return true; |
208 | 0 | } |
209 | | |
210 | | bool SwWrtShell::FwdPara_() |
211 | 0 | { |
212 | 0 | Push(); |
213 | 0 | ClearMark(); |
214 | 0 | bool bRet = SwCursorShell::MovePara(GoNextPara, fnParaStart); |
215 | |
|
216 | 0 | ClearMark(); |
217 | 0 | Combine(); |
218 | 0 | return bRet; |
219 | 0 | } |
220 | | |
221 | | bool SwWrtShell::BwdPara_() |
222 | 0 | { |
223 | 0 | Push(); |
224 | 0 | ClearMark(); |
225 | |
|
226 | 0 | bool bRet = SwCursorShell::MovePara(GoPrevPara, fnParaStart); |
227 | 0 | if ( !bRet && !IsSttOfPara() ) |
228 | 0 | { |
229 | 0 | SttPara(); |
230 | 0 | } |
231 | |
|
232 | 0 | ClearMark(); |
233 | 0 | Combine(); |
234 | 0 | return bRet; |
235 | 0 | } |
236 | | |
237 | | std::optional<OString> SwWrtShell::getLOKPayload(int nType, int nViewId) const |
238 | 0 | { |
239 | 0 | switch(nType) |
240 | 0 | { |
241 | 0 | case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: |
242 | 0 | case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR: |
243 | 0 | return GetVisibleCursor()->getLOKPayload(nType, nViewId); |
244 | 0 | case LOK_CALLBACK_TEXT_SELECTION: |
245 | 0 | case LOK_CALLBACK_TEXT_SELECTION_START: |
246 | 0 | case LOK_CALLBACK_TEXT_SELECTION_END: |
247 | 0 | case LOK_CALLBACK_TEXT_VIEW_SELECTION: |
248 | 0 | return GetCursor_()->getLOKPayload(nType, nViewId); |
249 | 0 | } |
250 | 0 | abort(); |
251 | 0 | } |
252 | | |
253 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |