1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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()
36 // Create temporary cursor without selection.
40 // not found --> go to the beginning of the paragraph.
41 SwCursorShell::MovePara( GoCurrPara
, fnParaStart
);
43 // If Mark was previously set, summarize.
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
50 // The end of a paragraph is also the end of a word.
52 void SwWrtShell::EndWrd()
56 // Create temporary cursor without selection.
60 // not found --> go to the end of the paragraph.
61 SwCursorShell::MovePara(GoCurrPara
, fnParaEnd
);
63 // If Mark was previously set, summarize.
67 bool SwWrtShell::NxtWrd_()
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
);
85 if( (!IsEndPara() && !SwCursorShell::MovePara( GoCurrPara
, fnParaEnd
) )
86 || !SwCursorShell::Right(1,SwCursorSkipMode::Chars
) )
98 bool SwWrtShell::PrvWrd_()
102 { // if already at the beginning, then the next???
103 if(!SwCursorShell::Left(1,SwCursorSkipMode::Chars
))
104 { // Document - beginning ??
105 Pop(SwCursorShell::PopMode::DeleteCurrent
);
108 bRet
= IsStartWord() || IsEndPara();
116 if( (!IsSttPara() && !SwCursorShell::MovePara( GoCurrPara
, fnParaStart
) )
117 || !SwCursorShell::Left(1,SwCursorSkipMode::Chars
) )
119 bRet
= IsStartWord();
130 // method code of <SwWrtShell::NxtWrd_()> before fix for issue i72162
131 bool SwWrtShell::NxtWrdForDelete()
135 if ( !SwCursorShell::Right(1,SwCursorSkipMode::Chars
) )
137 Pop(SwCursorShell::PopMode::DeleteCurrent
);
146 SwCursorShell::MovePara( GoCurrPara
, fnParaEnd
);
153 // method code of <SwWrtShell::PrvWrd_()> before fix for issue i72162
154 bool SwWrtShell::PrvWrdForDelete()
158 if ( !SwCursorShell::Left(1,SwCursorSkipMode::Chars
) )
160 Pop(SwCursorShell::PopMode::DeleteCurrent
);
169 SwCursorShell::MovePara( GoCurrPara
, fnParaStart
);
176 bool SwWrtShell::FwdSentence_()
180 if(!SwCursorShell::Right(1,SwCursorSkipMode::Chars
))
182 Pop(SwCursorShell::PopMode::DeleteCurrent
);
185 if( !GoNextSentence() && !IsEndPara() )
186 SwCursorShell::MovePara(GoCurrPara
, fnParaEnd
);
193 bool SwWrtShell::BwdSentence_()
197 if(!SwCursorShell::Left(1,SwCursorSkipMode::Chars
))
199 Pop(SwCursorShell::PopMode::DeleteCurrent
);
202 if( !GoStartSentence() && !IsSttPara() )
203 // not found --> go to the beginning of the paragraph
204 SwCursorShell::MovePara( GoCurrPara
, fnParaStart
);
210 bool SwWrtShell::FwdPara_()
214 bool bRet
= SwCursorShell::MovePara(GoNextPara
, fnParaStart
);
221 bool SwWrtShell::BwdPara_()
226 bool bRet
= SwCursorShell::MovePara(GoPrevPara
, fnParaStart
);
227 if ( !bRet
&& !IsSttOfPara() )
237 std::optional
<OString
> SwWrtShell::getLOKPayload(int nType
, int nViewId
) const
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
);
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */