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