LibreOffice Module sw (master) 1
wrtsh4.cxx
Go to the documentation of this file.
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
33{
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.
42 ClearMark();
43 // If Mark was previously set, summarize.
44 Combine();
45}
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
53{
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.
62 ClearMark();
63 // If Mark was previously set, summarize.
64 Combine();
65}
66
68{
69 bool bRet = false;
70 while( IsEndPara() ) // If already at the end, then the next???
71 {
72 if(!SwCursorShell::Right(1,SwCursorSkipMode::Chars)) // Document - end ??
73 {
75 return bRet;
76 }
77 bRet = IsStartWord();
78 }
79 Push();
80 ClearMark();
81 while( !bRet )
82 {
83 if( !GoNextWord() )
84 {
87 break;
88 bRet = IsStartWord();
89 }
90 else
91 bRet = true;
92 }
93 ClearMark();
94 Combine();
95 return bRet;
96}
97
99{
100 bool bRet = false;
101 while( IsSttPara() )
102 { // if already at the beginning, then the next???
104 { // Document - beginning ??
106 return bRet;
107 }
108 bRet = IsStartWord() || IsEndPara();
109 }
110 Push();
111 ClearMark();
112 while( !bRet )
113 {
114 if( !GoPrevWord() )
115 {
118 break;
119 bRet = IsStartWord();
120 }
121 else
122 bRet = true;
123 }
124 ClearMark();
125 Combine();
126 return bRet;
127}
128
129// #i92468#
130// method code of <SwWrtShell::NxtWrd_()> before fix for issue i72162
132{
133 if ( IsEndPara() )
134 {
136 {
138 return false;
139 }
140 return true;
141 }
142 Push();
143 ClearMark();
144 if ( !GoNextWord() )
145 {
147 }
148 ClearMark();
149 Combine();
150 return true;
151}
152
153// method code of <SwWrtShell::PrvWrd_()> before fix for issue i72162
155{
156 if ( IsSttPara() )
157 {
159 {
161 return false;
162 }
163 return true;
164 }
165 Push();
166 ClearMark();
167 if( !GoPrevWord() )
168 {
170 }
171 ClearMark();
172 Combine();
173 return true;
174}
175
177{
178 Push();
179 ClearMark();
181 {
183 return false;
184 }
185 if( !GoNextSentence() && !IsEndPara() )
187
188 ClearMark();
189 Combine();
190 return true;
191}
192
194{
195 Push();
196 ClearMark();
198 {
200 return false;
201 }
202 if( !GoStartSentence() && !IsSttPara() )
203 // not found --> go to the beginning of the paragraph
205 ClearMark();
206 Combine();
207 return true;
208}
209
211{
212 Push();
213 ClearMark();
215
216 ClearMark();
217 Combine();
218 return bRet;
219}
220
222{
223 Push();
224 ClearMark();
225
227 if ( !bRet && !IsSttOfPara() )
228 {
229 SttPara();
230 }
231
232 ClearMark();
233 Combine();
234 return bRet;
235}
236
237std::optional<OString> SwWrtShell::getLOKPayload(int nType, int nViewId) const
238{
239 switch(nType)
240 {
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);
249 }
250 abort();
251}
252
253/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GoStartWord()
Definition: crstrvl1.cxx:50
SwVisibleCursor * GetVisibleCursor() const
Definition: crsrsh.cxx:2729
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2246
bool GoNextSentence()
Definition: crstrvl1.cxx:68
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:340
bool GoEndWord()
Definition: crstrvl1.cxx:54
bool GoPrevWord()
Definition: crstrvl1.cxx:63
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: crsrsh.cxx:695
bool IsEndPara() const
Definition: crsrsh.cxx:1113
bool IsSttPara() const
Definition: crsrsh.cxx:1094
bool GoNextWord()
Definition: crstrvl1.cxx:59
void Combine()
Combine two cursors.
Definition: crsrsh.cxx:2342
bool GoStartSentence()
Definition: crstrvl1.cxx:78
bool Right(sal_uInt16 nCnt, SwCursorSkipMode nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:363
void ClearMark()
Definition: crsrsh.cxx:938
bool Left(sal_uInt16 nCnt, SwCursorSkipMode nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:361
bool IsStartWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES) const
Definition: crstrvl1.cxx:27
std::optional< OString > getLOKPayload(int nType, int nViewId) const
Definition: viscrs.cxx:519
std::optional< OString > getLOKPayload(int nType, int nViewId) const
Definition: viscrs.cxx:274
bool IsSttOfPara() const
Definition: wrtsh.hxx:196
SAL_DLLPRIVATE bool PrvWrdForDelete()
Definition: wrtsh4.cxx:154
std::optional< OString > getLOKPayload(int nType, int nViewId) const
Definition: wrtsh4.cxx:237
SAL_DLLPRIVATE bool BwdPara_()
Definition: wrtsh4.cxx:221
bool FwdPara_()
Definition: wrtsh4.cxx:210
bool SttPara(bool bSelect=false)
Definition: move.cxx:356
SAL_DLLPRIVATE void SttWrd()
Definition: wrtsh4.cxx:32
SAL_DLLPRIVATE bool NxtWrd_()
Definition: wrtsh4.cxx:67
SAL_DLLPRIVATE bool BwdSentence_()
Definition: wrtsh4.cxx:193
SAL_DLLPRIVATE bool PrvWrd_()
Definition: wrtsh4.cxx:98
SAL_DLLPRIVATE bool FwdSentence_()
Definition: wrtsh4.cxx:176
SAL_DLLPRIVATE void EndWrd()
Definition: wrtsh4.cxx:52
SAL_DLLPRIVATE bool NxtWrdForDelete()
Definition: wrtsh4.cxx:131
bool IsEndWrd()
Definition: wrtsh1.cxx:194
bool Pop(SwCursorShell::PopMode, ::std::optional< SwCallLink > &roLink)
Definition: wrtsh1.cxx:2025
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1218
bool GoPrevPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1204
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1246
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:48
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:49
QPRO_FUNC_TYPE nType