LibreOffice Module sw (master)  1
crsrsh.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 <memory>
21 #include <com/sun/star/text/XTextRange.hpp>
22 
23 #include <hintids.hxx>
24 #include <svx/srchdlg.hxx>
25 #include <sfx2/viewsh.hxx>
26 #include <SwSmartTagMgr.hxx>
27 #include <doc.hxx>
28 #include <rootfrm.hxx>
29 #include <pagefrm.hxx>
30 #include <cntfrm.hxx>
31 #include <viewimp.hxx>
32 #include <pam.hxx>
33 #include <swselectionlist.hxx>
34 #include "BlockCursor.hxx"
35 #include <ndtxt.hxx>
36 #include <flyfrm.hxx>
37 #include <dview.hxx>
38 #include <viewopt.hxx>
39 #include <crsrsh.hxx>
40 #include <tabfrm.hxx>
41 #include <txtfrm.hxx>
42 #include <sectfrm.hxx>
43 #include <swtable.hxx>
44 #include "callnk.hxx"
45 #include <viscrs.hxx>
46 #include <section.hxx>
47 #include <docsh.hxx>
48 #include <scriptinfo.hxx>
49 #include <globdoc.hxx>
50 #include <pamtyp.hxx>
51 #include <mdiexp.hxx>
52 #include <fmteiro.hxx>
53 #include <wrong.hxx>
54 #include <unotextrange.hxx>
55 #include <vcl/svapp.hxx>
56 #include <vcl/settings.hxx>
57 #include <IGrammarContact.hxx>
58 #include <comphelper/flagguard.hxx>
59 #include <strings.hrc>
61 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
62 #include <comphelper/lok.hxx>
63 #include <comphelper/sequence.hxx>
64 #include <sfx2/lokhelper.hxx>
65 #include <editeng/editview.hxx>
66 #include <editeng/frmdir.hxx>
67 #include <sal/log.hxx>
68 #include <PostItMgr.hxx>
70 #include <vcl/uitest/logger.hxx>
72 #include <tabcol.hxx>
73 #include <wrtsh.hxx>
74 #include <undobj.hxx>
75 #include <view.hxx>
76 #include <boost/property_tree/json_parser.hpp>
77 #include <hints.hxx>
78 
79 using namespace com::sun::star;
80 using namespace util;
81 
86 static void CheckRange( SwCursor* pCurrentCursor )
87 {
88  const SwPosition *pStt = pCurrentCursor->Start(),
89  *pEnd = pCurrentCursor->GetPoint() == pStt ? pCurrentCursor->GetMark() : pCurrentCursor->GetPoint();
90 
91  SwPaM *pTmpDel = nullptr,
92  *pTmp = pCurrentCursor->GetNext();
93 
94  // Search the complete ring
95  while( pTmp != pCurrentCursor )
96  {
97  const SwPosition *pTmpStt = pTmp->Start(),
98  *pTmpEnd = pTmp->GetPoint() == pTmpStt ?
99  pTmp->GetMark() : pTmp->GetPoint();
100  if( *pStt <= *pTmpStt )
101  {
102  if( *pEnd > *pTmpStt ||
103  ( *pEnd == *pTmpStt && *pEnd == *pTmpEnd ))
104  pTmpDel = pTmp;
105  }
106  else
107  if( *pStt < *pTmpEnd )
108  pTmpDel = pTmp;
109 
110  // If Point or Mark is within the Cursor range, we need to remove the old
111  // range. Take note that Point does not belong to the range anymore.
112  pTmp = pTmp->GetNext();
113  delete pTmpDel; // Remove old range
114  pTmpDel = nullptr;
115  }
116 }
117 
118 // SwCursorShell
119 
125 {
126  // don't create new Cursor with active table Selection
127  assert(!IsTableMode());
128 
129  // ensure that m_pCurrentCursor is valid; if it's invalid it would be
130  // copied to pNew and then pNew would be deleted in UpdateCursor() below
131  ClearUpCursors();
132 
133  // New cursor as copy of current one. Add to the ring.
134  // Links point to previously created one, ie forward.
135  SwShellCursor* pNew = new SwShellCursor( *m_pCurrentCursor );
136 
137  // Hide PaM logically, to avoid undoing the inverting from
138  // copied PaM (#i75172#)
139  pNew->swapContent(*m_pCurrentCursor);
140 
141  m_pCurrentCursor->DeleteMark();
142 
143  UpdateCursor( SwCursorShell::SCROLLWIN );
144  return pNew;
145 }
146 
153 {
154  // don't delete Cursor with active table Selection
155  assert(!IsTableMode());
156 
157  // Is there a next one? Don't do anything if not.
158  if(!m_pCurrentCursor->IsMultiSelection())
159  return;
160 
161  SwCallLink aLk( *this ); // watch Cursor-Moves
162  SwCursor* pNextCursor = static_cast<SwCursor*>(m_pCurrentCursor->GetNext());
163  delete m_pCurrentCursor;
164  m_pCurrentCursor = dynamic_cast<SwShellCursor*>(pNextCursor);
165  UpdateCursor();
166 }
167 
174 {
175  if (HasSelection())
176  {
177  (void) CreateCursor(); // n.b. returns old cursor
178  }
179  return *GetCursor();
180 }
181 
187 {
188  return *GetCursor();
189 }
190 
195 SwPaM* SwCursorShell::GetCursor( bool bMakeTableCursor ) const
196 {
197  if( m_pTableCursor )
198  {
199  if( bMakeTableCursor && m_pTableCursor->IsCursorMovedUpdate() )
200  {
201  //don't re-create 'parked' cursors
202  if( m_pTableCursor->GetPoint()->nNode.GetIndex() &&
203  m_pTableCursor->GetMark()->nNode.GetIndex() )
204  {
205  const SwContentNode* pCNd = m_pTableCursor->GetContentNode();
206  if( pCNd && pCNd->getLayoutFrame( GetLayout() ) )
207  {
208  pCNd = m_pTableCursor->GetContentNode(false);
209  if( pCNd && pCNd->getLayoutFrame( GetLayout() ) )
210  {
211  SwShellTableCursor* pTC = m_pTableCursor;
212  GetLayout()->MakeTableCursors( *pTC );
213  }
214  }
215  }
216  }
217 
218  if( m_pTableCursor->IsChgd() )
219  {
220  const_cast<SwCursorShell*>(this)->m_pCurrentCursor =
221  dynamic_cast<SwShellCursor*>(m_pTableCursor->MakeBoxSels( m_pCurrentCursor ));
222  }
223  }
224  return m_pCurrentCursor;
225 }
226 
228 {
229  if( !ActionPend() )
230  {
231  // save for update of the ribbon bar
232  const SwNode& rNd = m_pCurrentCursor->GetPoint()->nNode.GetNode();
233  m_nCurrentNode = rNd.GetIndex();
234  m_nCurrentContent = m_pCurrentCursor->GetPoint()->nContent.GetIndex();
235  m_nCurrentNdTyp = rNd.GetNodeType();
236  if( rNd.IsTextNode() )
237  m_nLeftFramePos = SwCallLink::getLayoutFrame( GetLayout(), *rNd.GetTextNode(), m_nCurrentContent, true );
238  else
239  m_nLeftFramePos = 0;
240  }
241  SwViewShell::StartAction(); // to the SwViewShell
242 }
243 
244 void SwCursorShell::EndAction( const bool bIdleEnd )
245 {
246  comphelper::FlagRestorationGuard g(mbSelectAll, StartsWithTable() && ExtendedSelectedAll());
247  bool bVis = m_bSVCursorVis;
248 
249  // Idle-formatting?
250  if( bIdleEnd && Imp()->GetRegion() )
251  {
252  m_pCurrentCursor->Hide();
253  }
254 
255  // Update all invalid numberings before the last action
256  if( 1 == mnStartAction )
257  GetDoc()->UpdateNumRule();
258 
259  // #i76923#: Don't show the cursor in the SwViewShell::EndAction() - call.
260  // Only the UpdateCursor shows the cursor.
261  bool bSavSVCursorVis = m_bSVCursorVis;
262  m_bSVCursorVis = false;
263 
264  SwViewShell::EndAction( bIdleEnd ); // have SwViewShell go first
265 
266  m_bSVCursorVis = bSavSVCursorVis;
267 
268  if( ActionPend() )
269  {
270  if( bVis ) // display SV-Cursor again
271  m_pVisibleCursor->Show();
272 
273  return;
274  }
275 
276  sal_uInt16 eFlags = SwCursorShell::CHKRANGE;
277  if ( !bIdleEnd )
278  eFlags |= SwCursorShell::SCROLLWIN;
279 
280  UpdateCursor( eFlags, bIdleEnd ); // Show Cursor changes
281 
282  {
283  SwCallLink aLk( *this ); // Watch cursor moves,
284  aLk.m_nNode = m_nCurrentNode; // possibly call the link
285  aLk.m_nNodeType = m_nCurrentNdTyp;
286  aLk.m_nContent = m_nCurrentContent;
287  aLk.m_nLeftFramePos = m_nLeftFramePos;
288 
289  if( !m_nCursorMove ||
290  ( 1 == m_nCursorMove && m_bInCMvVisportChgd ) )
291  // display Cursor & Selections again
292  ShowCursors( m_bSVCursorVis );
293  }
294  // call ChgCall if there is still one
295  if( m_bCallChgLnk && m_bChgCallFlag && m_aChgLnk.IsSet() )
296  {
297  m_aChgLnk.Call(nullptr);
298  m_bChgCallFlag = false; // reset flag
299  }
300 }
301 
303 {
304 #ifdef DBG_UTIL
305  OSL_ENSURE( m_nCursorMove < USHRT_MAX, "Too many nested CursorMoves." );
306 #endif
307  ++m_nCursorMove;
308  StartAction();
309 }
310 
311 void SwCursorShell::EndCursorMove( const bool bIdleEnd )
312 {
313 #ifdef DBG_UTIL
314  OSL_ENSURE( m_nCursorMove, "EndCursorMove() without SttCursorMove()." );
315 #endif
316  EndAction( bIdleEnd );
317  --m_nCursorMove;
318 #ifdef DBG_UTIL
319  if( !m_nCursorMove )
320  m_bInCMvVisportChgd = false;
321 #endif
322 }
323 
324 bool SwCursorShell::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
325  bool bVisualAllowed )
326 {
327  if( IsTableMode() )
328  return bLeft ? GoPrevCell() : GoNextCell();
329 
330  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
331  bool bRet = false;
332 
333  // #i27615# Handle cursor in front of label.
334  const SwTextNode* pTextNd = nullptr;
335 
336  if( m_pBlockCursor )
337  m_pBlockCursor->clearPoints();
338 
339  // 1. CASE: Cursor is in front of label. A move to the right
340  // will simply reset the bInFrontOfLabel flag:
341  SwShellCursor* pShellCursor = getShellCursor( true );
342  if ( !bLeft && pShellCursor->IsInFrontOfLabel() )
343  {
344  SetInFrontOfLabel( false );
345  bRet = true;
346  }
347  // 2. CASE: Cursor is at beginning of numbered paragraph. A move
348  // to the left will simply set the bInFrontOfLabel flag:
349  else if (bLeft
350  && pShellCursor->GetPoint()->nNode.GetNode().IsTextNode()
351  && static_cast<SwTextFrame const*>(
352  pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->getLayoutFrame(GetLayout())
353  )->MapModelToViewPos(*pShellCursor->GetPoint()) == TextFrameIndex(0)
354  && !pShellCursor->IsInFrontOfLabel()
355  && !pShellCursor->HasMark()
356  && nullptr != (pTextNd = sw::GetParaPropsNode(*GetLayout(), pShellCursor->GetPoint()->nNode))
357  && pTextNd->HasVisibleNumberingOrBullet())
358  {
359  SetInFrontOfLabel( true );
360  bRet = true;
361  }
362  // 3. CASE: Regular cursor move. Reset the bInFrontOfLabel flag:
363  else
364  {
365  const bool bSkipHidden = !GetViewOptions()->IsShowHiddenChar();
366  // #i107447#
367  // To avoid loop the reset of <bInFrontOfLabel> flag is no longer
368  // reflected in the return value <bRet>.
369  const bool bResetOfInFrontOfLabel = SetInFrontOfLabel( false );
370  bRet = pShellCursor->LeftRight( bLeft, nCnt, nMode, bVisualAllowed,
371  bSkipHidden, !IsOverwriteCursor(),
372  GetLayout(),
373  GetViewOptions()->IsFieldName());
374  if ( !bRet && bLeft && bResetOfInFrontOfLabel )
375  {
376  // undo reset of <bInFrontOfLabel> flag
377  SetInFrontOfLabel( true );
378  }
379  }
380 
381  if( bRet )
382  {
383  UpdateCursor();
384  }
385 
386  return bRet;
387 }
388 
389 void SwCursorShell::MarkListLevel( const OUString& sListId,
390  const int nListLevel )
391 {
392  if (sListId == m_sMarkedListId && nListLevel == m_nMarkedListLevel)
393  return;
394 
395  if ( !m_sMarkedListId.isEmpty() )
396  mxDoc->MarkListLevel( m_sMarkedListId, m_nMarkedListLevel, false );
397 
398  if ( !sListId.isEmpty() )
399  {
400  mxDoc->MarkListLevel( sListId, nListLevel, true );
401  }
402 
403  m_sMarkedListId = sListId;
404  m_nMarkedListLevel = nListLevel;
405 }
406 
408 {
409  SwTextNode const*const pTextNd = sw::GetParaPropsNode(*GetLayout(),
410  GetCursor_()->GetPoint()->nNode);
411 
412  if ( !pTextNd )
413  return;
414 
415  if (!pTextNd->IsNumbered(GetLayout()))
416  {
417  m_pCurrentCursor->SetInFrontOfLabel_( false );
418  MarkListLevel( OUString(), 0 );
419  }
420  else if ( m_pCurrentCursor->IsInFrontOfLabel() )
421  {
422  if ( pTextNd->IsInList() )
423  {
424  assert(pTextNd->GetActualListLevel() >= 0 &&
425  pTextNd->GetActualListLevel() < MAXLEVEL);
426  MarkListLevel( pTextNd->GetListId(),
427  pTextNd->GetActualListLevel() );
428  }
429  }
430  else
431  {
432  MarkListLevel( OUString(), 0 );
433  }
434 }
435 
436 void SwCursorShell::FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage)
437 {
438 #ifdef ACCESSIBLE_LAYOUT
439  if( Imp()->IsAccessible() )
440  Imp()->FirePageChangeEvent( nOldPage, nNewPage );
441 #else
442  (void)nOldPage;
443  (void)nNewPage;
444 #endif
445 }
446 
447 void SwCursorShell::FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn)
448 {
449 #ifdef ACCESSIBLE_LAYOUT
450  if( Imp()->IsAccessible() )
451  Imp()->FireColumnChangeEvent( nOldColumn, nNewColumn);
452 #else
453  (void)nOldColumn;
454  (void)nNewColumn;
455 #endif
456 }
457 
458 void SwCursorShell::FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection)
459 {
460 #ifdef ACCESSIBLE_LAYOUT
461  if( Imp()->IsAccessible() )
462  Imp()->FireSectionChangeEvent( nOldSection, nNewSection );
463 #else
464  (void)nOldSection;
465  (void)nNewSection;
466 #endif
467 }
468 
470 {
471  SwFrame* pCurrFrame = GetCurrFrame(false);
472 
473  if (pCurrFrame == nullptr)
474  {
475  return false;
476  }
477 
478  SwFrame* pCurrCol=pCurrFrame->FindColFrame();
479 
480  while(pCurrCol== nullptr && pCurrFrame!=nullptr )
481  {
482  SwLayoutFrame* pParent = pCurrFrame->GetUpper();
483  if(pParent!=nullptr)
484  {
485  pCurrCol=static_cast<SwFrame*>(pParent)->FindColFrame();
486  pCurrFrame = pParent;
487  }
488  else
489  {
490  break;
491  }
492  }
493 
494  if(m_oldColFrame == pCurrCol)
495  return false;
496  else
497  {
498  m_oldColFrame = pCurrCol;
499  return true;
500  }
501 }
502 
503 bool SwCursorShell::UpDown( bool bUp, sal_uInt16 nCnt )
504 {
505  CurrShell aCurr( this );
506  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
507 
508  bool bTableMode = IsTableMode();
509  SwShellCursor* pTmpCursor = getShellCursor( true );
510 
511  bool bRet = pTmpCursor->UpDown( bUp, nCnt );
512  // #i40019# UpDown should always reset the bInFrontOfLabel flag:
513  bRet |= SetInFrontOfLabel(false);
514 
515  if( m_pBlockCursor )
516  m_pBlockCursor->clearPoints();
517 
518  if( bRet )
519  {
520  m_eMvState = CursorMoveState::UpDown; // status for Cursor travelling - GetModelPositionForViewPoint
521  if( !ActionPend() )
522  {
523  CursorFlag eUpdateMode = SwCursorShell::SCROLLWIN;
524  if( !bTableMode )
525  eUpdateMode = static_cast<CursorFlag>(eUpdateMode
527  UpdateCursor( o3tl::narrowing<sal_uInt16>(eUpdateMode) );
528  }
529  }
530  return bRet;
531 }
532 
533 bool SwCursorShell::LRMargin( bool bLeft, bool bAPI)
534 {
535  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
536  CurrShell aCurr( this );
537  m_eMvState = CursorMoveState::LeftMargin; // status for Cursor travelling - GetModelPositionForViewPoint
538 
539  const bool bTableMode = IsTableMode();
540  SwShellCursor* pTmpCursor = getShellCursor( true );
541 
542  if( m_pBlockCursor )
543  m_pBlockCursor->clearPoints();
544 
545  const bool bWasAtLM = GetCursor_()->IsAtLeftRightMargin(*GetLayout(), true, bAPI);
546 
547  bool bRet = pTmpCursor->LeftRightMargin(*GetLayout(), bLeft, bAPI);
548 
549  if ( bLeft && !bTableMode && bRet && bWasAtLM && !GetCursor_()->HasMark() )
550  {
551  const SwTextNode * pTextNd = GetCursor_()->GetNode().GetTextNode();
552  assert(sw::GetParaPropsNode(*GetLayout(), GetCursor_()->GetPoint()->nNode) == pTextNd);
553  if ( pTextNd && pTextNd->HasVisibleNumberingOrBullet() )
554  SetInFrontOfLabel( true );
555  }
556  else if ( !bLeft )
557  {
558  bRet = SetInFrontOfLabel( false ) || bRet;
559  }
560 
561  if( bRet )
562  {
563  UpdateCursor();
564  }
565  return bRet;
566 }
567 
568 bool SwCursorShell::IsAtLRMargin( bool bLeft, bool bAPI ) const
569 {
570  const SwShellCursor* pTmpCursor = getShellCursor( true );
571  return pTmpCursor->IsAtLeftRightMargin(*GetLayout(), bLeft, bAPI);
572 }
573 
574 bool SwCursorShell::SttEndDoc( bool bStt )
575 {
576  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
577 
578  SwShellCursor* pTmpCursor = m_pBlockCursor ? &m_pBlockCursor->getShellCursor() : m_pCurrentCursor;
579  bool bRet = pTmpCursor->SttEndDoc( bStt );
580  if( bRet )
581  {
582  if( bStt )
583  pTmpCursor->GetPtPos().setY( 0 ); // set to 0 explicitly (table header)
584  if( m_pBlockCursor )
585  {
586  m_pBlockCursor->clearPoints();
587  RefreshBlockCursor();
588  }
589 
591  }
592  return bRet;
593 }
594 
595 void SwCursorShell::ExtendedSelectAll(bool bFootnotes)
596 {
597  SwNodes& rNodes = GetDoc()->GetNodes();
598  SwPosition* pPos = m_pCurrentCursor->GetPoint();
599  pPos->nNode = bFootnotes ? rNodes.GetEndOfPostIts() : rNodes.GetEndOfAutotext();
600  pPos->nContent.Assign( rNodes.GoNext( &pPos->nNode ), 0 );
601  pPos = m_pCurrentCursor->GetMark();
602  pPos->nNode = rNodes.GetEndOfContent();
603  SwContentNode* pCNd = SwNodes::GoPrevious( &pPos->nNode );
604  pPos->nContent.Assign( pCNd, pCNd ? pCNd->Len() : 0 );
605 }
606 
608 {
609  SwNodes& rNodes = GetDoc()->GetNodes();
610  SwNodeIndex nNode = rNodes.GetEndOfAutotext();
611  SwContentNode* pStart = rNodes.GoNext(&nNode);
612  if (!pStart)
613  return false;
614 
615  nNode = rNodes.GetEndOfContent();
616  SwContentNode* pEnd = SwNodes::GoPrevious(&nNode);
617  if (!pEnd)
618  return false;
619 
620  SwPosition aStart(*pStart, 0);
621  SwPosition aEnd(*pEnd, pEnd->Len());
622  SwShellCursor* pShellCursor = getShellCursor(false);
623  return aStart == *pShellCursor->Start() && aEnd == *pShellCursor->End();
624 }
625 
627 {
628  SwNodes& rNodes = GetDoc()->GetNodes();
629  SwNodeIndex nNode(rNodes.GetEndOfExtras());
630  SwContentNode* pContentNode = rNodes.GoNext(&nNode);
631  return pContentNode->FindTableNode();
632 }
633 
634 bool SwCursorShell::MovePage( SwWhichPage fnWhichPage, SwPosPage fnPosPage )
635 {
636  bool bRet = false;
637 
638  // never jump of section borders at selection
639  if( !m_pCurrentCursor->HasMark() || !m_pCurrentCursor->IsNoContent() )
640  {
641  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
642  CurrShell aCurr( this );
643 
644  SwCursorSaveState aSaveState( *m_pCurrentCursor );
645  Point& rPt = m_pCurrentCursor->GetPtPos();
646  std::pair<Point, bool> tmp(rPt, false);
647  SwContentFrame * pFrame = m_pCurrentCursor->GetContentNode()->
648  getLayoutFrame(GetLayout(), m_pCurrentCursor->GetPoint(), &tmp);
649  if( pFrame && GetFrameInPage( pFrame, fnWhichPage, fnPosPage, m_pCurrentCursor ) &&
650  !m_pCurrentCursor->IsSelOvr( SwCursorSelOverFlags::Toggle |
652  {
653  UpdateCursor();
654  bRet = true;
655  }
656  }
657  return bRet;
658 }
659 
661 {
662  SwContentNode *pCNode = pShellCursor->GetContentNode();
663  std::pair<Point, bool> tmp(pShellCursor->GetPtPos(), false);
664  SwContentFrame *const pFrame = pCNode
665  ? pCNode->getLayoutFrame(GetLayout(), pShellCursor->GetPoint(), &tmp)
666  : nullptr;
667  return !pFrame || (pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsHiddenNow());
668 }
669 
670 // sw_redlinehide: this should work for all cases: GoCurrPara, GoNextPara, GoPrevPara
671 static bool IsAtStartOrEndOfFrame(SwCursorShell const*const pShell,
672  SwShellCursor const*const pShellCursor, SwMoveFnCollection const& fnPosPara)
673 {
674  SwContentNode *const pCNode = pShellCursor->GetContentNode();
675  assert(pCNode); // surely can't have moved otherwise?
676  std::pair<Point, bool> tmp(pShellCursor->GetPtPos(), false);
677  SwContentFrame const*const pFrame = pCNode->getLayoutFrame(
678  pShell->GetLayout(), pShellCursor->GetPoint(), &tmp);
679  if (!pFrame || !pFrame->IsTextFrame())
680  {
681  return false;
682  }
683  SwTextFrame const& rTextFrame(static_cast<SwTextFrame const&>(*pFrame));
684  TextFrameIndex const ix(rTextFrame.MapModelToViewPos(*pShellCursor->GetPoint()));
685  if (&fnParaStart == &fnPosPara)
686  {
687  return ix == TextFrameIndex(0);
688  }
689  else
690  {
691  assert(&fnParaEnd == &fnPosPara);
692  return ix == TextFrameIndex(rTextFrame.GetText().getLength());
693  }
694 }
695 
696 bool SwCursorShell::MovePara(SwWhichPara fnWhichPara, SwMoveFnCollection const & fnPosPara )
697 {
698  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
699  SwShellCursor* pTmpCursor = getShellCursor( true );
700  bool bRet = pTmpCursor->MovePara( fnWhichPara, fnPosPara );
701  if( bRet )
702  {
703  //keep going until we get something visible, i.e. skip
704  //over hidden paragraphs, don't get stuck at the start
705  //which is what SwCursorShell::UpdateCursorPos will reset
706  //the position to if we pass it a position in an
707  //invisible hidden paragraph field
708  while (isInHiddenTextFrame(pTmpCursor)
709  || !IsAtStartOrEndOfFrame(this, pTmpCursor, fnPosPara))
710  {
711  if (!pTmpCursor->MovePara(fnWhichPara, fnPosPara))
712  break;
713  }
714 
715  UpdateCursor();
716  }
717  return bRet;
718 }
719 
721  SwMoveFnCollection const & fnPosSect)
722 {
723  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
724  SwCursor* pTmpCursor = getShellCursor( true );
725  bool bRet = pTmpCursor->MoveSection( fnWhichSect, fnPosSect );
726  if( bRet )
727  UpdateCursor();
728  return bRet;
729 
730 }
731 
732 // position cursor
733 
734 static SwFrame* lcl_IsInHeaderFooter( const SwNodeIndex& rIdx, Point& rPt )
735 {
736  SwFrame* pFrame = nullptr;
737  SwContentNode* pCNd = rIdx.GetNode().GetContentNode();
738  if( pCNd )
739  {
740  std::pair<Point, bool> tmp(rPt, false);
741  SwContentFrame *pContentFrame = pCNd->getLayoutFrame(
743  nullptr, &tmp);
744  pFrame = pContentFrame ? pContentFrame->GetUpper() : nullptr;
745  while( pFrame && !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() )
746  pFrame = pFrame->IsFlyFrame() ? static_cast<SwFlyFrame*>(pFrame)->AnchorFrame()
747  : pFrame->GetUpper();
748  }
749  return pFrame;
750 }
751 
752 bool SwCursorShell::IsInHeaderFooter( bool* pbInHeader ) const
753 {
754  Point aPt;
755  SwFrame* pFrame = ::lcl_IsInHeaderFooter( m_pCurrentCursor->GetPoint()->nNode, aPt );
756  if( pFrame && pbInHeader )
757  *pbInHeader = pFrame->IsHeaderFrame();
758  return nullptr != pFrame;
759 }
760 
761 int SwCursorShell::SetCursor( const Point &rLPt, bool bOnlyText, bool bBlock )
762 {
763  CurrShell aCurr( this );
764 
765  SwShellCursor* pCursor = getShellCursor( bBlock );
766  SwPosition aPos( *pCursor->GetPoint() );
767  Point aPt( rLPt );
768  Point & rCurrentCursorPt = pCursor->GetPtPos();
769  SwCursorMoveState aTmpState( IsTableMode() ? CursorMoveState::TableSel :
771  aTmpState.m_bSetInReadOnly = IsReadOnlyAvailable();
772 
773  SwTextNode const*const pTextNd = sw::GetParaPropsNode(*GetLayout(), pCursor->GetPoint()->nNode);
774 
775  if ( pTextNd && !IsTableMode() &&
776  // #i37515# No bInFrontOfLabel during selection
777  !pCursor->HasMark() &&
778  pTextNd->HasVisibleNumberingOrBullet() )
779  {
780  aTmpState.m_bInFrontOfLabel = true; // #i27615#
781  }
782  else
783  {
784  aTmpState.m_bInFrontOfLabel = false;
785  }
786 
787  int bRet = CRSR_POSOLD |
788  ( GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aTmpState )
789  ? 0 : CRSR_POSCHG );
790 
791  const bool bOldInFrontOfLabel = IsInFrontOfLabel();
792  const bool bNewInFrontOfLabel = aTmpState.m_bInFrontOfLabel;
793 
794  pCursor->SetCursorBidiLevel( aTmpState.m_nCursorBidiLevel );
795 
796  if( CursorMoveState::RightMargin == aTmpState.m_eState )
797  m_eMvState = CursorMoveState::RightMargin;
798  // is the new position in header or footer?
799  SwFrame* pFrame = lcl_IsInHeaderFooter( aPos.nNode, aPt );
800  if( IsTableMode() && !pFrame && aPos.nNode.GetNode().StartOfSectionNode() ==
801  pCursor->GetPoint()->nNode.GetNode().StartOfSectionNode() )
802  // same table column and not in header/footer -> back
803  return bRet;
804 
805  if( m_pBlockCursor && bBlock )
806  {
807  m_pBlockCursor->setEndPoint( rLPt );
808  if( !pCursor->HasMark() )
809  m_pBlockCursor->setStartPoint( rLPt );
810  else if( !m_pBlockCursor->getStartPoint() )
811  m_pBlockCursor->setStartPoint( pCursor->GetMkPos() );
812  }
813  if( !pCursor->HasMark() )
814  {
815  // is at the same position and if in header/footer -> in the same
816  if( aPos == *pCursor->GetPoint() &&
817  bOldInFrontOfLabel == bNewInFrontOfLabel )
818  {
819  if( pFrame )
820  {
821  if( pFrame->getFrameArea().IsInside( rCurrentCursorPt ))
822  return bRet;
823  }
824  else if( aPos.nNode.GetNode().IsContentNode() )
825  {
826  // in the same frame?
827  std::pair<Point, bool> tmp(m_aCharRect.Pos(), false);
828  SwFrame* pOld = static_cast<SwContentNode&>(aPos.nNode.GetNode()).getLayoutFrame(
829  GetLayout(), nullptr, &tmp);
830  tmp.first = aPt;
831  SwFrame* pNew = static_cast<SwContentNode&>(aPos.nNode.GetNode()).getLayoutFrame(
832  GetLayout(), nullptr, &tmp);
833  if( pNew == pOld )
834  return bRet;
835  }
836  }
837  }
838  else
839  {
840  // SSelection over not allowed sections or if in header/footer -> different
841  if( !CheckNodesRange( aPos.nNode, pCursor->GetMark()->nNode, true )
842  || ( pFrame && !pFrame->getFrameArea().IsInside( pCursor->GetMkPos() ) ))
843  return bRet;
844 
845  // is at same position but not in header/footer
846  if( aPos == *pCursor->GetPoint() )
847  return bRet;
848  }
849 
850  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
851  SwCursorSaveState aSaveState( *pCursor );
852 
853  *pCursor->GetPoint() = aPos;
854  rCurrentCursorPt = aPt;
855 
856  // #i41424# Only update the marked number levels if necessary
857  // Force update of marked number levels if necessary.
858  if ( bNewInFrontOfLabel || bOldInFrontOfLabel )
859  m_pCurrentCursor->SetInFrontOfLabel_( !bNewInFrontOfLabel );
860  SetInFrontOfLabel( bNewInFrontOfLabel );
861 
862  if( !pCursor->IsSelOvr( SwCursorSelOverFlags::ChangePos ) )
863  {
865  bRet &= ~CRSR_POSOLD;
866  }
867  else if( bOnlyText && !m_pCurrentCursor->HasMark() )
868  {
869  if( FindValidContentNode( bOnlyText ) )
870  {
871  // position cursor in a valid content
872  if( aPos == *pCursor->GetPoint() )
873  bRet = CRSR_POSOLD;
874  else
875  {
876  UpdateCursor();
877  bRet &= ~CRSR_POSOLD;
878  }
879  }
880  else
881  {
882  // there is no valid content -> hide cursor
883  m_pVisibleCursor->Hide(); // always hide visible cursor
884  m_eMvState = CursorMoveState::NONE; // status for Cursor travelling
885  m_bAllProtect = true;
886  if( GetDoc()->GetDocShell() )
887  {
888  GetDoc()->GetDocShell()->SetReadOnlyUI();
889  CallChgLnk(); // notify UI
890  }
891  }
892  }
893  return bRet;
894 }
895 
897 {
898  assert(m_pTableCursor);
899  delete m_pTableCursor;
900  m_pTableCursor = nullptr;
901 }
902 
904 {
905  assert(m_pBlockCursor);
906  if( m_pBlockCursor && !HasSelection() )
907  {
908  SwPaM& rPam = m_pBlockCursor->getShellCursor();
909  m_pCurrentCursor->SetMark();
910  *m_pCurrentCursor->GetPoint() = *rPam.GetPoint();
911  if( rPam.HasMark() )
912  *m_pCurrentCursor->GetMark() = *rPam.GetMark();
913  else
914  m_pCurrentCursor->DeleteMark();
915  }
916  delete m_pBlockCursor;
917  m_pBlockCursor = nullptr;
918 }
919 
921 {
922  if( !m_pBlockCursor )
923  {
924  SwPosition aPos( *m_pCurrentCursor->GetPoint() );
925  m_pBlockCursor = new SwBlockCursor( *this, aPos );
926  SwShellCursor &rBlock = m_pBlockCursor->getShellCursor();
927  rBlock.GetPtPos() = m_pCurrentCursor->GetPtPos();
928  if( m_pCurrentCursor->HasMark() )
929  {
930  rBlock.SetMark();
931  *rBlock.GetMark() = *m_pCurrentCursor->GetMark();
932  rBlock.GetMkPos() = m_pCurrentCursor->GetMkPos();
933  }
934  }
935  m_pBlockCursor->clearPoints();
936  RefreshBlockCursor();
937 }
938 
940 {
941  // is there any GetMark?
942  if( m_pTableCursor )
943  {
944  std::vector<SwPaM*> vCursors;
945  for(auto& rCursor : m_pCurrentCursor->GetRingContainer())
946  if(&rCursor != m_pCurrentCursor)
947  vCursors.push_back(&rCursor);
948  for(auto pCursor : vCursors)
949  delete pCursor;
950  m_pTableCursor->DeleteMark();
951 
952  m_pCurrentCursor->DeleteMark();
953 
954  *m_pCurrentCursor->GetPoint() = *m_pTableCursor->GetPoint();
955  m_pCurrentCursor->GetPtPos() = m_pTableCursor->GetPtPos();
956  delete m_pTableCursor;
957  m_pTableCursor = nullptr;
958  m_pCurrentCursor->SwSelPaintRects::Show();
959  }
960  else
961  {
962  if( !m_pCurrentCursor->HasMark() )
963  return;
964  m_pCurrentCursor->DeleteMark();
965  if( !m_nCursorMove )
966  m_pCurrentCursor->SwSelPaintRects::Show();
967  }
968 }
969 
970 void SwCursorShell::NormalizePam(bool bPointFirst)
971 {
972  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
973  m_pCurrentCursor->Normalize(bPointFirst);
974 }
975 
977 {
978  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
979  m_pCurrentCursor->Exchange();
980 }
981 
982 //TODO: provide documentation
992  const Point & rPt,
993  bool bTstHit )
994 {
995  CurrShell aCurr( this );
996 
997  // check if the SPoint is in a table selection
998  if( m_pTableCursor )
999  return m_pTableCursor->IsInside( rPt );
1000 
1001  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
1002  // search position <rPt> in document
1003  SwPosition aPtPos( *m_pCurrentCursor->GetPoint() );
1004  Point aPt( rPt );
1005 
1007  aTmpState.m_bSetInReadOnly = IsReadOnlyAvailable();
1008  if ( !GetLayout()->GetModelPositionForViewPoint( &aPtPos, aPt, &aTmpState ) && bTstHit )
1009  return false;
1010 
1011  // search in all selections for this position
1012  SwShellCursor* pCmp = m_pCurrentCursor; // keep the pointer on cursor
1013  do
1014  {
1015  if (pCmp->HasMark() && *pCmp->Start() <= aPtPos && *pCmp->End() > aPtPos)
1016  return true; // return without update
1017  pCmp = pCmp->GetNext();
1018  } while (m_pCurrentCursor != pCmp);
1019  return false;
1020 }
1021 
1023 {
1024  // Does any exist for deletion?
1025  if( !m_pTableCursor && !m_pBlockCursor && !m_pCurrentCursor->IsMultiSelection() )
1026  return;
1027 
1028  while( m_pCurrentCursor->GetNext() != m_pCurrentCursor )
1029  delete m_pCurrentCursor->GetNext();
1030  m_pCurrentCursor->SetColumnSelection( false );
1031 
1032  if( m_pTableCursor )
1033  {
1034  // delete the ring of cursors
1035  m_pCurrentCursor->DeleteMark();
1036  *m_pCurrentCursor->GetPoint() = *m_pTableCursor->GetPoint();
1037  m_pCurrentCursor->GetPtPos() = m_pTableCursor->GetPtPos();
1038  delete m_pTableCursor;
1039  m_pTableCursor = nullptr;
1040  }
1041  else if( m_pBlockCursor )
1042  {
1043  // delete the ring of cursors
1044  m_pCurrentCursor->DeleteMark();
1045  SwShellCursor &rBlock = m_pBlockCursor->getShellCursor();
1046  *m_pCurrentCursor->GetPoint() = *rBlock.GetPoint();
1047  m_pCurrentCursor->GetPtPos() = rBlock.GetPtPos();
1048  rBlock.DeleteMark();
1049  m_pBlockCursor->clearPoints();
1050  }
1051  UpdateCursor( SwCursorShell::SCROLLWIN );
1052 }
1053 
1055 {
1056  int nRet = 0;
1057  const SwPosition *pFirst = nullptr, *pSecond = nullptr;
1058  const SwPaM *pCur = GetCursor(), *pStack = m_pStackCursor;
1059  // cursor on stack is needed if we compare against stack
1060  if( pStack )
1061  {
1062  pFirst = pStack->GetMark();
1063  pSecond = pCur->GetPoint();
1064  }
1065  if( !pFirst || !pSecond )
1066  nRet = INT_MAX;
1067  else if( *pFirst < *pSecond )
1068  nRet = -1;
1069  else if( *pFirst == *pSecond )
1070  nRet = 0;
1071  else
1072  nRet = 1;
1073  return nRet;
1074 }
1075 
1077 {
1078  if (m_pCurrentCursor->IsMultiSelection())
1079  {
1080  return false;
1081  }
1082  if (m_pCurrentCursor->GetPoint()->nNode == m_pCurrentCursor->GetMark()->nNode)
1083  {
1084  return true;
1085  }
1086  if (GetLayout()->HasMergedParas())
1087  {
1088  SwContentFrame const*const pFrame(GetCurrFrame(false));
1089  auto const n(m_pCurrentCursor->GetMark()->nNode.GetIndex());
1090  return FrameContainsNode(*pFrame, n);
1091  }
1092  return false;
1093 }
1094 
1096 {
1097  if (GetLayout()->HasMergedParas())
1098  {
1099  SwTextNode const*const pNode(m_pCurrentCursor->GetPoint()->nNode.GetNode().GetTextNode());
1100  if (pNode)
1101  {
1102  SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(
1103  pNode->getLayoutFrame(GetLayout())));
1104  if (pFrame)
1105  {
1106  return pFrame->MapModelToViewPos(*m_pCurrentCursor->GetPoint())
1107  == TextFrameIndex(0);
1108  }
1109  }
1110  }
1111  return m_pCurrentCursor->GetPoint()->nContent == 0;
1112 }
1113 
1115 {
1116  if (GetLayout()->HasMergedParas())
1117  {
1118  SwTextNode const*const pNode(m_pCurrentCursor->GetPoint()->nNode.GetNode().GetTextNode());
1119  if (pNode)
1120  {
1121  SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(
1122  pNode->getLayoutFrame(GetLayout())));
1123  if (pFrame)
1124  {
1125  return pFrame->MapModelToViewPos(*m_pCurrentCursor->GetPoint())
1126  == TextFrameIndex(pFrame->GetText().getLength());
1127  }
1128  }
1129  }
1130  return m_pCurrentCursor->GetPoint()->nContent == m_pCurrentCursor->GetContentNode()->Len();
1131 }
1132 
1134 {
1135  if (IsTableMode() || IsBlockMode() || !IsEndPara())
1136  {
1137  return false;
1138  }
1139  SwTableNode const*const pTableNode( IsCursorInTable() );
1140  if (!pTableNode)
1141  {
1142  return false;
1143  }
1144  SwEndNode const*const pEndTableNode(pTableNode->EndOfSectionNode());
1145  SwNodeIndex const lastNode(*pEndTableNode, -2);
1146  SAL_WARN_IF(!lastNode.GetNode().GetTextNode(), "sw.core",
1147  "text node expected");
1148  return (lastNode == m_pCurrentCursor->GetPoint()->nNode);
1149 }
1150 
1152 {
1153  SwStartNodeType aStartNodeType = m_pCurrentCursor->GetNode().StartOfSectionNode()->GetStartNodeType();
1154  return aStartNodeType == SwStartNodeType::SwFootnoteStartNode;
1155 }
1156 
1158 {
1159  return m_pCurrentCursor->IsInFrontOfLabel();
1160 }
1161 
1163 {
1164  if ( bNew != IsInFrontOfLabel() )
1165  {
1166  m_pCurrentCursor->SetInFrontOfLabel_( bNew );
1167  UpdateMarkedListLevel();
1168  return true;
1169  }
1170  return false;
1171 }
1172 
1173 namespace {
1174 
1175 void collectUIInformation(const OUString& aPage)
1176 {
1177  EventDescription aDescription;
1178  aDescription.aAction = "GOTO";
1179  aDescription.aParameters = {{"PAGE", aPage}};
1180  aDescription.aID = "writer_edit";
1181  aDescription.aKeyWord = "SwEditWinUIObject";
1182  aDescription.aParent = "MainWindow";
1183  UITestLogger::getInstance().logEvent(aDescription);
1184 }
1185 
1186 }
1187 
1188 bool SwCursorShell::GotoPage( sal_uInt16 nPage )
1189 {
1190  CurrShell aCurr( this );
1191  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
1192  SwCursorSaveState aSaveState( *m_pCurrentCursor );
1193  bool bRet = GetLayout()->SetCurrPage( m_pCurrentCursor, nPage ) &&
1194  !m_pCurrentCursor->IsSelOvr( SwCursorSelOverFlags::Toggle |
1196  if( bRet )
1198 
1199  collectUIInformation(OUString::number(nPage));
1200  return bRet;
1201 }
1202 
1204 {
1205  SwContentFrame* pFrame = GetCurrFrame();
1206  pFrame->GetCharRect( rRect, *pPos );
1207 }
1208 
1209 void SwCursorShell::GetPageNum( sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum,
1210  bool bAtCursorPos, const bool bCalcFrame )
1211 {
1212  CurrShell aCurr( this );
1213  // page number: first visible page or the one at the cursor
1214  const SwContentFrame* pCFrame;
1215  const SwPageFrame *pPg = nullptr;
1216 
1217  if( !bAtCursorPos || nullptr == (pCFrame = GetCurrFrame( bCalcFrame )) ||
1218  nullptr == (pPg = pCFrame->FindPageFrame()) )
1219  {
1220  pPg = Imp()->GetFirstVisPage(GetOut());
1221  while( pPg && pPg->IsEmptyPage() )
1222  pPg = static_cast<const SwPageFrame *>(pPg->GetNext());
1223  }
1224  // pPg has to exist with a default of 1 for the special case "Writerstart"
1225  rnPhyNum = pPg? pPg->GetPhyPageNum() : 1;
1226  rnVirtNum = pPg? pPg->GetVirtPageNum() : 1;
1227 }
1228 
1230 {
1231  CurrShell aCurr(this);
1232  // page number: first visible page or the one at the cursor
1233  const SwContentFrame* pCFrame = GetCurrFrame(/*bCalcFrame*/true);
1234  const SwPageFrame* pPg = nullptr;
1235 
1236  if (pCFrame == nullptr || nullptr == (pPg = pCFrame->FindPageFrame()))
1237  {
1238  pPg = Imp()->GetFirstVisPage(GetOut());
1239  while (pPg && pPg->IsEmptyPage())
1240  pPg = static_cast<const SwPageFrame*>(pPg->GetNext());
1241  }
1242 
1243  sal_uInt16 nPageNo = 0;
1244  while (pPg)
1245  {
1246  if (!pPg->IsEmptyPage())
1247  ++nPageNo;
1248  pPg = static_cast<const SwPageFrame*>(pPg->GetPrev());
1249  }
1250  return nPageNo;
1251 }
1252 
1253 sal_uInt16 SwCursorShell::GetNextPrevPageNum( bool bNext )
1254 {
1255  CurrShell aCurr( this );
1256  // page number: first visible page or the one at the cursor
1257  const SwPageFrame *pPg = Imp()->GetFirstVisPage(GetOut());
1258  if( pPg )
1259  {
1260  const SwTwips nPageTop = pPg->getFrameArea().Top();
1261 
1262  if( bNext )
1263  {
1264  // go to next view layout row:
1265  do
1266  {
1267  pPg = static_cast<const SwPageFrame *>(pPg->GetNext());
1268  }
1269  while( pPg && pPg->getFrameArea().Top() == nPageTop );
1270 
1271  while( pPg && pPg->IsEmptyPage() )
1272  pPg = static_cast<const SwPageFrame *>(pPg->GetNext());
1273  }
1274  else
1275  {
1276  // go to previous view layout row:
1277  do
1278  {
1279  pPg = static_cast<const SwPageFrame *>(pPg->GetPrev());
1280  }
1281  while( pPg && pPg->getFrameArea().Top() == nPageTop );
1282 
1283  while( pPg && pPg->IsEmptyPage() )
1284  pPg = static_cast<const SwPageFrame *>(pPg->GetPrev());
1285  }
1286  }
1287  // pPg has to exist with a default of 1 for the special case "Writerstart"
1288  return pPg ? pPg->GetPhyPageNum() : USHRT_MAX;
1289 }
1290 
1292 {
1293  CurrShell aCurr( this );
1294  // return number of pages
1295  return GetLayout()->GetPageNum();
1296 }
1297 
1299 {
1300  CurrShell aCurr(this);
1301  SwRootFrame* pLayout = GetLayout();
1302  OUStringBuffer aBuf;
1303  for (const SwFrame* pFrame = pLayout->GetLower(); pFrame; pFrame = pFrame->GetNext())
1304  {
1305  aBuf.append(pFrame->getFrameArea().Left());
1306  aBuf.append(", ");
1307  aBuf.append(pFrame->getFrameArea().Top());
1308  aBuf.append(", ");
1309  aBuf.append(pFrame->getFrameArea().Width());
1310  aBuf.append(", ");
1311  aBuf.append(pFrame->getFrameArea().Height());
1312  aBuf.append("; ");
1313  }
1314  if (!aBuf.isEmpty())
1315  aBuf.setLength( aBuf.getLength() - 2); // remove the last "; "
1316  return aBuf.makeStringAndClear();
1317 }
1318 
1320 {
1321  auto pView = const_cast<SdrView*>(GetDrawView());
1322  if (pView->GetTextEditObject())
1323  {
1324  // Blinking cursor.
1325  EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
1326  rEditView.RegisterOtherShell(pOtherShell);
1327  rEditView.ShowCursor();
1328  rEditView.RegisterOtherShell(nullptr);
1329  // Text selection, if any.
1330  rEditView.DrawSelectionXOR(pOtherShell);
1331 
1332  // Shape text lock.
1333  if (OutlinerView* pOutlinerView = pView->GetTextEditOutlinerView())
1334  {
1335  OString sRect = pOutlinerView->GetOutputArea().toString();
1336  SfxLokHelper::notifyOtherView(GetSfxViewShell(), pOtherShell, LOK_CALLBACK_VIEW_LOCK, "rectangle", sRect);
1337  }
1338  }
1339  else
1340  {
1341  // Cursor position.
1342  m_pVisibleCursor->SetPosAndShow(pOtherShell);
1343  // Cursor visibility.
1344  if (GetSfxViewShell() != pOtherShell)
1345  {
1346  OString aPayload = OString::boolean(m_bSVCursorVis);
1347  SfxLokHelper::notifyOtherView(GetSfxViewShell(), pOtherShell, LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
1348  }
1349  // Text selection.
1350  m_pCurrentCursor->Show(pOtherShell);
1351  // Graphic selection.
1352  pView->AdjustMarkHdl(pOtherShell);
1353  }
1354 }
1355 
1358 {
1359  if( !m_pCurrentCursor->IsMultiSelection() )
1360  return false;
1361 
1362  CurrShell aCurr( this );
1363  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
1364  m_pCurrentCursor = m_pCurrentCursor->GetNext();
1365 
1366  // #i24086#: show also all others
1367  if( !ActionPend() )
1368  {
1369  UpdateCursor();
1370  m_pCurrentCursor->Show(nullptr);
1371  }
1372  return true;
1373 }
1374 
1377 {
1378  if( !m_pCurrentCursor->IsMultiSelection() )
1379  return false;
1380 
1381  CurrShell aCurr( this );
1382  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
1383  m_pCurrentCursor = m_pCurrentCursor->GetPrev();
1384 
1385  // #i24086#: show also all others
1386  if( !ActionPend() )
1387  {
1388  UpdateCursor();
1389  m_pCurrentCursor->Show(nullptr);
1390  }
1391  return true;
1392 }
1393 
1395 {
1396  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
1397 
1398  if( !m_pCurrentCursor->IsMultiSelection() )
1399  {
1400  if( !m_pCurrentCursor->HasMark() )
1401  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1402  return;
1403  }
1404 
1405  if (bNext)
1406  GoNextCursor();
1407  else
1408  GoPrevCursor();
1409 }
1410 
1411 void SwCursorShell::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect)
1412 {
1413  comphelper::FlagRestorationGuard g(mbSelectAll, StartsWithTable() && ExtendedSelectedAll());
1414  CurrShell aCurr( this );
1415 
1416  // always switch off all cursors when painting
1417  SwRect aRect( rRect );
1418 
1419  bool bVis = false;
1420  // if a cursor is visible then hide the SV cursor
1421  if( m_pVisibleCursor->IsVisible() && !aRect.IsOver( m_aCharRect ) )
1422  {
1423  bVis = true;
1424  m_pVisibleCursor->Hide();
1425  }
1426 
1427  // re-paint area
1428  SwViewShell::Paint(rRenderContext, rRect);
1429 
1430  if( m_bHasFocus && !m_bBasicHideCursor )
1431  {
1432  SwShellCursor* pCurrentCursor = m_pTableCursor ? m_pTableCursor : m_pCurrentCursor;
1433 
1434  if( !ActionPend() )
1435  {
1436  // so that right/bottom borders will not be cropped
1437  pCurrentCursor->Invalidate( VisArea() );
1438  pCurrentCursor->Show(nullptr);
1439  }
1440  else
1441  pCurrentCursor->Invalidate( aRect );
1442 
1443  }
1444 
1445  if (SwPostItMgr* pPostItMgr = GetPostItMgr())
1446  {
1447  // No point in showing the cursor for Writer text when there is an
1448  // active annotation edit.
1449  if (bVis)
1450  bVis = !pPostItMgr->HasActiveSidebarWin();
1451  }
1452 
1453  if( m_bSVCursorVis && bVis ) // also show SV cursor again
1454  m_pVisibleCursor->Show();
1455 }
1456 
1457 void SwCursorShell::VisPortChgd( const SwRect & rRect )
1458 {
1459  CurrShell aCurr( this );
1460  bool bVis; // switch off all cursors when scrolling
1461 
1462  // if a cursor is visible then hide the SV cursor
1463  bVis = m_pVisibleCursor->IsVisible();
1464  if( bVis )
1465  m_pVisibleCursor->Hide();
1466 
1467  m_bVisPortChgd = true;
1468  m_aOldRBPos.setX(VisArea().Right());
1469  m_aOldRBPos.setY(VisArea().Bottom());
1470 
1471  // For not having problems with the SV cursor, Update() is called for the
1472  // Window in SwViewShell::VisPo...
1473  // During painting no selections should be shown, thus the call is encapsulated. <- TODO: old artefact?
1474  SwViewShell::VisPortChgd( rRect ); // move area
1475 
1476  if( m_bSVCursorVis && bVis ) // show SV cursor again
1477  m_pVisibleCursor->Show();
1478 
1479  if( m_nCursorMove )
1480  m_bInCMvVisportChgd = true;
1481 
1482  m_bVisPortChgd = false;
1483 }
1484 
1492 {
1493  CurrShell aCurr( this );
1494  ++mnStartAction;
1495  SwShellCursor* pShellCursor = getShellCursor( true );
1496  Size aOldSz( GetDocSize() );
1497 
1498  if( isInHiddenTextFrame(pShellCursor) )
1499  {
1501  aTmpState.m_bSetInReadOnly = IsReadOnlyAvailable();
1502  GetLayout()->GetModelPositionForViewPoint( pShellCursor->GetPoint(), pShellCursor->GetPtPos(),
1503  &aTmpState );
1504  pShellCursor->DeleteMark();
1505  }
1506  IGrammarContact *pGrammarContact = GetDoc() ? GetDoc()->getGrammarContact() : nullptr;
1507  if( pGrammarContact )
1508  pGrammarContact->updateCursorPosition( *m_pCurrentCursor->GetPoint() );
1509  --mnStartAction;
1510  if( aOldSz != GetDocSize() )
1511  SizeChgNotify();
1512 }
1513 
1514 // #i65475# - if Point/Mark in hidden sections, move them out
1516 {
1517  bool bOk = true;
1518  const SwSectionNode* pSectNd = rIdx.GetNode().FindSectionNode();
1519  if( pSectNd && pSectNd->GetSection().IsHiddenFlag() )
1520  {
1521  SwNodeIndex aTmp( *pSectNd );
1522  const SwNode* pFrameNd =
1523  rIdx.GetNodes().FindPrvNxtFrameNode( aTmp, pSectNd->EndOfSectionNode() );
1524  bOk = pFrameNd != nullptr;
1525  SAL_WARN_IF(!bOk, "sw.core", "found no Node with Frames");
1526  rIdx = aTmp;
1527  }
1528  return bOk;
1529 }
1530 
1532 static void lcl_CheckHiddenPara( SwPosition& rPos )
1533 {
1534  SwNodeIndex aTmp( rPos.nNode );
1535  SwTextNode* pTextNd = aTmp.GetNode().GetTextNode();
1536  while( pTextNd && pTextNd->HasHiddenCharAttribute( true ) )
1537  {
1538  SwContentNode* pContent = aTmp.GetNodes().GoNext( &aTmp );
1539  if ( pContent && pContent->IsTextNode() )
1540  pTextNd = pContent->GetTextNode();
1541  else
1542  pTextNd = nullptr;
1543  }
1544 
1545  if ( pTextNd )
1546  rPos = SwPosition( aTmp, SwIndex( pTextNd, 0 ) );
1547 }
1548 
1549 namespace {
1550 
1551 // #i27301# - helper class that notifies the accessibility about invalid text
1552 // selections in its destructor
1553 class SwNotifyAccAboutInvalidTextSelections
1554 {
1555  private:
1556  SwCursorShell& mrCursorSh;
1557 
1558  public:
1559  explicit SwNotifyAccAboutInvalidTextSelections( SwCursorShell& _rCursorSh )
1560  : mrCursorSh( _rCursorSh )
1561  {}
1562 
1563  ~SwNotifyAccAboutInvalidTextSelections() COVERITY_NOEXCEPT_FALSE
1564  {
1566  }
1567 };
1568 
1569 }
1570 
1571 void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
1572 {
1573  CurrShell aCurr( this );
1574  ClearUpCursors();
1575 
1576  if (ActionPend())
1577  {
1578  if ( eFlags & SwCursorShell::READONLY )
1579  m_bIgnoreReadonly = true;
1580  return; // if not then no update
1581  }
1582 
1583  SwNotifyAccAboutInvalidTextSelections aInvalidateTextSelections( *this );
1584 
1585  if ( m_bIgnoreReadonly )
1586  {
1587  m_bIgnoreReadonly = false;
1588  eFlags |= SwCursorShell::READONLY;
1589  }
1590 
1591  if( eFlags & SwCursorShell::CHKRANGE ) // check all cursor moves for
1592  CheckRange( m_pCurrentCursor ); // overlapping ranges
1593 
1594  if( !bIdleEnd )
1595  CheckTableBoxContent();
1596 
1597  // If the current cursor is in a table and point/mark in different boxes,
1598  // then the table mode is active (also if it is already active: m_pTableCursor)
1599  SwPaM* pTstCursor = getShellCursor( true );
1600  if( pTstCursor->HasMark() && !m_pBlockCursor &&
1601  mxDoc->IsIdxInTable( pTstCursor->GetPoint()->nNode ) &&
1602  ( m_pTableCursor ||
1603  pTstCursor->GetNode().StartOfSectionNode() !=
1604  pTstCursor->GetNode( false ).StartOfSectionNode() ) && !mbSelectAll)
1605  {
1606  SwShellCursor* pITmpCursor = getShellCursor( true );
1607  Point aTmpPt( pITmpCursor->GetPtPos() );
1608  Point aTmpMk( pITmpCursor->GetMkPos() );
1609  SwPosition* pPos = pITmpCursor->GetPoint();
1610 
1611  // Bug 65475 (1999) - if Point/Mark in hidden sections, move them out
1612  lcl_CheckHiddenSection( pPos->nNode );
1613  lcl_CheckHiddenSection( pITmpCursor->GetMark()->nNode );
1614 
1615  // Move cursor out of hidden paragraphs
1616  if ( !GetViewOptions()->IsShowHiddenChar() )
1617  {
1618  lcl_CheckHiddenPara( *pPos );
1619  lcl_CheckHiddenPara( *pITmpCursor->GetMark() );
1620  }
1621 
1622  std::pair<Point, bool> const tmp(aTmpPt, false);
1623  SwContentFrame *pTableFrame = pPos->nNode.GetNode().GetContentNode()->
1624  getLayoutFrame( GetLayout(), pPos, &tmp);
1625 
1626  OSL_ENSURE( pTableFrame, "Table Cursor not in Content ??" );
1627 
1628  // --> Make code robust. The table cursor may point
1629  // to a table in a currently inactive header.
1630  SwTabFrame *pTab = pTableFrame ? pTableFrame->FindTabFrame() : nullptr;
1631 
1632  if ( pTab && pTab->GetTable()->GetRowsToRepeat() > 0 )
1633  {
1634  // First check if point is in repeated headline:
1635  bool bInRepeatedHeadline = pTab->IsFollow() && pTab->IsInHeadline( *pTableFrame );
1636 
1637  // Second check if mark is in repeated headline:
1638  if ( !bInRepeatedHeadline )
1639  {
1640  std::pair<Point, bool> const tmp1(aTmpMk, false);
1641  SwContentFrame* pMarkTableFrame = pITmpCursor->GetContentNode( false )->
1642  getLayoutFrame(GetLayout(), pITmpCursor->GetMark(), &tmp1);
1643  OSL_ENSURE( pMarkTableFrame, "Table Cursor not in Content ??" );
1644 
1645  if ( pMarkTableFrame )
1646  {
1647  SwTabFrame* pMarkTab = pMarkTableFrame->FindTabFrame();
1648  OSL_ENSURE( pMarkTab, "Table Cursor not in Content ??" );
1649 
1650  // Make code robust:
1651  if ( pMarkTab )
1652  {
1653  bInRepeatedHeadline = pMarkTab->IsFollow() && pMarkTab->IsInHeadline( *pMarkTableFrame );
1654  }
1655  }
1656  }
1657 
1658  // No table cursor in repeated headlines:
1659  if ( bInRepeatedHeadline )
1660  {
1661  pTableFrame = nullptr;
1662 
1663  SwMoveFnCollection const & fnPosSect = *pPos < *pITmpCursor->GetMark()
1664  ? fnSectionStart
1665  : fnSectionEnd;
1666 
1667  // then only select inside the Box
1668  if( m_pTableCursor )
1669  {
1670  m_pCurrentCursor->SetMark();
1671  *m_pCurrentCursor->GetMark() = *m_pTableCursor->GetMark();
1672  m_pCurrentCursor->GetMkPos() = m_pTableCursor->GetMkPos();
1673  m_pTableCursor->DeleteMark();
1674  m_pTableCursor->SwSelPaintRects::Hide();
1675  }
1676 
1677  *m_pCurrentCursor->GetPoint() = *m_pCurrentCursor->GetMark();
1678  GoCurrSection( *m_pCurrentCursor, fnPosSect );
1679  }
1680  }
1681 
1682  // we really want a table selection
1683  if( pTab && pTableFrame )
1684  {
1685  if( !m_pTableCursor )
1686  {
1687  m_pTableCursor = new SwShellTableCursor( *this,
1688  *m_pCurrentCursor->GetMark(), m_pCurrentCursor->GetMkPos(),
1689  *pPos, aTmpPt );
1690  m_pCurrentCursor->DeleteMark();
1691  m_pCurrentCursor->SwSelPaintRects::Hide();
1692 
1693  CheckTableBoxContent();
1694  if(!m_pTableCursor)
1695  {
1696  SAL_WARN("sw.core", "fdo#74854: "
1697  "this should not happen, but better lose the selection "
1698  "rather than crashing");
1699  return;
1700  }
1701  }
1702 
1704  aTmpState.m_bRealHeight = true;
1705  {
1706  DisableCallbackAction a(*GetLayout());
1707  if (!pTableFrame->GetCharRect( m_aCharRect, *m_pTableCursor->GetPoint(), &aTmpState))
1708  {
1709  Point aCentrPt( m_aCharRect.Center() );
1710  aTmpState.m_bSetInReadOnly = IsReadOnlyAvailable();
1711  pTableFrame->GetModelPositionForViewPoint(m_pTableCursor->GetPoint(), aCentrPt, &aTmpState);
1712  bool const bResult =
1713  pTableFrame->GetCharRect(m_aCharRect, *m_pTableCursor->GetPoint());
1714  OSL_ENSURE( bResult, "GetCharRect failed." );
1715  }
1716  }
1717 
1718  m_pVisibleCursor->Hide(); // always hide visible Cursor
1719  // scroll Cursor to visible area
1720  if( eFlags & SwCursorShell::SCROLLWIN &&
1721  (HasSelection() || eFlags & SwCursorShell::READONLY ||
1722  !IsCursorReadonly()) )
1723  {
1724  SwFrame* pBoxFrame = pTableFrame;
1725  while( pBoxFrame && !pBoxFrame->IsCellFrame() )
1726  pBoxFrame = pBoxFrame->GetUpper();
1727  if( pBoxFrame && pBoxFrame->getFrameArea().HasArea() )
1728  MakeVisible( pBoxFrame->getFrameArea() );
1729  else
1730  MakeVisible( m_aCharRect );
1731  }
1732 
1733  // let Layout create the Cursors in the Boxes
1734  if( m_pTableCursor->IsCursorMovedUpdate() )
1735  GetLayout()->MakeTableCursors( *m_pTableCursor );
1736  if( m_bHasFocus && !m_bBasicHideCursor )
1737  m_pTableCursor->Show(nullptr);
1738 
1739  // set Cursor-Points to the new Positions
1740  m_pTableCursor->GetPtPos().setX(m_aCharRect.Left());
1741  m_pTableCursor->GetPtPos().setY(m_aCharRect.Top());
1742 
1743  if( m_bSVCursorVis )
1744  {
1745  m_aCursorHeight.setX(0);
1746  m_aCursorHeight.setY(aTmpState.m_aRealHeight.getY() < 0 ?
1747  -m_aCharRect.Width() : m_aCharRect.Height());
1748  m_pVisibleCursor->Show(); // show again
1749  }
1750  m_eMvState = CursorMoveState::NONE; // state for cursor travelling - GetModelPositionForViewPoint
1751  if (Imp()->IsAccessible())
1752  Imp()->InvalidateAccessibleCursorPosition( pTableFrame );
1753  return;
1754  }
1755  }
1756 
1757  if( m_pTableCursor )
1758  {
1759  // delete Ring
1760  while( m_pCurrentCursor->GetNext() != m_pCurrentCursor )
1761  delete m_pCurrentCursor->GetNext();
1762  m_pCurrentCursor->DeleteMark();
1763  *m_pCurrentCursor->GetPoint() = *m_pTableCursor->GetPoint();
1764  m_pCurrentCursor->GetPtPos() = m_pTableCursor->GetPtPos();
1765  delete m_pTableCursor;
1766  m_pTableCursor = nullptr;
1767  }
1768 
1769  m_pVisibleCursor->Hide(); // always hide visible Cursor
1770 
1771  // are we perhaps in a protected / hidden Section ?
1772  {
1773  SwShellCursor* pShellCursor = getShellCursor( true );
1774  bool bChgState = true;
1775  const SwSectionNode* pSectNd = pShellCursor->GetNode().FindSectionNode();
1776  if( pSectNd && ( pSectNd->GetSection().IsHiddenFlag() ||
1777  ( !IsReadOnlyAvailable() &&
1778  pSectNd->GetSection().IsProtectFlag() &&
1779  ( !mxDoc->GetDocShell() ||
1780  !mxDoc->GetDocShell()->IsReadOnly() || m_bAllProtect )) ) )
1781  {
1782  if( !FindValidContentNode( !HasDrawView() ||
1783  0 == Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount()))
1784  {
1785  // everything protected/hidden -> special mode
1786  if( m_bAllProtect && !IsReadOnlyAvailable() &&
1787  pSectNd->GetSection().IsProtectFlag() )
1788  bChgState = false;
1789  else
1790  {
1791  m_eMvState = CursorMoveState::NONE; // state for cursor travelling
1792  m_bAllProtect = true;
1793  if( GetDoc()->GetDocShell() )
1794  {
1795  GetDoc()->GetDocShell()->SetReadOnlyUI();
1796  CallChgLnk(); // notify UI!
1797  }
1798  return;
1799  }
1800  }
1801  }
1802  if( bChgState )
1803  {
1804  bool bWasAllProtect = m_bAllProtect;
1805  m_bAllProtect = false;
1806  if( bWasAllProtect && GetDoc()->GetDocShell() &&
1807  GetDoc()->GetDocShell()->IsReadOnlyUI() )
1808  {
1809  GetDoc()->GetDocShell()->SetReadOnlyUI( false );
1810  CallChgLnk(); // notify UI!
1811  }
1812  }
1813  }
1814 
1815  UpdateCursorPos();
1816 
1817  // The cursor must always point into content; there's some code
1818  // that relies on this. (E.g. in SwEditShell::GetScriptType, which always
1819  // loops _behind_ the last node in the selection, which always works if you
1820  // are in content.) To achieve this, we'll force cursor(s) to point into
1821  // content, if UpdateCursorPos() hasn't already done so.
1822  for(SwPaM& rCmp : m_pCurrentCursor->GetRingContainer())
1823  {
1824  // start will move forwards, end will move backwards
1825  bool bPointIsStart = ( rCmp.Start() == rCmp.GetPoint() );
1826 
1827  // move point; forward if it's the start, backwards if it's the end
1828  if( ! rCmp.GetPoint()->nNode.GetNode().IsContentNode() )
1829  rCmp.Move( bPointIsStart ? fnMoveForward : fnMoveBackward,
1830  GoInContent );
1831 
1832  // move mark (if exists); forward if it's the start, else backwards
1833  if( rCmp.HasMark() )
1834  {
1835  if( ! rCmp.GetMark()->nNode.GetNode().IsContentNode() )
1836  {
1837  rCmp.Exchange();
1838  rCmp.Move( !bPointIsStart ? fnMoveForward : fnMoveBackward,
1839  GoInContent );
1840  rCmp.Exchange();
1841  }
1842  }
1843  }
1844 
1845  SwRect aOld( m_aCharRect );
1846  bool bFirst = true;
1847  SwContentFrame *pFrame;
1848  int nLoopCnt = 100;
1849  SwShellCursor* pShellCursor = getShellCursor( true );
1850 
1851  do {
1852  bool bAgainst;
1853  do {
1854  bAgainst = false;
1855  std::pair<Point, bool> const tmp1(pShellCursor->GetPtPos(), false);
1856  pFrame = pShellCursor->GetContentNode()->getLayoutFrame(GetLayout(),
1857  pShellCursor->GetPoint(), &tmp1);
1858  // if the Frame doesn't exist anymore, the complete Layout has to be
1859  // created, because there used to be a Frame here!
1860  if ( !pFrame )
1861  {
1862  do
1863  {
1864  CalcLayout();
1865  std::pair<Point, bool> const tmp(pShellCursor->GetPtPos(), false);
1866  pFrame = pShellCursor->GetContentNode()->getLayoutFrame(
1867  GetLayout(), pShellCursor->GetPoint(), &tmp);
1868  } while( !pFrame );
1869  }
1870  else if ( Imp()->IsIdleAction() )
1871  // Guarantee everything's properly formatted
1872  pFrame->PrepareCursor();
1873 
1874  // In protected Fly? but ignore in case of frame selection
1875  if( !IsReadOnlyAvailable() && pFrame->IsProtected() &&
1876  ( !Imp()->GetDrawView() ||
1877  !Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() ) &&
1878  (!mxDoc->GetDocShell() ||
1879  !mxDoc->GetDocShell()->IsReadOnly() || m_bAllProtect ) )
1880  {
1881  // look for a valid position
1882  bool bChgState = true;
1883  if( !FindValidContentNode(!HasDrawView() ||
1884  0 == Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount()))
1885  {
1886  // everything is protected / hidden -> special Mode
1887  if( m_bAllProtect )
1888  bChgState = false;
1889  else
1890  {
1891  m_eMvState = CursorMoveState::NONE; // state for cursor travelling
1892  m_bAllProtect = true;
1893  if( GetDoc()->GetDocShell() )
1894  {
1895  GetDoc()->GetDocShell()->SetReadOnlyUI();
1896  CallChgLnk(); // notify UI!
1897  }
1898  return;
1899  }
1900  }
1901 
1902  if( bChgState )
1903  {
1904  bool bWasAllProtect = m_bAllProtect;
1905  m_bAllProtect = false;
1906  if( bWasAllProtect && GetDoc()->GetDocShell() &&
1907  GetDoc()->GetDocShell()->IsReadOnlyUI() )
1908  {
1909  GetDoc()->GetDocShell()->SetReadOnlyUI( false );
1910  CallChgLnk(); // notify UI!
1911  }
1912  m_bAllProtect = false;
1913  bAgainst = true; // look for the right Frame again
1914  }
1915  }
1916  } while( bAgainst );
1917 
1918  SwCursorMoveState aTmpState( m_eMvState );
1919  aTmpState.m_bSetInReadOnly = IsReadOnlyAvailable();
1920  aTmpState.m_bRealHeight = true;
1921  aTmpState.m_bRealWidth = IsOverwriteCursor();
1922  aTmpState.m_nCursorBidiLevel = pShellCursor->GetCursorBidiLevel();
1923 
1924  // #i27615#,#i30453#
1925  SwSpecialPos aSpecialPos;
1926  aSpecialPos.nExtendRange = SwSPExtendRange::BEFORE;
1927  if (pShellCursor->IsInFrontOfLabel())
1928  {
1929  aTmpState.m_pSpecialPos = &aSpecialPos;
1930  }
1931 
1932  {
1933  DisableCallbackAction a(*GetLayout()); // tdf#91602 prevent recursive Action
1934  if (!pFrame->GetCharRect(m_aCharRect, *pShellCursor->GetPoint(), &aTmpState))
1935  {
1936  Point& rPt = pShellCursor->GetPtPos();
1937  rPt = m_aCharRect.Center();
1938  pFrame->GetModelPositionForViewPoint( pShellCursor->GetPoint(), rPt, &aTmpState );
1939  }
1940  }
1941  UISizeNotify(); // tdf#96256 update view size
1942 
1943  if( !pShellCursor->HasMark() )
1944  m_aCursorHeight = aTmpState.m_aRealHeight;
1945  else
1946  {
1947  m_aCursorHeight.setX(0);
1948  m_aCursorHeight.setY(aTmpState.m_aRealHeight.getY() < 0 ?
1949  -m_aCharRect.Width() : m_aCharRect.Height());
1950  }
1951 
1952  if( !bFirst && aOld == m_aCharRect )
1953  break;
1954 
1955  // if the layout says that we are after the 100th iteration still in
1956  // flow then we should always take the current position for granted.
1957  // (see bug: 29658)
1958  if( !--nLoopCnt )
1959  {
1960  OSL_ENSURE( false, "endless loop? CharRect != OldCharRect ");
1961  break;
1962  }
1963  aOld = m_aCharRect;
1964  bFirst = false;
1965 
1966  // update cursor Points to the new Positions
1967  pShellCursor->GetPtPos().setX(m_aCharRect.Left());
1968  pShellCursor->GetPtPos().setY(m_aCharRect.Top());
1969 
1970  if( !(eFlags & SwCursorShell::UPDOWN )) // delete old Pos. of Up/Down
1971  {
1972  DisableCallbackAction a(*GetLayout());
1973  pFrame->Calc(GetOut());
1974  m_nUpDownX = pFrame->IsVertical() ?
1975  m_aCharRect.Top() - pFrame->getFrameArea().Top() :
1976  m_aCharRect.Left() - pFrame->getFrameArea().Left();
1977  }
1978 
1979  // scroll Cursor to visible area
1980  if( m_bHasFocus && eFlags & SwCursorShell::SCROLLWIN &&
1981  (HasSelection() || eFlags & SwCursorShell::READONLY ||
1982  !IsCursorReadonly() || GetViewOptions()->IsSelectionInReadonly()) )
1983  {
1984  // in case of scrolling this EndAction doesn't show the SV cursor
1985  // again, thus save and reset the flag here
1986  bool bSav = m_bSVCursorVis;
1987  m_bSVCursorVis = false;
1988  MakeSelVisible();
1989  m_bSVCursorVis = bSav;
1990  }
1991 
1992  } while( eFlags & SwCursorShell::SCROLLWIN );
1993 
1994  assert(pFrame);
1995 
1996  if( m_pBlockCursor )
1997  RefreshBlockCursor();
1998 
1999  // We should not restrict cursor update to the active view when using LOK
2000  bool bCheckFocus = m_bHasFocus || comphelper::LibreOfficeKit::isActive();
2001 
2002  if( !bIdleEnd && bCheckFocus && !m_bBasicHideCursor )
2003  {
2004  if( m_pTableCursor )
2005  m_pTableCursor->SwSelPaintRects::Show();
2006  else
2007  {
2008  m_pCurrentCursor->SwSelPaintRects::Show();
2009  if( m_pBlockCursor )
2010  {
2011  SwShellCursor* pNxt = m_pCurrentCursor->GetNext();
2012  while( pNxt && pNxt != m_pCurrentCursor )
2013  {
2014  pNxt->SwSelPaintRects::Show();
2015  pNxt = pNxt->GetNext();
2016  }
2017  }
2018  }
2019  }
2020 
2021  m_eMvState = CursorMoveState::NONE; // state for cursor travelling - GetModelPositionForViewPoint
2022 
2023  if (Imp()->IsAccessible())
2024  Imp()->InvalidateAccessibleCursorPosition( pFrame );
2025 
2026  // switch from blinking cursor to read-only-text-selection cursor
2027  const sal_uInt64 nBlinkTime = GetOut()->GetSettings().GetStyleSettings().
2028  GetCursorBlinkTime();
2029 
2030  if ( (IsCursorReadonly() && GetViewOptions()->IsSelectionInReadonly()) ==
2031  ( nBlinkTime != STYLE_CURSOR_NOBLINKTIME ) )
2032  {
2033  // non blinking cursor in read only - text selection mode
2034  AllSettings aSettings = GetOut()->GetSettings();
2035  StyleSettings aStyleSettings = aSettings.GetStyleSettings();
2036  const sal_uInt64 nNewBlinkTime = nBlinkTime == STYLE_CURSOR_NOBLINKTIME ?
2039  aStyleSettings.SetCursorBlinkTime( nNewBlinkTime );
2040  aSettings.SetStyleSettings( aStyleSettings );
2041  GetOut()->SetSettings( aSettings );
2042  }
2043 
2044  if( m_bSVCursorVis )
2045  m_pVisibleCursor->Show(); // show again
2046 
2048  sendLOKCursorUpdates();
2049 
2050  getIDocumentMarkAccess()->NotifyCursorUpdate(*this);
2051 }
2052 
2054 {
2055  SwView* pView = static_cast<SwView*>(GetSfxViewShell());
2056  if (!pView || !pView->GetWrtShellPtr())
2057  return;
2058 
2059  SwWrtShell* pShell = &pView->GetWrtShell();
2060 
2061  SwFrame* pCurrentFrame = GetCurrFrame();
2062  SelectionType eType = pShell->GetSelectionType();
2063 
2064  boost::property_tree::ptree aRootTree;
2065 
2066  if (pCurrentFrame && (eType & SelectionType::Table) && pCurrentFrame->IsInTab())
2067  {
2068  const SwRect& rPageRect = pShell->GetAnyCurRect(CurRectType::Page, nullptr);
2069 
2070  boost::property_tree::ptree aTableColumns;
2071  {
2072  SwTabCols aTabCols;
2073  pShell->GetTabCols(aTabCols);
2074 
2075  const int nColumnOffset = aTabCols.GetLeftMin() + rPageRect.Left();
2076 
2077  aTableColumns.put("left", aTabCols.GetLeft());
2078  aTableColumns.put("right", aTabCols.GetRight());
2079  aTableColumns.put("tableOffset", nColumnOffset);
2080 
2081  boost::property_tree::ptree aEntries;
2082  for (size_t i = 0; i < aTabCols.Count(); ++i)
2083  {
2084  auto const & rEntry = aTabCols.GetEntry(i);
2085  boost::property_tree::ptree aTableColumnEntry;
2086  aTableColumnEntry.put("position", rEntry.nPos);
2087  aTableColumnEntry.put("min", rEntry.nMin);
2088  aTableColumnEntry.put("max", rEntry.nMax);
2089  aTableColumnEntry.put("hidden", rEntry.bHidden);
2090  aEntries.push_back(std::make_pair("", aTableColumnEntry));
2091  }
2092  aTableColumns.push_back(std::make_pair("entries", aEntries));
2093  }
2094 
2095  boost::property_tree::ptree aTableRows;
2096  {
2097  SwTabCols aTabRows;
2098  pShell->GetTabRows(aTabRows);
2099 
2100  const int nRowOffset = aTabRows.GetLeftMin() + rPageRect.Top();
2101 
2102  aTableRows.put("left", aTabRows.GetLeft());
2103  aTableRows.put("right", aTabRows.GetRight());
2104  aTableRows.put("tableOffset", nRowOffset);
2105 
2106  boost::property_tree::ptree aEntries;
2107  for (size_t i = 0; i < aTabRows.Count(); ++i)
2108  {
2109  auto const & rEntry = aTabRows.GetEntry(i);
2110  boost::property_tree::ptree aTableRowEntry;
2111  aTableRowEntry.put("position", rEntry.nPos);
2112  aTableRowEntry.put("min", rEntry.nMin);
2113  aTableRowEntry.put("max", rEntry.nMax);
2114  aTableRowEntry.put("hidden", rEntry.bHidden);
2115  aEntries.push_back(std::make_pair("", aTableRowEntry));
2116  }
2117  aTableRows.push_back(std::make_pair("entries", aEntries));
2118  }
2119 
2120  aRootTree.add_child("columns", aTableColumns);
2121  aRootTree.add_child("rows", aTableRows);
2122  }
2123 
2124  std::stringstream aStream;
2125  boost::property_tree::write_json(aStream, aRootTree);
2126  GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, aStream.str().c_str());
2127 }
2128 
2130 {
2131  assert(m_pBlockCursor);
2132  SwShellCursor &rBlock = m_pBlockCursor->getShellCursor();
2133  Point aPt = rBlock.GetPtPos();
2134  std::pair<Point, bool> const tmp(aPt, false);
2135  SwContentFrame* pFrame = rBlock.GetContentNode()->getLayoutFrame(
2136  GetLayout(), rBlock.GetPoint(), &tmp);
2137  Point aMk;
2138  if( m_pBlockCursor->getEndPoint() && m_pBlockCursor->getStartPoint() )
2139  {
2140  aPt = *m_pBlockCursor->getStartPoint();
2141  aMk = *m_pBlockCursor->getEndPoint();
2142  }
2143  else
2144  {
2145  aPt = rBlock.GetPtPos();
2146  if( pFrame )
2147  {
2148  if( pFrame->IsVertical() )
2149  aPt.setY(pFrame->getFrameArea().Top() + GetUpDownX());
2150  else
2151  aPt.setX(pFrame->getFrameArea().Left() + GetUpDownX());
2152  }
2153  aMk = rBlock.GetMkPos();
2154  }
2155  SwRect aRect( aMk, aPt );
2156  aRect.Justify();
2157  SwSelectionList aSelList( pFrame );
2158 
2159  if( !GetLayout()->FillSelection( aSelList, aRect ) )
2160  return;
2161 
2162  SwCursor* pNxt = static_cast<SwCursor*>(m_pCurrentCursor->GetNext());
2163  while( pNxt != m_pCurrentCursor )
2164  {
2165  delete pNxt;
2166  pNxt = static_cast<SwCursor*>(m_pCurrentCursor->GetNext());
2167  }
2168 
2169  std::list<SwPaM*>::iterator pStart = aSelList.getStart();
2170  std::list<SwPaM*>::iterator pPam = aSelList.getEnd();
2171  OSL_ENSURE( pPam != pStart, "FillSelection should deliver at least one PaM" );
2172  m_pCurrentCursor->SetMark();
2173  --pPam;
2174  // If there is only one text portion inside the rectangle, a simple
2175  // selection is created
2176  if( pPam == pStart )
2177  {
2178  *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint();
2179  if( (*pPam)->HasMark() )
2180  *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
2181  else
2182  m_pCurrentCursor->DeleteMark();
2183  delete *pPam;
2184  m_pCurrentCursor->SetColumnSelection( false );
2185  }
2186  else
2187  {
2188  // The order of the SwSelectionList has to be preserved but
2189  // the order inside the ring created by CreateCursor() is not like
2190  // expected => First create the selections before the last one
2191  // downto the first selection.
2192  // At least create the cursor for the last selection
2193  --pPam;
2194  *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n-1 (if n == number of selections)
2195  if( (*pPam)->HasMark() )
2196  *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
2197  else
2198  m_pCurrentCursor->DeleteMark();
2199  delete *pPam;
2200  m_pCurrentCursor->SetColumnSelection( true );
2201  while( pPam != pStart )
2202  {
2203  --pPam;
2204 
2205  SwShellCursor* pNew = new SwShellCursor( *m_pCurrentCursor );
2206  pNew->insert( pNew->begin(), m_pCurrentCursor->begin(), m_pCurrentCursor->end());
2207  m_pCurrentCursor->clear();
2208  m_pCurrentCursor->DeleteMark();
2209 
2210  *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n-2, n-3, .., 2, 1
2211  if( (*pPam)->HasMark() )
2212  {
2213  m_pCurrentCursor->SetMark();
2214  *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
2215  }
2216  else
2217  m_pCurrentCursor->DeleteMark();
2218  m_pCurrentCursor->SetColumnSelection( true );
2219  delete *pPam;
2220  }
2221  {
2222  SwShellCursor* pNew = new SwShellCursor( *m_pCurrentCursor );
2223  pNew->insert( pNew->begin(), m_pCurrentCursor->begin(), m_pCurrentCursor->end() );
2224  m_pCurrentCursor->clear();
2225  m_pCurrentCursor->DeleteMark();
2226  }
2227  pPam = aSelList.getEnd();
2228  --pPam;
2229  *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n, the last selection
2230  if( (*pPam)->HasMark() )
2231  {
2232  m_pCurrentCursor->SetMark();
2233  *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
2234  }
2235  else
2236  m_pCurrentCursor->DeleteMark();
2237  m_pCurrentCursor->SetColumnSelection( true );
2238  delete *pPam;
2239  }
2240 }
2241 
2244 {
2245  // fdo#60513: if we have a table cursor, copy that; else copy current.
2246  // This seems to work because UpdateCursor() will fix this up on Pop(),
2247  // then MakeBoxSels() will re-create the current m_pCurrentCursor cell ring.
2248  SwShellCursor *const pCurrent(m_pTableCursor ? m_pTableCursor : m_pCurrentCursor);
2249  m_pStackCursor = new SwShellCursor( *this, *pCurrent->GetPoint(),
2250  pCurrent->GetPtPos(), m_pStackCursor );
2251 
2252  if (pCurrent->HasMark())
2253  {
2254  m_pStackCursor->SetMark();
2255  *m_pStackCursor->GetMark() = *pCurrent->GetMark();
2256  }
2257 }
2258 
2265 bool SwCursorShell::Pop(PopMode const eDelete)
2266 {
2267  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
2268 
2269  // are there any left?
2270  if (nullptr == m_pStackCursor)
2271  return false;
2272 
2273  SwShellCursor *pTmp = nullptr, *pOldStack = m_pStackCursor;
2274 
2275  // the successor becomes the current one
2276  if (m_pStackCursor->GetNext() != m_pStackCursor)
2277  {
2278  pTmp = m_pStackCursor->GetNext();
2279  }
2280 
2281  if (PopMode::DeleteStack == eDelete)
2282  delete m_pStackCursor;
2283 
2284  m_pStackCursor = pTmp; // assign new one
2285 
2286  if (PopMode::DeleteCurrent == eDelete)
2287  {
2288  SwCursorSaveState aSaveState( *m_pCurrentCursor );
2289 
2290  // If the visible SSelection was not changed
2291  const Point& rPoint = pOldStack->GetPtPos();
2292  if (rPoint == m_pCurrentCursor->GetPtPos() || rPoint == m_pCurrentCursor->GetMkPos())
2293  {
2294  // move "Selections Rectangles"
2295  m_pCurrentCursor->insert( m_pCurrentCursor->begin(), pOldStack->begin(), pOldStack->end() );
2296  pOldStack->clear();
2297  }
2298 
2299  if( pOldStack->HasMark() )
2300  {
2301  m_pCurrentCursor->SetMark();
2302  *m_pCurrentCursor->GetMark() = *pOldStack->GetMark();
2303  m_pCurrentCursor->GetMkPos() = pOldStack->GetMkPos();
2304  }
2305  else
2306  // no selection so revoke old one and set to old position
2307  m_pCurrentCursor->DeleteMark();
2308  *m_pCurrentCursor->GetPoint() = *pOldStack->GetPoint();
2309  m_pCurrentCursor->GetPtPos() = pOldStack->GetPtPos();
2310  delete pOldStack;
2311 
2312  if( !m_pCurrentCursor->IsInProtectTable( true ) &&
2313  !m_pCurrentCursor->IsSelOvr( SwCursorSelOverFlags::Toggle |
2315  {
2316  UpdateCursor(); // update current cursor
2317  if (m_pTableCursor)
2318  { // tdf#106929 ensure m_pCurrentCursor ring is recreated from table
2319  m_pTableCursor->SetChgd();
2320  }
2321  }
2322  }
2323  return true;
2324 }
2325 
2331 {
2332  // any others left?
2333  if (nullptr == m_pStackCursor)
2334  return;
2335 
2336  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
2337  // rhbz#689053: IsSelOvr must restore the saved stack position, not the
2338  // current one, because current point + stack mark may be invalid PaM
2339  SwCursorSaveState aSaveState(*m_pStackCursor);
2340  // stack cursor & current cursor in same Section?
2341  assert(!m_pStackCursor->HasMark() ||
2342  CheckNodesRange(m_pStackCursor->GetMark()->nNode,
2343  m_pCurrentCursor->GetPoint()->nNode, true));
2344  *m_pStackCursor->GetPoint() = *m_pCurrentCursor->GetPoint();
2345  m_pStackCursor->GetPtPos() = m_pCurrentCursor->GetPtPos();
2346 
2347  SwShellCursor * pTmp = nullptr;
2348  if (m_pStackCursor->GetNext() != m_pStackCursor)
2349  {
2350  pTmp = m_pStackCursor->GetNext();
2351  }
2352  delete m_pCurrentCursor;
2353  m_pCurrentCursor = m_pStackCursor;
2354  m_pStackCursor->MoveTo(nullptr); // remove from ring
2355  m_pStackCursor = pTmp;
2356  if( !m_pCurrentCursor->IsInProtectTable( true ) &&
2357  !m_pCurrentCursor->IsSelOvr( SwCursorSelOverFlags::Toggle |
2359  {
2360  UpdateCursor(); // update current cursor
2361  }
2362 }
2363 
2365 {
2366  if( !m_bHasFocus || m_bBasicHideCursor )
2367  return;
2368 
2369  // if cursor is visible then hide SV cursor
2370  if( m_pVisibleCursor->IsVisible() )
2371  {
2372  CurrShell aCurr( this );
2373  m_pVisibleCursor->Hide();
2374  }
2375  // revoke inversion of SSelection
2376  SwShellCursor* pCurrentCursor = m_pTableCursor ? m_pTableCursor : m_pCurrentCursor;
2377  pCurrentCursor->Hide();
2378 }
2379 
2380 void SwCursorShell::ShowCursors( bool bCursorVis )
2381 {
2382  if( !m_bHasFocus || m_bAllProtect || m_bBasicHideCursor )
2383  return;
2384 
2385  CurrShell aCurr( this );
2386  SwShellCursor* pCurrentCursor = m_pTableCursor ? m_pTableCursor : m_pCurrentCursor;
2387  pCurrentCursor->Show(nullptr);
2388 
2389  if( m_bSVCursorVis && bCursorVis ) // also show SV cursor again
2390  m_pVisibleCursor->Show();
2391 }
2392 
2394 {
2395  if( m_bBasicHideCursor )
2396  return;
2397 
2398  m_bSVCursorVis = true;
2399  m_pCurrentCursor->SetShowTextInputFieldOverlay( true );
2400 
2402  {
2403  const OString aPayload = OString::boolean(m_bSVCursorVis);
2404  GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
2405  SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
2406  }
2407 
2408  UpdateCursor();
2409 }
2410 
2412 {
2413  if( m_bBasicHideCursor )
2414  return;
2415 
2416  m_bSVCursorVis = false;
2417  // possibly reverse selected areas!!
2418  CurrShell aCurr( this );
2419  m_pCurrentCursor->SetShowTextInputFieldOverlay( false );
2420  m_pVisibleCursor->Hide();
2421 
2423  {
2424  OString aPayload = OString::boolean(m_bSVCursorVis);
2425  GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
2426  SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
2427  }
2428 }
2429 
2431 {
2432  if( !m_bBasicHideCursor )
2433  HideCursors();
2434  m_bHasFocus = false;
2435 }
2436 
2438 {
2439  comphelper::FlagRestorationGuard g(mbSelectAll, StartsWithTable() && ExtendedSelectedAll());
2440 
2441  m_bHasFocus = true;
2442  if( !m_bBasicHideCursor && VisArea().Width() )
2443  {
2444  UpdateCursor( o3tl::narrowing<sal_uInt16>( SwCursorShell::CHKRANGE ) );
2445  ShowCursors( m_bSVCursorVis );
2446  }
2447 }
2448 
2450 SwContentFrame *SwCursorShell::GetCurrFrame( const bool bCalcFrame ) const
2451 {
2452  CurrShell aCurr( const_cast<SwCursorShell*>(this) );
2453  SwContentFrame *pRet = nullptr;
2454  SwContentNode *pNd = m_pCurrentCursor->GetContentNode();
2455  if ( pNd )
2456  {
2457  if ( bCalcFrame )
2458  {
2459  sal_uInt16* pST = const_cast<sal_uInt16*>(&mnStartAction);
2460  ++(*pST);
2461  const Size aOldSz( GetDocSize() );
2462  std::pair<Point, bool> const tmp(m_pCurrentCursor->GetPtPos(), true);
2463  pRet = pNd->getLayoutFrame(GetLayout(), m_pCurrentCursor->GetPoint(), &tmp);
2464  --(*pST);
2465  if( aOldSz != GetDocSize() )
2466  const_cast<SwCursorShell*>(this)->SizeChgNotify();
2467  }
2468  else
2469  {
2470  std::pair<Point, bool> const tmp(m_pCurrentCursor->GetPtPos(), false);
2471  pRet = pNd->getLayoutFrame(GetLayout(), m_pCurrentCursor->GetPoint(), &tmp);
2472  }
2473  }
2474  return pRet;
2475 }
2476 
2477 //TODO: provide documentation
2484 {
2485  if(dynamic_cast<const sw::PostGraphicArrivedHint*>(&rHint) && m_aGrfArrivedLnk.IsSet())
2486  {
2487  m_aGrfArrivedLnk.Call(*this);
2488  return;
2489  }
2490  if (rHint.GetId() != SfxHintId::SwLegacyModify)
2491  return;
2492  auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
2493  auto nWhich = pLegacy->GetWhich();
2494  if(!nWhich)
2495  nWhich = sal::static_int_cast<sal_uInt16>(RES_MSG_BEGIN);
2496  if( m_bCallChgLnk &&
2497  ( nWhich < RES_MSG_BEGIN || nWhich >= RES_MSG_END ||
2498  nWhich == RES_FMT_CHG || nWhich == RES_UPDATE_ATTR ||
2499  nWhich == RES_ATTRSET_CHG ))
2500  // messages are not forwarded
2501  // #i6681#: RES_UPDATE_ATTR is implicitly unset in
2502  // SwTextNode::Insert(SwTextHint*, sal_uInt16); we react here and thus do
2503  // not need to send the expensive RES_FMT_CHG in Insert.
2504  CallChgLnk();
2505  switch(nWhich)
2506  {
2507  case RES_OBJECTDYING:
2508  EndListeningAll();
2509  break;
2510  case RES_GRAPHIC_SWAPIN:
2511  if(m_aGrfArrivedLnk.IsSet())
2512  m_aGrfArrivedLnk.Call(*this);
2513  }
2514 
2515 }
2516 
2522 {
2523  const SwPaM* pCursor = getShellCursor( true );
2524  return IsTableMode()
2525  || (pCursor->HasMark() &&
2526  (*pCursor->GetPoint() != *pCursor->GetMark()
2527  || IsFlySelectedByCursor(*GetDoc(), *pCursor->Start(), *pCursor->End())));
2528 }
2529 
2531 {
2532  // Do not make any call in StartAction/EndAction but just set the flag.
2533  // This will be handled in EndAction.
2534  if (ActionPend())
2535  m_bChgCallFlag = true; // remember change
2536  else if( m_aChgLnk.IsSet() )
2537  {
2538  if( m_bCallChgLnk )
2539  m_aChgLnk.Call(nullptr);
2540  m_bChgCallFlag = false; // reset flag
2541  }
2542 }
2543 
2546 {
2547  OUString aText;
2548  if (GetLayout()->HasMergedParas())
2549  {
2550  SwContentFrame const*const pFrame(GetCurrFrame(false));
2551  if (FrameContainsNode(*pFrame, m_pCurrentCursor->GetMark()->nNode.GetIndex()))
2552  {
2553  OUStringBuffer buf;
2554  SwPosition const*const pStart(m_pCurrentCursor->Start());
2555  SwPosition const*const pEnd(m_pCurrentCursor->End());
2556  for (sal_uLong i = pStart->nNode.GetIndex(); i <= pEnd->nNode.GetIndex(); ++i)
2557  {
2558  SwNode const& rNode(*pStart->nNode.GetNodes()[i]);
2559  assert(!rNode.IsEndNode());
2560  if (rNode.IsStartNode())
2561  {
2562  i = rNode.EndOfSectionIndex();
2563  }
2564  else if (rNode.IsTextNode())
2565  {
2566  sal_Int32 const nStart(i == pStart->nNode.GetIndex()
2567  ? pStart->nContent.GetIndex()
2568  : 0);
2569  sal_Int32 const nEnd(i == pEnd->nNode.GetIndex()
2570  ? pEnd->nContent.GetIndex()
2571  : rNode.GetTextNode()->Len());
2572  buf.append(rNode.GetTextNode()->GetExpandText(
2573  GetLayout(),
2574  nStart, nEnd - nStart, false, false, false,
2576 
2577  }
2578  }
2579  aText = buf.makeStringAndClear();
2580  }
2581  }
2582  else if( m_pCurrentCursor->GetPoint()->nNode.GetIndex() ==
2583  m_pCurrentCursor->GetMark()->nNode.GetIndex() )
2584  {
2585  SwTextNode* pTextNd = m_pCurrentCursor->GetNode().GetTextNode();
2586  if( pTextNd )
2587  {
2588  const sal_Int32 nStt = m_pCurrentCursor->Start()->nContent.GetIndex();
2589  aText = pTextNd->GetExpandText(GetLayout(), nStt,
2590  m_pCurrentCursor->End()->nContent.GetIndex() - nStt );
2591  }
2592  }
2593  return aText;
2594 }
2595 
2602 {
2603  if( IsTableMode() ) // not possible in table mode
2604  return 0;
2605 
2606  const SwPosition* pPos = !m_pCurrentCursor->HasMark() ? m_pCurrentCursor->GetPoint()
2607  : bEnd ? m_pCurrentCursor->End() : m_pCurrentCursor->Start();
2608  SwTextNode* pTextNd = pPos->nNode.GetNode().GetTextNode();
2609  if( !pTextNd )
2610  return 0;
2611 
2612  const sal_Int32 nPos = pPos->nContent.GetIndex();
2613  const OUString& rStr = pTextNd->GetText();
2614  sal_Unicode cCh = 0;
2615 
2616  if (((nPos+nOffset) >= 0 ) && (nPos+nOffset) < rStr.getLength())
2617  cCh = rStr[nPos + nOffset];
2618 
2619  return cCh;
2620 }
2621 
2627 bool SwCursorShell::ExtendSelection( bool bEnd, sal_Int32 nCount )
2628 {
2629  if( !m_pCurrentCursor->HasMark() || IsTableMode() )
2630  return false; // no selection
2631 
2632  SwPosition* pPos = bEnd ? m_pCurrentCursor->End() : m_pCurrentCursor->Start();
2633  SwTextNode* pTextNd = pPos->nNode.GetNode().GetTextNode();
2634  assert(pTextNd);
2635 
2636  sal_Int32 nPos = pPos->nContent.GetIndex();
2637  if( bEnd )
2638  {
2639  if ((nPos + nCount) <= pTextNd->GetText().getLength())
2640  nPos = nPos + nCount;
2641  else
2642  return false; // not possible
2643  }
2644  else if( nPos >= nCount )
2645  nPos = nPos - nCount;
2646  else
2647  return false; // not possible anymore
2648 
2649  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
2650 
2651  pPos->nContent = nPos;
2652  UpdateCursor();
2653 
2654  return true;
2655 }
2656 
2662 bool SwCursorShell::SetVisibleCursor( const Point &rPt )
2663 {
2664  CurrShell aCurr( this );
2665  Point aPt( rPt );
2666  SwPosition aPos( *m_pCurrentCursor->GetPoint() );
2668  aTmpState.m_bSetInReadOnly = IsReadOnlyAvailable();
2669  aTmpState.m_bRealHeight = true;
2670 
2671  const bool bRet = GetLayout()->GetModelPositionForViewPoint( &aPos, aPt /*, &aTmpState*/ );
2672 
2673  SetInFrontOfLabel( false ); // #i27615#
2674 
2675  // show only in TextNodes
2676  SwTextNode* pTextNd = aPos.nNode.GetNode().GetTextNode();
2677  if( !pTextNd )
2678  return false;
2679 
2680  const SwSectionNode* pSectNd = pTextNd->FindSectionNode();
2681  if( pSectNd && (pSectNd->GetSection().IsHiddenFlag() ||
2682  ( !IsReadOnlyAvailable() &&
2683  pSectNd->GetSection().IsProtectFlag())) )
2684  return false;
2685 
2686  std::pair<Point, bool> const tmp(aPt, true);
2687  SwContentFrame *pFrame = pTextNd->getLayoutFrame(GetLayout(), &aPos, &tmp);
2688  if ( Imp()->IsIdleAction() )
2689  pFrame->PrepareCursor();
2690  SwRect aTmp( m_aCharRect );
2691 
2692  pFrame->GetCharRect( m_aCharRect, aPos, &aTmpState );
2693 
2694  // #i10137#
2695  if( aTmp == m_aCharRect && m_pVisibleCursor->IsVisible() )
2696  return true;
2697 
2698  m_pVisibleCursor->Hide(); // always hide visible cursor
2699  if( IsScrollMDI( this, m_aCharRect ))
2700  {
2701  MakeVisible( m_aCharRect );
2702  m_pCurrentCursor->Show(nullptr);
2703  }
2704 
2705  {
2706  if( aTmpState.m_bRealHeight )
2707  m_aCursorHeight = aTmpState.m_aRealHeight;
2708  else
2709  {
2710  m_aCursorHeight.setX(0);
2711  m_aCursorHeight.setY(m_aCharRect.Height());
2712  }
2713 
2714  m_pVisibleCursor->SetDragCursor();
2715  m_pVisibleCursor->Show(); // show again
2716  }
2717  return bRet;
2718 }
2719 
2721 {
2722  return m_pVisibleCursor;
2723 }
2724 
2725 bool SwCursorShell::IsOverReadOnlyPos( const Point& rPt ) const
2726 {
2727  Point aPt( rPt );
2728  SwPaM aPam( *m_pCurrentCursor->GetPoint() );
2729  GetLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aPt );
2730  // form view
2731  return aPam.HasReadonlySel( GetViewOptions()->IsFormView() );
2732 }
2733 
2738 sal_uInt16 SwCursorShell::GetCursorCnt( bool bAll ) const
2739 {
2740  SwPaM* pTmp = GetCursor()->GetNext();
2741  sal_uInt16 n = (bAll || ( m_pCurrentCursor->HasMark() &&
2742  *m_pCurrentCursor->GetPoint() != *m_pCurrentCursor->GetMark())) ? 1 : 0;
2743  while( pTmp != m_pCurrentCursor )
2744  {
2745  if( bAll || ( pTmp->HasMark() &&
2746  *pTmp->GetPoint() != *pTmp->GetMark()))
2747  ++n;
2748  pTmp = pTmp->GetNext();
2749  }
2750  return n;
2751 }
2752 
2754 {
2755  if( m_pCurrentCursor->GetPoint()->nContent.GetIndex() )
2756  return false;
2757 
2758  // after EndOfIcons comes the content selection (EndNd+StNd+ContentNd)
2759  SwNodeIndex aIdx( GetDoc()->GetNodes().GetEndOfExtras(), 2 );
2760  if( !aIdx.GetNode().IsContentNode() )
2761  GetDoc()->GetNodes().GoNext( &aIdx );
2762  return aIdx == m_pCurrentCursor->GetPoint()->nNode;
2763 }
2764 
2766 {
2767  SwNodeIndex aIdx( GetDoc()->GetNodes().GetEndOfContent(), -1 );
2768  SwContentNode* pCNd = aIdx.GetNode().GetContentNode();
2769  if( !pCNd )
2770  pCNd = SwNodes::GoPrevious( &aIdx );
2771 
2772  return aIdx == m_pCurrentCursor->GetPoint()->nNode &&
2773  pCNd->Len() == m_pCurrentCursor->GetPoint()->nContent.GetIndex();
2774 }
2775 
2784 {
2785  if( !m_pTableCursor )
2786  return false;
2787 
2788  m_pTableCursor->ParkCursor();
2789 
2790  while( m_pCurrentCursor->GetNext() != m_pCurrentCursor )
2791  delete m_pCurrentCursor->GetNext();
2792 
2793  // *always* move cursor's Point and Mark
2794  m_pCurrentCursor->DeleteMark();
2795  *m_pCurrentCursor->GetPoint() = *m_pTableCursor->GetPoint();
2796 
2797  return true;
2798 }
2799 
2800 void SwCursorShell::ParkPams( SwPaM* pDelRg, SwShellCursor** ppDelRing )
2801 {
2802  const SwPosition *pStt = pDelRg->Start(),
2803  *pEnd = pDelRg->GetPoint() == pStt ? pDelRg->GetMark() : pDelRg->GetPoint();
2804 
2805  SwPaM *pTmpDel = nullptr, *pTmp = *ppDelRing;
2806 
2807  // search over the whole ring
2808  bool bGoNext;
2809  do {
2810 
2811  if (!pTmp)
2812  break;
2813 
2814  const SwPosition *pTmpStt = pTmp->Start(),
2815  *pTmpEnd = pTmp->GetPoint() == pTmpStt ?
2816  pTmp->GetMark() : pTmp->GetPoint();
2817  // If a SPoint or GetMark are in a cursor area then cancel the old area.
2818  // During comparison keep in mind that End() is outside the area.
2819  if( *pStt <= *pTmpStt )
2820  {
2821  if( *pEnd > *pTmpStt ||
2822  ( *pEnd == *pTmpStt && *pEnd == *pTmpEnd ))
2823  pTmpDel = pTmp;
2824  }
2825  else
2826  if( *pStt < *pTmpEnd )
2827  pTmpDel = pTmp;
2828 
2829  bGoNext = true;
2830  if (pTmpDel) // is the pam in the range -> delete
2831  {
2832  bool bDelete = true;
2833  if( *ppDelRing == pTmpDel )
2834  {
2835  if( *ppDelRing == m_pCurrentCursor )
2836  {
2837  bDelete = GoNextCursor();
2838  if( bDelete )
2839  {
2840  bGoNext = false;
2841  pTmp = pTmp->GetNext();
2842  }
2843  }
2844  else
2845  bDelete = false; // never delete the StackCursor
2846  }
2847 
2848  if( bDelete )
2849  {
2850  if (pTmp == pTmpDel)
2851  pTmp = nullptr;
2852  delete pTmpDel; // invalidate old area
2853  }
2854  else
2855  {
2856  pTmpDel->GetPoint()->nContent.Assign(nullptr, 0);
2857  pTmpDel->GetPoint()->nNode = 0;
2858  pTmpDel->DeleteMark();
2859  }
2860  pTmpDel = nullptr;
2861  }
2862  if( bGoNext && pTmp )
2863  pTmp = pTmp->GetNext();
2864 
2865  } while( !bGoNext || *ppDelRing != pTmp );
2866 }
2867 
2868 //TODO: provide documentation
2876 {
2877  SwNode *pNode = &rIdx.GetNode();
2878 
2879  // create a new PaM
2880  std::unique_ptr<SwPaM> pNew( new SwPaM( *GetCursor()->GetPoint() ) );
2881  if( pNode->GetStartNode() )
2882  {
2883  pNode = pNode->StartOfSectionNode();
2884  if( pNode->IsTableNode() )
2885  {
2886  // the given node is in a table, thus park cursor to table node
2887  // (outside of the table)
2888  pNew->GetPoint()->nNode = *pNode->StartOfSectionNode();
2889  }
2890  else
2891  // Also on the start node itself. Then we need to request the start
2892  // node always via its end node! (StartOfSelection of StartNode is
2893  // the parent)
2894  pNew->GetPoint()->nNode = *pNode->EndOfSectionNode()->StartOfSectionNode();
2895  }
2896  else
2897  pNew->GetPoint()->nNode = *pNode->StartOfSectionNode();
2898  pNew->SetMark();
2899  pNew->GetPoint()->nNode = *pNode->EndOfSectionNode();
2900 
2901  // take care of all shells
2902  for(SwViewShell& rTmp : GetRingContainer())
2903  {
2904  if( auto pSh = dynamic_cast<SwCursorShell *>(&rTmp))
2905  {
2906  if (pSh->m_pStackCursor)
2907  pSh->ParkPams(pNew.get(), &pSh->m_pStackCursor);
2908 
2909  pSh->ParkPams( pNew.get(), &pSh->m_pCurrentCursor );
2910  if( pSh->m_pTableCursor )
2911  {
2912  // set table cursor always to 0 and the current one always to
2913  // the beginning of the table
2914  SwPaM* pTCursor = pSh->GetTableCrs();
2915  SwNode* pTableNd = pTCursor->GetPoint()->nNode.GetNode().FindTableNode();
2916  if ( pTableNd )
2917  {
2918  pTCursor->GetPoint()->nContent.Assign(nullptr, 0);
2919  pTCursor->GetPoint()->nNode = 0;
2920  pTCursor->DeleteMark();
2921  pSh->m_pCurrentCursor->GetPoint()->nNode = *pTableNd;
2922  }
2923  }
2924  }
2925  }
2926 }
2927 
2934  : SwViewShell( rShell, pInitWin )
2935  , sw::BroadcastingModify()
2936  , m_pStackCursor( nullptr )
2937  , m_pBlockCursor( nullptr )
2938  , m_pTableCursor( nullptr )
2939  , m_pBoxIdx( nullptr )
2940  , m_pBoxPtr( nullptr )
2941  , m_nUpDownX(0)
2942  , m_nLeftFramePos(0)
2943  , m_nCurrentNode(0)
2944  , m_nCurrentContent(0)
2945  , m_nCurrentNdTyp(SwNodeType::NONE)
2946  , m_nCursorMove( 0 )
2947  , m_eMvState( CursorMoveState::NONE )
2948  , m_eEnhancedTableSel(SwTable::SEARCH_NONE)
2949  , m_sMarkedListId()
2950  , m_nMarkedListLevel( 0 )
2951  , m_oldColFrame(nullptr)
2952 {
2953  CurrShell aCurr( this );
2954  // only keep the position of the current cursor of the copy shell
2955  m_pCurrentCursor = new SwShellCursor( *this, *(rShell.m_pCurrentCursor->GetPoint()) );
2956  m_pCurrentCursor->GetContentNode()->Add( this );
2957 
2960  m_bOverwriteCursor = false;
2962  m_bSVCursorVis = true;
2963  m_bSetCursorInReadOnly = true;
2964  m_pVisibleCursor = new SwVisibleCursor( this );
2966 }
2967 
2970  const SwViewOption *pInitOpt )
2971  : SwViewShell( rDoc, pInitWin, pInitOpt )
2972  , sw::BroadcastingModify()
2973  , m_pStackCursor( nullptr )
2974  , m_pBlockCursor( nullptr )
2975  , m_pTableCursor( nullptr )
2976  , m_pBoxIdx( nullptr )
2977  , m_pBoxPtr( nullptr )
2978  , m_nUpDownX(0)
2979  , m_nLeftFramePos(0)
2980  , m_nCurrentNode(0)
2981  , m_nCurrentContent(0)
2982  , m_nCurrentNdTyp(SwNodeType::NONE)
2983  , m_nCursorMove( 0 )
2984  , m_eMvState( CursorMoveState::NONE ) // state for crsr-travelling - GetModelPositionForViewPoint
2985  , m_eEnhancedTableSel(SwTable::SEARCH_NONE)
2986  , m_sMarkedListId()
2987  , m_nMarkedListLevel( 0 )
2988  , m_oldColFrame(nullptr)
2989 {
2990  CurrShell aCurr( this );
2991  // create initial cursor and set it to first content position
2992  SwNodes& rNds = rDoc.GetNodes();
2993 
2994  SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() );
2995  SwContentNode* pCNd = rNds.GoNext( &aNodeIdx ); // go to the first ContentNode
2996 
2997  m_pCurrentCursor = new SwShellCursor( *this, SwPosition( aNodeIdx, SwIndex( pCNd, 0 )));
2998 
2999  // Register shell as dependent at current node. As a result all attribute
3000  // changes can be forwarded via the Link.
3001  pCNd->Add( this );
3002 
3005  m_bOverwriteCursor = false;
3007  m_bSVCursorVis = true;
3008  m_bSetCursorInReadOnly = true;
3009 
3010  m_pVisibleCursor = new SwVisibleCursor( this );
3011  m_bMacroExecAllowed = true;
3012 }
3013 
3015 {
3016  // if it is not the last view then at least the field should be updated
3017  if( !unique() )
3019  else
3021 
3022  delete m_pVisibleCursor;
3023  delete m_pBlockCursor;
3024  delete m_pTableCursor;
3025 
3026  // release cursors
3028  delete m_pCurrentCursor->GetNext();
3029  delete m_pCurrentCursor;
3030 
3031  // free stack
3032  if (m_pStackCursor)
3033  {
3034  while (m_pStackCursor->GetNext() != m_pStackCursor)
3035  delete m_pStackCursor->GetNext();
3036  delete m_pStackCursor;
3037  }
3038 
3039  // #i54025# - do not give a HTML parser that might potentially hang as
3040  // a client at the cursor shell the chance to hang itself on a TextNode
3041  EndListeningAll();
3042 }
3043 
3045 {
3046  if( m_pTableCursor )
3047  return m_pTableCursor;
3048  if( m_pBlockCursor && bBlock )
3049  return &m_pBlockCursor->getShellCursor();
3050  return m_pCurrentCursor;
3051 }
3052 
3058 {
3059  if ( IsTableMode() || GetCursorCnt() > 1 )
3060  return true;
3061 
3062  if( HasDrawView() && GetDrawView()->GetMarkedObjectList().GetMarkCount() )
3063  return true;
3064 
3065  SwPaM* pPam = GetCursor();
3066  return pPam->Start()->nNode.GetIndex() + 10 <
3067  pPam->End()->nNode.GetIndex();
3068 }
3069 
3071 {
3073  {
3075  }
3077 }
3078 
3081 {
3082  OSL_ENSURE( m_bHasFocus, "no focus but cursor should be made visible?" );
3084  {
3085  SwRect aTmp( m_aCharRect );
3086  tools::Long nDiff = m_aCharRect.Height() - VisArea().Height();
3087  if( nDiff < m_aCursorHeight.getX() )
3088  aTmp.Top( nDiff + m_aCharRect.Top() );
3089  else
3090  {
3091  aTmp.Top( m_aCursorHeight.getX() + m_aCharRect.Top() );
3092  aTmp.Height( m_aCursorHeight.getY() );
3093  }
3094  if( !aTmp.HasArea() )
3095  {
3096  aTmp.AddHeight(1 );
3097  aTmp.AddWidth(1 );
3098  }
3099  MakeVisible( aTmp );
3100  }
3101  else
3102  {
3103  if( m_aCharRect.HasArea() )
3105  else
3106  {
3107  SwRect aTmp( m_aCharRect );
3108  aTmp.AddHeight(1 );
3109  aTmp.AddWidth(1 );
3110  MakeVisible( aTmp );
3111  }
3112  }
3113 }
3114 
3117 {
3118  if( m_pTableCursor )
3119  {
3120  assert(!"Did not remove table selection!");
3121  return false;
3122  }
3123 
3124  // #i45129# - everything is allowed in UI-readonly
3125  if( !m_bAllProtect && GetDoc()->GetDocShell() &&
3126  GetDoc()->GetDocShell()->IsReadOnlyUI() )
3127  return true;
3128 
3129  if( m_pCurrentCursor->HasMark() )
3130  ClearMark();
3131 
3132  // first check for frames
3134  sal_uLong nNdIdx = rNdIdx.GetIndex(); // keep backup
3135  SwNodes& rNds = mxDoc->GetNodes();
3136  SwContentNode* pCNd = rNdIdx.GetNode().GetContentNode();
3137  const SwContentFrame * pFrame;
3138 
3139  if (pCNd && nullptr != (pFrame = pCNd->getLayoutFrame(GetLayout(), m_pCurrentCursor->GetPoint())) &&
3140  !IsReadOnlyAvailable() && pFrame->IsProtected() &&
3141  nNdIdx < rNds.GetEndOfExtras().GetIndex() )
3142  {
3143  // skip protected frame
3144  SwPaM aPam( *m_pCurrentCursor->GetPoint() );
3145  aPam.SetMark();
3146  aPam.GetMark()->nNode = rNds.GetEndOfContent();
3147  aPam.GetPoint()->nNode = *pCNd->EndOfSectionNode();
3148 
3149  bool bFirst = false;
3150  if( nullptr == (pCNd = ::GetNode( aPam, bFirst, fnMoveForward )))
3151  {
3152  aPam.GetMark()->nNode = *rNds.GetEndOfPostIts().StartOfSectionNode();
3153  pCNd = ::GetNode( aPam, bFirst, fnMoveBackward );
3154  }
3155 
3156  if( !pCNd ) // should *never* happen
3157  {
3158  rNdIdx = nNdIdx; // back to old node
3159  return false;
3160  }
3161  *m_pCurrentCursor->GetPoint() = *aPam.GetPoint();
3162  }
3163  else if( bOnlyText && pCNd && pCNd->IsNoTextNode() )
3164  {
3165  // set to beginning of document
3166  rNdIdx = mxDoc->GetNodes().GetEndOfExtras();
3167  m_pCurrentCursor->GetPoint()->nContent.Assign( mxDoc->GetNodes().GoNext(
3168  &rNdIdx ), 0 );
3169  nNdIdx = rNdIdx.GetIndex();
3170  }
3171 
3172  bool bOk = true;
3173 
3174  // #i9059# cursor may not stand in protected cells
3175  // (unless cursor in protected areas is OK.)
3176  const SwTableNode* pTableNode = rNdIdx.GetNode().FindTableNode();
3177  if( !IsReadOnlyAvailable() &&
3178  pTableNode != nullptr && rNdIdx.GetNode().IsProtect() )
3179  {
3180  // we're in a table, and we're in a protected area, so we're
3181  // probably in a protected cell.
3182 
3183  // move forward into non-protected area.
3184  SwPaM aPam( rNdIdx.GetNode(), 0 );
3185  while( aPam.GetNode().IsProtect() &&
3186  aPam.Move( fnMoveForward, GoInContent ) )
3187  ; // nothing to do in the loop; the aPam.Move does the moving!
3188 
3189  // didn't work? then go backwards!
3190  if( aPam.GetNode().IsProtect() )
3191  {
3192  SwPaM aTmpPaM( rNdIdx.GetNode(), 0 );
3193  aPam = aTmpPaM;
3194  while( aPam.GetNode().IsProtect() &&
3195  aPam.Move( fnMoveBackward, GoInContent ) )
3196  ; // nothing to do in the loop; the aPam.Move does the moving!
3197  }
3198 
3199  // if we're successful, set the new position
3200  if( ! aPam.GetNode().IsProtect() )
3201  {
3202  *m_pCurrentCursor->GetPoint() = *aPam.GetPoint();
3203  }
3204  }
3205 
3206  // in a protected frame
3207  const SwSectionNode* pSectNd = rNdIdx.GetNode().FindSectionNode();
3208  if( pSectNd && ( pSectNd->GetSection().IsHiddenFlag() ||
3209  ( !IsReadOnlyAvailable() &&
3210  pSectNd->GetSection().IsProtectFlag() )) )
3211  {
3212  bOk = false;
3213  bool bGoNextSection = true;
3214  for( int nLoopCnt = 0; !bOk && nLoopCnt < 2; ++nLoopCnt )
3215  {
3216  bool bContinue;
3217  do {
3218  bContinue = false;
3219  for (;;)
3220  {
3221  if (bGoNextSection)
3222  pCNd = rNds.GoNextSection( &rNdIdx,
3223  true, !IsReadOnlyAvailable() );
3224  else
3225  pCNd = SwNodes::GoPrevSection( &rNdIdx,
3226  true, !IsReadOnlyAvailable() );
3227  if ( pCNd == nullptr) break;
3228  // moved inside a table -> check if it is protected
3229  if( pCNd->FindTableNode() )
3230  {
3231  SwCallLink aTmp( *this );
3232  SwCursorSaveState aSaveState( *m_pCurrentCursor );
3233  aTmp.m_nNodeType = SwNodeType::NONE; // don't do anything in DTOR
3234  if( !m_pCurrentCursor->IsInProtectTable( true ) )
3235  {
3236  const SwSectionNode* pSNd = pCNd->FindSectionNode();
3237  if( !pSNd || !pSNd->GetSection().IsHiddenFlag()
3238  || (!IsReadOnlyAvailable() &&
3239  pSNd->GetSection().IsProtectFlag() ))
3240  {
3241  bOk = true;
3242  break; // found non-protected cell
3243  }
3244  continue; // continue search
3245  }
3246  }
3247  else
3248  {
3249  bOk = true;
3250  break; // found non-protected cell
3251  }
3252  }
3253 
3254  if( bOk && rNdIdx.GetIndex() < rNds.GetEndOfExtras().GetIndex() )
3255  {
3256  // also check for Fly - might be protected as well
3257  pFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, nullptr);
3258  if (nullptr == pFrame ||
3259  ( !IsReadOnlyAvailable() && pFrame->IsProtected() ) ||
3260  ( bOnlyText && pCNd->IsNoTextNode() ) )
3261  {
3262  // continue search
3263  bOk = false;
3264  bContinue = true;
3265  }
3266  }
3267  } while( bContinue );
3268 
3269  if( !bOk )
3270  {
3271  if( !nLoopCnt )
3272  bGoNextSection = false;
3273  rNdIdx = nNdIdx;
3274  }
3275  }
3276  }
3277  if( bOk )
3278  {
3279  pCNd = rNdIdx.GetNode().GetContentNode();
3280  const sal_Int32 nContent = rNdIdx.GetIndex() < nNdIdx ? pCNd->Len() : 0;
3281  m_pCurrentCursor->GetPoint()->nContent.Assign( pCNd, nContent );
3282  }
3283  else
3284  {
3285  pCNd = rNdIdx.GetNode().GetContentNode();
3286  // if cursor in hidden frame, always move it
3287  if (!pCNd || !pCNd->getLayoutFrame(GetLayout(), nullptr, nullptr))
3288  {
3290  aTmpState.m_bSetInReadOnly = IsReadOnlyAvailable();
3292  &aTmpState );
3293  }
3294  }
3295  return bOk;
3296 }
3297 
3299 {
3300  if ( GetViewOptions()->IsReadonly() ||
3301  GetViewOptions()->IsFormView() /* Formula view */ )
3302  {
3303  SwFrame *pFrame = GetCurrFrame( false );
3304  const SwFlyFrame* pFly;
3305  const SwSection* pSection;
3306 
3307  if( pFrame && pFrame->IsInFly() &&
3308  (pFly = pFrame->FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
3309  pFly->Lower() &&
3310  !pFly->Lower()->IsNoTextFrame() &&
3312  {
3313  return false;
3314  }
3315  // edit in readonly sections
3316  else if ( pFrame && pFrame->IsInSct() &&
3317  nullptr != ( pSection = pFrame->FindSctFrame()->GetSection() ) &&
3318  pSection->IsEditInReadonlyFlag() )
3319  {
3320  return false;
3321  }
3322  else if ( !IsMultiSelection() && CursorInsideInputField() )
3323  {
3324  return false;
3325  }
3326 
3327  return true;
3328  }
3329  return false;
3330 }
3331 
3334 {
3335  // *never* switch in GlobalDoc
3336  if( (!GetDoc()->GetDocShell() ||
3337  dynamic_cast<const SwGlobalDocShell*>(GetDoc()->GetDocShell()) == nullptr ) &&
3338  bFlag != m_bSetCursorInReadOnly )
3339  {
3340  // If the flag is switched off then all selections need to be
3341  // invalidated. Otherwise we would trust that nothing protected is selected.
3342  if( !bFlag )
3343  {
3344  ClearMark();
3345  }
3346  m_bSetCursorInReadOnly = bFlag;
3347  UpdateCursor();
3348  }
3349 }
3350 
3352 {
3353  if (GetViewOptions()->IsShowOutlineContentVisibilityButton())
3354  {
3355  // Treat selections that span over start or end of paragraph of an outline node
3356  // with folded outline content as read-only.
3357  SwWrtShell* pWrtSh = GetDoc()->GetDocShell()->GetWrtShell();
3358  if (pWrtSh)
3359  {
3360  for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
3361  {
3362  SwPaM aPaM(*rPaM.GetMark(), *rPaM.GetPoint());
3363  aPaM.Normalize();
3364  SwNodeIndex aPointIdx(aPaM.GetPoint()->nNode.GetNode());
3365  SwNodeIndex aMarkIdx(aPaM.GetMark()->nNode.GetNode());
3366  if (aPointIdx == aMarkIdx)
3367  continue;
3368  // If any nodes in PaM are folded outline content nodes, then set read-only.
3370  for (SwNodeIndex aIdx = aPointIdx; aIdx <= aMarkIdx; aIdx++)
3371  {
3372  if (GetDoc()->GetNodes().GetOutLineNds().Seek_Entry(&(aIdx.GetNode()), &nPos) &&
3373  !pWrtSh->GetAttrOutlineContentVisible(nPos))
3374  return true;
3375  }
3376  }
3377  }
3378  }
3379  bool bRet = false;
3380  // If protected area is to be ignored, then selections are never read-only.
3381  if ((IsReadOnlyAvailable() || GetViewOptions()->IsFormView() ||
3382  GetDoc()->GetDocumentSettingManager().get( DocumentSettingId::PROTECT_FORM )) &&
3384  {
3385  if ( m_pTableCursor != nullptr )
3386  {
3388  || m_pTableCursor->HasReadonlySel( GetViewOptions()->IsFormView() );
3389  }
3390  else
3391  {
3392  for(const SwPaM& rCursor : m_pCurrentCursor->GetRingContainer())
3393  {
3394  if( rCursor.HasReadonlySel( GetViewOptions()->IsFormView() ) )
3395  {
3396  bRet = true;
3397  break;
3398  }
3399  }
3400  }
3401  }
3402  return bRet;
3403 }
3404 
3406 {
3407  bool bRet = false;
3408 
3411  {
3412  sal_Int32 nStt = m_pCurrentCursor->GetPoint()->nContent.GetIndex();
3413  sal_Int32 nEnd = m_pCurrentCursor->GetMark()->nContent.GetIndex();
3414  if( nStt > nEnd )
3415  {
3416  sal_Int32 nTmp = nStt;
3417  nStt = nEnd;
3418  nEnd = nTmp;
3419  }
3421  bRet = pCNd && !nStt && nEnd == pCNd->Len();
3422  }
3423  return bRet;
3424 }
3425 
3427 {
3428  SwPosition aPos( *m_pCurrentCursor->GetPoint() );
3429  Point aPt( pPt ? *pPt : m_pCurrentCursor->GetPtPos() );
3430  if( pPt )
3431  {
3433  aTmpState.m_bSetInReadOnly = IsReadOnlyAvailable();
3434 
3435  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aTmpState );
3436  }
3437 
3438  return mxDoc->GetTextDirection( aPos, &aPt );
3439 }
3440 
3441 bool SwCursorShell::IsInVerticalText( const Point* pPt ) const
3442 {
3443  const SvxFrameDirection nDir = GetTextDirection( pPt );
3444  return SvxFrameDirection::Vertical_RL_TB == nDir || SvxFrameDirection::Vertical_LR_TB == nDir
3445  || nDir == SvxFrameDirection::Vertical_LR_BT;
3446 }
3447 
3449 {
3450  const SvxFrameDirection nDir = GetTextDirection();
3451  // GetTextDirection uses SvxFrameDirection::Vertical_LR_TB to indicate RTL in
3452  // vertical environment
3453  return SvxFrameDirection::Vertical_LR_TB == nDir || SvxFrameDirection::Horizontal_RL_TB == nDir;
3454 }
3455 
3459 {
3460  bool bRet = false;
3461  if ( !GetViewOptions()->IsShowHiddenChar() && !m_pCurrentCursor->HasMark() )
3462  {
3464  const SwTextNode* pNode = rPt.nNode.GetNode().GetTextNode();
3465  if ( pNode )
3466  {
3467  const sal_Int32 nPos = rPt.nContent.GetIndex();
3468 
3469  // check if nPos is in hidden range
3470  sal_Int32 nHiddenStart;
3471  sal_Int32 nHiddenEnd;
3472  SwScriptInfo::GetBoundsOfHiddenRange( *pNode, nPos, nHiddenStart, nHiddenEnd );
3473  if ( COMPLETE_STRING != nHiddenStart )
3474  {
3475  // make selection:
3477  m_pCurrentCursor->GetMark()->nContent = nHiddenEnd;
3478  bRet = true;
3479  }
3480  }
3481  }
3482 
3483  return bRet;
3484 }
3485 
3487  bool bSearchInNotes,
3488  SwDocPositions eStart, SwDocPositions eEnd,
3489  bool& bCancel,
3490  FindRanges eRng,
3491  bool bReplace )
3492 {
3493  if( m_pTableCursor )
3494  GetCursor();
3495  delete m_pTableCursor;
3496  m_pTableCursor = nullptr;
3497  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
3498  sal_uLong nRet = m_pCurrentCursor->Find_Text(rSearchOpt, bSearchInNotes, eStart, eEnd,
3499  bCancel, eRng, bReplace, GetLayout());
3500  if( nRet || bCancel )
3501  UpdateCursor();
3502  return nRet;
3503 }
3504 
3506  SwDocPositions eStart, SwDocPositions eEnd,
3507  bool& bCancel,
3508  FindRanges eRng,
3509  const SwTextFormatColl* pReplFormat )
3510 {
3511  if( m_pTableCursor )
3512  GetCursor();
3513  delete m_pTableCursor;
3514  m_pTableCursor = nullptr;
3515  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
3516  sal_uLong nRet = m_pCurrentCursor->FindFormat(rFormatColl, eStart, eEnd, bCancel, eRng,
3517  pReplFormat );
3518  if( nRet )
3519  UpdateCursor();
3520  return nRet;
3521 }
3522 
3524  bool bNoCollections,
3525  SwDocPositions eStart, SwDocPositions eEnd,
3526  bool& bCancel,
3527  FindRanges eRng,
3528  const i18nutil::SearchOptions2* pSearchOpt,
3529  const SfxItemSet* rReplSet )
3530 {
3531  if( m_pTableCursor )
3532  GetCursor();
3533  delete m_pTableCursor;
3534  m_pTableCursor = nullptr;
3535  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
3536  sal_uLong nRet = m_pCurrentCursor->FindAttrs(rSet, bNoCollections, eStart, eEnd,
3537  bCancel, eRng, pSearchOpt, rReplSet, GetLayout());
3538  if( nRet )
3539  UpdateCursor();
3540  return nRet;
3541 }
3542 
3543 void SwCursorShell::SetSelection( const SwPaM& rCursor )
3544 {
3545  StartAction();
3546  SwPaM* pCursor = GetCursor();
3547  *pCursor->GetPoint() = *rCursor.GetPoint();
3548  if(rCursor.GetNext() != &rCursor)
3549  {
3550  const SwPaM *_pStartCursor = rCursor.GetNext();
3551  do
3552  {
3553  SwPaM* pCurrentCursor = CreateCursor();
3554  *pCurrentCursor->GetPoint() = *_pStartCursor->GetPoint();
3555  if(_pStartCursor->HasMark())
3556  {
3557  pCurrentCursor->SetMark();
3558  *pCurrentCursor->GetMark() = *_pStartCursor->GetMark();
3559  }
3560  } while( (_pStartCursor = _pStartCursor->GetNext()) != &rCursor );
3561  }
3562  // CreateCursor() adds a copy of current cursor after current, and then deletes mark of current
3563  // cursor; therefore set current cursor's mark only after creating all other cursors
3564  if (rCursor.HasMark())
3565  {
3566  pCursor->SetMark();
3567  *pCursor->GetMark() = *rCursor.GetMark();
3568  }
3569  EndAction();
3570 }
3571 
3572 static const SwStartNode* lcl_NodeContext( const SwNode& rNode )
3573 {
3574  const SwStartNode *pRet = rNode.StartOfSectionNode();
3575  while( pRet->IsSectionNode() || pRet->IsTableNode() ||
3577  {
3578  pRet = pRet->StartOfSectionNode();
3579  }
3580  return pRet;
3581 }
3582 
3589 bool sw_PosOk(const SwPosition & aPos)
3590 {
3591  return nullptr != aPos.nNode.GetNode().GetContentNode() &&
3592  aPos.nContent.GetIdxReg();
3593 }
3594 
3601 static bool lcl_CursorOk(SwPaM & aPam)
3602 {
3603  return sw_PosOk(*aPam.GetPoint()) && (! aPam.HasMark()
3604  || sw_PosOk(*aPam.GetMark()));
3605 }
3606 
3608 {
3609  // start of the ring
3610  SwPaM * pStartCursor = GetCursor();
3611  // start loop with second entry of the ring
3612  SwPaM * pCursor = pStartCursor->GetNext();
3613  SwPaM * pTmpCursor;
3614  bool bChanged = false;
3615 
3616  // For all entries in the ring except the start entry delete the entry if
3617  // it is invalid.
3618  while (pCursor != pStartCursor)
3619  {
3620  pTmpCursor = pCursor->GetNext();
3621  if ( ! lcl_CursorOk(*pCursor))
3622  {
3623  delete pCursor;
3624  bChanged = true;
3625  }
3626  pCursor = pTmpCursor;
3627  }
3628 
3629  if( pStartCursor->HasMark() && !sw_PosOk( *pStartCursor->GetMark() ) )
3630  {
3631  pStartCursor->DeleteMark();
3632  bChanged = true;
3633  }
3634  if( !sw_PosOk( *pStartCursor->GetPoint() ) )
3635  {
3636  SwNodes & aNodes = GetDoc()->GetNodes();
3637  const SwNode* pStart = lcl_NodeContext( pStartCursor->GetPoint()->nNode.GetNode() );
3638  SwNodeIndex aIdx( pStartCursor->GetPoint()->nNode );
3639  SwNode * pNode = SwNodes::GoPrevious(&aIdx);
3640  if( pNode == nullptr || lcl_NodeContext( *pNode ) != pStart )
3641  aNodes.GoNext( &aIdx );
3642  if( pNode == nullptr || lcl_NodeContext( *pNode ) != pStart )
3643  {
3644  // If the start entry of the ring is invalid replace it with a
3645  // cursor pointing to the beginning of the first content node in the
3646  // document.
3647  aIdx = *(aNodes.GetEndOfContent().StartOfSectionNode());
3648  pNode = aNodes.GoNext( &aIdx );
3649  }
3650  bool bFound = (pNode != nullptr);
3651 
3652  assert(bFound);
3653 
3654  if (bFound)
3655  {
3656  SwPaM aTmpPam(*pNode);
3657  *pStartCursor = aTmpPam;
3658  }
3659 
3660  bChanged = true;
3661  }
3662 
3663  // If at least one of the cursors in the ring have been deleted or replaced,
3664  // remove the table cursor.
3665  if (m_pTableCursor != nullptr && bChanged)
3667 }
3668 
3670 {
3671  OUString aResult;
3672 
3673  if (IsMultiSelection())
3674  aResult += SwResId(STR_MULTISEL);
3675  else
3676  aResult = SwDoc::GetPaMDescr(*GetCursor());
3677 
3678  return aResult;
3679 }
3680 
3682 {
3683  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwCursorShell"));
3684 
3685  SwViewShell::dumpAsXml(pWriter);
3686 
3687  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_pCurrentCursor"));
3688  for (const SwPaM& rPaM : m_pCurrentCursor->GetRingContainer())
3689  rPaM.dumpAsXml(pWriter);
3690  (void)xmlTextWriterEndElement(pWriter);
3691 
3692  (void)xmlTextWriterEndElement(pWriter);
3693 }
3694 
3695 static void lcl_FillRecognizerData( std::vector< OUString >& rSmartTagTypes,
3696  uno::Sequence< uno::Reference< container::XStringKeyMap > >& rStringKeyMaps,
3697  const SwWrongList& rSmartTagList, sal_Int32 nCurrent )
3698 {
3699  // Insert smart tag information
3700  std::vector< uno::Reference< container::XStringKeyMap > > aStringKeyMaps;
3701 
3702  for ( sal_uInt16 i = 0; i < rSmartTagList.Count(); ++i )
3703  {
3704  const sal_Int32 nSTPos = rSmartTagList.Pos( i );
3705  const sal_Int32 nSTLen = rSmartTagList.Len( i );
3706 
3707  if ( nSTPos <= nCurrent && nCurrent < nSTPos + nSTLen )
3708  {
3709  const SwWrongArea* pArea = rSmartTagList.GetElement( i );
3710  if ( pArea )
3711  {
3712  rSmartTagTypes.push_back( pArea->maType );
3713  aStringKeyMaps.push_back( pArea->mxPropertyBag );
3714  }
3715  }
3716  }
3717 
3718  if ( !rSmartTagTypes.empty() )
3719  {
3720  rStringKeyMaps = comphelper::containerToSequence(aStringKeyMaps);
3721  }
3722 }
3723 
3724 static void lcl_FillTextRange( uno::Reference<text::XTextRange>& rRange,
3725  SwTextNode& rNode, sal_Int32 nBegin, sal_Int32 nLen )
3726 {
3727  // create SwPosition for nStartIndex
3728  SwIndex aIndex( &rNode, nBegin );
3729  SwPosition aStartPos( rNode, aIndex );
3730 
3731  // create SwPosition for nEndIndex
3732  SwPosition aEndPos( aStartPos );
3733  aEndPos.nContent = nBegin + nLen;
3734 
3735  const uno::Reference<text::XTextRange> xRange =
3736  SwXTextRange::CreateXTextRange(rNode.GetDoc(), aStartPos, &aEndPos);
3737 
3738  rRange = xRange;
3739 }
3740 
3741 void SwCursorShell::GetSmartTagTerm( std::vector< OUString >& rSmartTagTypes,
3742  uno::Sequence< uno::Reference< container::XStringKeyMap > >& rStringKeyMaps,
3743  uno::Reference< text::XTextRange>& rRange ) const
3744 {
3745  if ( !SwSmartTagMgr::Get().IsSmartTagsEnabled() )
3746  return;
3747 
3748  SwPaM* pCursor = GetCursor();
3749  SwPosition aPos( *pCursor->GetPoint() );
3750  SwTextNode *pNode = aPos.nNode.GetNode().GetTextNode();
3751  if ( !pNode || pNode->IsInProtectSect() )
3752  return;
3753 
3754  const SwWrongList *pSmartTagList = pNode->GetSmartTags();
3755  if ( !pSmartTagList )
3756  return;
3757 
3758  sal_Int32 nCurrent = aPos.nContent.GetIndex();
3759  sal_Int32 nBegin = nCurrent;
3760  sal_Int32 nLen = 1;
3761 
3762  if (!pSmartTagList->InWrongWord(nBegin, nLen) || pNode->IsSymbolAt(nBegin))
3763  return;
3764 
3765  const sal_uInt16 nIndex = pSmartTagList->GetWrongPos( nBegin );
3766  const SwWrongList* pSubList = pSmartTagList->SubList( nIndex );
3767  if ( pSubList )
3768  {
3769  pSmartTagList = pSubList;
3770  nCurrent = 0;
3771  }
3772 
3773  lcl_FillRecognizerData( rSmartTagTypes, rStringKeyMaps, *pSmartTagList, nCurrent );
3774  lcl_FillTextRange( rRange, *pNode, nBegin, nLen );
3775 }
3776 
3777 // see also SwEditShell::GetCorrection( const Point* pPt, SwRect& rSelectRect )
3778 void SwCursorShell::GetSmartTagRect( const Point& rPt, SwRect& rSelectRect )
3779 {
3780  SwPaM* pCursor = GetCursor();
3781  SwPosition aPos( *pCursor->GetPoint() );
3782  Point aPt( rPt );
3784  SwSpecialPos aSpecialPos;
3785  eTmpState.m_pSpecialPos = &aSpecialPos;
3786  SwTextNode *pNode;
3787  const SwWrongList *pSmartTagList;
3788 
3789  if( !GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &eTmpState ) )
3790  return;
3791  pNode = aPos.nNode.GetNode().GetTextNode();
3792  if( !pNode )
3793  return;
3794  pSmartTagList = pNode->GetSmartTags();
3795  if( !pSmartTagList )
3796  return;
3797  if( pNode->IsInProtectSect() )
3798  return;
3799 
3800  sal_Int32 nBegin = aPos.nContent.GetIndex();
3801  sal_Int32 nLen = 1;
3802 
3803  if (!pSmartTagList->InWrongWord(nBegin, nLen) || pNode->IsSymbolAt(nBegin))
3804  return;
3805 
3806  // get smarttag word
3807  OUString aText( pNode->GetText().copy(nBegin, nLen) );
3808 
3809  //save the start and end positions of the line and the starting point
3810  Push();
3811  LeftMargin();
3812  const sal_Int32 nLineStart = GetCursor()->GetPoint()->nContent.GetIndex();
3813  RightMargin();
3814  const sal_Int32 nLineEnd = GetCursor()->GetPoint()->nContent.GetIndex();
3816 
3817  // make sure the selection build later from the data below does not
3818  // include "in word" character to the left and right in order to
3819  // preserve those. Therefore count those "in words" in order to
3820  // modify the selection accordingly.
3821  const sal_Unicode* pChar = aText.getStr();
3822  sal_Int32 nLeft = 0;
3823  while (*pChar++ == CH_TXTATR_INWORD)
3824  ++nLeft;
3825  pChar = aText.getLength() ? aText.getStr() + aText.getLength() - 1 : nullptr;
3826  sal_Int32 nRight = 0;
3827  while (pChar && *pChar-- == CH_TXTATR_INWORD)
3828  ++nRight;
3829 
3830  aPos.nContent = nBegin + nLeft;
3831  pCursor = GetCursor();
3832  *pCursor->GetPoint() = aPos;
3833  pCursor->SetMark();
3834  ExtendSelection( true, nLen - nLeft - nRight );
3835  // do not determine the rectangle in the current line
3836  const sal_Int32 nWordStart = (nBegin + nLeft) < nLineStart ? nLineStart : nBegin + nLeft;
3837  // take one less than the line end - otherwise the next line would
3838  // be calculated
3839  const sal_Int32 nWordEnd = std::min(nBegin + nLen - nLeft - nRight, nLineEnd);
3840  Push();
3841  pCursor->DeleteMark();
3842  SwIndex& rContent = GetCursor()->GetPoint()->nContent;
3843  rContent = nWordStart;
3844  SwRect aStartRect;
3845  SwCursorMoveState aState;
3846  aState.m_bRealWidth = true;
3847  SwContentNode* pContentNode = pCursor->GetContentNode();
3848  std::pair<Point, bool> const tmp(rPt, false);
3849  SwContentFrame *pContentFrame = pContentNode->getLayoutFrame(
3850  GetLayout(), pCursor->GetPoint(), &tmp);
3851 
3852  pContentFrame->GetCharRect( aStartRect, *pCursor->GetPoint(), &aState );
3853  rContent = nWordEnd - 1;
3854  SwRect aEndRect;
3855  pContentFrame->GetCharRect( aEndRect, *pCursor->GetPoint(),&aState );
3856  rSelectRect = aStartRect.Union( aEndRect );
3858 }
3859 
3860 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE void MarkListLevel(const OUString &sListId, const int nLevel)
Mark a certain list level of a certain list.
Definition: crsrsh.cxx:389
bool SttEndDoc(bool bSttDoc)
Definition: swcrsr.cxx:2170
sal_Int32 Pos(sal_uInt16 nIdx) const
Definition: wrong.hxx:319
bool m_bSVCursorVis
SV-Cursor visible/invisible.
Definition: crsrsh.hxx:208
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:983
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:683
Starts a section of nodes in the document model.
Definition: node.hxx:312
bool GotoPage(sal_uInt16 nPage)
Definition: crsrsh.cxx:1188
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2295
SwVisibleCursor * m_pVisibleCursor
the visible cursor
Definition: crsrsh.hxx:177
Base class of the Writer layout elements.
Definition: frame.hxx:313
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:158
virtual sal_Int32 Len() const
Definition: node.cxx:1246
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
void DeleteMark()
Definition: pam.hxx:177
void KillPams()
Definition: crsrsh.cxx:1022
virtual SwPaM & CreateNewShellCursor() override
Create and return a new shell cursor.
Definition: crsrsh.cxx:173
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: viewsh.cxx:139
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
sal_uLong GetIndex() const
Definition: node.hxx:291
SAL_DLLPRIVATE void UpdateCursor(sal_uInt16 eFlags=SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE, bool bIdleEnd=false)
Definition: crsrsh.cxx:1571
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:156
SwShellCursor * m_pCurrentCursor
current cursor
Definition: crsrsh.hxx:175
sal_Int32 nIndex
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:970
void Add(SwClient *pDepend)
Definition: calbck.cxx:173
bool IsFollow() const
Definition: flowfrm.hxx:166
sal_uLong Find_Text(const i18nutil::SearchOptions2 &rSearchOpt, bool bSearchInNotes, SwDocPositions eStart, SwDocPositions eEnd, bool &bCancel, FindRanges eRng, bool bReplace=false)
Definition: crsrsh.cxx:3486
static void lcl_CheckHiddenPara(SwPosition &rPos)
Try to set the cursor to the next visible content node.
Definition: crsrsh.cxx:1532
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
bool IsInVerticalText(const Point *pPt=nullptr) const
Definition: crsrsh.cxx:3441
size_t GetMarkCount() const
Marks a position in the document model.
Definition: pam.hxx:35
void GoNextPrevCursorSetSearchLabel(const bool bNext)
Definition: crsrsh.cxx:1394
bool m_bHasFocus
Shell is "active" in a window.
Definition: crsrsh.hxx:207
bool IsInProtectTable(bool bMove=false, bool bChgCursor=true)
Definition: swcrsr.cxx:568
bool IsSectionNode() const
Definition: node.hxx:645
sal_uInt16 GetWhich() const
Definition: calbck.hxx:72
bool IsMultiSelection() const
Definition: pam.hxx:272
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:823
SdrView * GetDrawView()
Definition: vnew.cxx:376
bool IsInFly() const
Definition: frame.hxx:958
SwRect & Union(const SwRect &rRect)
Definition: swrect.cxx:41
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
virtual void updateCursorPosition(const SwPosition &rNewPos)=0
Update cursor position reacts to a change of the current input cursor As long as the cursor in inside...
bool IsInSct() const
Definition: frame.hxx:964
static SwFrame * lcl_IsInHeaderFooter(const SwNodeIndex &rIdx, Point &rPt)
Definition: crsrsh.cxx:734
SAL_DLLPRIVATE bool UpDown(bool, sal_uInt16)
Definition: crsrsh.cxx:503
bool m_bRealHeight
should the real height be calculated?
Definition: crstate.hxx:141
const OUString & GetText() const
Definition: ndtxt.hxx:215
OUString getPageRectangles()
Implementation of lok::Document::getPartPageRectangles() for Writer.
Definition: crsrsh.cxx:1298
virtual const SwRootFrame * GetCurrentLayout() const =0
static const SwStartNode * lcl_NodeContext(const SwNode &rNode)
Definition: crsrsh.cxx:3572
bool MoveSection(SwWhichSection, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2334
sal_uInt16 GetNextPrevPageNum(bool bNext=true)
Definition: crsrsh.cxx:1253
bool GoNextCursor()
go to the next SSelection
Definition: crsrsh.cxx:1357
bool SttEndDoc(bool bStt)
Definition: crsrsh.cxx:574
bool m_bInCMvVisportChgd
Flag for CursorMoves.
Definition: crsrsh.hxx:218
SwDocShell * GetDocShell()
Definition: doc.hxx:1352
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
void ClearTableBoxContent()
Definition: trvltbl.cxx:909
static void lcl_FillRecognizerData(std::vector< OUString > &rSmartTagTypes, uno::Sequence< uno::Reference< container::XStringKeyMap > > &rStringKeyMaps, const SwWrongList &rSmartTagList, sal_Int32 nCurrent)
Definition: crsrsh.cxx:3695
constexpr TypedWhichId< SwMsgPoolItem > RES_GRAPHIC_SWAPIN(186)
check overlapping PaMs
Definition: crsrsh.hxx:154
void SetStyleSettings(const StyleSettings &rSet)
bool IsCursorInFootnote() const
Definition: crsrsh.cxx:1151
const SwTable * GetTable() const
Definition: tabfrm.hxx:157
bool IsAtLeftRightMargin(SwRootFrame const &rLayout, bool bLeftMargin, bool bAPI) const
Definition: swcrsr.cxx:2149
void Left(const tools::Long nLeft)
Definition: swrect.hxx:194
SwNodeIndex nNode
Definition: pam.hxx:37
SwVisibleCursor * GetVisibleCursor() const
Definition: crsrsh.cxx:2720
bool IsTableMode() const
Definition: crsrsh.hxx:643
bool IsSttPara() const
Definition: crsrsh.cxx:1095
keep Up/Down on columns
Definition: crsrsh.hxx:152
SwShellCursor & getShellCursor()
Access to the shell cursor.
Definition: BlockCursor.cxx:25
void UpdateCursorPos()
Set the cursor back into content.
Definition: crsrsh.cxx:1491
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:90
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:3044
bool IsStartOfDoc() const
Definition: crsrsh.cxx:2753
sal_uIntPtr sal_uLong
long Long
void NotifyCursor(SfxViewShell *pViewShell) const
See SwView::NotifyCursor().
Definition: crsrsh.cxx:1319
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
bool IsEditInReadonlyFlag() const
Definition: section.hxx:189
const SwPosition * GetMark() const
Definition: pam.hxx:209
void ShowCursor(bool bGotoCursor=true, bool bForceVisCursor=true, bool bActivate=false)
tools::Long GetLeft() const
Definition: tabcol.hxx:78
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:46
bool m_bAllProtect
Flag for areas.
Definition: crsrsh.hxx:216
sal_uInt8 m_nCursorBidiLevel
Definition: crstate.hxx:139
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1213
sal_Int64 n
OUString GetListId() const
Definition: ndtxt.cxx:4363
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:649
bool m_bRealWidth
Calculation of the width required.
Definition: crstate.hxx:149
virtual bool IsSelOvr(SwCursorSelOverFlags eFlags=SwCursorSelOverFlags::CheckNodeSection|SwCursorSelOverFlags::Toggle|SwCursorSelOverFlags::ChangePos)
Definition: swcrsr.cxx:226
Definition: doc.hxx:188
SwShellCursor * m_pStackCursor
stack for the cursor
Definition: crsrsh.hxx:176
void ShellLoseFocus()
Definition: crsrsh.cxx:2430
static SwContentNode * GoPrevSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true)
Definition: nodes.cxx:1968
void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: crsrsh.cxx:1411
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
void GetTabRows(SwTabCols &rToFill) const
Definition: fetab.cxx:680
helper class to disable creation of an action by a callback event in particular, change event from a ...
Definition: rootfrm.hxx:451
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:90
aBuf
bool m_bSetInReadOnly
ReadOnly areas may be entered.
Definition: crstate.hxx:148
virtual void MakeSelVisible()
show the current selected "object"
Definition: crsrsh.cxx:3080
void GetPageNum(sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum, bool bAtCursorPos=true, const bool bCalcFrame=true)
Definition: crsrsh.cxx:1209
bool HasDrawView() const
Definition: vnew.cxx:361
virtual bool LeftRight(bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual, bool bSkipHidden, bool bInsertCursor, SwRootFrame const *pLayout, bool isFieldNames)
Definition: swcrsr.cxx:1739
sal_uInt8 GetCursorBidiLevel() const
Definition: swcrsr.hxx:211
void GetSmartTagRect(const Point &rPt, SwRect &rSelectRect)
Definition: crsrsh.cxx:3778
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1310
std::list< SwPaM * >::iterator getEnd()
End of the container for the selected text portions.
SwNode & GetNode() const
Definition: ndindex.hxx:119
sal_Unicode GetChar(bool bEnd=true, tools::Long nOffset=0)
get the nth character of the current SSelection
Definition: crsrsh.cxx:2601
bool m_bOverwriteCursor
Definition: crsrsh.hxx:227
bool IsSelFullPara() const
Definition: crsrsh.cxx:3405
void DestroyCursor()
transform TableCursor to normal cursor, nullify Tablemode
Definition: crsrsh.cxx:152
This class is used as parameter for creation of a block cursor selection.
virtual void VisPortChgd(const SwRect &)
Definition: viewsh.cxx:1070
SvxFrameDirection
sal_uInt16 GetRowsToRepeat() const
Definition: swtable.hxx:195
void ExtendedSelectAll(bool bFootnotes=true)
Definition: crsrsh.cxx:595
bool m_bVisPortChgd
in VisPortChg-Call
Definition: crsrsh.hxx:210
Dialog to specify the properties of date form field.
SwNode & GetEndOfPostIts() const
A still empty section.
Definition: ndarr.hxx:152
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1788
bool IsCellFrame() const
Definition: frame.hxx:1223
bool GetAttrOutlineContentVisible(const size_t nPos)
Definition: wrtsh1.cxx:2273
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1295
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
forward all attribute/format changes at the current node to the Link
Definition: crsrsh.cxx:2483
OUString GetCursorDescr() const
Returns textual description of the current selection.
Definition: crsrsh.cxx:3669
void Hide()
Definition: viscrs.cxx:718
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4087
void MoveTo(value_type *pDestRing)
Removes this item from its current ring container and adds it to another ring container.
Definition: ring.hxx:135
constexpr sal_uInt16 RES_MSG_BEGIN(RES_FMT_END)
SfxHintId GetId() const
const SwTabColsEntry & GetEntry(size_t nPos) const
Definition: tabcol.hxx:74
bool HasSelection() const
Does the current cursor create a selection?
Definition: crsrsh.cxx:2521
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
Definition: itratr.cxx:853
SwWrtShell & GetWrtShell() const
Definition: view.hxx:413
not in repeated headlines
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
SwBlockCursor * m_pBlockCursor
interface of cursor for block (=rectangular) selection
Definition: crsrsh.hxx:179
SwDocPositions
Definition: cshtyp.hxx:103
void SwapPam()
Definition: crsrsh.cxx:976
const SwSection & GetSection() const
Definition: node.hxx:542
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:47
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
const int CRSR_POSOLD
Definition: crsrsh.hxx:119
static UITestLogger & getInstance()
bool IsInFrontOfLabel() const
Definition: crsrsh.cxx:1157
void logEvent(const EventDescription &rDescription)
bool SelectHiddenRange()
If the current cursor position is inside a hidden range, the hidden range is selected.
Definition: crsrsh.cxx:3458
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:425
sal_uInt16 sal_Unicode
void PrepareCursor()
Definition: calcmove.cxx:403
bool IsFlyFrame() const
Definition: frame.hxx:1207
SwWrongList * SubList(sal_uInt16 nIdx) const
Definition: wrong.hxx:343
#define CH_TXTATR_INWORD
Definition: hintids.hxx:171
NONE
void SttCursorMove()
Definition: crsrsh.cxx:302
SwNodeType GetNodeType() const
Definition: node.hxx:145
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:171
SwIndex nContent
Definition: pam.hxx:38
const SwRect & getFrameArea() const
Definition: frame.hxx:178
void NormalizePam(bool bPointFirst=true)
Ensure point and mark of the current PaM are in a specific order.
Definition: crsrsh.cxx:970
Cursor Up/Down.
bool IsEmptyPage() const
Definition: pagefrm.hxx:157
tools::Long GetLeftMin() const
Definition: tabcol.hxx:77
bool IsInTab() const
Definition: frame.hxx:952
bool HasHiddenCharAttribute(bool bWholePara) const
Hidden Paragraph Field:
Definition: ndtxt.hxx:726
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
void RegisterOtherShell(OutlinerViewShell *pOtherShell)
FindRanges
Definition: cshtyp.hxx:90
SAL_DLLPRIVATE bool isInHiddenTextFrame(SwShellCursor *pShellCursor)
Definition: crsrsh.cxx:660
bool FindValidContentNode(bool bOnlyText)
search a valid content position (not protected/hidden)
Definition: crsrsh.cxx:3116
bool m_bChgCallFlag
attribute change inside Start- and EndAction
Definition: crsrsh.hxx:209
int SetCursor(const Point &rPt, bool bOnlyText=false, bool bBlock=true)
Definition: crsrsh.cxx:761
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
Definition: pam.cxx:259
bool m_bMacroExecAllowed
Definition: crsrsh.hxx:229
css::uno::Reference< css::container::XStringKeyMap > mxPropertyBag
Definition: wrong.hxx:70
bool IsProtectFlag() const
Definition: section.hxx:188
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
constexpr sal_uInt16 RES_MSG_END(190)
#define STYLE_CURSOR_NOBLINKTIME
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1108
void Show(SfxViewShell const *pViewShell)
Definition: viscrs.cxx:670
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:706
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: crsrsh.cxx:3681
SwShellTableCursor * m_pTableCursor
table Cursor; only in tables when the selection lays over 2 columns
Definition: crsrsh.hxx:181
bool m_bCallChgLnk
flag for derived classes
Definition: crsrsh.hxx:213
std::list< SwPaM * >::iterator getStart()
Start of the container for the selected text portions.
SwPaM * GetNext()
Definition: pam.hxx:264
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:541
bool MovePage(SwWhichPage, SwPosPage)
Definition: crsrsh.cxx:634
void GetCharRectAt(SwRect &rRect, const SwPosition *pPos)
Definition: crsrsh.cxx:1203
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Definition: unusedf.cxx:72
static void CheckRange(SwCursor *pCurrentCursor)
Check if pCurrentCursor points into already existing ranges and delete those.
Definition: crsrsh.cxx:86
void MakeVisible(const SwRect &)
Definition: viewsh.cxx:571
void EndListeningAll()
Definition: calbck.cxx:137
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
DocumentType eType
static OUString GetPaMDescr(const SwPaM &rPaM)
Returns a textual description of a PaM.
Definition: doc.cxx:1737
bool LeftRight(bool, sal_uInt16, sal_uInt16, bool)
Definition: crsrsh.cxx:324
void EndCursorMove(const bool bIdleEnd=false)
Definition: crsrsh.cxx:311
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1806
void SetCursorBlinkTime(sal_uInt64 nBlinkTime)
bool IsContentNode() const
Definition: node.hxx:629
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: crsrsh.cxx:696
struct _xmlTextWriter * xmlTextWriterPtr
bool FrameContainsNode(SwContentFrame const &rFrame, sal_uLong nNodeIndex)
Definition: txtfrm.cxx:288
bool ShouldWait() const
Should WaitPtr be switched on for the clipboard?
Definition: crsrsh.cxx:3057
bool ExtendedSelectedAll()
If ExtendedSelectAll() was called and selection didn't change since then.
Definition: crsrsh.cxx:607
bool LeftMargin()
Definition: crsrsh.hxx:355
static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn)
Definition: crsrsh.cxx:447
static void lcl_FillTextRange(uno::Reference< text::XTextRange > &rRange, SwTextNode &rNode, sal_Int32 nBegin, sal_Int32 nLen)
Definition: crsrsh.cxx:3724
Right
bool m_bAutoUpdateCells
Definition: crsrsh.hxx:224
virtual SwPaM & GetCurrentShellCursor() override
Return the current shell cursor.
Definition: crsrsh.cxx:186
bool ParkTableCursor()
Invalidate cursors.
Definition: crsrsh.cxx:2783
bool IsInRightToLeftText() const
Definition: crsrsh.cxx:3448
sal_uInt16 Count() const
Definition: wrong.hxx:324
A helper class to save cursor state (position).
Definition: swcrsr.hxx:232
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1269
SwNodeType
Definition: ndtyp.hxx:28
constexpr TypedWhichId< SwUpdateAttr > RES_UPDATE_ATTR(167)
bool(* SwWhichPara)(SwPaM &, SwMoveFnCollection const &)
Definition: cshtyp.hxx:43
SwPaM * CreateCursor()
delete the current cursor and make the following into the current
Definition: crsrsh.cxx:124
static bool lcl_CursorOk(SwPaM &aPam)
Checks if a PaM is valid.
Definition: crsrsh.cxx:3601
SwCursor * GetNext()
Definition: swcrsr.hxx:219
int i
const SwRect & VisArea() const
Definition: viewsh.cxx:564
uno_Any a
sal_uInt16 GetPageCnt()
Definition: crsrsh.cxx:1291
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:132
SwDoc & GetDoc()
Definition: node.hxx:212
const SwPosition * GetPoint() const
Definition: pam.hxx:207
bool unique() const
Definition: ring.hxx:96
bool IsOverReadOnlyPos(const Point &rPt) const
Definition: crsrsh.cxx:2725
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
static SwSmartTagMgr & Get()
bool UpDown(bool bUp, sal_uInt16 nCnt)
Definition: viscrs.cxx:778
SAL_DLLPRIVATE void UpdateMarkedListLevel()
Updates the marked list level according to the cursor.
Definition: crsrsh.cxx:407
SelectionType
SAL_DLLPRIVATE void sendLOKCursorUpdates()
Definition: crsrsh.cxx:2053
SwPageFrame * FindPageFrame()
Definition: frame.hxx:679
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2243
size_t UpdateTableSelBoxes()
Definition: crsrsh.cxx:3070
void ParkCursor(const SwNodeIndex &rIdx)
Remove selections and additional cursors of all shells.
Definition: crsrsh.cxx:2875
bool IsEndOfTable() const
at the very last SwPosition inside a table
Definition: crsrsh.cxx:1133
SwLayoutFrame *(* SwWhichPage)(const SwLayoutFrame *)
Definition: cshtyp.hxx:34
const SwFrame * Lower() const
Definition: layfrm.hxx:101
bool IsHiddenFlag() const
Definition: section.hxx:187
static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection)
Definition: crsrsh.cxx:458
SwContentNode * GetContentNode()
Definition: node.hxx:616
void BlockCursorToCursor()
Definition: crsrsh.cxx:903
SwSection * GetSection()
Definition: sectfrm.hxx:93
const SdrMarkList & GetMarkedObjectList() const
sal_uInt16 GetPageNumSeqNonEmpty()
Definition: crsrsh.cxx:1229
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
const int CRSR_POSCHG
Definition: crsrsh.hxx:120
bool IsChgd() const
Definition: swcrsr.hxx:298
friend class SwVisibleCursor
Definition: crsrsh.hxx:142
SwLayoutFrame * GetUpper()
Definition: frame.hxx:677
void StartAction()
Definition: viewsh.hxx:590
void ShowCursors(bool bCursorVis)
Definition: crsrsh.cxx:2380
bool HasArea() const
Definition: swrect.hxx:287
void AddHeight(const tools::Long nAdd)
Definition: swrect.cxx:161
sal_Int32 Len(sal_uInt16 nIdx) const
Definition: wrong.hxx:314
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
bool RightMargin(bool bAPI=false)
Definition: crsrsh.hxx:356
Marks a character position inside a document model node.
Definition: index.hxx:33
void SetSelection(const SwPaM &rCursor)
Definition: crsrsh.cxx:3543
::rtl::Reference< Content > pContent
bool IsCursorReadonly() const
Definition: crsrsh.cxx:3298
bool m_bSetCursorInReadOnly
Definition: crsrsh.hxx:226
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:224
SAL_DLLPRIVATE SvxFrameDirection GetTextDirection(const Point *pPt=nullptr) const
Definition: crsrsh.cxx:3426
bool IsNoTextNode() const
Definition: node.hxx:649
SwFrame * GetPrev()
Definition: frame.hxx:676
const Point & GetMkPos() const
Definition: viscrs.hxx:143
void DrawSelectionXOR(OutlinerViewShell *pOtherShell)
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:2738
bool GoCurrSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1058
void ClearUpCursors()
Definition: crsrsh.cxx:3607
void AddWidth(const tools::Long nAdd)
Definition: swrect.cxx:160
SwWrongList * GetSmartTags()
Definition: txtedt.cxx:2248
Marks a node in the document model.
Definition: ndindex.hxx:31
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:231
bool m_bSelTableCells
Definition: crsrsh.hxx:223
void GetTabCols(SwTabCols &rToFill) const
Info about columns and margins.
Definition: fetab.cxx:663
ring_container GetRingContainer()
Definition: ring.hxx:240
sal_uLong FindFormat(const SwTextFormatColl &rFormatColl, SwDocPositions eStart, SwDocPositions eEnd, bool &bCancel, FindRanges eRng, const SwTextFormatColl *pReplFormat)
Definition: crsrsh.cxx:3505
SwStartNodeType GetStartNodeType() const
Definition: node.hxx:329
bool m_bInFrontOfLabel
cursor in front of label
Definition: crstate.hxx:162
bool HasReadonlySel() const
Definition: crsrsh.cxx:3351
Point m_aRealHeight
contains then the position/height of the cursor
Definition: crstate.hxx:137
SwStartNode * GetStartNode()
Definition: node.hxx:592
bool m_bIgnoreReadonly
Definition: crsrsh.hxx:221
bool IsProtect() const
Is node in something that is protected (range, frame, table cells ...
Definition: node.cxx:426
A page of the document layout.
Definition: pagefrm.hxx:57
void TableCursorToCursor()
enter block mode, change normal cursor into block cursor
Definition: crsrsh.cxx:896
stay with the cursor inside text
static void SetSearchLabel(const SearchLabel &rSL)
bool MakeTableCursors(SwTableCursor &)
Calculates the cells included from the current selection.
Definition: trvlfrm.cxx:1860
tools::Long SwTwips
Definition: swtypes.hxx:50
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:111
const SwPosition * Start() const
Definition: pam.hxx:212
CursorMoveState
Definition: crstate.hxx:121
CursorFlag
for calling UpdateCursor
Definition: crsrsh.hxx:151
SAL_DLLPRIVATE bool IsAtLRMargin(bool, bool bAPI=false) const
Definition: crsrsh.cxx:568
SwTextNode * GetParaPropsNode(SwRootFrame const &rLayout, SwNodeIndex const &rNode)
Definition: txtfrm.cxx:328
bool IsInProtectSect() const
Is node in a protected area?
Definition: node.cxx:416
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1112
SwFrame * FindColFrame()
Definition: findfrm.cxx:530
void EndAction(const bool bIdleEnd=false)
Definition: viewsh.hxx:595
bool MoveSection(SwWhichSection, SwMoveFnCollection const &)
Definition: crsrsh.cxx:720
Rect of current page.
void StartAction()
Definition: crsrsh.cxx:227
void CallChgLnk()
Definition: crsrsh.cxx:2530
bool IsMacroExecAllowed() const
Definition: crsrsh.hxx:837
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
bool LeftRightMargin(SwRootFrame const &rLayout, bool bLeftMargin, bool bAPI)
Definition: swcrsr.cxx:2132
bool IsMultiSelection() const
Definition: crsrsh.hxx:884
bool IsReadOnlyAvailable() const
Definition: crsrsh.hxx:474
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:414
void Justify()
Definition: swrect.cxx:131
static void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage)
Definition: crsrsh.cxx:436
SwContentFrame *(* SwPosPage)(const SwLayoutFrame *)
Definition: cshtyp.hxx:38
OUString GetExpandText(SwRootFrame const *pLayout, const sal_Int32 nIdx=0, const sal_Int32 nLen=-1, const bool bWithNum=false, const bool bAddSpaceAfterListLabelStr=false, const bool bWithSpacesForLevel=false, const ExpandMode eAdditionalMode=ExpandMode::ExpandFootnote) const
add 4th optional parameter indicating, when that a spa...
Definition: ndtxt.cxx:3359
std::deque< AttacherIndex_Impl > aIndex
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
Point m_aCursorHeight
height & offset from visible Cursor
Definition: crsrsh.hxx:165
void HideCursors()
Definition: crsrsh.cxx:2364
virtual void VisPortChgd(const SwRect &) override
Definition: crsrsh.cxx:1457
bool TestCurrPam(const Point &rPt, bool bTstHit=false)
Search in the selected area for a Selection that covers the given point.
Definition: crsrsh.cxx:991
sal_uInt64 GetCursorBlinkTime() const
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2450
void Combine()
Combine two cursors.
Definition: crsrsh.cxx:2330
#define SAL_WARN_IF(condition, area, stream)
void CursorToBlockCursor()
leave block mode, change block cursor into normal cursor
Definition: crsrsh.cxx:920
void ShellGetFocus()
Definition: crsrsh.cxx:2437
sal_uLong FindAttrs(const SfxItemSet &rSet, bool bNoCollections, SwDocPositions nStart, SwDocPositions nEnd, bool &bCancel, FindRanges, const i18nutil::SearchOptions2 *pSearchOpt, const SfxItemSet *rReplSet=nullptr, SwRootFrame const *const pLayout=nullptr)
search for attributes
Definition: findattr.cxx:1409
const SwNodes & GetNodes() const
Definition: ndindex.hxx:156
void GetSmartTagTerm(std::vector< OUString > &rSmartTagTypes, css::uno::Sequence< css::uno::Reference< css::container::XStringKeyMap > > &rStringKeyMaps, css::uno::Reference< css::text::XTextRange > &rRange) const
Definition: crsrsh.cxx:3741
bool IsNumbered(SwRootFrame const *pLayout=nullptr) const
Returns is this text node is numbered.
Definition: ndtxt.cxx:2866
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
sal_uLong Find_Text(const i18nutil::SearchOptions2 &rSearchOpt, bool bSearchInNotes, SwDocPositions nStart, SwDocPositions nEnd, bool &bCancel, FindRanges, bool bReplace=false, SwRootFrame const *const pLayout=nullptr)
Definition: findtxt.cxx:1014
OUString maType
Definition: wrong.hxx:69
bool m_bBasicHideCursor
Definition: crsrsh.hxx:225
bool ExtendSelection(bool bEnd=true, sal_Int32 nCount=1)
extend current SSelection by n characters
Definition: crsrsh.cxx:2627
SwMoveFnCollection const & fnSectionEnd
Definition: paminit.cxx:50
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
sal_uInt16 GetWrongPos(sal_Int32 nValue) const
Find the first position that is greater or equal to the given value.
Definition: wrong.cxx:190
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2545
SwShellCursor * GetNext()
Definition: viscrs.hxx:164
sal_Int32 GetIndex() const
Definition: index.hxx:91
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
Definition: wrong.cxx:102
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
bool IsNoTextFrame() const
Definition: frame.hxx:1235
bool StartsWithTable()
If document body starts with a table.
Definition: crsrsh.cxx:626
SwNodes & GetNodes()
Definition: doc.hxx:409
bool GoPrevCursor()
go to the previous SSelection
Definition: crsrsh.cxx:1376
size_t GetSelectedBoxesCount() const
Definition: swcrsr.hxx:279
const SwPosition * End() const
Definition: pam.hxx:217
void SetCursorBidiLevel(sal_uInt8 nNewLevel)
Definition: swcrsr.hxx:212
bool GetFrameInPage(const SwContentFrame *, SwWhichPage, SwPosPage, SwPaM *)
Returns the first/last Contentframe (controlled using the parameter fnPosPage) of the current/previou...
Definition: trvlfrm.cxx:1094
void Top(const tools::Long nTop)
Definition: swrect.hxx:203
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: viewsh.cxx:1756
void ShowCursor()
Definition: crsrsh.cxx:2393
Organizer of the contact between SwTextNodes and grammar checker.
SwFrame * GetLower()
Definition: findfrm.cxx:170
const SwWrongArea * GetElement(sal_uInt16 nIdx) const
Definition: wrong.hxx:350
int CompareCursorStackMkCurrPt() const
Definition: crsrsh.cxx:1054
const Point & GetPtPos() const
Definition: viscrs.hxx:141
bool HasReadonlySel(bool bFormView) const
Is in something protected (readonly) or selection contains something protected.
Definition: pam.cxx:598
SwSpecialPos * m_pSpecialPos
for positions inside fields
Definition: crstate.hxx:136
SAL_DLLPRIVATE bool LRMargin(bool, bool bAPI=false)
Definition: crsrsh.cxx:533
const char * pChar
bool CheckTableBoxContent(const SwPosition *pPos=nullptr)
Definition: trvltbl.cxx:807
CursorMoveState m_eState
Definition: crstate.hxx:138
scroll window
Definition: crsrsh.hxx:153
static bool IsAtStartOrEndOfFrame(SwCursorShell const *const pShell, SwShellCursor const *const pShellCursor, SwMoveFnCollection const &fnPosPara)
Definition: crsrsh.cxx:671
bool IsScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:45
void ClearMark()
Definition: crsrsh.cxx:939
SwMoveFnCollection const & fnSectionStart
Definition: paminit.cxx:49
SwStartNodeType
Definition: ndtyp.hxx:50
bool bColumnChange()
Definition: crsrsh.cxx:469
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:357
void InvalidateAccessibleParaTextSelection()
invalidate text selection for paragraphs
Definition: viewsh.cxx:2498
static bool GetBoundsOfHiddenRange(const SwTextNode &rNode, sal_Int32 nPos, sal_Int32 &rnStartPos, sal_Int32 &rnEndPos, std::vector< sal_Int32 > *pList=nullptr)
Hidden text range information - static and non-version.
Definition: porlay.cxx:1864
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:56
static bool IsIgnoreProtectedArea()
Definition: viewopt.cxx:607
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:3523
bool IsEndOfDoc() const
Definition: crsrsh.cxx:2765
bool IsVertical() const
Definition: frame.hxx:970
ScXMLEditAttributeMap::Entry const aEntries[]
SAL_DLLPRIVATE void ParkPams(SwPaM *pDelRg, SwShellCursor **ppDelRing)
Definition: crsrsh.cxx:2800
SwSPExtendRange nExtendRange
Definition: crstate.hxx:112
SwContentNode * GoNextSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true) const
Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!!!).
Definition: nodes.cxx:1916
#define SAL_WARN(area, stream)
bool IsTableNode() const
Definition: node.hxx:641
bool IsInList() const
Definition: ndtxt.cxx:4329
make visible in spite of Readonly
Definition: crsrsh.hxx:155
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
Ends a section of nodes in the document model.
Definition: node.hxx:342
bool IsFlySelectedByCursor(SwDoc const &rDoc, SwPosition const &rStart, SwPosition const &rEnd)
check at-char and at-para flys in rDoc
Definition: undobj.cxx:1681
bool IsEndPara() const
Definition: crsrsh.cxx:1114
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:478
static bool lcl_CheckHiddenSection(SwNodeIndex &rIdx)
Definition: crsrsh.cxx:1515
bool Pop(PopMode)
delete cursor
Definition: crsrsh.cxx:2265
bool Seek_Entry(SwNode *rP, size_type *pnPos) const
Definition: ndnum.cxx:32
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1210
bool HasVisibleNumberingOrBullet() const
Returns if the paragraph has a visible numbering or bullet.
Definition: ndtxt.cxx:4122
std::map< OUString, OUString > aParameters
SwRect m_aCharRect
Char-SRectangle on which the cursor is located.
Definition: crsrsh.hxx:164
std::vector< SwNode * >::size_type size_type
const SwIndexReg * GetIdxReg() const
Definition: index.hxx:97
bool IsOver(const SwRect &rRect) const
Definition: swrect.cxx:123
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:161
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1432
OUString SwResId(std::string_view aId)
Definition: swmodule.cxx:165
sal_uLong FindFormat(const SwTextFormatColl &rFormatColl, SwDocPositions nStart, SwDocPositions nEnd, bool &bCancel, FindRanges, const SwTextFormatColl *pReplFormat, SwRootFrame const *const pLayout=nullptr)
search for Format-Collections
Definition: findcoll.cxx:75
bool IsInHeaderFooter(bool *pbInHeader=nullptr) const
Definition: crsrsh.cxx:752
bool IsSelOnePara() const
Definition: crsrsh.cxx:1076
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2068
void swapContent(SwSelPaintRects &rSwap)
Definition: viscrs.cxx:339
void RefreshBlockCursor()
Definition: crsrsh.cxx:2129
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
bool IsTextNode() const
Definition: node.hxx:637
bool HasReadOnlyBoxSel() const
Definition: swcrsr.cxx:2616
void Height(tools::Long nNew)
Definition: swrect.hxx:190
tools::Long GetRight() const
Definition: tabcol.hxx:79
SwCursorShell(SwDoc &rDoc, vcl::Window *pWin, const SwViewOption *pOpt)
default constructor
Definition: crsrsh.cxx:2969
SwNode * FindPrvNxtFrameNode(SwNodeIndex &rFrameIdx, const SwNode *pEnd) const
Search previous / next content node or table node with frames.
Definition: nodes.cxx:2035
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1293
bool sw_PosOk(const SwPosition &aPos)
Checks if a position is valid.
Definition: crsrsh.cxx:3589
Access to the block cursor.
Definition: BlockCursor.hxx:39
bool IsFooterFrame() const
Definition: frame.hxx:1191
bool(* SwWhichSection)(SwPaM &, SwMoveFnCollection const &)
Definition: cshtyp.hxx:51
void SetReadOnlyAvailable(bool bFlag)
is the cursor allowed to enter ReadOnly sections?
Definition: crsrsh.cxx:3333
bool m_bGCAttr
Definition: crsrsh.hxx:220
void HideCursor()
Definition: crsrsh.cxx:2411
virtual ~SwCursorShell() override
Definition: crsrsh.cxx:3014
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_MSG_BEGIN)
Definition: view.hxx:144
sal_uInt16 nPos
static void notifyOtherView(const SfxViewShell *pThisView, SfxViewShell const *pOtherView, int nType, std::string_view rKey, const OString &rPayload)
bool SetVisibleCursor(const Point &rPt)
Move visible cursor to given position in document.
Definition: crsrsh.cxx:2662
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:850
size_t Count() const
Definition: tabcol.hxx:65
bool SetInFrontOfLabel(bool bNew)
Definition: crsrsh.cxx:1162
bool IsHeaderFrame() const
Definition: frame.hxx:1187
bool IsInHeadline(const SwFrame &rFrame) const
Definition: tabfrm.cxx:5710
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:244
bool IsInFrontOfLabel() const
Definition: pam.hxx:171
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1628
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1096
SwFrame * GetNext()
Definition: frame.hxx:675
Base class of the Writer document model elements.
Definition: node.hxx:80
bool CursorInsideInputField() const
Definition: crstrvl.cxx:929
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo