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 // Private methods, which move the cursor over search.
23 // The removal of the selection must be made on the level above.
24 
25 // The beginning of a word is the follow of a
26 // non-delimiter to delimiter. Furthermore, the follow of
27 // non-sentence separators on sentence separator.
28 // The begin of paragraph is also the word beginning.
29 
31 {
32  if ( IsSttPara() )
33  return;
34  // Create temporary cursor without selection.
35  Push();
36  ClearMark();
37  if( !GoStartWord() )
38  // not found --> go to the beginning of the paragraph.
40  ClearMark();
41  // If Mark was previously set, summarize.
42  Combine();
43 }
44 
45 // The end of a word is the follow of separator to nonseparator.
46 // The end of a word is also the sequence of word separators to
47 // punctuation marks.
48 // The end of a paragraph is also the end of a word.
49 
51 {
52  if ( IsEndWrd() )
53  return;
54  // Create temporary cursor without selection.
55  Push();
56  ClearMark();
57  if( !GoEndWord() )
58  // not found --> go to the end of the paragraph.
60  ClearMark();
61  // If Mark was previously set, summarize.
62  Combine();
63 }
64 
66 {
67  bool bRet = false;
68  while( IsEndPara() ) // If already at the end, then the next???
69  {
70  if(!SwCursorShell::Right(1,CRSR_SKIP_CHARS)) // Document - end ??
71  {
73  return bRet;
74  }
75  bRet = IsStartWord();
76  }
77  Push();
78  ClearMark();
79  while( !bRet )
80  {
81  if( !GoNextWord() )
82  {
85  break;
86  bRet = IsStartWord();
87  }
88  else
89  bRet = true;
90  }
91  ClearMark();
92  Combine();
93  return bRet;
94 }
95 
97 {
98  bool bRet = false;
99  while( IsSttPara() )
100  { // if already at the beginning, then the next???
102  { // Document - beginning ??
104  return bRet;
105  }
106  bRet = IsStartWord() || IsEndPara();
107  }
108  Push();
109  ClearMark();
110  while( !bRet )
111  {
112  if( !GoPrevWord() )
113  {
116  break;
117  bRet = IsStartWord();
118  }
119  else
120  bRet = true;
121  }
122  ClearMark();
123  Combine();
124  return bRet;
125 }
126 
127 // #i92468#
128 // method code of <SwWrtShell::NxtWrd_()> before fix for issue i72162
130 {
131  if ( IsEndPara() )
132  {
134  {
136  return false;
137  }
138  return true;
139  }
140  Push();
141  ClearMark();
142  if ( !GoNextWord() )
143  {
145  }
146  ClearMark();
147  Combine();
148  return true;
149 }
150 
151 // method code of <SwWrtShell::PrvWrd_()> before fix for issue i72162
153 {
154  if ( IsSttPara() )
155  {
157  {
159  return false;
160  }
161  return true;
162  }
163  Push();
164  ClearMark();
165  if( !GoPrevWord() )
166  {
168  }
169  ClearMark();
170  Combine();
171  return true;
172 }
173 
175 {
176  Push();
177  ClearMark();
179  {
181  return false;
182  }
183  if( !GoNextSentence() && !IsEndPara() )
185 
186  ClearMark();
187  Combine();
188  return true;
189 }
190 
192 {
193  Push();
194  ClearMark();
196  {
198  return false;
199  }
200  if( !GoStartSentence() && !IsSttPara() )
201  // not found --> go to the beginning of the paragraph
203  ClearMark();
204  Combine();
205  return true;
206 }
207 
209 {
210  Push();
211  ClearMark();
213 
214  ClearMark();
215  Combine();
216  return bRet;
217 }
218 
220 {
221  Push();
222  ClearMark();
223 
225  if ( !bRet && !IsSttOfPara() )
226  {
227  SttPara();
228  }
229 
230  ClearMark();
231  Combine();
232  return bRet;
233 }
234 
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool SttPara(bool bSelect=false)
Definition: move.cxx:348
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
bool Right(sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:355
bool GoStartWord()
Definition: crstrvl1.cxx:50
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:947
bool IsSttPara() const
Definition: crsrsh.cxx:1082
bool GoNextWord()
Definition: crstrvl1.cxx:59
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1726
bool GoNextSentence()
Definition: crstrvl1.cxx:68
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
SAL_DLLPRIVATE void EndWrd()
Definition: wrtsh4.cxx:50
SAL_DLLPRIVATE bool BwdPara_()
Definition: wrtsh4.cxx:219
bool Left(sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:353
SAL_DLLPRIVATE bool FwdSentence_()
Definition: wrtsh4.cxx:174
bool GoPrevWord()
Definition: crstrvl1.cxx:63
bool GoStartSentence()
Definition: crstrvl1.cxx:78
bool GoPrevPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:933
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: crsrsh.cxx:683
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2221
SAL_DLLPRIVATE bool BwdSentence_()
Definition: wrtsh4.cxx:191
bool IsSttOfPara() const
Definition: wrtsh.hxx:189
SAL_DLLPRIVATE bool PrvWrdForDelete()
Definition: wrtsh4.cxx:152
SAL_DLLPRIVATE void SttWrd()
Definition: wrtsh4.cxx:30
bool IsStartWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES) const
Definition: crstrvl1.cxx:27
void Combine()
Combine two cursors.
Definition: crsrsh.cxx:2308
bool GoEndWord()
Definition: crstrvl1.cxx:54
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:975
void ClearMark()
Definition: crsrsh.cxx:926
bool IsEndWrd()
Definition: wrtsh1.cxx:175
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
SAL_DLLPRIVATE bool NxtWrd_()
Definition: wrtsh4.cxx:65
bool FwdPara_()
Definition: wrtsh4.cxx:208
SAL_DLLPRIVATE bool PrvWrd_()
Definition: wrtsh4.cxx:96
bool IsEndPara() const
Definition: crsrsh.cxx:1101
SAL_DLLPRIVATE bool NxtWrdForDelete()
Definition: wrtsh4.cxx:129