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