LibreOffice Module sw (master)  1
select.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 <limits.h>
21 #include <hintids.hxx>
22 #include <sfx2/bindings.hxx>
23 #include <sfx2/viewfrm.hxx>
24 #include <svl/eitem.hxx>
25 #include <svl/macitem.hxx>
26 #include <svx/svxids.hrc>
27 #include <unotools/charclass.hxx>
29 #include <sfx2/event.hxx>
30 #include <cmdid.h>
31 #include <view.hxx>
32 #include <basesh.hxx>
33 #include <wrtsh.hxx>
34 #include <frmatr.hxx>
35 #include <initui.hxx>
36 #include <mdiexp.hxx>
37 #include <fmtcol.hxx>
38 #include <frmfmt.hxx>
39 #include <swundo.hxx>
40 #include <swevent.hxx>
41 #include <swdtflvr.hxx>
42 #include <doc.hxx>
43 #include <wordcountdialog.hxx>
44 #include <memory>
45 #include <vcl/uitest/logger.hxx>
47 
48 namespace com { namespace sun { namespace star { namespace util {
49  struct SearchOptions2;
50 } } } }
51 
52 using namespace ::com::sun::star::util;
53 
54 static long nStartDragX = 0, nStartDragY = 0;
55 static bool bStartDrag = false;
56 
58 {
59  // to avoid making the slot volatile, invalidate it every time if something could have been changed
60  // this is still much cheaper than asking for the state every 200 ms (and avoid background processing)
62  SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
63  if (pWrdCnt)
64  pWrdCnt->UpdateCounts();
65 }
66 
68 {
69  SwMvContext aMvContext(this);
70  if( !IsInWord() && !IsEndWrd() && !IsStartWord() )
71  PrvWrd();
72  if( IsEndWrd() )
73  Left(CRSR_SKIP_CELLS, false, 1, false );
74  return SelWrd();
75 }
76 
77 bool SwWrtShell::SelWrd(const Point *pPt )
78 {
79  bool bRet;
80  {
81  SwMvContext aMvContext(this);
82  SttSelect();
83  bRet = SwCursorShell::SelectWord( pPt );
84  }
85  EndSelect();
86  if( bRet )
87  {
88  m_bSelWrd = true;
89  if(pPt)
90  m_aStart = *pPt;
91  }
92  return bRet;
93 }
94 
95 void SwWrtShell::SelSentence(const Point *pPt )
96 {
97  {
98  SwMvContext aMvContext(this);
99  ClearMark();
101  SttSelect();
103  }
104  EndSelect();
105  if(pPt)
106  m_aStart = *pPt;
107  m_bSelLn = true;
108  m_bSelWrd = false; // disable SelWord, otherwise no SelLine goes on
109 }
110 
111 void SwWrtShell::SelPara(const Point *pPt )
112 {
113  {
114  SwMvContext aMvContext(this);
115  ClearMark();
117  SttSelect();
119  }
120  EndSelect();
121  if(pPt)
122  m_aStart = *pPt;
123  m_bSelLn = false;
124  m_bSelWrd = false; // disable SelWord, otherwise no SelLine goes on
125 }
126 
128 {
129  const bool bLockedView = IsViewLocked();
130  LockView( true );
131  {
132  if(m_bBlockMode)
133  LeaveBlockMode();
134  SwMvContext aMvContext(this);
135  bool bMoveTable = false;
136  std::unique_ptr<SwPosition> pStartPos;
137  std::unique_ptr<SwPosition> pEndPos;
138  SwShellCursor* pTmpCursor = nullptr;
139 
140  // Query these early, before we move the cursor.
141  bool bHasWholeTabSelection = HasWholeTabSelection();
142  bool bIsCursorInTable = IsCursorInTable();
143 
144  if (!bHasWholeTabSelection)
145  {
146  if ( IsSelection() && IsCursorPtAtEnd() )
147  SwapPam();
148  pTmpCursor = getShellCursor( false );
149  if( pTmpCursor )
150  {
151  pStartPos.reset(new SwPosition( *pTmpCursor->GetPoint() ));
152  pEndPos.reset(new SwPosition( *pTmpCursor->GetMark() ));
153  }
154  Push();
155  bool bIsFullSel = !MoveSection( GoCurrSection, fnSectionStart);
156  SwapPam();
157  bIsFullSel &= !MoveSection( GoCurrSection, fnSectionEnd);
159  GoStart(true, &bMoveTable, false, !bIsFullSel);
160  }
161  else
162  {
163  EnterStdMode();
164  SttEndDoc(true);
165  }
166  SttSelect();
167  GoEnd(true, &bMoveTable);
168 
169  bool bNeedsExtendedSelectAll = StartsWithTable();
170 
171  // If the cursor was in a table, then we only need the extended select
172  // all if the whole table is already selected, to still allow selecting
173  // only a single cell or a single table before selecting the whole
174  // document.
175  if (bNeedsExtendedSelectAll && bIsCursorInTable)
176  bNeedsExtendedSelectAll = bHasWholeTabSelection;
177 
178  if (bNeedsExtendedSelectAll)
179  {
180  // Disable table cursor to make sure getShellCursor() returns m_pCurrentCursor, not m_pTableCursor.
181  if (IsTableMode())
183  // Do the extended select all on m_pCurrentCursor.
184  ExtendedSelectAll(/*bFootnotes =*/ false);
185  }
186 
187  SwDoc *pDoc = GetDoc();
188  if ( pDoc )
189  {
190  pDoc->SetPrepareSelAll();
191  }
192 
193  if( pStartPos )
194  {
195  pTmpCursor = getShellCursor( false );
196  if( pTmpCursor )
197  {
198  // Some special handling for sections (e.g. TOC) at the beginning of the document body
199  // to avoid the selection of the first section
200  // if the last selection was behind the first section or
201  // if the last selection was already the first section
202  // In this both cases we select to the end of document
203  if( ( *pTmpCursor->GetPoint() < *pEndPos ||
204  ( *pStartPos == *pTmpCursor->GetMark() &&
205  *pEndPos == *pTmpCursor->GetPoint() ) ) && !bNeedsExtendedSelectAll)
207  }
208  }
209  }
210  EndSelect();
211  LockView( bLockedView );
212 }
213 
214 // Description: Text search
215 
216 sal_uLong SwWrtShell::SearchPattern( const i18nutil::SearchOptions2& rSearchOpt, bool bSearchInNotes,
217  SwDocPositions eStt, SwDocPositions eEnd,
218  FindRanges eFlags, bool bReplace )
219 {
220  // no enhancement of existing selections
221  if(!(eFlags & FindRanges::InSel))
222  ClearMark();
223  bool bCancel = false;
224  sal_uLong nRet = Find_Text(rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace);
225  if(bCancel)
226  {
227  Undo();
228  nRet = ULONG_MAX;
229  }
230  return nRet;
231 }
232 
233 // Description: search for templates
234 
235 sal_uLong SwWrtShell::SearchTempl( const OUString &rTempl,
236  SwDocPositions eStt, SwDocPositions eEnd,
237  FindRanges eFlags, const OUString* pReplTempl )
238 {
239  // no enhancement of existing selections
240  if(!(eFlags & FindRanges::InSel))
241  ClearMark();
243  SwTextFormatColl *pReplaceColl = nullptr;
244  if( pReplTempl )
245  pReplaceColl = GetParaStyle(*pReplTempl, SwWrtShell::GETSTYLE_CREATESOME );
246 
247  bool bCancel = false;
248  sal_uLong nRet = FindFormat(pColl ? *pColl : GetDfltTextFormatColl(),
249  eStt,eEnd, bCancel, eFlags, pReplaceColl);
250  if(bCancel)
251  {
252  Undo();
253  nRet = ULONG_MAX;
254  }
255  return nRet;
256 }
257 
258 // search for attributes
259 
260 sal_uLong SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, bool bNoColls,
261  SwDocPositions eStart, SwDocPositions eEnd,
262  FindRanges eFlags, const i18nutil::SearchOptions2* pSearchOpt,
263  const SfxItemSet* pReplaceSet )
264 {
265  // no enhancement of existing selections
266  if (!(eFlags & FindRanges::InSel))
267  ClearMark();
268 
269  // Searching
270  bool bCancel = false;
271  sal_uLong nRet = FindAttrs(rFindSet, bNoColls, eStart, eEnd, bCancel, eFlags, pSearchOpt, pReplaceSet);
272 
273  if(bCancel)
274  {
275  Undo();
276  nRet = ULONG_MAX;
277  }
278  return nRet;
279 }
280 
281 // Selection modes
282 
284 {
286 }
287 
289 {
290  if ( nullptr == m_pModeStack )
291  return;
292 
293  if ( m_bExtMode && !m_pModeStack->bExt )
294  LeaveExtMode();
295  if ( m_bAddMode && !m_pModeStack->bAdd )
296  LeaveAddMode();
297  if ( m_bBlockMode && !m_pModeStack->bBlock )
298  LeaveBlockMode();
300 
301  m_pModeStack = std::move(m_pModeStack->pNext);
302 }
303 
304 // Two methods for setting cursors: the first maps at the
305 // eponymous methods in the CursorShell, the second removes
306 // all selections at first.
307 
308 long SwWrtShell::SetCursor(const Point *pPt, bool bTextOnly)
309 {
310  // Remove a possibly present selection at the position
311  // of the mouseclick
312 
313  if(!IsInSelect() && TestCurrPam(*pPt)) {
314  ClearMark();
315  }
316 
317  return SwCursorShell::SetCursor(*pPt, bTextOnly);
318 }
319 
320 long SwWrtShell::SetCursorKillSel(const Point *pPt, bool bTextOnly )
321 {
322  SwActContext aActContext(this);
323  ResetSelect(pPt,false);
324  return SwCursorShell::SetCursor(*pPt, bTextOnly);
325 }
326 
328 {
329  // Remove Frame selection with guaranteed invalid position
330  Point aPt(LONG_MIN, LONG_MIN);
331  SelectObj(aPt);
333 }
334 
335 // Remove of all selections
336 
337 long SwWrtShell::ResetSelect(const Point *,bool)
338 {
339  if(IsSelFrameMode())
340  {
341  UnSelectFrame();
343  }
344  else
345  {
346  // SwActContext opens an Action -
347  // to avoid problems in the basic process with the
348  // shell switching, GetChgLnk().Call() may be called
349  // after EndAction().
350  {
351  SwActContext aActContext(this);
352  m_bSelWrd = m_bSelLn = false;
353  KillPams();
354  ClearMark();
357  }
358 
359  // After canceling of all selections an update of Attr-Controls
360  // could be necessary.
361  GetChgLnk().Call(nullptr);
362 
365  }
366  Invalidate();
368  return 1;
369 }
370 
372 {
373  return GetDoc()->IsSplitVerticalByDefault();
374 }
375 
377 {
379 }
380 
381 // Do nothing
382 
383 long SwWrtShell::Ignore(const Point *, bool ) {
384  return 1;
385 }
386 
387 // Begin of a selection process.
388 
390 {
391  if(m_bInSelect)
392  return;
393  if(!HasMark())
394  SetMark();
395  if( m_bBlockMode )
396  {
397  SwShellCursor* pTmp = getShellCursor( true );
398  if( !pTmp->HasMark() )
399  pTmp->SetMark();
400  }
403  m_bInSelect = true;
404  Invalidate();
406 }
407 
408 namespace {
409 
410 void collectUIInformation(SwShellCursor* pCursor)
411 {
412  EventDescription aDescription;
413  OUString aSelStart = OUString::number(pCursor->Start()->nContent.GetIndex());
414  OUString aSelEnd = OUString::number(pCursor->End()->nContent.GetIndex());
415 
416  aDescription.aParameters = {{"START_POS", aSelStart}, {"END_POS", aSelEnd}};
417  aDescription.aAction = "SELECT";
418  aDescription.aID = "writer_edit";
419  aDescription.aKeyWord = "SwEditWinUIObject";
420  aDescription.aParent = "MainWindow";
421 
422  UITestLogger::getInstance().logEvent(aDescription);
423 }
424 
425 }
426 
427 // End of a selection process.
428 
430 {
431  if(m_bInSelect && !m_bExtMode)
432  {
433  m_bInSelect = false;
434  if (m_bAddMode)
435  {
436  AddLeaveSelect();
437  }
438  else
439  {
440  SttLeaveSelect();
443  }
444  }
445  SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
446  if (pWrdCnt)
447  pWrdCnt->UpdateCounts();
448 
449  collectUIInformation(GetCursor_());
450 }
451 
452 void SwWrtShell::ExtSelWrd(const Point *pPt, bool )
453 {
454  SwMvContext aMvContext(this);
455  if( IsTableMode() )
456  return;
457 
458  // Bug 66823: actual crsr has in additional mode no selection?
459  // Then destroy the actual and go to prev, this will be expand
460  if( !HasMark() && GoPrevCursor() )
461  {
462  bool bHasMark = HasMark(); // that's wrong!
463  GoNextCursor();
464  if( bHasMark )
465  {
466  DestroyCursor();
467  GoPrevCursor();
468  }
469  }
470 
471  // check the direction of the selection with the new point
472  bool bMoveCursor = true, bToTop = false;
473  SwCursorShell::SelectWord( &m_aStart ); // select the startword
474  SwCursorShell::Push(); // save the cursor
475  SwCursorShell::SetCursor( *pPt ); // and check the direction
476 
478  {
479  case -1: bToTop = false; break;
480  case 1: bToTop = true; break;
481  default: bMoveCursor = false; break;
482  }
483 
484  SwCursorShell::Pop(SwCursorShell::PopMode::DeleteCurrent); // restore the saved cursor
485 
486  if( bMoveCursor )
487  {
488  // select to Top but cursor select to Bottom? or
489  // select to Bottom but cursor select to Top? --> swap the cursor
490  if( bToTop )
491  SwapPam();
492 
493  SwCursorShell::Push(); // save cur cursor
494  if( SwCursorShell::SelectWord( pPt )) // select the current word
495  {
496  if( bToTop )
497  SwapPam();
498  Combine();
499  }
500  else
501  {
503  if( bToTop )
504  SwapPam();
505  }
506  }
507 }
508 
509 void SwWrtShell::ExtSelLn(const Point *pPt, bool )
510 {
511  SwMvContext aMvContext(this);
513  if( IsTableMode() )
514  return;
515 
516  // Bug 66823: actual crsr has in additional mode no selection?
517  // Then destroy the actual and go to prev, this will be expand
518  if( !HasMark() && GoPrevCursor() )
519  {
520  bool bHasMark = HasMark(); // that's wrong!
521  GoNextCursor();
522  if( bHasMark )
523  {
524  DestroyCursor();
525  GoPrevCursor();
526  }
527  }
528 
529  // if applicable fit the selection to the "Mark"
530  bool bToTop = !IsCursorPtAtEnd();
531  SwapPam();
532 
533  // The "Mark" has to be at the end or the beginning of the line.
534  if( bToTop ? !IsEndSentence() : !IsStartSentence() )
535  {
536  if( bToTop )
537  {
538  if( !IsEndPara() )
541  }
542  else
544  }
545  SwapPam();
546 
547  if (bToTop)
549  else
551 }
552 
553 // Back into the standard mode: no mode, no selections.
554 
556 {
557  if(m_bAddMode)
558  LeaveAddMode();
559  if(m_bBlockMode)
560  LeaveBlockMode();
561  m_bBlockMode = false;
562  m_bExtMode = false;
563  m_bInSelect = false;
564  if(IsSelFrameMode())
565  {
566  UnSelectFrame();
568  }
569  else
570  {
571  // SwActContext opens and action which has to be
572  // closed prior to the call of
573  // GetChgLnk().Call()
574  SwActContext aActContext(this);
575  m_bSelWrd = m_bSelLn = false;
576  if( !IsRetainSelection() )
577  KillPams();
578  ClearMark();
581  }
582  Invalidate();
584 }
585 
586 // Extended Mode
587 
589 {
590  if(m_bBlockMode)
591  {
592  LeaveBlockMode();
593  KillPams();
594  ClearMark();
595  }
596  m_bExtMode = true;
597  m_bAddMode = false;
598  m_bBlockMode = false;
599  SttSelect();
600 }
601 
603 {
604  m_bExtMode = false;
605  EndSelect();
606 }
607 
608 // End of a selection; if the selection is empty,
609 // ClearMark().
610 
612 {
614  return;
615  }
616  ClearMark();
617 }
618 
619 // Leaving of the selection mode in additional mode
620 
622 {
623  if(IsTableMode()) LeaveAddMode();
624  else if(SwCursorShell::HasSelection())
625  CreateCursor();
626 }
627 
628 // Additional Mode
629 
631 {
632  if(IsTableMode()) return;
633  if(m_bBlockMode)
634  LeaveBlockMode();
637  m_bAddMode = true;
638  m_bBlockMode = false;
639  m_bExtMode = false;
641  CreateCursor();
642  Invalidate();
643 }
644 
646 {
649  m_bAddMode = false;
650  Invalidate();
651 }
652 
653 // Block Mode
654 
656 {
657  m_bBlockMode = false;
658  EnterStdMode();
659  m_bBlockMode = true;
661  Invalidate();
662 }
663 
665 {
666  m_bBlockMode = false;
668  EndSelect();
669  Invalidate();
670 }
671 
672 // Insert mode
673 
674 void SwWrtShell::SetInsMode( bool bOn )
675 {
676  m_bIns = bOn;
678  const SfxBoolItem aTmp( SID_ATTR_INSERT, m_bIns );
679  GetView().GetViewFrame()->GetBindings().SetState( aTmp );
680  StartAction();
681  EndAction();
682  Invalidate();
683 }
684 //Overwrite mode is incompatible with red-lining
686 {
687  SetRedlineFlags( eMode );
688  if (IsRedlineOn())
689  SetInsMode();
690 }
691 
692 // Edit frame
693 
694 void SwWrtShell::BeginFrameDrag(const Point *pPt, bool bIsShift)
695 {
697  if(bStartDrag)
698  {
699  Point aTmp( nStartDragX, nStartDragY );
700  SwFEShell::BeginDrag( &aTmp, bIsShift );
701  }
702  else
703  SwFEShell::BeginDrag( pPt, bIsShift );
704 }
705 
707 {
708  if(pPos)
709  {
710  nStartDragX = pPos->X();
711  nStartDragY = pPos->Y();
712  bStartDrag = true;
713  }
714  m_bLayoutMode = true;
715  HideCursor();
716 
717  // equal call of BeginDrag in the SwFEShell
721  Invalidate();
722 }
723 
725 {
728  m_bLayoutMode = false;
729  bStartDrag = false;
730  Edit();
732  Invalidate();
733 }
734 
735 // Description: execute framebound macro
736 
737 IMPL_LINK( SwWrtShell, ExecFlyMac, const SwFlyFrameFormat*, pFlyFormat, void )
738 {
739  const SwFrameFormat *pFormat = pFlyFormat ? static_cast<const SwFrameFormat*>(pFlyFormat) : GetFlyFrameFormat();
740  OSL_ENSURE(pFormat, "no frame format");
741  const SvxMacroItem &rFormatMac = pFormat->GetMacro();
742 
743  if(rFormatMac.HasMacro(SvMacroItemId::SwObjectSelect))
744  {
745  const SvxMacro &rMac = rFormatMac.GetMacro(SvMacroItemId::SwObjectSelect);
746  if( IsFrameSelected() )
747  m_bLayoutMode = true;
748  CallChgLnk();
749  ExecMacro( rMac );
750  }
751 }
752 
754 {
755  // still a dummy
758 }
759 
760 // Handler for toggling the modes. Returns back the old mode.
761 
763 {
765  Invalidate();
766 }
767 
769 {
771  Invalidate();
772  return !m_bBlockMode;
773 }
774 
776 {
778  Invalidate();
779  return !m_bExtMode;
780 }
781 
782 // Dragging in standard mode (Selecting of content)
783 
784 void SwWrtShell::BeginDrag(const Point * /*pPt*/, bool )
785 {
786  if(m_bSelWrd)
787  {
788  m_bInSelect = true;
789  if( !IsCursorPtAtEnd() )
790  SwapPam();
791 
794  }
795  else if(m_bSelLn)
796  {
797  m_bInSelect = true;
800  }
801  else
802  {
804  SttSelect();
805  }
806 }
807 
808 void SwWrtShell::DefaultDrag(const Point *, bool )
809 {
810  if( IsSelTableCells() )
811  m_aSelTableLink.Call(*this);
812 }
813 
814 void SwWrtShell::DefaultEndDrag(const Point * /*pPt*/, bool )
815 {
817  if( IsExtSel() )
818  LeaveExtSel();
819 
820  if( IsSelTableCells() )
821  m_aSelTableLink.Call(*this);
822  EndSelect();
823 }
824 
825 // #i32329# Enhanced table selection
826 bool SwWrtShell::SelectTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag )
827 {
828  SwMvContext aMvContext(this);
829  SttSelect();
830  if(SelTableRowCol( rPt, pEnd, bRowDrag ))
831  {
834  return true;
835  }
836  return false;
837 }
838 
839 // Description: Selection of a table line or column
840 
842 {
843  if ( SelTableRow() )
844  {
847  }
848 }
849 
851 {
852  if ( SelTableCol() )
853  {
856  }
857 }
858 
860 {
861  if ( SelTableBox() )
862  {
865  }
866 }
867 
868 // Description: Check if a word selection is present.
869 // According to the rules for intelligent cut / paste
870 // surrounding spaces are cut out.
871 // Return: Delivers the type of the word selection.
872 
873 int SwWrtShell::IntelligentCut(SelectionType nSelection, bool bCut)
874 {
875  // On multiple selection no intelligent drag and drop
876  // there are multiple cursors, since a second was placed
877  // already at the target position.
878  if( IsAddMode() || !(nSelection & SelectionType::Text) )
879  return NO_WORD;
880 
881  OUString sText;
882  CharClass& rCC = GetAppCharClass();
883 
884  // If the first character is no word character,
885  // no word selected.
886  sal_Unicode cPrev = GetChar(false);
887  sal_Unicode cNext = GetChar(true, -1);
888  if( !cPrev || !cNext ||
889  !rCC.isLetterNumeric( ( sText = OUString(cPrev) ), 0 ) ||
890  !rCC.isLetterNumeric( ( sText = OUString(cNext) ), 0 ) )
891  return NO_WORD;
892 
893  cPrev = GetChar(false, -1);
894  cNext = GetChar();
895 
896  int cWord = NO_WORD;
897  // is a word selected?
898  if (cPrev && cNext &&
899  CH_TXTATR_BREAKWORD != cPrev && CH_TXTATR_INWORD != cPrev &&
900  CH_TXTATR_BREAKWORD != cNext && CH_TXTATR_INWORD != cNext &&
901  !rCC.isLetterNumeric( ( sText = OUString(cPrev) ), 0 ) &&
902  !rCC.isLetterNumeric( ( sText = OUString(cNext) ), 0 ) )
903  cWord = WORD_NO_SPACE;
904 
905  if(cWord == WORD_NO_SPACE && ' ' == cPrev )
906  {
907  cWord = WORD_SPACE_BEFORE;
908  // delete the space before
909  if(bCut)
910  {
911  Push();
912  if(IsCursorPtAtEnd())
913  SwapPam();
914  ClearMark();
915  SetMark();
919  }
920  }
921  else if(cWord == WORD_NO_SPACE && cNext == ' ')
922  {
923  cWord = WORD_SPACE_AFTER;
924  // delete the space behind
925  if(bCut) {
926  Push();
927  if(!IsCursorPtAtEnd()) SwapPam();
928  ClearMark();
929  SetMark();
933  }
934  }
935  return cWord;
936 }
937 
938  // jump to the next / previous hyperlink - inside text and also
939  // on graphics
941 {
942  StartAction();
943  bool bRet = SwCursorShell::SelectNxtPrvHyperlink( bNext );
944  if( !bRet ) // didn't find? wrap and check again
945  {
946  SwShellCursor* pCursor = GetCursor_();
947  SwCursorSaveState aSaveState(*pCursor);
948  EnterStdMode();
949  if( bNext )
950  SttEndDoc(true);
951  else
952  SttEndDoc(false);
954  if (!bRet) // didn't find again? restore cursor position and bail
955  {
956  pCursor->RestoreSavePos();
957  EndAction(true); // don't scroll to restored cursor position
958  return;
959  }
960  }
961  EndAction();
962 
963  bool bCreateXSelection = false;
964  const bool bFrameSelected = IsFrameSelected() || IsObjSelected();
965  if( IsSelection() )
966  {
967  if ( bFrameSelected )
968  UnSelectFrame();
969 
970  // Set the function pointer for the canceling of the selection
971  // set at cursor
974  bCreateXSelection = true;
975  }
976  else if( bFrameSelected )
977  {
979  bCreateXSelection = true;
980  }
981  else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
982  {
983  SelectObj( GetCharRect().Pos() );
985  bCreateXSelection = true;
986  }
987 
988  if( bCreateXSelection )
990 }
991 
992 // For the preservation of the selection the cursor will be moved left
993 // after SetMark(), so that the cursor is not moved by inserting text.
994 // Because a present selection at the CORE page is cleared at the
995 // current cursor position, the cursor will be pushed on the stack.
996 // After moving, they will again resummarized.
997 
998 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bSelLn
Definition: wrtsh.hxx:572
SfxViewFrame * GetViewFrame() const
bool SelectTableRowCol(const Point &rPt, const Point *pEnd=nullptr, bool bRowDrag=false)
Definition: select.cxx:826
bool ToggleBlockMode()
Definition: select.cxx:768
static bool bStartDrag
Definition: select.cxx:55
void EnterBlockMode()
Definition: select.cxx:655
void KillPams()
Definition: crsrsh.cxx:1009
bool SelNearestWrd()
Definition: select.cxx:67
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
sal_uLong Find_Text(const i18nutil::SearchOptions2 &rSearchOpt, bool bSearchInNotes, SwDocPositions eStart, SwDocPositions eEnd, bool &bCancel, FindRanges eRng, bool bReplace=false)
Definition: crsrsh.cxx:3421
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
Marks a position in the document model.
Definition: pam.hxx:35
SfxChildWindow * GetChildWindow(sal_uInt16)
bool Right(sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:355
sal_uLong SearchTempl(const OUString &rTempl, SwDocPositions eStart, SwDocPositions eEnd, FindRanges eFlags=FindRanges::InBody, const OUString *pReplTempl=nullptr)
Definition: select.cxx:235
void SetPrepareSelAll()
Definition: doc.hxx:560
void SetState(const SfxItemSet &rSet)
bool GoNextCursor()
go to the next SSelection
Definition: crsrsh.cxx:1344
bool SttEndDoc(bool bStt)
Definition: crsrsh.cxx:562
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:951
bool m_bBlockMode
Definition: wrtsh.hxx:569
sal_Unicode GetChar(bool bEnd=true, long nOffset=0)
get the nth character of the current SSelection
Definition: crsrsh.cxx:2563
SELECTFUNC2 m_fnDrag
Definition: wrtsh.hxx:108
void LeaveBlockMode()
Definition: select.cxx:664
bool IsTableMode() const
Definition: crsrsh.hxx:647
bool SelTableRow()
Definition: crsrsh.hxx:604
void SetRedlineFlags(RedlineFlags eMode)
Definition: edredln.cxx:31
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:3006
SAL_DLLPRIVATE void UpdateLayoutFrame(const Point *, bool bProp)
Definition: select.cxx:753
bool IsRetainSelection() const
Definition: wrtsh.hxx:269
sal_uIntPtr sal_uLong
#define CNT_GRF
Definition: editsh.hxx:132
const SwPosition * GetMark() const
Definition: pam.hxx:209
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1726
bool GoEndSentence()
Definition: crstrvl1.cxx:73
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:572
Definition: doc.hxx:185
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
bool m_bSelWrd
Definition: wrtsh.hxx:571
Link< SwWrtShell &, void > m_aSelTableLink
Definition: wrtsh.hxx:578
bool Left(sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:353
void EnterStdMode()
Definition: select.cxx:555
void DestroyCursor()
transform TableCursor to normal cursor, nullify Tablemode
Definition: crsrsh.cxx:141
void ExtendedSelectAll(bool bFootnotes=true)
Definition: crsrsh.cxx:583
bool m_bLayoutMode
Definition: wrtsh.hxx:570
void SetRedlineFlagsAndCheckInsMode(RedlineFlags eMode)
Definition: select.cxx:685
void Invalidate(sal_uInt16 nId)
Find in selections.
SAL_DLLPRIVATE void ExtSelLn(const Point *, bool bProp)
Definition: select.cxx:509
bool HasSelection() const
Does the current cursor create a selection?
Definition: crsrsh.cxx:2486
SAL_DLLPRIVATE void BeginFrameDrag(const Point *, bool bProp)
Definition: select.cxx:694
SwDocPositions
Definition: cshtyp.hxx:103
void SwapPam()
Definition: crsrsh.cxx:963
bool GoStartSentence()
Definition: crstrvl1.cxx:78
bool IsRedlineOn() const
Definition: edredln.cxx:42
bool IsStartSentence() const
Definition: crstrvl1.cxx:41
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
static UITestLogger & getInstance()
void SelectTableRow()
Definition: select.cxx:841
void BeginDrag(const Point *pPt, bool bProp)
Definition: feshview.cxx:713
#define CH_TXTATR_BREAKWORD
Definition: hintids.hxx:43
void logEvent(const EventDescription &rDescription)
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
sal_uInt16 sal_Unicode
#define CH_TXTATR_INWORD
Definition: hintids.hxx:44
const SwView & GetView() const
Definition: wrtsh.hxx:428
bool const bExt
Definition: wrtsh.hxx:500
SwIndex nContent
Definition: pam.hxx:38
static void CreateSelection(SwWrtShell &rSh, const SwFrameShell *pCreator=nullptr)
Definition: swdtflvr.cxx:3963
void LeaveAddMode()
Definition: select.cxx:645
void Edit()
Definition: wrtsh1.cxx:167
FindRanges
Definition: cshtyp.hxx:90
SELECTFUNC m_fnSetCursor
Definition: wrtsh.hxx:109
void SetOverwriteCursor(bool bFlag)
Definition: crsrsh.hxx:464
bool PrvWrd(bool bSelect=false)
Definition: wrtsh.hxx:211
SAL_DLLPRIVATE bool GoStart(bool KeepArea, bool *, bool bSelect, bool bDontMoveRegion=false)
Definition: move.cxx:200
int SetCursor(const Point &rPt, bool bOnlyText=false, bool bBlock=true)
Definition: crsrsh.cxx:748
#define FN_STAT_SELMODE
Definition: cmdid.h:811
bool SelTableCol()
Definition: crsrsh.hxx:605
const SvxMacroItem & GetMacro(bool=true) const
Definition: frmatr.hxx:92
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
bool SelTableRowCol(const Point &rPt, const Point *pEnd, bool bRowDrag)
pEnd will be used during MouseMove
Definition: fetab.cxx:1771
bool SelectNxtPrvHyperlink(bool bNext)
Definition: crstrvl.cxx:2402
void SelectTableCol()
Definition: select.cxx:850
void SelPara(const Point *)
Definition: select.cxx:111
SAL_DLLPRIVATE void DefaultDrag(const Point *, bool bProp)
Definition: select.cxx:808
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:332
SELECTFUNC2 m_fnEndDrag
Definition: wrtsh.hxx:110
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: crsrsh.cxx:683
void EndSelect()
Definition: select.cxx:429
Class for automated call of Start- and EndAction().
Definition: editsh.hxx:1020
bool IsSelection() const
Definition: crsrsh.hxx:883
const SwTableNode * IsCursorInTable() const
Definition: crsrsh.hxx:893
Style of a layout element.
Definition: frmfmt.hxx:57
bool ToggleExtMode()
Definition: select.cxx:775
A helper class to save cursor state (position).
Definition: swcrsr.hxx:230
bool SelWrd(const Point *=nullptr)
Definition: select.cxx:77
SwPaM * CreateCursor()
delete the current cursor and make the following into the current
Definition: crsrsh.cxx:117
const SwPosition * GetPoint() const
Definition: pam.hxx:207
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:228
void EndDrag()
Definition: feshview.cxx:739
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2221
void SetSplitVerticalByDefault(bool value)
Definition: doc.cxx:1717
SAL_DLLPRIVATE void AddLeaveSelect()
Definition: select.cxx:621
bool m_bIns
Definition: wrtsh.hxx:565
bool SelTableBox()
Definition: trvltbl.cxx:285
SfxBindings & GetBindings()
IMPL_LINK(SwWrtShell, ExecFlyMac, const SwFlyFrameFormat *, pFlyFormat, void)
Definition: select.cxx:737
bool HasMark() const
Definition: crsrsh.hxx:881
void BlockCursorToCursor()
Definition: crsrsh.cxx:890
int IntelligentCut(SelectionType nSelectionType, bool bCut=true)
Definition: select.cxx:873
SAL_DLLPRIVATE bool GoEnd(bool KeepArea=false, const bool *=nullptr)
Definition: move.cxx:266
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
bool m_bExtMode
Definition: wrtsh.hxx:567
void SelSentence(const Point *)
Definition: select.cxx:95
bool IsInWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES) const
Definition: crstrvl1.cxx:36
sal_uLong SearchPattern(const i18nutil::SearchOptions2 &rSearchOpt, bool bSearchInNotes, SwDocPositions eStart, SwDocPositions eEnd, FindRanges eFlags=FindRanges::InBody, bool bReplace=false)
Definition: select.cxx:216
bool m_bInSelect
Definition: wrtsh.hxx:566
void Invalidate()
Definition: select.cxx:57
SwTable::SearchType GetEnhancedTableSelection() const
Definition: crsrsh.hxx:807
void SetMark()
Definition: crsrsh.hxx:879
bool GoCurrSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:993
static void SetFrameMode(FlyMode eMode, SwWrtShell *pShell)
Definition: basesh.cxx:1988
long ResetSelect(const Point *, bool)
Definition: select.cxx:337
sal_uLong SearchAttr(const SfxItemSet &rFindSet, bool bNoColls, SwDocPositions eStart, SwDocPositions eEnd, FindRanges eFlags=FindRanges::InBody, const i18nutil::SearchOptions2 *pSearchOpt=nullptr, const SfxItemSet *pReplaceSet=nullptr)
Definition: select.cxx:260
#define CNT_OLE
Definition: editsh.hxx:133
bool IsSelTableCells() const
Definition: crsrsh.hxx:804
sal_uLong FindFormat(const SwTextFormatColl &rFormatColl, SwDocPositions eStart, SwDocPositions eEnd, bool &bCancel, FindRanges eRng, const SwTextFormatColl *pReplFormat)
Definition: crsrsh.cxx:3440
bool HasMacro(SvMacroItemId nEvent) const
bool IsEndSentence() const
Definition: crstrvl1.cxx:45
void SttSelect()
Definition: select.cxx:389
struct SwWrtShell::ModeStack * m_pModeStack
void SelAll()
Definition: select.cxx:127
void PopMode()
Definition: select.cxx:288
const Link< LinkParamNone *, void > & GetChgLnk() const
Definition: crsrsh.hxx:488
bool IsInSelect() const
Definition: wrtsh.hxx:138
void TableCursorToCursor()
enter block mode, change normal cursor into block cursor
Definition: crsrsh.cxx:883
long X() const
Point m_aStart
Definition: wrtsh.hxx:577
const SwPosition * Start() const
Definition: pam.hxx:212
void LeaveExtMode()
Definition: select.cxx:602
SAL_DLLPRIVATE void DefaultEndDrag(const Point *, bool bProp)
Definition: select.cxx:814
bool MoveSection(SwWhichSection, SwMoveFnCollection const &)
Definition: crsrsh.cxx:707
void StartAction()
Definition: crsrsh.cxx:211
bool IsStartWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES) const
Definition: crstrvl1.cxx:27
bool Delete()
Delete content of all ranges.
Definition: eddel.cxx:110
SelectionType
Definition: wrtsh.hxx:58
SAL_DLLPRIVATE void SttLeaveSelect()
Definition: select.cxx:611
const sal_uInt16 CRSR_SKIP_CELLS
Definition: swcrsr.hxx:64
void PushMode()
Definition: select.cxx:283
Class for automated call of Start- and EndCursorMove().
Definition: editsh.hxx:1028
void SetInsMode(bool bOn=true)
Definition: select.cxx:674
void Drag(const Point *pPt, bool bProp)
Definition: feshview.cxx:727
void EnterExtMode()
Definition: select.cxx:588
bool Left(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:102
bool const bAdd
Definition: wrtsh.hxx:500
SAL_DLLPRIVATE void ExtSelWrd(const Point *, bool bProp)
Definition: select.cxx:452
bool TestCurrPam(const Point &rPt, bool bTstHit=false)
Search in the selected area for a Selection that covers the given point.
Definition: crsrsh.cxx:978
void ToggleAddMode()
Definition: select.cxx:762
void Combine()
Combine two cursors.
Definition: crsrsh.cxx:2308
void CursorToBlockCursor()
leave block mode, change block cursor into normal cursor
Definition: crsrsh.cxx:907
void LockView(bool b)
Definition: viewsh.hxx:465
static void ClearSelection(SwWrtShell &rSh, const SwFrameShell *pCreator=nullptr)
Definition: swdtflvr.cxx:3975
sal_uInt16 GetCntType() const
Determine form of content. Return Type at CurrentCursor->SPoint.
Definition: edws.cxx:125
bool IsCursorPtAtEnd() const
Definition: crsrsh.hxx:898
SwMoveFnCollection const & fnSectionEnd
Definition: paminit.cxx:50
const SvxMacro & GetMacro(SvMacroItemId nEvent) const
void SetSplitVerticalByDefault(bool value)
Definition: select.cxx:376
sal_Int32 GetIndex() const
Definition: index.hxx:95
bool IsSplitVerticalByDefault() const
Definition: select.cxx:371
bool StartsWithTable()
If document body starts with a table.
Definition: crsrsh.cxx:613
bool GoPrevCursor()
go to the previous SSelection
Definition: crsrsh.cxx:1363
const SwPosition * End() const
Definition: pam.hxx:217
static long nStartDragY
Definition: select.cxx:54
const SwRect & GetCharRect() const
Definition: crsrsh.hxx:520
void SelectTableCell()
Definition: select.cxx:859
size_t IsObjSelected() const
Definition: feshview.cxx:1158
int CompareCursorStackMkCurrPt() const
Definition: crsrsh.cxx:1041
void UnSelectFrame()
Definition: select.cxx:327
SAL_DLLPRIVATE void BeginDrag(const Point *, bool bProp)
Definition: select.cxx:784
SAL_DLLPRIVATE long SetCursor(const Point *, bool bProp=false)
Definition: select.cxx:308
bool SelectObj(const Point &rSelPt, sal_uInt8 nFlag=0, SdrObject *pObj=nullptr)
If an object has been given, exactly this object is selected (instead of searching over position)...
Definition: feshview.cxx:176
void SelectNextPrevHyperlink(bool bNext)
Definition: select.cxx:940
SAL_DLLPRIVATE long SetCursorKillSel(const Point *, bool bProp)
Definition: select.cxx:320
void ClearMark()
Definition: crsrsh.cxx:926
SwMoveFnCollection const & fnSectionStart
Definition: paminit.cxx:49
void LeaveSelFrameMode()
Definition: select.cxx:724
sal_uLong FindAttrs(const SfxItemSet &rSet, bool bNoCollections, SwDocPositions eStart, SwDocPositions eEnd, bool &bCancel, FindRanges eRng, const i18nutil::SearchOptions2 *pSearchOpt, const SfxItemSet *rReplSet)
Definition: crsrsh.cxx:3458
bool m_bAddMode
Definition: wrtsh.hxx:568
bool IsEndWrd()
Definition: wrtsh1.cxx:175
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
SwTextFormatColl & GetDfltTextFormatColl() const
Definition: edfcol.cxx:680
bool IsExtSel() const
Definition: wrtsh.hxx:181
SAL_DLLPRIVATE long Ignore(const Point *, bool bProp)
Definition: select.cxx:383
bool IsAddMode() const
Definition: wrtsh.hxx:156
void EnterSelFrameMode(const Point *pStartDrag=nullptr)
Definition: select.cxx:706
bool SelectWord(const Point *pPt)
Definition: crstrvl1.cxx:83
bool IsEndPara() const
Definition: crsrsh.cxx:1101
bool Pop(PopMode)
delete cursor
Definition: crsrsh.cxx:2243
std::map< OUString, OUString > aParameters
bool HasWholeTabSelection() const
Definition: fetab.cxx:837
void EnterAddMode()
Definition: select.cxx:630
bool const bIns
Definition: wrtsh.hxx:500
CharClass & GetAppCharClass()
Definition: init.cxx:709
bool IsSplitVerticalByDefault() const
Definition: doc.cxx:1712
bool const bBlock
Definition: wrtsh.hxx:500
void Undo(sal_uInt16 const nCount=1)
Definition: edundo.cxx:97
bool IsFrameSelected() const
Definition: feshview.cxx:1166
bool m_bClearMark
Definition: wrtsh.hxx:574
bool IsViewLocked() const
Definition: viewsh.hxx:464
void HideCursor()
Definition: crsrsh.cxx:2389
SELECTFUNC m_fnKillSel
Definition: wrtsh.hxx:111
long Y() const
bool IsSelFrameMode() const
Definition: wrtsh.hxx:170
void RestoreSavePos()
Restore cursor state to the one saved by SwCursorSaveState.
Definition: swcrsr.cxx:2246
SwTextFormatColl * GetParaStyle(const OUString &rCollName, GetStyle eCreate=GETSTYLE_NOCREATE)
Definition: wrtsh1.cxx:1506
SAL_DLLPRIVATE void LeaveExtSel()
Definition: wrtsh.hxx:604
ModeStack * pNext
Definition: wrtsh.hxx:499
static long nStartDragX
Definition: select.cxx:54
void UnsetEnhancedTableSelection()
Definition: crsrsh.hxx:806