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"
51 class SwTextFormatColl
;
52 class SwTextINetFormat
;
53 class SwFormatINetFormat
;
62 class SwTextContentControl
;
65 struct SearchOptions2
;
67 namespace com::sun::star::text
{ class XTextRange
; }
68 namespace com::sun::star::container
{ class XStringKeyMap
; }
70 // enum and struct to get information via the Doc-Position
72 enum class IsAttrAtPos
85 ContentCheck
= 0x0400,
90 ,CurrAttrs
= 0x4000 ///< only for debugging
91 ,TableBoxValue
= 0x8000 ///< only for debugging
93 , ContentControl
= 0x10000
96 template<> struct typed_flags
<IsAttrAtPos
> : is_typed_flags
<IsAttrAtPos
, 0x1ffff> {};
102 const SwField
* pField
;
103 const SfxPoolItem
* pAttr
;
104 const SwRangeRedline
* pRedl
;
105 SwContentNode
* pNode
;
106 const sw::mark::IFieldmark
* pFieldmark
;
108 IsAttrAtPos eContentAtPos
;
111 const SwTextAttr
* pFndTextAttr
;
113 SwContentAtPos( IsAttrAtPos eGetAtPos
)
114 : eContentAtPos( eGetAtPos
)
116 aFnd
.pField
= nullptr;
117 pFndTextAttr
= nullptr;
118 nDist
= 0; // #i23726#
121 bool IsInProtectSect() const;
122 bool IsInRTLText() const;
125 // return values of SetCursor (can be combined via ||)
126 const int CRSR_POSOLD
= 0x01, // cursor stays at old position
127 CRSR_POSCHG
= 0x02; // position changed by the layout
131 bool ReplaceImpl(SwPaM
& rCursor
, OUString
const& rReplacement
,
132 bool const bRegExp
, SwDoc
& rDoc
, SwRootFrame
const*const pLayout
);
134 /// Helperfunction to resolve backward references in regular expressions
135 std::optional
<OUString
> ReplaceBackReferences(const i18nutil::SearchOptions2
& rSearchOpt
,
136 SwPaM
* pPam
, SwRootFrame
const* pLayout
);
138 bool GetRanges(std::vector
<std::shared_ptr
<SwUnoCursor
>> & rRanges
,
139 SwDoc
& rDoc
, SwPaM
const& rDelPam
);
143 class SW_DLLPUBLIC SwCursorShell
145 , public sw::BroadcastingModify
146 , public ::sw::IShellCursorSupplier
148 friend class SwCallLink
;
149 friend class SwVisibleCursor
;
150 friend class SwSelPaintRects
;
152 // requires the Cursor as InternalCursor
153 friend bool GetAutoSumSel( const SwCursorShell
&, SwCellFrames
& );
157 /** for calling UpdateCursor */
159 UPDOWN
= (1 << 0), ///< keep Up/Down on columns
160 SCROLLWIN
= (1 << 1), ///< scroll window
161 CHKRANGE
= (1 << 2), ///< check overlapping PaMs
162 READONLY
= (1 << 3) ///< make visible in spite of Readonly
165 SAL_DLLPRIVATE
void UpdateCursor(
166 sal_uInt16 eFlags
= SwCursorShell::SCROLLWIN
|SwCursorShell::CHKRANGE
,
167 bool bIdleEnd
= false );
171 SwRect m_aCharRect
; ///< Char-SRectangle on which the cursor is located
172 Point m_aCursorHeight
; ///< height & offset from visible Cursor
173 Point m_aOldRBPos
; ///< Right/Bottom of last VisArea
174 // (used in Invalidate by Cursor)
176 Link
<const SwFlyFrameFormat
*,void> m_aFlyMacroLnk
; /**< Link will be called, if the Cursor is set
177 into a fly. A macro can then be called */
178 Link
<LinkParamNone
*,void> m_aChgLnk
; /**< link will be called by every attribute/
179 format changes at cursor position.*/
180 Link
<SwCursorShell
&,void> m_aGrfArrivedLnk
; ///< Link calls to UI if a graphic is arrived
182 SwShellCursor
* m_pCurrentCursor
; ///< current cursor
183 SwShellCursor
* m_pStackCursor
; ///< stack for the cursor
184 SwVisibleCursor
*m_pVisibleCursor
; ///< the visible cursor
186 SwBlockCursor
*m_pBlockCursor
; ///< interface of cursor for block (=rectangular) selection
188 SwShellTableCursor
* m_pTableCursor
; /**< table Cursor; only in tables when the
189 selection lays over 2 columns */
191 SwNodeIndex
* m_pBoxIdx
; ///< for recognizing of the changed
192 SwTableBox
* m_pBoxPtr
; ///< table row
194 tools::Long m_nUpDownX
; /**< try to move the cursor on up/down always
195 in the same column */
196 tools::Long m_nLeftFramePos
;
197 SwNodeOffset m_nCurrentNode
; // save CursorPos at Start-Action
198 sal_Int32 m_nCurrentContent
;
199 SwNodeType m_nCurrentNdTyp
;
202 * Via the Method SttCursorMove and EndCursorMove this counter gets
203 * incremented/decremented. As long as the counter is inequal to 0, the
204 * current Cursor gets no update. This way, "complicated" cursor movements
205 * (via Find()) can be realised.
207 sal_uInt16 m_nCursorMove
;
208 CursorMoveState m_eMvState
; ///< Status for Cursor-Travelling - GetModelPositionForViewPoint
209 SwTable::SearchType m_eEnhancedTableSel
; /// table rows or columns selected by not cell by cell
211 OUString m_sMarkedListId
;
212 int m_nMarkedListLevel
;
214 bool m_bHasFocus
: 1; ///< Shell is "active" in a window
215 bool m_bSVCursorVis
: 1; ///< SV-Cursor visible/invisible
216 bool m_bChgCallFlag
: 1; ///< attribute change inside Start- and EndAction
217 bool m_bVisPortChgd
: 1; ///< in VisPortChg-Call
218 // (used in Invalidate by the Cursor)
220 bool m_bCallChgLnk
: 1; ///< flag for derived classes
221 // true -> call ChgLnk
222 // access only via SwChgLinkFlag
223 bool m_bAllProtect
: 1; ///< Flag for areas
224 // true -> everything protected / hidden
225 bool m_bInCMvVisportChgd
: 1; ///< Flag for CursorMoves
226 // true -> view was moved
227 bool m_bGCAttr
: 1; // true -> non expanded attributes exist.
228 bool m_bIgnoreReadonly
: 1; // true -> make the cursor visible on next
229 // EndAction in spite of Readonly
230 bool m_bSelTableCells
: 1; // true -> select cells over the InputWin
231 bool m_bAutoUpdateCells
: 1; // true -> autoformat cells
232 bool m_bBasicHideCursor
: 1; // true -> HideCursor from Basic
233 bool m_bSetCursorInReadOnly
: 1;// true -> Cursor is allowed in ReadOnly-Areas
234 bool m_bOverwriteCursor
: 1; // true -> show Overwrite Cursor
236 bool m_bMacroExecAllowed
: 1;
238 SwFrame
* m_oldColFrame
;
240 SAL_DLLPRIVATE
void MoveCursorToNum();
242 SAL_DLLPRIVATE
void ParkPams( SwPaM
* pDelRg
, SwShellCursor
** ppDelRing
);
244 /** Mark a certain list level of a certain list
246 levels of a certain lists are marked now
248 @param sListId list Id of the list whose level is marked
249 @param nLevel to be marked list level
251 An empty sListId denotes that no level of a list is marked.
253 SAL_DLLPRIVATE
void MarkListLevel( const OUString
& sListId
,
256 // private method(s) accessed from public inline method(s) must be exported.
257 bool LeftRight( bool, sal_uInt16
, sal_uInt16
, bool );
258 SAL_DLLPRIVATE
bool UpDown( bool, sal_uInt16
);
259 SAL_DLLPRIVATE
bool LRMargin( bool, bool bAPI
= false );
260 SAL_DLLPRIVATE
bool IsAtLRMargin( bool, bool bAPI
= false ) const;
262 SAL_DLLPRIVATE
bool isInHiddenTextFrame(SwShellCursor
* pShellCursor
);
264 SAL_DLLPRIVATE
bool GoStartWordImpl();
265 SAL_DLLPRIVATE
bool GoEndWordImpl();
266 SAL_DLLPRIVATE
bool GoNextWordImpl();
267 SAL_DLLPRIVATE
bool GoPrevWordImpl();
268 SAL_DLLPRIVATE
bool GoNextSentenceImpl();
269 SAL_DLLPRIVATE
bool GoEndSentenceImpl();
270 SAL_DLLPRIVATE
bool GoStartSentenceImpl();
272 typedef bool (SwCursor::*FNCursor
)();
273 typedef bool (SwCursorShell::*FNCursorShell
)();
274 SAL_DLLPRIVATE
bool CallCursorFN( FNCursor
);
275 SAL_DLLPRIVATE
bool CallCursorShellFN( FNCursorShell
);
277 SAL_DLLPRIVATE
const SwRangeRedline
* GotoRedline_( SwRedlineTable::size_type nArrPos
, bool bSelect
);
279 SAL_DLLPRIVATE
void sendLOKCursorUpdates();
282 inline SwMoveFnCollection
const & MakeFindRange( SwDocPositions
, SwDocPositions
, SwPaM
* ) const;
285 * Compare-Method for the StackCursor and the current Cursor.
286 * The Methods return -1, 0, 1 for lower, equal, greater.
288 int CompareCursorStackMkCurrPt() const;
290 bool SelTableRowOrCol( bool bRow
, bool bRowSimple
= false );
292 bool SetInFrontOfLabel( bool bNew
);
294 void RefreshBlockCursor();
296 /** Updates the marked list level according to the cursor.
298 SAL_DLLPRIVATE
void UpdateMarkedListLevel();
301 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
304 SwCursorShell( SwDoc
& rDoc
, vcl::Window
*pWin
, const SwViewOption
*pOpt
);
305 // disguised copy constructor
306 SwCursorShell( SwCursorShell
& rShell
, vcl::Window
*pWin
);
307 virtual ~SwCursorShell() override
;
309 // create new cursor and append the old one
310 virtual SwCursor
& CreateNewShellCursor() override
;
311 virtual SwCursor
& GetCurrentShellCursor() override
;
313 SwPaM
* CreateCursor();
314 ///< delete the current cursor and make the following into the current
315 void DestroyCursor();
316 ///< transform TableCursor to normal cursor, nullify Tablemode
317 void TableCursorToCursor();
318 ///< enter block mode, change normal cursor into block cursor
319 void CursorToBlockCursor();
320 ///< leave block mode, change block cursor into normal cursor
321 void BlockCursorToCursor();
323 // SelAll() selects the document body content
324 // if ExtendedSelect() is called afterwards, the whole nodes array is selected
325 // only for usage in special cases allowed!
326 void ExtendedSelectAll(bool bFootnotes
= true);
327 /// If ExtendedSelectAll() was called and selection didn't change since then.
328 bool ExtendedSelectedAll();
329 /// If document body starts with a table.
330 bool StartsWithTable();
332 SwCursor
* GetCursor( bool bMakeTableCursor
= true ) const;
333 // return only the current cursor
334 SwShellCursor
* GetCursor_() { return m_pCurrentCursor
; }
335 const SwShellCursor
* GetCursor_() const { return m_pCurrentCursor
; }
337 // show passed cursor - for UNO
338 void SetSelection(const SwPaM
& rCursor
);
340 // remove all cursors from ContentNodes and set to 0
341 void ParkCursor( const SwNodeIndex
&rIdx
);
343 // return the current cursor stack
344 // (required in EditShell when deleting contents)
345 inline SwPaM
* GetStackCursor() const;
347 // start parenthesing, hide SV-Cursor and selected areas
349 // end parenthesing, show SV-Cursor and selected areas
350 void EndAction( const bool bIdleEnd
= false );
352 // basic cursor travelling
353 tools::Long
GetUpDownX() const { return m_nUpDownX
; }
355 bool Left( sal_uInt16 nCnt
, sal_uInt16 nMode
, bool bAllowVisual
= false )
356 { return LeftRight( true, nCnt
, nMode
, bAllowVisual
); }
357 bool Right( sal_uInt16 nCnt
, sal_uInt16 nMode
, bool bAllowVisual
= false )
358 { return LeftRight( false, nCnt
, nMode
, bAllowVisual
); }
359 bool Up( sal_uInt16 nCnt
= 1 ) { return UpDown( true, nCnt
); }
360 bool Down( sal_uInt16 nCnt
= 1 ) { return UpDown( false, nCnt
); }
361 bool LeftMargin() { return LRMargin( true ); }
362 bool RightMargin(bool bAPI
= false) { return LRMargin( false, bAPI
); }
363 bool SttEndDoc( bool bStt
);
365 bool MovePage( SwWhichPage
, SwPosPage
);
366 bool MovePara( SwWhichPara
, SwMoveFnCollection
const & );
367 bool MoveSection( SwWhichSection
, SwMoveFnCollection
const & );
368 bool MoveTable( SwWhichTable
, SwMoveFnCollection
const & );
369 void MoveColumn( SwWhichColumn
, SwPosColumn
);
370 bool MoveRegion( SwWhichRegion
, SwMoveFnCollection
const & );
372 // note: DO NOT call it FindText because windows.h
373 sal_uLong
Find_Text( const i18nutil::SearchOptions2
& rSearchOpt
,
375 SwDocPositions eStart
, SwDocPositions eEnd
,
377 FindRanges eRng
, bool bReplace
= false );
379 sal_uLong
FindFormat( const SwTextFormatColl
& rFormatColl
,
380 SwDocPositions eStart
, SwDocPositions eEnd
,
382 FindRanges eRng
, const SwTextFormatColl
* pReplFormat
);
384 sal_uLong
FindAttrs( const SfxItemSet
& rSet
, bool bNoCollections
,
385 SwDocPositions eStart
, SwDocPositions eEnd
,
388 const i18nutil::SearchOptions2
* pSearchOpt
,
389 const SfxItemSet
* rReplSet
);
391 // Position the Cursor
393 // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
394 // CRSR_POSOLD: when the cursor was not changed
395 int SetCursor( const Point
&rPt
, bool bOnlyText
= false, bool bBlock
= true );
398 * Notification that the visible area was changed. m_aVisArea is reset, then
399 * scrolling is done. The passed Rectangle lays on pixel borders to avoid
402 virtual void VisPortChgd( const SwRect
& ) override
;
405 * virtual paint method to make selection visible again after Paint
407 void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
410 inline void SetMark();
411 inline bool HasMark() const;
416 Ensure point and mark of the current PaM are in a specific order.
418 @param bPointFirst true: If the point is behind the mark then
419 swap the PaM. false: If the mark is behind the point then swap
422 void NormalizePam(bool bPointFirst
= true);
425 bool TestCurrPam( const Point
& rPt
,
426 bool bTstHit
= false); // only exact matches
429 /// store a copy of the current cursor on the cursor stack
431 enum class PopMode
{ DeleteCurrent
, DeleteStack
};
434 * - either from the top of the stack
435 * - or delete the current one and replace it with the cursor from the
437 * @return <true> if there was one on the stack, <false> otherwise
442 * Delete the topmost from the stack and move its Mark into the current.
446 void SttCursorMove();
447 void EndCursorMove( const bool bIdleEnd
= false );
450 * When the focus is lost the selected ranges are not displayed anymore.
451 * On the other hand, on receiving the focus all selected ranges are displayed again
452 * (ranges must be recalculated!).
454 bool HasShellFocus() const { return m_bHasFocus
; }
455 void ShellLoseFocus();
456 void ShellGetFocus();
458 // Methods for displaying or hiding the visible text cursor.
461 // Methods for displaying or hiding the selected ranges with visible cursor.
462 void ShowCursors( bool bCursorVis
);
465 bool IsOverwriteCursor() const { return m_bOverwriteCursor
; }
466 void SetOverwriteCursor( bool bFlag
) { m_bOverwriteCursor
= bFlag
; }
468 // Return current frame in which the cursor is placed.
469 SwContentFrame
*GetCurrFrame( const bool bCalcFrame
= true ) const;
471 //true if cursor is hidden because of readonly.
472 //false if it is working despite readonly.
473 bool IsCursorReadonly() const;
475 // Cursor is placed in something that is protected or selection contains
476 // something that is protected.
477 bool HasReadonlySel() const;
479 // Can the cursor be set to read only ranges?
480 bool IsReadOnlyAvailable() const { return m_bSetCursorInReadOnly
; }
481 void SetReadOnlyAvailable( bool bFlag
);
482 bool IsOverReadOnlyPos( const Point
& rPt
) const;
484 // Methods for aFlyMacroLnk.
485 void SetFlyMacroLnk( const Link
<const SwFlyFrameFormat
*,void>& rLnk
) { m_aFlyMacroLnk
= rLnk
; }
486 const Link
<const SwFlyFrameFormat
*,void>& GetFlyMacroLnk() const { return m_aFlyMacroLnk
; }
488 // Methods returning/altering link for changes of attributes/formats.
489 void SetChgLnk( const Link
<LinkParamNone
*,void> &rLnk
) { m_aChgLnk
= rLnk
; }
490 const Link
<LinkParamNone
*,void>& GetChgLnk() const { return m_aChgLnk
; }
492 // Methods returning/altering link for "graphic completely loaded".
493 void SetGrfArrivedLnk( const Link
<SwCursorShell
&,void> &rLnk
) { m_aGrfArrivedLnk
= rLnk
; }
494 const Link
<SwCursorShell
&,void>& GetGrfArrivedLnk() const { return m_aGrfArrivedLnk
; }
496 //Call ChgLink. When within an action calling will be delayed.
499 // Check if the current cursor contains a selection, i.e.
500 // if Mark is set and SPoint and Mark are different.
501 bool HasSelection() const;
503 // Check if a selection exists, i.e. if the current cursor comprises a selection.
504 inline bool IsSelection() const;
505 // returns if multiple cursors are available
506 inline bool IsMultiSelection() const;
508 // Check if a complete paragraph was selected.
509 bool IsSelFullPara() const;
511 // Check if selection is within one paragraph.
513 //Should WaitPtr be activated for Clipboard.
514 bool ShouldWait() const;
516 // Check if selection is within one paragraph.
517 bool IsSelOnePara() const;
520 * Returns SRectangle, at which the cursor is located.
522 const SwRect
&GetCharRect() const { return m_aCharRect
; }
524 * Returns if cursor is wholly or partly within visible range.
526 bool IsCursorVisible() const { return VisArea().Overlaps( GetCharRect() ); }
528 * Returns SwRect, at which the character is located.
530 void GetCharRectAt(SwRect
& rRect
, const SwPosition
* pPos
);
532 // Return current page number:
533 // true: in which cursor is located.
534 // false: which is visible at the upper margin.
535 void GetPageNum( sal_uInt16
&rnPhyNum
, sal_uInt16
&rnVirtNum
,
536 bool bAtCursorPos
= true, const bool bCalcFrame
= true );
537 // Returns current page's sequential number (1-based),in which cursor is located, ignoring autoinserted empty pages.
538 // Returns 0 on error
539 sal_uInt16
GetPageNumSeqNonEmpty();
540 // Determine how "empty pages" are handled
541 // (used in PhyPage).
542 sal_uInt16
GetNextPrevPageNum( bool bNext
= true );
544 // Move cursor at the beginning of page "nPage".
545 bool GotoPage( sal_uInt16 nPage
);
547 sal_uInt16
GetPageCnt();
553 void GoNextPrevCursorSetSearchLabel(const bool bNext
);
555 // at CurrentCursor.SPoint
556 ::sw::mark::IMark
* SetBookmark(
558 const OUString
& rName
,
559 IDocumentMarkAccess::MarkType eMark
= IDocumentMarkAccess::MarkType::BOOKMARK
);
560 ::sw::mark::IMark
* SetBookmark2(
562 const OUString
& rName
,
564 const OUString
& rCondition
);
565 bool GotoMark( const ::sw::mark::IMark
* const pMark
); // sets CurrentCursor.SPoint
566 bool GotoMark( const ::sw::mark::IMark
* const pMark
, bool bAtStart
);
567 bool GoNextBookmark(); // true, if there was one
568 bool GoPrevBookmark();
570 bool IsFormProtected();
571 ::sw::mark::IFieldmark
* GetCurrentFieldmark();
572 ::sw::mark::IFieldmark
* GetFieldmarkAfter();
573 ::sw::mark::IFieldmark
* GetFieldmarkBefore();
574 bool GotoFieldmark( const ::sw::mark::IFieldmark
* const pMark
);
576 // update Cursr, i.e. reset it into content should only be called when the
577 // cursor was set to a random position e.g. when deleting frames
578 void UpdateCursorPos();
580 // get the selected text at the current cursor. It will be filled with
582 OUString
GetSelText() const;
584 // Check of SPoint or Mark of current cursor are placed within a table.
585 inline const SwTableNode
* IsCursorInTable() const;
587 bool IsCursorInFootnote() const;
589 inline Point
& GetCursorDocPos() const;
590 inline bool IsCursorPtAtEnd() const;
592 inline const SwPaM
* GetTableCrs() const;
593 inline SwPaM
* GetTableCrs();
595 bool IsTableComplexForChart();
596 // get current table selection as text
597 OUString
GetBoxNms() const;
599 // set Cursor to the next/previous cell
600 bool GoNextCell( bool bAppendLine
= true );
602 // go to this box (if available and inside of table)
603 bool GotoTable( const OUString
& rName
);
605 // select a table row, column or box (based on the current cursor)
606 bool SelTableRow() { return SelTableRowOrCol( true ); }
607 bool SelTableCol() { return SelTableRowOrCol( false ); }
615 bool GotoOutline( const OUString
& rName
);
616 // to the next/previous or the given OutlineNode
617 void GotoOutline( SwOutlineNodes::size_type nIdx
);
618 // find the "outline position" in the nodes array of the current chapter
619 SwOutlineNodes::size_type
GetOutlinePos(sal_uInt8 nLevel
= UCHAR_MAX
, SwPaM
* pPaM
= nullptr);
620 // select the given range of OutlineNodes. Optionally including the children
621 // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell)
622 void MakeOutlineSel(SwOutlineNodes::size_type nSttPos
, SwOutlineNodes::size_type nEndPos
,
623 bool bWithChildren
, bool bKillPams
= true );
625 bool GotoNextOutline();
626 bool GotoPrevOutline();
628 /** Delivers the current shell cursor
630 Some operations have to run on the current cursor ring,
631 some on the m_pTableCursor (if exist) or the current cursor ring and
632 some on the m_pTableCursor or m_pBlockCursor or the current cursor ring.
633 This small function checks the existence and delivers the wished cursor.
636 if the block cursor is of interest or not
638 @return m_pTableCursor if exist,
639 m_pBlockCursor if exist and of interest (param bBlock)
640 otherwise m_pCurrentCursor
642 SwShellCursor
* getShellCursor( bool bBlock
);
643 const SwShellCursor
* getShellCursor( bool bBlock
) const
644 { return const_cast<SwCursorShell
*>(this)->getShellCursor( bBlock
); }
646 bool IsBlockMode() const { return nullptr != m_pBlockCursor
; }
648 // is the Cursor in a table and is the selection over 2 columns
649 bool IsTableMode() const { return nullptr != m_pTableCursor
; }
651 const SwShellTableCursor
* GetTableCursor() const { return m_pTableCursor
; }
652 SwShellTableCursor
* GetTableCursor() { return m_pTableCursor
; }
653 size_t UpdateTableSelBoxes();
655 bool GotoFootnoteText(); ///< jump from content to footnote
656 bool GotoFootnoteAnchor(); ///< jump from footnote to anchor
657 bool GotoPrevFootnoteAnchor();
658 bool GotoNextFootnoteAnchor();
660 void GotoFlyAnchor(); ///< jump from the frame to the anchor
661 bool GotoHeaderText(); ///< jump from the content to the header
662 bool GotoFooterText(); ///< jump from the content to the footer
663 // jump to the header/footer of the given or current PageDesc
664 bool SetCursorInHdFt( size_t nDescNo
, bool bInHeader
);
665 // is point of cursor in header/footer. pbInHeader return true if it is
666 // in a headerframe otherwise in a footerframe
667 bool IsInHeaderFooter( bool* pbInHeader
= nullptr ) const;
669 bool GotoNextTOXBase( const OUString
* = nullptr );
670 bool GotoPrevTOXBase( const OUString
* = nullptr );
671 void GotoTOXMarkBase();
672 // jump to the next or previous index entry
673 bool GotoNxtPrvTOXMark( bool bNext
= true );
674 // jump to the next/previous index mark of this type
675 const SwTOXMark
& GotoTOXMark( const SwTOXMark
& rStart
, SwTOXSearch eDir
);
677 // jump to the next or previous table formula
678 // optionally only to broken formulas
679 bool GotoNxtPrvTableFormula( bool bNext
= true,
680 bool bOnlyErrors
= false );
681 // jump to the next / previous hyperlink - inside text and also
683 bool SelectNxtPrvHyperlink( bool bNext
);
685 bool GotoRefMark( const OUString
& rRefMark
, sal_uInt16 nSubType
,
688 // get the nth character from the start or end of the current selection
689 sal_Unicode
GetChar( bool bEnd
= true, tools::Long nOffset
= 0 );
690 bool ExtendSelection( bool bEnd
= true, sal_Int32 nCount
= 1 );
692 // Place only the visible cursor at the given position in the document.
693 // Return false if SPoint was corrected by layout.
694 // (This is needed for displaying the Drag&Drop/Copy-Cursor.)
695 bool SetVisibleCursor( const Point
&rPt
);
696 inline void UnSetVisibleCursor();
697 SwVisibleCursor
* GetVisibleCursor() const;
699 // jump to the next or previous field of the corresponding type
701 const SwFieldType
* pFieldType
,
703 const SwFieldIds nResType
= SwFieldIds::Unknown
,
704 const bool bAddSetExpressionFieldsToInputFields
= true );
706 bool GotoFormatField( const SwFormatField
& rField
);
708 bool GotoFormatContentControl(const SwFormatContentControl
& rContentControl
);
710 static SwTextField
* GetTextFieldAtPos(
711 const SwPosition
* pPos
,
712 const bool bIncludeInputFieldAtStart
);
713 static SwTextField
* GetTextFieldAtCursor(
714 const SwPaM
* pCursor
,
715 const bool bIncludeInputFieldAtStart
);
716 static SwField
* GetFieldAtCursor(
717 const SwPaM
* pCursor
,
718 const bool bIncludeInputFieldAtStart
);
719 SwField
* GetCurField( const bool bIncludeInputFieldAtStart
= false ) const;
720 bool CursorInsideInputField() const;
721 SwTextContentControl
* CursorInsideContentControl() const;
722 static bool PosInsideInputField( const SwPosition
& rPos
);
723 bool DocPtInsideInputField( const Point
& rDocPt
) const;
724 static sal_Int32
StartOfInputFieldAtPos( const SwPosition
& rPos
);
725 static sal_Int32
EndOfInputFieldAtPos( const SwPosition
& rPos
);
727 // Return number of cursors in ring (The flag indicates whether
728 // only cursors containing selections are requested).
729 sal_uInt16
GetCursorCnt( bool bAll
= true ) const;
731 // Char Travelling - methods (in crstrvl1.cxx)
736 bool GoNextSentence();
737 bool GoStartSentence();
738 bool GoEndSentence();
739 bool SelectWord( const Point
* pPt
);
740 void ExpandToSentenceBorders();
742 // get position from current cursor
743 bool IsStartWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
)const;
744 bool IsEndWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
745 bool IsInWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
746 bool IsStartSentence() const;
747 bool IsEndSentence() const;
748 bool IsSttPara() const;
749 bool IsEndPara() const;
750 bool IsEndOfTable() const; ///< at the very last SwPosition inside a table
751 bool IsStartOfDoc() const;
752 bool IsEndOfDoc() const;
753 bool IsInFrontOfLabel() const;
754 bool IsAtLeftMargin() const { return IsAtLRMargin( true ); }
755 bool IsAtRightMargin() const { return IsAtLRMargin( false, true/*bAPI*/ ); }
757 // delete all created cursors, set the table cursor and the last cursor to
758 // its TextNode (or StartNode?)
759 // They all get created on the next ::GetCursor again
760 // Used for Drag&Drop/Clipboard-Paste in tables
761 bool ParkTableCursor();
763 // Non expanded attributes?
764 bool IsGCAttr() const { return m_bGCAttr
; }
765 void ClearGCAttr() { m_bGCAttr
= false; }
766 void UpdateAttr() { m_bGCAttr
= true; }
768 // is the whole document protected/hidden (for UI...)
769 bool IsAllProtect() const { return m_bAllProtect
; }
771 bool GotoRegion( std::u16string_view rName
);
773 // show the current selection
774 virtual void MakeSelVisible();
776 // set the cursor to a NOT protected/hidden node
777 bool FindValidContentNode( bool bOnlyText
);
779 bool GetContentAtPos( const Point
& rPt
,
780 SwContentAtPos
& rContentAtPos
,
781 bool bSetCursor
= false,
782 SwRect
* pFieldRect
= nullptr );
784 const SwPostItField
* GetPostItFieldAtCursor() const;
786 // get smart tags rectangle for the given point
787 void GetSmartTagRect( const Point
& rPt
, SwRect
& rSelectRect
);
789 // get smart tags at current cursor position
790 void GetSmartTagTerm( std::vector
< OUString
>& rSmartTagTypes
,
791 css::uno::Sequence
< css::uno::Reference
< css::container::XStringKeyMap
> >& rStringKeyMaps
,
792 css::uno::Reference
<css::text::XTextRange
>& rRange
) const;
794 bool IsPageAtPos( const Point
&rPt
) const;
796 bool SelectTextAttr( sal_uInt16 nWhich
, bool bExpand
, const SwTextAttr
* pAttr
= nullptr );
797 bool GotoINetAttr( const SwTextINetFormat
& rAttr
);
798 const SwFormatINetFormat
* FindINetAttr( std::u16string_view rName
) const;
800 bool SelectTextModel(sal_Int32 nStart
, sal_Int32 nEnd
);
801 #ifdef SW_DLLIMPLEMENTATION
802 bool SelectTextView(TextFrameIndex nStart
, TextFrameIndex nEnd
);
803 // result is only valid while cursor isn't moved!
804 TextFrameIndex
GetCursorPointAsViewIndex() const;
807 bool CheckTableBoxContent( const SwPosition
* pPos
= nullptr );
808 void SaveTableBoxContent( const SwPosition
* pPos
= nullptr );
809 void ClearTableBoxContent();
810 bool EndAllTableBoxEdit();
812 void SetSelTableCells( bool bFlag
) { m_bSelTableCells
= bFlag
; }
813 bool IsSelTableCells() const { return m_bSelTableCells
; }
815 void UnsetEnhancedTableSelection() { m_eEnhancedTableSel
= SwTable::SEARCH_NONE
; }
816 SwTable::SearchType
GetEnhancedTableSelection() const { return m_eEnhancedTableSel
; }
818 bool IsAutoUpdateCells() const { return m_bAutoUpdateCells
; }
819 void SetAutoUpdateCells( bool bFlag
) { m_bAutoUpdateCells
= bFlag
; }
821 bool GetShadowCursorPos( const Point
& rPt
, SwFillMode eFillMode
,
822 SwRect
& rRect
, sal_Int16
& rOrient
);
823 bool SetShadowCursorPos( const Point
& rPt
, SwFillMode eFillMode
);
825 const SwRangeRedline
* SelNextRedline();
826 const SwRangeRedline
* SelPrevRedline();
827 const SwRangeRedline
* GotoRedline( SwRedlineTable::size_type nArrPos
, bool bSelect
);
829 bool GotoFootnoteAnchor(const SwTextFootnote
& rTextFootnote
);
831 SAL_DLLPRIVATE SvxFrameDirection
GetTextDirection( const Point
* pPt
= nullptr ) const;
832 // is cursor or the point in/over a vertical formatted text?
833 bool IsInVerticalText( const Point
* pPt
= nullptr ) const;
834 // is cursor or the point in/over a right to left formatted text?
835 bool IsInRightToLeftText() const;
837 static void FirePageChangeEvent(sal_uInt16 nOldPage
, sal_uInt16 nNewPage
);
838 bool bColumnChange();
839 static void FireSectionChangeEvent(sal_uInt16 nOldSection
, sal_uInt16 nNewSection
);
840 static void FireColumnChangeEvent(sal_uInt16 nOldColumn
, sal_uInt16 nNewColumn
);
841 // If the current cursor position is inside a hidden range, the hidden range
842 // is selected and true is returned:
843 bool SelectHiddenRange();
845 // remove all invalid cursors
846 void ClearUpCursors();
848 void SetMacroExecAllowed( const bool _bMacroExecAllowed
)
850 m_bMacroExecAllowed
= _bMacroExecAllowed
;
852 bool IsMacroExecAllowed() const
854 return m_bMacroExecAllowed
;
858 Returns textual description of the current selection.
860 - If the current selection is a multi-selection the result is
862 - Else the result is the text of the selection.
864 @return the textual description of the current selection
866 OUString
GetCursorDescr() const;
868 virtual void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
869 /// Implementation of lok::Document::getPartPageRectangles() for Writer.
870 OUString
getPageRectangles();
872 /// See SwView::NotifyCursor().
873 void NotifyCursor(SfxViewShell
* pViewShell
) const;
877 inline SwMoveFnCollection
const & SwCursorShell::MakeFindRange(
878 SwDocPositions nStt
, SwDocPositions nEnd
, SwPaM
* pPam
) const
880 return m_pCurrentCursor
->MakeFindRange( nStt
, nEnd
, pPam
);
883 inline SwPaM
* SwCursorShell::GetStackCursor() const { return m_pStackCursor
; }
885 inline void SwCursorShell::SetMark() { m_pCurrentCursor
->SetMark(); }
887 inline bool SwCursorShell::HasMark() const { return m_pCurrentCursor
->HasMark(); }
889 inline bool SwCursorShell::IsSelection() const
891 return IsTableMode() || m_pCurrentCursor
->HasMark() ||
892 m_pCurrentCursor
->GetNext() != m_pCurrentCursor
;
894 inline bool SwCursorShell::IsMultiSelection() const
896 return m_pCurrentCursor
->GetNext() != m_pCurrentCursor
;
899 inline const SwTableNode
* SwCursorShell::IsCursorInTable() const
901 return m_pCurrentCursor
->GetNode().FindTableNode();
904 inline bool SwCursorShell::IsCursorPtAtEnd() const
906 return m_pCurrentCursor
->End() == m_pCurrentCursor
->GetPoint();
909 inline Point
& SwCursorShell::GetCursorDocPos() const
911 return m_pCurrentCursor
->GetPtPos();
914 inline const SwPaM
* SwCursorShell::GetTableCrs() const
916 return m_pTableCursor
;
919 inline SwPaM
* SwCursorShell::GetTableCrs()
921 return m_pTableCursor
;
924 inline void SwCursorShell::UnSetVisibleCursor()
926 m_pVisibleCursor
->Hide();
927 m_pVisibleCursor
->SetDragCursor( false );
930 #endif // _CRSRSH_HXX
932 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */