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