android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / uibase / wrtsh / wrtsh4.cxx
blob0442e3152bb61c6b9e760555eebcb545b93988ae
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 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
24 // Private methods, which move the cursor over search.
25 // The removal of the selection must be made on the level above.
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.
32 void SwWrtShell::SttWrd()
34 if ( IsSttPara() )
35 return;
36 // Create temporary cursor without selection.
37 Push();
38 ClearMark();
39 if( !GoStartWord() )
40 // not found --> go to the beginning of the paragraph.
41 SwCursorShell::MovePara( GoCurrPara, fnParaStart );
42 ClearMark();
43 // If Mark was previously set, summarize.
44 Combine();
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.
52 void SwWrtShell::EndWrd()
54 if ( IsEndWrd() )
55 return;
56 // Create temporary cursor without selection.
57 Push();
58 ClearMark();
59 if( !GoEndWord() )
60 // not found --> go to the end of the paragraph.
61 SwCursorShell::MovePara(GoCurrPara, fnParaEnd);
62 ClearMark();
63 // If Mark was previously set, summarize.
64 Combine();
67 bool SwWrtShell::NxtWrd_()
69 bool bRet = false;
70 while( IsEndPara() ) // If already at the end, then the next???
72 if(!SwCursorShell::Right(1,SwCursorSkipMode::Chars)) // Document - end ??
74 Pop(SwCursorShell::PopMode::DeleteCurrent);
75 return bRet;
77 bRet = IsStartWord();
79 Push();
80 ClearMark();
81 while( !bRet )
83 if( !GoNextWord() )
85 if( (!IsEndPara() && !SwCursorShell::MovePara( GoCurrPara, fnParaEnd ) )
86 || !SwCursorShell::Right(1,SwCursorSkipMode::Chars) )
87 break;
88 bRet = IsStartWord();
90 else
91 bRet = true;
93 ClearMark();
94 Combine();
95 return bRet;
98 bool SwWrtShell::PrvWrd_()
100 bool bRet = false;
101 while( IsSttPara() )
102 { // if already at the beginning, then the next???
103 if(!SwCursorShell::Left(1,SwCursorSkipMode::Chars))
104 { // Document - beginning ??
105 Pop(SwCursorShell::PopMode::DeleteCurrent);
106 return bRet;
108 bRet = IsStartWord() || IsEndPara();
110 Push();
111 ClearMark();
112 while( !bRet )
114 if( !GoPrevWord() )
116 if( (!IsSttPara() && !SwCursorShell::MovePara( GoCurrPara, fnParaStart ) )
117 || !SwCursorShell::Left(1,SwCursorSkipMode::Chars) )
118 break;
119 bRet = IsStartWord();
121 else
122 bRet = true;
124 ClearMark();
125 Combine();
126 return bRet;
129 // #i92468#
130 // method code of <SwWrtShell::NxtWrd_()> before fix for issue i72162
131 bool SwWrtShell::NxtWrdForDelete()
133 if ( IsEndPara() )
135 if ( !SwCursorShell::Right(1,SwCursorSkipMode::Chars) )
137 Pop(SwCursorShell::PopMode::DeleteCurrent);
138 return false;
140 return true;
142 Push();
143 ClearMark();
144 if ( !GoNextWord() )
146 SwCursorShell::MovePara( GoCurrPara, fnParaEnd );
148 ClearMark();
149 Combine();
150 return true;
153 // method code of <SwWrtShell::PrvWrd_()> before fix for issue i72162
154 bool SwWrtShell::PrvWrdForDelete()
156 if ( IsSttPara() )
158 if ( !SwCursorShell::Left(1,SwCursorSkipMode::Chars) )
160 Pop(SwCursorShell::PopMode::DeleteCurrent);
161 return false;
163 return true;
165 Push();
166 ClearMark();
167 if( !GoPrevWord() )
169 SwCursorShell::MovePara( GoCurrPara, fnParaStart );
171 ClearMark();
172 Combine();
173 return true;
176 bool SwWrtShell::FwdSentence_()
178 Push();
179 ClearMark();
180 if(!SwCursorShell::Right(1,SwCursorSkipMode::Chars))
182 Pop(SwCursorShell::PopMode::DeleteCurrent);
183 return false;
185 if( !GoNextSentence() && !IsEndPara() )
186 SwCursorShell::MovePara(GoCurrPara, fnParaEnd);
188 ClearMark();
189 Combine();
190 return true;
193 bool SwWrtShell::BwdSentence_()
195 Push();
196 ClearMark();
197 if(!SwCursorShell::Left(1,SwCursorSkipMode::Chars))
199 Pop(SwCursorShell::PopMode::DeleteCurrent);
200 return false;
202 if( !GoStartSentence() && !IsSttPara() )
203 // not found --> go to the beginning of the paragraph
204 SwCursorShell::MovePara( GoCurrPara, fnParaStart );
205 ClearMark();
206 Combine();
207 return true;
210 bool SwWrtShell::FwdPara_()
212 Push();
213 ClearMark();
214 bool bRet = SwCursorShell::MovePara(GoNextPara, fnParaStart);
216 ClearMark();
217 Combine();
218 return bRet;
221 bool SwWrtShell::BwdPara_()
223 Push();
224 ClearMark();
226 bool bRet = SwCursorShell::MovePara(GoPrevPara, fnParaStart);
227 if ( !bRet && !IsSttOfPara() )
229 SttPara();
232 ClearMark();
233 Combine();
234 return bRet;
237 std::optional<OString> SwWrtShell::getLOKPayload(int nType, int nViewId) const
239 switch(nType)
241 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
242 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
243 return GetVisibleCursor()->getLOKPayload(nType, nViewId);
244 case LOK_CALLBACK_TEXT_SELECTION:
245 case LOK_CALLBACK_TEXT_SELECTION_START:
246 case LOK_CALLBACK_TEXT_SELECTION_END:
247 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
248 return GetCursor_()->getLOKPayload(nType, nViewId);
250 abort();
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */