1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_CRSRSH_HXX
20 #define INCLUDED_SW_INC_CRSRSH_HXX
22 #include <com/sun/star/i18n/WordType.hpp>
24 #include <rtl/ustring.hxx>
25 #include <tools/link.hxx>
26 #include <vcl/keycod.hxx>
27 #include <o3tl/typed_flags_set.hxx>
29 #ifdef SW_DLLIMPLEMENTATION
30 #include <TextFrameIndex.hxx>
32 #include "IShellCursorSupplier.hxx"
38 #include "crstate.hxx"
44 #include "IDocumentMarkAccess.hxx"
53 class SwTextFormatColl
;
54 class SwTextINetFormat
;
55 class SwFormatINetFormat
;
64 class SwTextContentControl
;
67 struct SearchOptions2
;
69 namespace com::sun::star::text
{ class XTextRange
; }
70 namespace com::sun::star::container
{ class XStringKeyMap
; }
72 // enum and struct to get information via the Doc-Position
74 enum class IsAttrAtPos
87 ContentCheck
= 0x0400,
90 TableRedline
= 0x2000,
91 TableColRedline
= 0x4000,
93 CurrAttrs
= 0x8000, ///< only for debugging
94 TableBoxValue
= 0x10000, ///< only for debugging
96 ContentControl
= 0x20000,
97 AllowContaining
= 0x40000, // With Outline, finds an outline node for non-outline position
100 template<> struct typed_flags
<IsAttrAtPos
> : is_typed_flags
<IsAttrAtPos
, 0x7ffff> {};
103 struct SwContentAtPos
106 const SwField
* pField
;
107 const SfxPoolItem
* pAttr
;
108 const SwRangeRedline
* pRedl
;
109 SwContentNode
* pNode
;
110 const sw::mark::IFieldmark
* pFieldmark
;
112 IsAttrAtPos eContentAtPos
;
115 const SwTextAttr
* pFndTextAttr
;
117 SwContentAtPos( IsAttrAtPos eGetAtPos
)
118 : eContentAtPos( eGetAtPos
)
120 aFnd
.pField
= nullptr;
121 pFndTextAttr
= nullptr;
122 nDist
= 0; // #i23726#
125 bool IsInProtectSect() const;
126 bool IsInRTLText() const;
129 // return values of SetCursor (can be combined via ||)
130 const int CRSR_POSOLD
= 0x01, // cursor stays at old position
131 CRSR_POSCHG
= 0x02; // position changed by the layout
135 bool ReplaceImpl(SwPaM
& rCursor
, OUString
const& rReplacement
,
136 bool const bRegExp
, SwDoc
& rDoc
, SwRootFrame
const*const pLayout
);
138 /// Helperfunction to resolve backward references in regular expressions
139 std::optional
<OUString
> ReplaceBackReferences(const i18nutil::SearchOptions2
& rSearchOpt
,
140 SwPaM
* pPam
, SwRootFrame
const* pLayout
);
142 bool GetRanges(std::vector
<std::shared_ptr
<SwUnoCursor
>> & rRanges
,
143 SwDoc
& rDoc
, SwPaM
const& rDelPam
);
147 class SW_DLLPUBLIC SwCursorShell
149 , public sw::BroadcastingModify
150 , public ::sw::IShellCursorSupplier
152 friend class SwCallLink
;
153 friend class SwVisibleCursor
;
154 friend class SwSelPaintRects
;
156 // requires the Cursor as InternalCursor
157 friend bool GetAutoSumSel( const SwCursorShell
&, SwCellFrames
& );
161 /** for calling UpdateCursor */
163 UPDOWN
= (1 << 0), ///< keep Up/Down on columns
164 SCROLLWIN
= (1 << 1), ///< scroll window
165 CHKRANGE
= (1 << 2), ///< check overlapping PaMs
166 READONLY
= (1 << 3) ///< make visible in spite of Readonly
169 SAL_DLLPRIVATE
void UpdateCursor(
170 sal_uInt16 eFlags
= SwCursorShell::SCROLLWIN
|SwCursorShell::CHKRANGE
,
171 bool bIdleEnd
= false );
175 SwRect m_aCharRect
; ///< Char-SRectangle on which the cursor is located
176 Point m_aCursorHeight
; ///< height & offset from visible Cursor
177 Point m_aOldRBPos
; ///< Right/Bottom of last VisArea
178 // (used in Invalidate by Cursor)
180 Link
<const SwFlyFrameFormat
*,void> m_aFlyMacroLnk
; /**< Link will be called, if the Cursor is set
181 into a fly. A macro can then be called */
182 Link
<LinkParamNone
*,void> m_aChgLnk
; /**< link will be called by every attribute/
183 format changes at cursor position.*/
184 Link
<SwCursorShell
&,void> m_aGrfArrivedLnk
; ///< Link calls to UI if a graphic is arrived
186 SwShellCursor
* m_pCurrentCursor
; ///< current cursor
187 SwShellCursor
* m_pStackCursor
; ///< stack for the cursor
188 SwVisibleCursor
*m_pVisibleCursor
; ///< the visible cursor
190 SwBlockCursor
*m_pBlockCursor
; ///< interface of cursor for block (=rectangular) selection
192 SwShellTableCursor
* m_pTableCursor
; /**< table Cursor; only in tables when the
193 selection lays over 2 columns */
195 SwNodeIndex
* m_pBoxIdx
; ///< for recognizing of the changed
196 SwTableBox
* m_pBoxPtr
; ///< table row
198 tools::Long m_nUpDownX
; /**< try to move the cursor on up/down always
199 in the same column */
200 tools::Long m_nLeftFramePos
;
201 SwNodeOffset m_nCurrentNode
; // save CursorPos at Start-Action
202 sal_Int32 m_nCurrentContent
;
203 SwNodeType m_nCurrentNdTyp
;
206 * Via the Method SttCursorMove and EndCursorMove this counter gets
207 * incremented/decremented. As long as the counter is inequal to 0, the
208 * current Cursor gets no update. This way, "complicated" cursor movements
209 * (via Find()) can be realised.
211 sal_uInt16 m_nCursorMove
;
212 CursorMoveState m_eMvState
; ///< Status for Cursor-Travelling - GetModelPositionForViewPoint
213 SwTable::SearchType m_eEnhancedTableSel
; /// table rows or columns selected by not cell by cell
215 OUString m_sMarkedListId
;
216 int m_nMarkedListLevel
;
218 bool m_bHasFocus
: 1; ///< Shell is "active" in a window
219 bool m_bSVCursorVis
: 1; ///< SV-Cursor visible/invisible
220 bool m_bChgCallFlag
: 1; ///< attribute change inside Start- and EndAction
221 bool m_bVisPortChgd
: 1; ///< in VisPortChg-Call
222 // (used in Invalidate by the Cursor)
224 bool m_bCallChgLnk
: 1; ///< flag for derived classes
225 // true -> call ChgLnk
226 // access only via SwChgLinkFlag
227 bool m_bAllProtect
: 1; ///< Flag for areas
228 // true -> everything protected / hidden
229 bool m_bInCMvVisportChgd
: 1; ///< Flag for CursorMoves
230 // true -> view was moved
231 bool m_bGCAttr
: 1; // true -> non expanded attributes exist.
232 bool m_bIgnoreReadonly
: 1; // true -> make the cursor visible on next
233 // EndAction in spite of Readonly
234 bool m_bSelTableCells
: 1; // true -> select cells over the InputWin
235 bool m_bAutoUpdateCells
: 1; // true -> autoformat cells
236 bool m_bBasicHideCursor
: 1; // true -> HideCursor from Basic
237 bool m_bSetCursorInReadOnly
: 1;// true -> Cursor is allowed in ReadOnly-Areas
238 bool m_bOverwriteCursor
: 1; // true -> show Overwrite Cursor
240 // true -> send accessible events when cursor changes
241 // (set to false when using internal-only helper cursor)
242 bool m_bSendAccessibleCursorEvents
: 1;
244 bool m_bMacroExecAllowed
: 1;
246 SwFrame
* m_oldColFrame
;
248 SAL_DLLPRIVATE
void MoveCursorToNum();
250 SAL_DLLPRIVATE
void ParkPams( SwPaM
* pDelRg
, SwShellCursor
** ppDelRing
);
252 /** Mark a certain list level of a certain list
254 levels of a certain lists are marked now
256 @param sListId list Id of the list whose level is marked
257 @param nLevel to be marked list level
259 An empty sListId denotes that no level of a list is marked.
261 SAL_DLLPRIVATE
void MarkListLevel( const OUString
& sListId
,
264 // private method(s) accessed from public inline method(s) must be exported.
265 bool LeftRight( bool, sal_uInt16
, SwCursorSkipMode
, bool );
266 SAL_DLLPRIVATE
bool UpDown( bool, sal_uInt16
);
267 SAL_DLLPRIVATE
bool LRMargin( bool, bool bAPI
= false );
268 SAL_DLLPRIVATE
bool IsAtLRMargin( bool, bool bAPI
= false ) const;
270 SAL_DLLPRIVATE
bool isInHiddenTextFrame(SwShellCursor
* pShellCursor
);
272 SAL_DLLPRIVATE
bool GoStartWordImpl();
273 SAL_DLLPRIVATE
bool GoEndWordImpl();
274 SAL_DLLPRIVATE
bool GoNextWordImpl();
275 SAL_DLLPRIVATE
bool GoPrevWordImpl();
276 SAL_DLLPRIVATE
bool GoNextSentenceImpl();
277 SAL_DLLPRIVATE
bool GoEndSentenceImpl();
278 SAL_DLLPRIVATE
bool GoStartSentenceImpl();
280 typedef bool (SwCursor::*FNCursor
)();
281 typedef bool (SwCursorShell::*FNCursorShell
)();
282 SAL_DLLPRIVATE
bool CallCursorFN( FNCursor
);
283 SAL_DLLPRIVATE
bool CallCursorShellFN( FNCursorShell
);
285 SAL_DLLPRIVATE
const SwRangeRedline
* GotoRedline_( SwRedlineTable::size_type nArrPos
, bool bSelect
);
287 SAL_DLLPRIVATE
void sendLOKCursorUpdates();
290 inline SwMoveFnCollection
const & MakeFindRange( SwDocPositions
, SwDocPositions
, SwPaM
* ) const;
293 * Compare-Method for the StackCursor and the current Cursor.
294 * The Methods return -1, 0, 1 for lower, equal, greater.
296 int CompareCursorStackMkCurrPt() const;
298 bool SelTableRowOrCol( bool bRow
, bool bRowSimple
= false );
300 bool SetInFrontOfLabel( bool bNew
);
302 void RefreshBlockCursor();
304 /** Updates the marked list level according to the cursor.
306 SAL_DLLPRIVATE
void UpdateMarkedListLevel();
309 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
312 SwCursorShell( SwDoc
& rDoc
, vcl::Window
*pWin
, const SwViewOption
*pOpt
);
313 // disguised copy constructor
314 SwCursorShell( SwCursorShell
& rShell
, vcl::Window
*pWin
);
315 virtual ~SwCursorShell() override
;
317 // create new cursor and append the old one
318 virtual SwCursor
& CreateNewShellCursor() override
;
319 virtual SwCursor
& GetCurrentShellCursor() override
;
321 SwPaM
* CreateCursor();
322 ///< delete the current cursor and make the following into the current
323 void DestroyCursor();
324 ///< transform TableCursor to normal cursor, nullify Tablemode
325 void TableCursorToCursor();
326 ///< enter block mode, change normal cursor into block cursor
327 void CursorToBlockCursor();
328 ///< leave block mode, change block cursor into normal cursor
329 void BlockCursorToCursor();
331 // SelAll() selects the document body content
332 // if ExtendedSelect() is called afterwards, the whole nodes array is selected
333 // only for usage in special cases allowed!
334 void ExtendedSelectAll(bool bFootnotes
= true);
335 /// If ExtendedSelectAll() was called and selection didn't change since then.
336 ::std::optional
<::std::pair
<SwNode
const*, ::std::vector
<SwTableNode
*>>> ExtendedSelectedAll() const;
337 enum class StartsWith
{ None
, Table
, HiddenPara
};
338 /// If document body starts with a table or starts/ends with hidden paragraph.
339 StartsWith
StartsWith_();
341 SwCursor
* GetCursor( bool bMakeTableCursor
= true ) const;
342 // return only the current cursor
343 SwShellCursor
* GetCursor_() { return m_pCurrentCursor
; }
344 const SwShellCursor
* GetCursor_() const { return m_pCurrentCursor
; }
346 // show passed cursor - for UNO
347 void SetSelection(const SwPaM
& rCursor
);
349 // remove all cursors from ContentNodes and set to 0
350 void ParkCursor( const SwNode
&rIdx
);
352 // return the current cursor stack
353 // (required in EditShell when deleting contents)
354 inline SwPaM
* GetStackCursor() const;
356 // start parenthesing, hide SV-Cursor and selected areas
358 // end parenthesing, show SV-Cursor and selected areas
359 void EndAction( const bool bIdleEnd
= false );
361 // basic cursor travelling
362 tools::Long
GetUpDownX() const { return m_nUpDownX
; }
364 bool Left( sal_uInt16 nCnt
, SwCursorSkipMode nMode
, bool bAllowVisual
= false )
365 { return LeftRight( true, nCnt
, nMode
, bAllowVisual
); }
366 bool Right( sal_uInt16 nCnt
, SwCursorSkipMode nMode
, bool bAllowVisual
= false )
367 { return LeftRight( false, nCnt
, nMode
, bAllowVisual
); }
368 bool Up( sal_uInt16 nCnt
= 1 ) { return UpDown( true, nCnt
); }
369 bool Down( sal_uInt16 nCnt
= 1 ) { return UpDown( false, nCnt
); }
370 bool LeftMargin() { return LRMargin( true ); }
371 bool RightMargin(bool bAPI
= false) { return LRMargin( false, bAPI
); }
372 bool SttEndDoc( bool bStt
);
374 bool MovePage( SwWhichPage
, SwPosPage
);
375 bool MovePara( SwWhichPara
, SwMoveFnCollection
const & );
376 bool MoveSection( SwWhichSection
, SwMoveFnCollection
const & );
377 bool MoveTable( SwWhichTable
, SwMoveFnCollection
const & );
378 void MoveColumn( SwWhichColumn
, SwPosColumn
);
379 bool MoveRegion( SwWhichRegion
, SwMoveFnCollection
const & );
381 // note: DO NOT call it FindText because windows.h
382 sal_Int32
Find_Text( const i18nutil::SearchOptions2
& rSearchOpt
,
384 SwDocPositions eStart
, SwDocPositions eEnd
,
386 FindRanges eRng
, bool bReplace
= false );
388 sal_Int32
FindFormat( const SwTextFormatColl
& rFormatColl
,
389 SwDocPositions eStart
, SwDocPositions eEnd
,
391 FindRanges eRng
, const SwTextFormatColl
* pReplFormat
);
393 sal_Int32
FindAttrs( const SfxItemSet
& rSet
, bool bNoCollections
,
394 SwDocPositions eStart
, SwDocPositions eEnd
,
397 const i18nutil::SearchOptions2
* pSearchOpt
,
398 const SfxItemSet
* rReplSet
);
400 // Position the Cursor
402 // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
403 // CRSR_POSOLD: when the cursor was not changed
404 int SetCursor( const Point
&rPt
, bool bOnlyText
= false, bool bBlock
= true );
407 * Notification that the visible area was changed. m_aVisArea is reset, then
408 * scrolling is done. The passed Rectangle lays on pixel borders to avoid
411 virtual void VisPortChgd( const SwRect
& ) override
;
414 * virtual paint method to make selection visible again after Paint
416 void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
419 inline void SetMark();
420 inline bool HasMark() const;
425 Ensure point and mark of the current PaM are in a specific order.
427 @param bPointFirst true: If the point is behind the mark then
428 swap the PaM. false: If the mark is behind the point then swap
431 void NormalizePam(bool bPointFirst
= true);
434 bool TestCurrPam( const Point
& rPt
,
435 bool bTstHit
= false); // only exact matches
438 /// store a copy of the current cursor on the cursor stack
440 enum class PopMode
{ DeleteCurrent
, DeleteStack
};
443 * - either from the top of the stack
444 * - or delete the current one and replace it with the cursor from the
446 * @return <true> if there was one on the stack, <false> otherwise
448 bool Pop(PopMode
, ::std::optional
<SwCallLink
>& roLink
);
452 * Delete the topmost from the stack and move its Mark into the current.
456 void SttCursorMove();
457 void EndCursorMove( const bool bIdleEnd
= false );
460 * When the focus is lost the selected ranges are not displayed anymore.
461 * On the other hand, on receiving the focus all selected ranges are displayed again
462 * (ranges must be recalculated!).
464 bool HasShellFocus() const { return m_bHasFocus
; }
465 void ShellLoseFocus();
466 void ShellGetFocus();
468 // Methods for displaying or hiding the visible text cursor.
471 // Methods for displaying or hiding the selected ranges with visible cursor.
472 void ShowCursors( bool bCursorVis
);
475 bool IsOverwriteCursor() const { return m_bOverwriteCursor
; }
476 void SetOverwriteCursor( bool bFlag
) { m_bOverwriteCursor
= bFlag
; }
478 bool IsSendAccessibleCursorEvents() const { return m_bSendAccessibleCursorEvents
; };
479 void SetSendAccessibleCursorEvents(bool bEnable
) { m_bSendAccessibleCursorEvents
= bEnable
; };
481 // Return current frame in which the cursor is placed.
482 SwContentFrame
*GetCurrFrame( const bool bCalcFrame
= true ) const;
484 //true if cursor is hidden because of readonly.
485 //false if it is working despite readonly.
486 bool IsCursorReadonly() const;
488 // Cursor is placed in something that is protected or selection contains
489 // something that is protected.
490 bool HasReadonlySel(bool isReplace
= false) const;
491 bool HasHiddenSections() const;
493 // Can the cursor be set to read only ranges?
494 bool IsReadOnlyAvailable() const { return m_bSetCursorInReadOnly
; }
495 void SetReadOnlyAvailable( bool bFlag
);
496 bool IsOverReadOnlyPos( const Point
& rPt
) const;
498 // Methods for aFlyMacroLnk.
499 void SetFlyMacroLnk( const Link
<const SwFlyFrameFormat
*,void>& rLnk
) { m_aFlyMacroLnk
= rLnk
; }
500 const Link
<const SwFlyFrameFormat
*,void>& GetFlyMacroLnk() const { return m_aFlyMacroLnk
; }
502 // Methods returning/altering link for changes of attributes/formats.
503 void SetChgLnk( const Link
<LinkParamNone
*,void> &rLnk
) { m_aChgLnk
= rLnk
; }
504 const Link
<LinkParamNone
*,void>& GetChgLnk() const { return m_aChgLnk
; }
506 // Methods returning/altering link for "graphic completely loaded".
507 void SetGrfArrivedLnk( const Link
<SwCursorShell
&,void> &rLnk
) { m_aGrfArrivedLnk
= rLnk
; }
508 const Link
<SwCursorShell
&,void>& GetGrfArrivedLnk() const { return m_aGrfArrivedLnk
; }
510 //Call ChgLink. When within an action calling will be delayed.
513 // Check if the current cursor contains a selection, i.e.
514 // if Mark is set and SPoint and Mark are different.
515 bool HasSelection() const;
517 // Check if a selection exists, i.e. if the current cursor comprises a selection.
518 inline bool IsSelection() const;
519 // returns if multiple cursors are available
520 inline bool IsMultiSelection() const;
522 // Check if a complete paragraph was selected.
523 bool IsSelFullPara() const;
525 // Check if selection is within one paragraph.
527 //Should WaitPtr be activated for Clipboard.
528 bool ShouldWait() const;
530 // Check if selection is within one paragraph.
531 bool IsSelOnePara() const;
534 * Returns SRectangle, at which the cursor is located.
536 const SwRect
&GetCharRect() const { return m_aCharRect
; }
538 * Returns if cursor is wholly or partly within visible range.
540 bool IsCursorVisible() const { return VisArea().Overlaps( GetCharRect() ); }
542 * Returns SwRect, at which the character is located.
544 void GetCharRectAt(SwRect
& rRect
, const SwPosition
* pPos
);
546 // Return current page number:
547 // true: in which cursor is located.
548 // false: which is visible at the upper margin.
549 void GetPageNum( sal_uInt16
&rnPhyNum
, sal_uInt16
&rnVirtNum
,
550 bool bAtCursorPos
= true, const bool bCalcFrame
= true );
551 // Returns current page's sequential number (1-based),in which cursor is located, ignoring autoinserted empty pages.
552 // Returns 0 on error
553 sal_uInt16
GetPageNumSeqNonEmpty();
554 // Determine how "empty pages" are handled
555 // (used in PhyPage).
556 sal_uInt16
GetNextPrevPageNum( bool bNext
= true );
558 // Move cursor at the beginning of page "nPage".
559 bool GotoPage( sal_uInt16 nPage
);
561 sal_uInt16
GetPageCnt();
567 void GoNextPrevCursorSetSearchLabel(const bool bNext
);
569 // at CurrentCursor.SPoint
570 ::sw::mark::IMark
* SetBookmark(
572 const OUString
& rName
,
573 IDocumentMarkAccess::MarkType eMark
= IDocumentMarkAccess::MarkType::BOOKMARK
);
574 ::sw::mark::IMark
* SetBookmark2(
576 const OUString
& rName
,
578 const OUString
& rCondition
);
579 bool GotoMark( const ::sw::mark::IMark
* const pMark
); // sets CurrentCursor.SPoint
580 bool GotoMark( const ::sw::mark::IMark
* const pMark
, bool bAtStart
);
581 bool GoNextBookmark(); // true, if there was one
582 bool GoPrevBookmark();
584 bool IsFormProtected();
585 ::sw::mark::IFieldmark
* GetCurrentFieldmark();
586 sw::mark::IFieldmark
* GetFieldmarkAfter(bool bLoop
);
587 sw::mark::IFieldmark
* GetFieldmarkBefore(bool bLoop
);
588 bool GotoFieldmark( const ::sw::mark::IFieldmark
* const pMark
);
590 // update Cursr, i.e. reset it into content should only be called when the
591 // cursor was set to a random position e.g. when deleting frames
592 void UpdateCursorPos();
594 // get the selected text at the current cursor. It will be filled with
596 OUString
GetSelText() const;
598 /// Check if Point of current cursor is placed within a table.
599 const SwTableNode
* IsCursorInTable() const;
600 bool MoveOutOfTable();
601 bool TrySelectOuterTable();
602 bool MoveStartText();
604 bool IsCursorInFootnote() const;
606 inline Point
& GetCursorDocPos() const;
607 // get cursor position relative to the page it is in
608 Point
GetCursorPagePos() const;
609 inline bool IsCursorPtAtEnd() const;
611 inline const SwPaM
* GetTableCrs() const;
612 inline SwPaM
* GetTableCrs();
614 bool IsTableComplexForChart();
615 // get current table selection as text
616 OUString
GetBoxNms() const;
618 // set Cursor to the next/previous cell
619 bool GoNextCell( bool bAppendLine
= true );
621 // go to this box (if available and inside of table)
622 bool GotoTable( const OUString
& rName
);
624 // select a table row, column or box (based on the current cursor)
625 bool SelTableRow() { return SelTableRowOrCol( true ); }
626 bool SelTableCol() { return SelTableRowOrCol( false ); }
634 bool GotoOutline( const OUString
& rName
);
635 // to the next/previous or the given OutlineNode
636 void GotoOutline( SwOutlineNodes::size_type nIdx
);
637 // find the "outline position" in the nodes array of the current chapter
638 SwOutlineNodes::size_type
GetOutlinePos(sal_uInt8 nLevel
= UCHAR_MAX
, SwPaM
* pPaM
= nullptr);
639 // select the given range of OutlineNodes. Optionally including the children
640 // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell)
641 void MakeOutlineSel(SwOutlineNodes::size_type nSttPos
, SwOutlineNodes::size_type nEndPos
,
642 bool bWithChildren
, bool bKillPams
= true );
644 bool GotoNextOutline();
645 bool GotoPrevOutline();
647 /** Delivers the current shell cursor
649 Some operations have to run on the current cursor ring,
650 some on the m_pTableCursor (if exist) or the current cursor ring and
651 some on the m_pTableCursor or m_pBlockCursor or the current cursor ring.
652 This small function checks the existence and delivers the wished cursor.
655 if the block cursor is of interest or not
657 @return m_pTableCursor if exist,
658 m_pBlockCursor if exist and of interest (param bBlock)
659 otherwise m_pCurrentCursor
661 SwShellCursor
* getShellCursor( bool bBlock
);
662 const SwShellCursor
* getShellCursor( bool bBlock
) const
663 { return const_cast<SwCursorShell
*>(this)->getShellCursor( bBlock
); }
665 bool IsBlockMode() const { return nullptr != m_pBlockCursor
; }
667 // is the Cursor in a table and is the selection over 2 columns
668 bool IsTableMode() const { return nullptr != m_pTableCursor
; }
670 const SwShellTableCursor
* GetTableCursor() const { return m_pTableCursor
; }
671 SwShellTableCursor
* GetTableCursor() { return m_pTableCursor
; }
672 size_t UpdateTableSelBoxes();
674 bool GotoFootnoteText(); ///< jump from content to footnote
675 bool GotoFootnoteAnchor(); ///< jump from footnote to anchor
676 bool GotoPrevFootnoteAnchor();
677 bool GotoNextFootnoteAnchor();
679 void GotoFlyAnchor(); ///< jump from the frame to the anchor
680 bool GotoHeaderText(); ///< jump from the content to the header
681 bool GotoFooterText(); ///< jump from the content to the footer
682 // jump to the header/footer of the given or current PageDesc
683 bool SetCursorInHdFt(size_t nDescNo
, bool bInHeader
, bool bEven
= false, bool bFirst
= false);
684 // is point of cursor in header/footer. pbInHeader return true if it is
685 // in a headerframe otherwise in a footerframe
686 bool IsInHeaderFooter( bool* pbInHeader
= nullptr ) const;
688 bool GotoNextTOXBase( const OUString
* = nullptr );
689 bool GotoPrevTOXBase( const OUString
* = nullptr );
690 void GotoTOXMarkBase();
691 // jump to the next or previous index entry
692 bool GotoNxtPrvTOXMark( bool bNext
= true );
693 // jump to the next/previous index mark of this type
694 const SwTOXMark
& GotoTOXMark( const SwTOXMark
& rStart
, SwTOXSearch eDir
);
696 // jump to the next or previous table formula
697 // optionally only to broken formulas
698 bool GotoNxtPrvTableFormula( bool bNext
= true,
699 bool bOnlyErrors
= false );
700 // jump to the next / previous hyperlink - inside text and also
702 bool SelectNxtPrvHyperlink( bool bNext
);
704 bool GotoRefMark( const OUString
& rRefMark
, sal_uInt16 nSubType
,
707 // get the nth character from the start or end of the current selection
708 sal_Unicode
GetChar( bool bEnd
= true, tools::Long nOffset
= 0 );
709 bool ExtendSelection( bool bEnd
= true, sal_Int32 nCount
= 1 );
711 // Place only the visible cursor at the given position in the document.
712 // Return false if SPoint was corrected by layout.
713 // (This is needed for displaying the Drag&Drop/Copy-Cursor.)
714 bool SetVisibleCursor( const Point
&rPt
);
715 inline void UnSetVisibleCursor();
716 SwVisibleCursor
* GetVisibleCursor() const;
718 // jump to the next or previous field of the corresponding type
720 const SwFieldType
* pFieldType
,
722 const SwFieldIds nResType
= SwFieldIds::Unknown
,
723 const bool bAddSetExpressionFieldsToInputFields
= true );
725 bool GotoFormatField( const SwFormatField
& rField
);
727 bool GotoFormatContentControl(const SwFormatContentControl
& rContentControl
);
729 void GotoFormControl(bool bNext
);
731 static SwTextField
* GetTextFieldAtPos(
732 const SwPosition
* pPos
,
733 ::sw::GetTextAttrMode eMode
);
734 static SwTextField
* GetTextFieldAtCursor(
735 const SwPaM
* pCursor
,
736 ::sw::GetTextAttrMode eMode
);
737 static SwField
* GetFieldAtCursor(
738 const SwPaM
* pCursor
,
739 const bool bIncludeInputFieldAtStart
);
740 SwField
* GetCurField( const bool bIncludeInputFieldAtStart
= false ) const;
741 bool CursorInsideInputField() const;
742 SwTextContentControl
* CursorInsideContentControl() const;
743 static bool PosInsideInputField( const SwPosition
& rPos
);
744 bool DocPtInsideInputField( const Point
& rDocPt
) const;
745 static sal_Int32
StartOfInputFieldAtPos( const SwPosition
& rPos
);
746 static sal_Int32
EndOfInputFieldAtPos( const SwPosition
& rPos
);
748 // Return number of cursors in ring (The flag indicates whether
749 // only cursors containing selections are requested).
750 sal_uInt16
GetCursorCnt( bool bAll
= true ) const;
752 // Char Travelling - methods (in crstrvl1.cxx)
757 bool GoNextSentence();
758 bool GoStartSentence();
759 bool GoEndSentence();
760 bool SelectWord( const Point
* pPt
);
761 void ExpandToSentenceBorders();
763 // get position from current cursor
764 bool IsStartWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
)const;
765 bool IsEndWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
766 bool IsInWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
767 bool IsStartSentence() const;
768 bool IsEndSentence() const;
769 bool IsSttPara() const;
770 bool IsEndPara() const;
771 bool IsEndOfTable() const; ///< at the very last SwPosition inside a table
772 bool IsStartOfDoc() const;
773 bool IsEndOfDoc() const;
774 bool IsInFrontOfLabel() const;
775 bool IsAtLeftMargin() const { return IsAtLRMargin( true ); }
776 bool IsAtRightMargin() const { return IsAtLRMargin( false, true/*bAPI*/ ); }
778 // delete all created cursors, set the table cursor and the last cursor to
779 // its TextNode (or StartNode?)
780 // They all get created on the next ::GetCursor again
781 // Used for Drag&Drop/Clipboard-Paste in tables
782 bool ParkTableCursor();
784 // Non expanded attributes?
785 bool IsGCAttr() const { return m_bGCAttr
; }
786 void ClearGCAttr() { m_bGCAttr
= false; }
787 void UpdateAttr() { m_bGCAttr
= true; }
789 // is the whole document protected/hidden (for UI...)
790 bool IsAllProtect() const { return m_bAllProtect
; }
792 bool GotoRegion( std::u16string_view rName
);
794 // show the current selection
795 virtual void MakeSelVisible();
797 // set the cursor to a NOT protected/hidden node
798 bool FindValidContentNode( bool bOnlyText
);
800 bool GetContentAtPos( const Point
& rPt
,
801 SwContentAtPos
& rContentAtPos
,
802 bool bSetCursor
= false,
803 SwRect
* pFieldRect
= nullptr );
805 const SwPostItField
* GetPostItFieldAtCursor() const;
807 // get smart tags rectangle for the given point
808 void GetSmartTagRect( const Point
& rPt
, SwRect
& rSelectRect
);
810 // get smart tags at current cursor position
811 void GetSmartTagTerm( std::vector
< OUString
>& rSmartTagTypes
,
812 css::uno::Sequence
< css::uno::Reference
< css::container::XStringKeyMap
> >& rStringKeyMaps
,
813 css::uno::Reference
<css::text::XTextRange
>& rRange
) const;
815 bool IsPageAtPos( const Point
&rPt
) const;
817 bool SelectTextAttr( sal_uInt16 nWhich
, bool bExpand
, const SwTextAttr
* pAttr
= nullptr );
818 bool GotoINetAttr( const SwTextINetFormat
& rAttr
);
819 const SwFormatINetFormat
* FindINetAttr( std::u16string_view rName
) const;
821 bool SelectTextModel(sal_Int32 nStart
, sal_Int32 nEnd
);
822 #ifdef SW_DLLIMPLEMENTATION
823 bool SelectTextView(TextFrameIndex nStart
, TextFrameIndex nEnd
);
824 // result is only valid while cursor isn't moved!
825 TextFrameIndex
GetCursorPointAsViewIndex() const;
828 bool CheckTableBoxContent( const SwPosition
* pPos
= nullptr );
829 void SaveTableBoxContent( const SwPosition
* pPos
= nullptr );
830 void ClearTableBoxContent();
831 bool EndAllTableBoxEdit();
833 void SetSelTableCells( bool bFlag
) { m_bSelTableCells
= bFlag
; }
834 bool IsSelTableCells() const { return m_bSelTableCells
; }
836 void UnsetEnhancedTableSelection() { m_eEnhancedTableSel
= SwTable::SEARCH_NONE
; }
837 SwTable::SearchType
GetEnhancedTableSelection() const { return m_eEnhancedTableSel
; }
839 bool IsAutoUpdateCells() const { return m_bAutoUpdateCells
; }
840 void SetAutoUpdateCells( bool bFlag
) { m_bAutoUpdateCells
= bFlag
; }
842 bool GetShadowCursorPos( const Point
& rPt
, SwFillMode eFillMode
,
843 SwRect
& rRect
, sal_Int16
& rOrient
);
844 bool SetShadowCursorPos( const Point
& rPt
, SwFillMode eFillMode
);
846 const SwRangeRedline
* SelNextRedline();
847 const SwRangeRedline
* SelPrevRedline();
848 const SwRangeRedline
* GotoRedline( SwRedlineTable::size_type nArrPos
, bool bSelect
);
850 bool GotoFootnoteAnchor(const SwTextFootnote
& rTextFootnote
);
852 SAL_DLLPRIVATE SvxFrameDirection
GetTextDirection( const Point
* pPt
= nullptr ) const;
853 // is cursor or the point in/over a vertical formatted text?
854 bool IsInVerticalText( const Point
* pPt
= nullptr ) const;
855 // is cursor or the point in/over a right to left formatted text?
856 bool IsInRightToLeftText() const;
858 static void FirePageChangeEvent(sal_uInt16 nOldPage
, sal_uInt16 nNewPage
);
859 bool bColumnChange();
860 static void FireSectionChangeEvent(sal_uInt16 nOldSection
, sal_uInt16 nNewSection
);
861 static void FireColumnChangeEvent(sal_uInt16 nOldColumn
, sal_uInt16 nNewColumn
);
862 // If the current cursor position is inside a hidden range true is returned. If bSelect is
863 // true, the hidden range is selected. If bSelect is false, the hidden range is not selected.
864 bool IsInHiddenRange(const bool bSelect
);
866 // remove all invalid cursors
867 void ClearUpCursors();
869 void SetMacroExecAllowed( const bool _bMacroExecAllowed
)
871 m_bMacroExecAllowed
= _bMacroExecAllowed
;
873 bool IsMacroExecAllowed() const
875 return m_bMacroExecAllowed
;
879 Returns textual description of the current selection.
881 - If the current selection is a multi-selection the result is
883 - Else the result is the text of the selection.
885 @return the textual description of the current selection
887 OUString
GetCursorDescr() const;
889 virtual void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
890 /// Implementation of lok::Document::getPartPageRectangles() for Writer.
891 OUString
getPageRectangles();
893 /// See SwView::NotifyCursor().
894 void NotifyCursor(SfxViewShell
* pViewShell
) const;
898 inline SwMoveFnCollection
const & SwCursorShell::MakeFindRange(
899 SwDocPositions nStt
, SwDocPositions nEnd
, SwPaM
* pPam
) const
901 return m_pCurrentCursor
->MakeFindRange( nStt
, nEnd
, pPam
);
904 inline SwPaM
* SwCursorShell::GetStackCursor() const { return m_pStackCursor
; }
906 inline void SwCursorShell::SetMark() { m_pCurrentCursor
->SetMark(); }
908 inline bool SwCursorShell::HasMark() const { return m_pCurrentCursor
->HasMark(); }
910 inline bool SwCursorShell::IsSelection() const
912 return IsTableMode() || m_pCurrentCursor
->HasMark() ||
913 m_pCurrentCursor
->GetNext() != m_pCurrentCursor
;
915 inline bool SwCursorShell::IsMultiSelection() const
917 return m_pCurrentCursor
->GetNext() != m_pCurrentCursor
;
920 inline bool SwCursorShell::IsCursorPtAtEnd() const
922 return m_pCurrentCursor
->End() == m_pCurrentCursor
->GetPoint();
925 inline Point
& SwCursorShell::GetCursorDocPos() const
927 return m_pCurrentCursor
->GetPtPos();
930 inline const SwPaM
* SwCursorShell::GetTableCrs() const
932 return m_pTableCursor
;
935 inline SwPaM
* SwCursorShell::GetTableCrs()
937 return m_pTableCursor
;
940 inline void SwCursorShell::UnSetVisibleCursor()
942 m_pVisibleCursor
->Hide();
943 m_pVisibleCursor
->SetDragCursor( false );
946 #endif // _CRSRSH_HXX
948 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */