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