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(this);
362  }
363  Invalidate();
365  return 1;
366 }
367 
369 {
370  return GetDoc()->IsSplitVerticalByDefault();
371 }
372 
374 {
376 }
377 
378 // Do nothing
379 
380 long SwWrtShell::Ignore(const Point *, bool ) {
381  return 1;
382 }
383 
384 // Begin of a selection process.
385 
387 {
388  if(m_bInSelect)
389  return;
390  if(!HasMark())
391  SetMark();
392  if( m_bBlockMode )
393  {
394  SwShellCursor* pTmp = getShellCursor( true );
395  if( !pTmp->HasMark() )
396  pTmp->SetMark();
397  }
400  m_bInSelect = true;
401  Invalidate();
403 }
404 
405 namespace {
406 
407 void collectUIInformation(SwShellCursor* pCursor)
408 {
409  EventDescription aDescription;
410  OUString aSelStart = OUString::number(pCursor->Start()->nContent.GetIndex());
411  OUString aSelEnd = OUString::number(pCursor->End()->nContent.GetIndex());
412 
413  aDescription.aParameters = {{"START_POS", aSelStart}, {"END_POS", aSelEnd}};
414  aDescription.aAction = "SELECT";
415  aDescription.aID = "writer_edit";
416  aDescription.aKeyWord = "SwEditWinUIObject";
417  aDescription.aParent = "MainWindow";
418 
419  UITestLogger::getInstance().logEvent(aDescription);
420 }
421 
422 }
423 
424 // End of a selection process.
425 
427 {
428  if(m_bInSelect && !m_bExtMode)
429  {
430  m_bInSelect = false;
431  if (m_bAddMode)
432  {
433  AddLeaveSelect();
434  }
435  else
436  {
437  SttLeaveSelect();
440  }
441  }
442  SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
443  if (pWrdCnt)
444  pWrdCnt->UpdateCounts();
445 
446  collectUIInformation(GetCursor_());
447 }
448 
449 void SwWrtShell::ExtSelWrd(const Point *pPt, bool )
450 {
451  SwMvContext aMvContext(this);
452  if( IsTableMode() )
453  return;
454 
455  // Bug 66823: actual crsr has in additional mode no selection?
456  // Then destroy the actual an go to prev, this will be expand
457  if( !HasMark() && GoPrevCursor() )
458  {
459  bool bHasMark = HasMark(); // that's wrong!
460  GoNextCursor();
461  if( bHasMark )
462  {
463  DestroyCursor();
464  GoPrevCursor();
465  }
466  }
467 
468  // check the direction of the selection with the new point
469  bool bMoveCursor = true, bToTop = false;
470  SwCursorShell::SelectWord( &m_aStart ); // select the startword
471  SwCursorShell::Push(); // save the cursor
472  SwCursorShell::SetCursor( *pPt ); // and check the direction
473 
475  {
476  case -1: bToTop = false; break;
477  case 1: bToTop = true; break;
478  default: bMoveCursor = false; break;
479  }
480 
481  SwCursorShell::Pop(SwCursorShell::PopMode::DeleteCurrent); // restore the saved cursor
482 
483  if( bMoveCursor )
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 
506 void SwWrtShell::ExtSelLn(const Point *pPt, bool )
507 {
508  SwMvContext aMvContext(this);
510  if( IsTableMode() )
511  return;
512 
513  // Bug 66823: actual crsr has in additional mode no selection?
514  // Then destroy the actual an go to prev, this will be expand
515  if( !HasMark() && GoPrevCursor() )
516  {
517  bool bHasMark = HasMark(); // that's wrong!
518  GoNextCursor();
519  if( bHasMark )
520  {
521  DestroyCursor();
522  GoPrevCursor();
523  }
524  }
525 
526  // if applicable fit the selection to the "Mark"
527  bool bToTop = !IsCursorPtAtEnd();
528  SwapPam();
529 
530  // The "Mark" has to be at the end or the beginning of the line.
531  if( bToTop ? !IsEndSentence() : !IsStartSentence() )
532  {
533  if( bToTop )
534  {
535  if( !IsEndPara() )
538  }
539  else
541  }
542  SwapPam();
543 
544  if (bToTop)
546  else
548 }
549 
550 // Back into the standard mode: no mode, no selections.
551 
553 {
554  if(m_bAddMode)
555  LeaveAddMode();
556  if(m_bBlockMode)
557  LeaveBlockMode();
558  m_bBlockMode = false;
559  m_bExtMode = false;
560  m_bInSelect = false;
561  if(IsSelFrameMode())
562  {
563  UnSelectFrame();
565  }
566  else
567  {
568  // SwActContext opens and action which has to be
569  // closed prior to the call of
570  // GetChgLnk().Call()
571  SwActContext aActContext(this);
572  m_bSelWrd = m_bSelLn = false;
573  if( !IsRetainSelection() )
574  KillPams();
575  ClearMark();
578  }
579  Invalidate();
581 }
582 
583 // Extended Mode
584 
586 {
587  if(m_bBlockMode)
588  {
589  LeaveBlockMode();
590  KillPams();
591  ClearMark();
592  }
593  m_bExtMode = true;
594  m_bAddMode = false;
595  m_bBlockMode = false;
596  SttSelect();
597 }
598 
600 {
601  m_bExtMode = false;
602  EndSelect();
603 }
604 
605 // End of a selection; if the selection is empty,
606 // ClearMark().
607 
609 {
611  return;
612  }
613  ClearMark();
614 }
615 
616 // Leaving of the selection mode in additional mode
617 
619 {
620  if(IsTableMode()) LeaveAddMode();
621  else if(SwCursorShell::HasSelection())
622  CreateCursor();
623 }
624 
625 // Additional Mode
626 
628 {
629  if(IsTableMode()) return;
630  if(m_bBlockMode)
631  LeaveBlockMode();
634  m_bAddMode = true;
635  m_bBlockMode = false;
636  m_bExtMode = false;
638  CreateCursor();
639  Invalidate();
640 }
641 
643 {
646  m_bAddMode = false;
647  Invalidate();
648 }
649 
650 // Block Mode
651 
653 {
654  m_bBlockMode = false;
655  EnterStdMode();
656  m_bBlockMode = true;
658  Invalidate();
659 }
660 
662 {
663  m_bBlockMode = false;
665  EndSelect();
666  Invalidate();
667 }
668 
669 // Insert mode
670 
671 void SwWrtShell::SetInsMode( bool bOn )
672 {
673  m_bIns = bOn;
675  const SfxBoolItem aTmp( SID_ATTR_INSERT, m_bIns );
676  GetView().GetViewFrame()->GetBindings().SetState( aTmp );
677  StartAction();
678  EndAction();
679  Invalidate();
680 }
681 //Overwrite mode is incompatible with red-lining
683 {
684  SetRedlineFlags( eMode );
685  if (IsRedlineOn())
686  SetInsMode();
687 }
688 
689 // Edit frame
690 
691 void SwWrtShell::BeginFrameDrag(const Point *pPt, bool bIsShift)
692 {
694  if(bStartDrag)
695  {
696  Point aTmp( nStartDragX, nStartDragY );
697  SwFEShell::BeginDrag( &aTmp, bIsShift );
698  }
699  else
700  SwFEShell::BeginDrag( pPt, bIsShift );
701 }
702 
704 {
705  if(pPos)
706  {
707  nStartDragX = pPos->X();
708  nStartDragY = pPos->Y();
709  bStartDrag = true;
710  }
711  m_bLayoutMode = true;
712  HideCursor();
713 
714  // equal call of BeginDrag in the SwFEShell
718  Invalidate();
719 }
720 
722 {
725  m_bLayoutMode = false;
726  bStartDrag = false;
727  Edit();
729  Invalidate();
730 }
731 
732 // Description: execute framebound macro
733 
734 IMPL_LINK( SwWrtShell, ExecFlyMac, const SwFlyFrameFormat*, pFlyFormat, void )
735 {
736  const SwFrameFormat *pFormat = pFlyFormat ? static_cast<const SwFrameFormat*>(pFlyFormat) : GetFlyFrameFormat();
737  OSL_ENSURE(pFormat, "no frame format");
738  const SvxMacroItem &rFormatMac = pFormat->GetMacro();
739 
740  if(rFormatMac.HasMacro(SvMacroItemId::SwObjectSelect))
741  {
742  const SvxMacro &rMac = rFormatMac.GetMacro(SvMacroItemId::SwObjectSelect);
743  if( IsFrameSelected() )
744  m_bLayoutMode = true;
745  CallChgLnk();
746  ExecMacro( rMac );
747  }
748 }
749 
751 {
752  // still a dummy
755 }
756 
757 // Handler for toggling the modes. Returns back the old mode.
758 
760 {
762  Invalidate();
763 }
764 
766 {
768  Invalidate();
769  return !m_bBlockMode;
770 }
771 
773 {
775  Invalidate();
776  return !m_bExtMode;
777 }
778 
779 // Dragging in standard mode (Selecting of content)
780 
781 void SwWrtShell::BeginDrag(const Point * /*pPt*/, bool )
782 {
783  if(m_bSelWrd)
784  {
785  m_bInSelect = true;
786  if( !IsCursorPtAtEnd() )
787  SwapPam();
788 
791  }
792  else if(m_bSelLn)
793  {
794  m_bInSelect = true;
797  }
798  else
799  {
801  SttSelect();
802  }
803 }
804 
805 void SwWrtShell::DefaultDrag(const Point *, bool )
806 {
807  if( IsSelTableCells() )
808  m_aSelTableLink.Call(*this);
809 }
810 
811 void SwWrtShell::DefaultEndDrag(const Point * /*pPt*/, bool )
812 {
814  if( IsExtSel() )
815  LeaveExtSel();
816 
817  if( IsSelTableCells() )
818  m_aSelTableLink.Call(*this);
819  EndSelect();
820 }
821 
822 // #i32329# Enhanced table selection
823 bool SwWrtShell::SelectTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag )
824 {
825  SwMvContext aMvContext(this);
826  SttSelect();
827  if(SelTableRowCol( rPt, pEnd, bRowDrag ))
828  {
831  return true;
832  }
833  return false;
834 }
835 
836 // Description: Selection of a table line or column
837 
839 {
840  if ( SelTableRow() )
841  {
844  }
845 }
846 
848 {
849  if ( SelTableCol() )
850  {
853  }
854 }
855 
857 {
858  if ( SelTableBox() )
859  {
862  }
863 }
864 
865 // Description: Check if a word selection is present.
866 // According to the rules for intelligent cut / paste
867 // surrounding spaces are cut out.
868 // Return: Delivers the type of the word selection.
869 
870 int SwWrtShell::IntelligentCut(SelectionType nSelection, bool bCut)
871 {
872  // On multiple selection no intelligent drag and drop
873  // there are multiple cursors, since a second was placed
874  // already at the target position.
875  if( IsAddMode() || !(nSelection & SelectionType::Text) )
876  return NO_WORD;
877 
878  OUString sText;
879  CharClass& rCC = GetAppCharClass();
880 
881  // If the first character is no word character,
882  // no word selected.
883  sal_Unicode cPrev = GetChar(false);
884  sal_Unicode cNext = GetChar(true, -1);
885  if( !cPrev || !cNext ||
886  !rCC.isLetterNumeric( ( sText = OUString(cPrev) ), 0 ) ||
887  !rCC.isLetterNumeric( ( sText = OUString(cNext) ), 0 ) )
888  return NO_WORD;
889 
890  cPrev = GetChar(false, -1);
891  cNext = GetChar();
892 
893  int cWord = NO_WORD;
894  // is a word selected?
895  if (cPrev && cNext &&
896  CH_TXTATR_BREAKWORD != cPrev && CH_TXTATR_INWORD != cPrev &&
897  CH_TXTATR_BREAKWORD != cNext && CH_TXTATR_INWORD != cNext &&
898  !rCC.isLetterNumeric( ( sText = OUString(cPrev) ), 0 ) &&
899  !rCC.isLetterNumeric( ( sText = OUString(cNext) ), 0 ) )
900  cWord = WORD_NO_SPACE;
901 
902  if(cWord == WORD_NO_SPACE && ' ' == cPrev )
903  {
904  cWord = WORD_SPACE_BEFORE;
905  // delete the space before
906  if(bCut)
907  {
908  Push();
909  if(IsCursorPtAtEnd())
910  SwapPam();
911  ClearMark();
912  SetMark();
916  }
917  }
918  else if(cWord == WORD_NO_SPACE && cNext == ' ')
919  {
920  cWord = WORD_SPACE_AFTER;
921  // delete the space behind
922  if(bCut) {
923  Push();
924  if(!IsCursorPtAtEnd()) SwapPam();
925  ClearMark();
926  SetMark();
930  }
931  }
932  return cWord;
933 }
934 
935  // jump to the next / previous hyperlink - inside text and also
936  // on graphics
938 {
939  StartAction();
940  bool bRet = SwCursorShell::SelectNxtPrvHyperlink( bNext );
941  if( !bRet )
942  {
943  // will we have this feature?
944  EnterStdMode();
945  if( bNext )
946  SttEndDoc(true);
947  else
948  SttEndDoc(false);
950  }
951  EndAction();
952 
953  bool bCreateXSelection = false;
954  const bool bFrameSelected = IsFrameSelected() || IsObjSelected();
955  if( IsSelection() )
956  {
957  if ( bFrameSelected )
958  UnSelectFrame();
959 
960  // Set the function pointer for the canceling of the selection
961  // set at cursor
964  bCreateXSelection = true;
965  }
966  else if( bFrameSelected )
967  {
969  bCreateXSelection = true;
970  }
971  else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
972  {
973  SelectObj( GetCharRect().Pos() );
975  bCreateXSelection = true;
976  }
977 
978  if( bCreateXSelection )
980 }
981 
982 // For the preservation of the selection the cursor will be moved left
983 // after SetMark(), so that the cursor is not moved by inserting text.
984 // Because a present selection at the CORE page is cleared at the
985 // current cursor position, the cursor will be pushed on the stack.
986 // After moving, they will again resummarized.
987 
988 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bSelLn
Definition: wrtsh.hxx:570
SfxViewFrame * GetViewFrame() const
bool SelectTableRowCol(const Point &rPt, const Point *pEnd=nullptr, bool bRowDrag=false)
Definition: select.cxx:823
bool ToggleBlockMode()
Definition: select.cxx:765
static bool bStartDrag
Definition: select.cxx:55
void EnterBlockMode()
Definition: select.cxx:652
void KillPams()
Definition: crsrsh.cxx:1010
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:3338
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:353
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:561
void SetState(const SfxItemSet &rSet)
bool GoNextCursor()
go to the next SSelection
Definition: crsrsh.cxx:1345
bool SttEndDoc(bool bStt)
Definition: crsrsh.cxx:563
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:949
bool m_bBlockMode
Definition: wrtsh.hxx:567
sal_Unicode GetChar(bool bEnd=true, long nOffset=0)
get the nth character of the current SSelection
Definition: crsrsh.cxx:2487
SELECTFUNC2 m_fnDrag
Definition: wrtsh.hxx:106
void LeaveBlockMode()
Definition: select.cxx:661
bool IsTableMode() const
Definition: crsrsh.hxx:645
bool SelTableRow()
Definition: crsrsh.hxx:602
void SetRedlineFlags(RedlineFlags eMode)
Definition: edredln.cxx:33
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:2923
SAL_DLLPRIVATE void UpdateLayoutFrame(const Point *, bool bProp)
Definition: select.cxx:750
bool IsRetainSelection() const
Definition: wrtsh.hxx:267
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:1697
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:573
Definition: doc.hxx:185
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
bool m_bSelWrd
Definition: wrtsh.hxx:569
Link< SwWrtShell &, void > m_aSelTableLink
Definition: wrtsh.hxx:576
bool Left(sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:351
void EnterStdMode()
Definition: select.cxx:552
void DestroyCursor()
transform TableCursor to normal cursor, nullify Tablemode
Definition: crsrsh.cxx:142
void ExtendedSelectAll(bool bFootnotes=true)
Definition: crsrsh.cxx:584
bool m_bLayoutMode
Definition: wrtsh.hxx:568
void SetRedlineFlagsAndCheckInsMode(RedlineFlags eMode)
Definition: select.cxx:682
void Invalidate(sal_uInt16 nId)
Find in selections.
SAL_DLLPRIVATE void ExtSelLn(const Point *, bool bProp)
Definition: select.cxx:506
bool HasSelection() const
Does the current cursor create a selection?
Definition: crsrsh.cxx:2410
SAL_DLLPRIVATE void BeginFrameDrag(const Point *, bool bProp)
Definition: select.cxx:691
SwDocPositions
Definition: cshtyp.hxx:103
void SwapPam()
Definition: crsrsh.cxx:964
bool GoStartSentence()
Definition: crstrvl1.cxx:78
bool IsRedlineOn() const
Definition: edredln.cxx:44
bool IsStartSentence() const
Definition: crstrvl1.cxx:41
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
static UITestLogger & getInstance()
void SelectTableRow()
Definition: select.cxx:838
void BeginDrag(const Point *pPt, bool bProp)
Definition: feshview.cxx:722
#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:426
bool const bExt
Definition: wrtsh.hxx:498
SwIndex nContent
Definition: pam.hxx:38
static void CreateSelection(SwWrtShell &rSh, const SwFrameShell *pCreator=nullptr)
Definition: swdtflvr.cxx:3800
void LeaveAddMode()
Definition: select.cxx:642
void Edit()
Definition: wrtsh1.cxx:150
FindRanges
Definition: cshtyp.hxx:90
SELECTFUNC m_fnSetCursor
Definition: wrtsh.hxx:107
void SetOverwriteCursor(bool bFlag)
Definition: crsrsh.hxx:462
bool PrvWrd(bool bSelect=false)
Definition: wrtsh.hxx:209
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:749
#define FN_STAT_SELMODE
Definition: cmdid.h:806
bool SelTableCol()
Definition: crsrsh.hxx:603
const SvxMacroItem & GetMacro(bool=true) const
Definition: frmatr.hxx:92
const Link< SwCursorShell *, void > & GetChgLnk() const
Definition: crsrsh.hxx:486
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:1785
bool SelectNxtPrvHyperlink(bool bNext)
Definition: crstrvl.cxx:2404
void SelectTableCol()
Definition: select.cxx:847
void SelPara(const Point *)
Definition: select.cxx:111
SAL_DLLPRIVATE void DefaultDrag(const Point *, bool bProp)
Definition: select.cxx:805
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:330
SELECTFUNC2 m_fnEndDrag
Definition: wrtsh.hxx:108
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: crsrsh.cxx:684
void EndSelect()
Definition: select.cxx:426
Class for automated call of Start- and EndAction().
Definition: editsh.hxx:1016
bool IsSelection() const
Definition: crsrsh.hxx:877
const SwTableNode * IsCursorInTable() const
Definition: crsrsh.hxx:887
Style of a layout element.
Definition: frmfmt.hxx:57
bool ToggleExtMode()
Definition: select.cxx:772
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:118
const SwPosition * GetPoint() const
Definition: pam.hxx:207
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:229
void EndDrag()
Definition: feshview.cxx:748
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2145
void SetSplitVerticalByDefault(bool value)
Definition: doc.cxx:1727
SAL_DLLPRIVATE void AddLeaveSelect()
Definition: select.cxx:618
bool m_bIns
Definition: wrtsh.hxx:563
bool SelTableBox()
Definition: trvltbl.cxx:289
SfxBindings & GetBindings()
IMPL_LINK(SwWrtShell, ExecFlyMac, const SwFlyFrameFormat *, pFlyFormat, void)
Definition: select.cxx:734
void BlockCursorToCursor()
Definition: crsrsh.cxx:891
int IntelligentCut(SelectionType nSelectionType, bool bCut=true)
Definition: select.cxx:870
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:565
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:564
void Invalidate()
Definition: select.cxx:57
void SetMark()
Definition: crsrsh.hxx:873
bool GoCurrSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:991
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:801
sal_uLong FindFormat(const SwTextFormatColl &rFormatColl, SwDocPositions eStart, SwDocPositions eEnd, bool &bCancel, FindRanges eRng, const SwTextFormatColl *pReplFormat)
Definition: crsrsh.cxx:3357
bool HasMacro(SvMacroItemId nEvent) const
bool IsEndSentence() const
Definition: crstrvl1.cxx:45
void SttSelect()
Definition: select.cxx:386
struct SwWrtShell::ModeStack * m_pModeStack
void SelAll()
Definition: select.cxx:127
void PopMode()
Definition: select.cxx:288
bool IsInSelect() const
Definition: wrtsh.hxx:136
void TableCursorToCursor()
enter block mode, change normal cursor into block cursor
Definition: crsrsh.cxx:884
long X() const
Point m_aStart
Definition: wrtsh.hxx:575
bool HasMark()
Definition: crsrsh.hxx:875
const SwPosition * Start() const
Definition: pam.hxx:212
void LeaveExtMode()
Definition: select.cxx:599
SAL_DLLPRIVATE void DefaultEndDrag(const Point *, bool bProp)
Definition: select.cxx:811
bool MoveSection(SwWhichSection, SwMoveFnCollection const &)
Definition: crsrsh.cxx:708
void StartAction()
Definition: crsrsh.cxx:212
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:117
SelectionType
Definition: wrtsh.hxx:58
SAL_DLLPRIVATE void SttLeaveSelect()
Definition: select.cxx:608
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:1024
void SetInsMode(bool bOn=true)
Definition: select.cxx:671
void Drag(const Point *pPt, bool bProp)
Definition: feshview.cxx:736
void EnterExtMode()
Definition: select.cxx:585
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:498
SAL_DLLPRIVATE void ExtSelWrd(const Point *, bool bProp)
Definition: select.cxx:449
bool TestCurrPam(const Point &rPt, bool bTstHit=false)
Search in the selected area for a Selection that covers the given point.
Definition: crsrsh.cxx:979
void ToggleAddMode()
Definition: select.cxx:759
void Combine()
Combine two cursors.
Definition: crsrsh.cxx:2232
void CursorToBlockCursor()
leave block mode, change block cursor into normal cursor
Definition: crsrsh.cxx:908
void LockView(bool b)
Definition: viewsh.hxx:465
static void ClearSelection(SwWrtShell &rSh, const SwFrameShell *pCreator=nullptr)
Definition: swdtflvr.cxx:3812
sal_uInt16 GetCntType() const
Determine form of content. Return Type at CurrentCursor->SPoint.
Definition: edws.cxx:125
bool IsCursorPtAtEnd() const
Definition: crsrsh.hxx:892
SwMoveFnCollection const & fnSectionEnd
Definition: paminit.cxx:50
const SvxMacro & GetMacro(SvMacroItemId nEvent) const
void SetSplitVerticalByDefault(bool value)
Definition: select.cxx:373
sal_Int32 GetIndex() const
Definition: index.hxx:95
bool IsSplitVerticalByDefault() const
Definition: select.cxx:368
bool StartsWithTable()
If document body starts with a table.
Definition: crsrsh.cxx:614
bool GoPrevCursor()
go to the previous SSelection
Definition: crsrsh.cxx:1364
const SwPosition * End() const
Definition: pam.hxx:217
static long nStartDragY
Definition: select.cxx:54
const SwRect & GetCharRect() const
Definition: crsrsh.hxx:518
void SelectTableCell()
Definition: select.cxx:856
size_t IsObjSelected() const
Definition: feshview.cxx:1167
int CompareCursorStackMkCurrPt() const
Definition: crsrsh.cxx:1042
void UnSelectFrame()
Definition: select.cxx:327
SAL_DLLPRIVATE void BeginDrag(const Point *, bool bProp)
Definition: select.cxx:781
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 as been given, exactly this object is selected (instead of searching over position)...
Definition: feshview.cxx:185
void SelectNextPrevHyperlink(bool bNext)
Definition: select.cxx:937
SAL_DLLPRIVATE long SetCursorKillSel(const Point *, bool bProp)
Definition: select.cxx:320
void ClearMark()
Definition: crsrsh.cxx:927
SwMoveFnCollection const & fnSectionStart
Definition: paminit.cxx:49
void LeaveSelFrameMode()
Definition: select.cxx:721
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:3375
bool m_bAddMode
Definition: wrtsh.hxx:566
bool IsEndWrd()
Definition: wrtsh1.cxx:158
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
SwTextFormatColl & GetDfltTextFormatColl() const
Definition: edfcol.cxx:689
bool IsExtSel() const
Definition: wrtsh.hxx:179
SAL_DLLPRIVATE long Ignore(const Point *, bool bProp)
Definition: select.cxx:380
bool IsAddMode() const
Definition: wrtsh.hxx:154
void EnterSelFrameMode(const Point *pStartDrag=nullptr)
Definition: select.cxx:703
bool SelectWord(const Point *pPt)
Definition: crstrvl1.cxx:83
bool IsEndPara() const
Definition: crsrsh.cxx:1102
bool Pop(PopMode)
delete cursor
Definition: crsrsh.cxx:2167
std::map< OUString, OUString > aParameters
bool HasWholeTabSelection() const
Definition: fetab.cxx:850
void EnterAddMode()
Definition: select.cxx:627
bool const bIns
Definition: wrtsh.hxx:498
CharClass & GetAppCharClass()
Definition: init.cxx:751
bool IsSplitVerticalByDefault() const
Definition: doc.cxx:1722
bool const bBlock
Definition: wrtsh.hxx:498
void Undo(sal_uInt16 const nCount=1)
Definition: edundo.cxx:101
bool IsFrameSelected() const
Definition: feshview.cxx:1175
bool m_bClearMark
Definition: wrtsh.hxx:572
bool IsViewLocked() const
Definition: viewsh.hxx:464
void HideCursor()
Definition: crsrsh.cxx:2313
SELECTFUNC m_fnKillSel
Definition: wrtsh.hxx:109
long Y() const
bool IsSelFrameMode() const
Definition: wrtsh.hxx:168
SwTextFormatColl * GetParaStyle(const OUString &rCollName, GetStyle eCreate=GETSTYLE_NOCREATE)
Definition: wrtsh1.cxx:1473
SAL_DLLPRIVATE void LeaveExtSel()
Definition: wrtsh.hxx:602
ModeStack * pNext
Definition: wrtsh.hxx:497
static long nStartDragX
Definition: select.cxx:54