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 #include <IShellCursorSupplier.hxx>
32 #include <swtypes.hxx>
36 #include <crstate.hxx>
41 #include <IDocumentMarkAccess.hxx>
55 class SwShellTableCursor
;
57 class SwTextFormatColl
;
58 class SwVisibleCursor
;
59 class SwTextINetFormat
;
60 class SwFormatINetFormat
;
72 struct SearchOptions2
;
74 namespace com
{ namespace sun
{ namespace star
{ namespace text
{
77 namespace com
{ namespace sun
{ namespace star
{ namespace container
{
81 // enum and struct to get information via the Doc-Position
83 enum class IsAttrAtPos
96 ContentCheck
= 0x0400,
100 ,CurrAttrs
= 0x2000 ///< only for debugging
101 ,TableBoxValue
= 0x4000 ///< only for debugging
105 template<> struct typed_flags
<IsAttrAtPos
> : is_typed_flags
<IsAttrAtPos
, 0x7fff> {};
108 struct SwContentAtPos
110 IsAttrAtPos eContentAtPos
;
113 const SwField
* pField
;
114 const SfxPoolItem
* pAttr
;
115 const SwRangeRedline
* pRedl
;
116 SwContentNode
* pNode
;
117 const sw::mark::IFieldmark
* pFieldmark
;
123 const SwTextAttr
* pFndTextAttr
;
125 SwContentAtPos( IsAttrAtPos eGetAtPos
)
126 : eContentAtPos( eGetAtPos
)
128 aFnd
.pField
= nullptr;
129 pFndTextAttr
= nullptr;
130 nDist
= 0; // #i23726#
133 bool IsInProtectSect() const;
134 bool IsInRTLText() const;
137 // return values of SetCursor (can be combined via ||)
138 const int CRSR_POSOLD
= 0x01, // cursor stays at old position
139 CRSR_POSCHG
= 0x02; // position changed by the layout
141 /// Helperfunction to resolve backward references in regular expressions
142 OUString
*ReplaceBackReferences( const i18nutil::SearchOptions2
& rSearchOpt
, SwPaM
* pPam
);
144 class SW_DLLPUBLIC SwCursorShell
147 , public ::sw::IShellCursorSupplier
149 friend class SwCallLink
;
150 friend class SwVisibleCursor
;
151 friend class SwSelPaintRects
;
153 // requires the Cursor as InternalCursor
154 friend bool GetAutoSumSel( const SwCursorShell
&, SwCellFrames
& );
158 /** for calling UpdateCursor */
160 UPDOWN
= (1 << 0), ///< keep Up/Down on columns
161 SCROLLWIN
= (1 << 1), ///< scroll window
162 CHKRANGE
= (1 << 2), ///< check overlapping PaMs
163 READONLY
= (1 << 3) ///< make visible in spite of Readonly
168 SwRect m_aCharRect
; ///< Char-SRectangle on which the cursor is located
169 Point m_aCursorHeight
; ///< height & offset from visible Cursor
170 Point m_aOldRBPos
; ///< Right/Bottom of last VisArea
171 // (used in Invalidate by Cursor)
173 Link
<const SwFlyFrameFormat
*,void> m_aFlyMacroLnk
; /**< Link will be called, if the Cursor is set
174 into a fly. A macro can then be called */
175 Link
<SwCursorShell
*,void> m_aChgLnk
; /**< link will be called by every attribute/
176 format changes at cursor position.*/
177 Link
<SwCursorShell
&,void> m_aGrfArrivedLnk
; ///< Link calls to UI if a graphic is arrived
179 SwShellCursor
* m_pCurrentCursor
; ///< current cursor
180 SwShellCursor
* m_pStackCursor
; ///< stack for the cursor
181 SwVisibleCursor
*m_pVisibleCursor
; ///< the visible cursor
183 SwBlockCursor
*m_pBlockCursor
; ///< interface of cursor for block (=rectangular) selection
185 SwShellTableCursor
* m_pTableCursor
; /**< table Cursor; only in tables when the
186 selection lays over 2 columns */
188 SwNodeIndex
* m_pBoxIdx
; ///< for recognizing of the changed
189 SwTableBox
* m_pBoxPtr
; ///< table row
191 long m_nUpDownX
; /**< try to move the cursor on up/down always
192 in the same column */
193 long m_nLeftFramePos
;
194 sal_uLong m_nAktNode
; // save CursorPos at Start-Action
195 sal_Int32 m_nAktContent
;
196 SwNodeType m_nAktNdTyp
;
197 bool m_bAktSelection
;
200 * Via the Method SttCursorMove and EndCursorMove this counter gets
201 * incremented/decremented. As long as the counter is inequal to 0, the
202 * current Cursor gets no update. This way, "complicated" cursor movements
203 * (via Find()) can be realised.
205 sal_uInt16 m_nCursorMove
;
206 CursorMoveState m_eMvState
; ///< Status for Cursor-Travelling - GetCursorOfst
208 OUString m_sMarkedListId
;
209 int m_nMarkedListLevel
;
211 bool m_bHasFocus
: 1; ///< Shell is "active" in a window
212 bool m_bSVCursorVis
: 1; ///< SV-Cursor visible/invisible
213 bool m_bChgCallFlag
: 1; ///< attribute change inside Start- and EndAction
214 bool m_bVisPortChgd
: 1; ///< in VisPortChg-Call
215 // (used in Invalidate by the Cursor)
217 bool m_bCallChgLnk
: 1; ///< flag for derived classes
218 // true -> call ChgLnk
219 // access only via SwChgLinkFlag
220 bool m_bAllProtect
: 1; ///< Flag for areas
221 // true -> everything protected / hidden
222 bool m_bInCMvVisportChgd
: 1; ///< Flag for CursorMoves
223 // true -> view was moved
224 bool m_bGCAttr
: 1; // true -> non expanded attributes exist.
225 bool m_bIgnoreReadonly
: 1; // true -> make the cursor visible on next
226 // EndAction in spite of Readonly
227 bool m_bSelTableCells
: 1; // true -> select cells over the InputWin
228 bool m_bAutoUpdateCells
: 1; // true -> autoformat cells
229 bool m_bBasicHideCursor
: 1; // true -> HideCursor from Basic
230 bool m_bSetCursorInReadOnly
: 1;// true -> Cursor is allowed in ReadOnly-Areas
231 bool m_bOverwriteCursor
: 1; // true -> show Overwrite Cursor
233 bool m_bMacroExecAllowed
: 1;
235 SwFrame
* m_oldColFrame
;
237 SAL_DLLPRIVATE
void UpdateCursor(
238 sal_uInt16 eFlags
= SwCursorShell::SCROLLWIN
|SwCursorShell::CHKRANGE
,
239 bool bIdleEnd
= false );
241 SAL_DLLPRIVATE
void MoveCursorToNum();
243 SAL_DLLPRIVATE
void ParkPams( SwPaM
* pDelRg
, SwShellCursor
** ppDelRing
);
245 /** Mark a certain list level of a certain list
247 levels of a certain lists are marked now
249 @param sListId list Id of the list whose level is marked
250 @param nLevel to be marked list level
252 An empty sListId denotes that no level of a list is marked.
254 SAL_DLLPRIVATE
void MarkListLevel( const OUString
& sListId
,
257 // private method(s) accessed from public inline method(s) must be exported.
258 bool LeftRight( bool, sal_uInt16
, sal_uInt16
, bool );
259 SAL_DLLPRIVATE
bool UpDown( bool, sal_uInt16
);
260 SAL_DLLPRIVATE
bool LRMargin( bool, bool bAPI
= false );
261 SAL_DLLPRIVATE
bool IsAtLRMargin( bool, bool bAPI
= false ) const;
263 SAL_DLLPRIVATE SvxFrameDirection
GetTextDirection( const Point
* pPt
= nullptr ) const;
265 SAL_DLLPRIVATE
bool isInHiddenTextFrame(SwShellCursor
* pShellCursor
);
267 typedef bool (SwCursor:: *FNCursor
)();
268 SAL_DLLPRIVATE
bool CallCursorFN( FNCursor
);
270 SAL_DLLPRIVATE
const SwRangeRedline
* GotoRedline_( SwRedlineTable::size_type nArrPos
, bool bSelect
);
274 inline SwMoveFnCollection
const & MakeFindRange( SwDocPositions
, SwDocPositions
, SwPaM
* ) const;
277 * Compare-Method for the StackCursor and the current Cursor.
278 * The Methods return -1, 0, 1 for lower, equal, greater.
280 int CompareCursorStackMkCurrPt() const;
282 bool SelTableRowOrCol( bool bRow
, bool bRowSimple
= false );
284 bool SetInFrontOfLabel( bool bNew
);
286 void RefreshBlockCursor();
288 /** Updates the marked list level according to the cursor.
290 SAL_DLLPRIVATE
void UpdateMarkedListLevel();
293 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
) override
;
296 SwCursorShell( SwDoc
& rDoc
, vcl::Window
*pWin
, const SwViewOption
*pOpt
);
297 // disguised copy constructor
298 SwCursorShell( SwCursorShell
& rShell
, vcl::Window
*pWin
);
299 virtual ~SwCursorShell() override
;
301 // create new cursor and append the old one
302 virtual SwPaM
& CreateNewShellCursor() override
;
303 virtual SwPaM
& GetCurrentShellCursor() override
;
305 SwPaM
* CreateCursor();
306 ///< delete the current cursor and make the following into the current
307 bool DestroyCursor();
308 ///< transform TableCursor to normal cursor, nullify Tablemode
309 void TableCursorToCursor();
310 ///< enter block mode, change normal cursor into block cursor
311 void CursorToBlockCursor();
312 ///< leave block mode, change block cursor into normal cursor
313 void BlockCursorToCursor();
315 // SelAll() selects the document body content
316 // if ExtendedSelect() is called afterwards, the whole nodes array is selected
317 // only for usage in special cases allowed!
318 void ExtendedSelectAll(bool bFootnotes
= true);
319 /// If ExtendedSelectAll() was called and selection didn't change since then.
320 bool ExtendedSelectedAll();
321 /// If document body starts with a table.
322 bool StartsWithTable();
324 SwPaM
* GetCursor( bool bMakeTableCursor
= true ) const;
325 inline SwCursor
* GetSwCursor() const;
326 // return only the current cursor
327 SwShellCursor
* GetCursor_() { return m_pCurrentCursor
; }
328 const SwShellCursor
* GetCursor_() const { return m_pCurrentCursor
; }
330 // show passed cursor - for UNO
331 void SetSelection(const SwPaM
& rCursor
);
333 // remove all cursors from ContentNodes and set to 0
334 void ParkCursor( const SwNodeIndex
&rIdx
);
336 // return the current cursor stack
337 // (required in EditShell when deleting contents)
338 inline SwPaM
* GetStackCursor() const;
340 // start parenthesing, hide SV-Cursor and selected areas
342 // end parenthesing, show SV-Cursor and selected areas
343 void EndAction( const bool bIdleEnd
= false, const bool DoSetPosX
= false );
345 // basic cursor travelling
346 long GetUpDownX() const { return m_nUpDownX
; }
348 bool Left( sal_uInt16 nCnt
, sal_uInt16 nMode
, bool bAllowVisual
= false )
349 { return LeftRight( true, nCnt
, nMode
, bAllowVisual
); }
350 bool Right( sal_uInt16 nCnt
, sal_uInt16 nMode
, bool bAllowVisual
= false )
351 { return LeftRight( false, nCnt
, nMode
, bAllowVisual
); }
352 bool Up( sal_uInt16 nCnt
= 1 ) { return UpDown( true, nCnt
); }
353 bool Down( sal_uInt16 nCnt
= 1 ) { return UpDown( false, nCnt
); }
354 bool LeftMargin() { return LRMargin( true ); }
355 bool RightMargin(bool bAPI
= false) { return LRMargin( false, bAPI
); }
356 bool SttEndDoc( bool bStt
);
358 bool MovePage( SwWhichPage
, SwPosPage
);
359 bool MovePara( SwWhichPara
, SwMoveFnCollection
const & );
360 bool MoveSection( SwWhichSection
, SwMoveFnCollection
const & );
361 bool MoveTable( SwWhichTable
, SwMoveFnCollection
const & );
362 bool MoveColumn( SwWhichColumn
, SwPosColumn
);
363 bool MoveRegion( SwWhichRegion
, SwMoveFnCollection
const & );
365 sal_uLong
Find( const i18nutil::SearchOptions2
& rSearchOpt
,
367 SwDocPositions eStart
, SwDocPositions eEnd
,
369 FindRanges eRng
, bool bReplace
= false );
371 sal_uLong
Find( const SwTextFormatColl
& rFormatColl
,
372 SwDocPositions eStart
, SwDocPositions eEnd
,
374 FindRanges eRng
, const SwTextFormatColl
* pReplFormat
);
376 sal_uLong
Find( const SfxItemSet
& rSet
, bool bNoCollections
,
377 SwDocPositions eStart
, SwDocPositions eEnd
,
380 const i18nutil::SearchOptions2
* pSearchOpt
,
381 const SfxItemSet
* rReplSet
);
383 // Position the Cursor
385 // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
386 // CRSR_POSOLD: when the cursor was not changed
387 int SetCursor( const Point
&rPt
, bool bOnlyText
= false, bool bBlock
= true );
390 * Notification that the visible area was changed. m_aVisArea is reset, then
391 * scrolling is done. The passed Rectangle lays on pixel borders to avoid
394 virtual void VisPortChgd( const SwRect
& ) override
;
397 * virtual paint method to make selection visible again after Paint
399 void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
402 inline void SetMark();
403 inline bool HasMark();
408 Ensure point and mark of the current PaM are in a specific order.
410 @param bPointFirst true: If the point is behind the mark then
411 swap the PaM. false: If the mark is behind the point then swap
414 void NormalizePam(bool bPointFirst
= true);
417 bool TestCurrPam( const Point
& rPt
,
418 bool bTstHit
= false); // only exact matches
421 /// store a copy of the current cursor on the cursor stack
423 enum class PopMode
{ DeleteCurrent
, DeleteStack
};
426 * - either from the top of the stack
427 * - or delete the current one and replace it with the cursor from the
429 * @return <true> if there was one on the stack, <false> otherwise
431 bool Pop(PopMode
= PopMode::DeleteStack
);
434 * Delete the topmost from the stack and move its Mark into the current.
438 void SttCursorMove();
439 void EndCursorMove( const bool bIdleEnd
= false );
442 * When the focus is lost the selected ranges are not displayed anymore.
443 * On the other hand, on receiving the focus all selected ranges are displayed again
444 * (ranges must be recalculated!).
446 bool HasShellFocus() const { return m_bHasFocus
; }
447 void ShellLoseFocus();
448 void ShellGetFocus();
450 // Methods for displaying or hiding the visible text cursor.
453 // Methods for displaying or hiding the selected ranges with visible cursor.
454 void ShowCursors( bool bCursorVis
);
457 bool IsOverwriteCursor() const { return m_bOverwriteCursor
; }
458 void SetOverwriteCursor( bool bFlag
) { m_bOverwriteCursor
= bFlag
; }
460 // Return current frame in which the cursor is placed.
461 SwContentFrame
*GetCurrFrame( const bool bCalcFrame
= true ) const;
463 //true if cursor is hidden because of readonly.
464 //false if it is working despite readonly.
465 bool IsCursorReadonly() const;
467 // Cursor is placed in something that is protected or selection contains
468 // something that is protected.
469 bool HasReadonlySel() const;
471 // Can the cursor be set to read only ranges?
472 bool IsReadOnlyAvailable() const { return m_bSetCursorInReadOnly
; }
473 void SetReadOnlyAvailable( bool bFlag
);
474 bool IsOverReadOnlyPos( const Point
& rPt
) const;
476 // Methods for aFlyMacroLnk.
477 void SetFlyMacroLnk( const Link
<const SwFlyFrameFormat
*,void>& rLnk
) { m_aFlyMacroLnk
= rLnk
; }
478 const Link
<const SwFlyFrameFormat
*,void>& GetFlyMacroLnk() const { return m_aFlyMacroLnk
; }
480 // Methods returning/altering link for changes of attributes/formats.
481 void SetChgLnk( const Link
<SwCursorShell
*,void> &rLnk
) { m_aChgLnk
= rLnk
; }
482 const Link
<SwCursorShell
*,void>& GetChgLnk() const { return m_aChgLnk
; }
484 // Methods returning/altering ling for "graphic completely loaded".
485 void SetGrfArrivedLnk( const Link
<SwCursorShell
&,void> &rLnk
) { m_aGrfArrivedLnk
= rLnk
; }
486 const Link
<SwCursorShell
&,void>& GetGrfArrivedLnk() const { return m_aGrfArrivedLnk
; }
488 //Call ChgLink. When within an action calling will be delayed.
491 // Check if the current cursor contains a selection, i.e.
492 // if Mark is set and SPoint and Mark are different.
493 bool HasSelection() const;
495 // Check if a selection exists, i.e. if the current cursor comprises a selection.
496 inline bool IsSelection() const;
497 // returns if multiple cursors are available
498 inline bool IsMultiSelection() const;
500 // Check if a complete paragraph was selected.
501 bool IsSelFullPara() const;
503 // Check if selection is within one paragraph.
505 //Should WaitPtr be activated for Clipboard.
506 bool ShouldWait() const;
508 // Check if selection is within one paragraph.
509 inline bool IsSelOnePara() const;
512 * Returns SRectangle, at which the cursor is located.
514 const SwRect
&GetCharRect() const { return m_aCharRect
; }
516 * Returns if cursor is wholly or partly within visible range.
518 bool IsCursorVisible() const { return VisArea().IsOver( GetCharRect() ); }
520 * Returns SwRect, at which the character is located.
522 bool GetCharRectAt(SwRect
& rRect
, const SwPosition
* pPos
);
524 // Return current page number:
525 // true: in which cursor is located.
526 // false: which is visible at the upper margin.
527 void GetPageNum( sal_uInt16
&rnPhyNum
, sal_uInt16
&rnVirtNum
,
528 bool bAtCursorPos
= true, const bool bCalcFrame
= true );
529 // Determine how "empty pages" are handled
530 // (used in PhyPage).
531 sal_uInt16
GetNextPrevPageNum( bool bNext
= true );
533 // Move cursor at the beginning of page "nPage".
534 bool GotoPage( sal_uInt16 nPage
);
536 sal_uInt16
GetPageCnt();
542 // at CurrentCursor.SPoint
543 ::sw::mark::IMark
* SetBookmark(
545 const OUString
& rName
,
546 IDocumentMarkAccess::MarkType eMark
= IDocumentMarkAccess::MarkType::BOOKMARK
);
547 bool GotoMark( const ::sw::mark::IMark
* const pMark
); // sets CurrentCursor.SPoint
548 bool GotoMark( const ::sw::mark::IMark
* const pMark
, bool bAtStart
);
549 bool GoNextBookmark(); // true, if there was one
550 bool GoPrevBookmark();
552 bool IsFormProtected();
553 ::sw::mark::IFieldmark
* GetCurrentFieldmark();
554 ::sw::mark::IFieldmark
* GetFieldmarkAfter();
555 ::sw::mark::IFieldmark
* GetFieldmarkBefore();
556 bool GotoFieldmark( const ::sw::mark::IFieldmark
* const pMark
);
558 // update Cursr, i.e. reset it into content should only be called when the
559 // cursor was set to a random position e.g. when deleting frames
560 void UpdateCursorPos();
562 // get the selected text at the current cursor. it will be filled with
564 OUString
GetSelText() const;
565 // return only the text starting from the current cursor position (to the
567 OUString
GetText() const;
569 // Check of SPoint or Mark of current cursor are placed within a table.
570 inline const SwTableNode
* IsCursorInTable() const;
572 bool IsCursorInFootnote() const;
574 inline Point
& GetCursorDocPos() const;
575 inline bool IsCursorPtAtEnd() const;
577 inline const SwPaM
* GetTableCrs() const;
578 inline SwPaM
* GetTableCrs();
580 bool IsTableComplexForChart();
581 // get current table selection as text
582 OUString
GetBoxNms() const;
584 // set Cursor to the next/previous cell
585 bool GoNextCell( bool bAppendLine
= true );
587 // go to this box (if available and inside of table)
588 bool GotoTable( const OUString
& rName
);
590 // select a table row, column or box (based on the current cursor)
591 bool SelTableRow() { return SelTableRowOrCol( true ); }
592 bool SelTableCol() { return SelTableRowOrCol( false ); }
600 bool GotoOutline( const OUString
& rName
);
601 // to the next/previous or the given OutlineNode
602 void GotoOutline( SwOutlineNodes::size_type nIdx
);
603 // find the "outline position" in the nodes array of the current chapter
604 SwOutlineNodes::size_type
GetOutlinePos( sal_uInt8 nLevel
= UCHAR_MAX
);
605 // select the given range of OutlineNodes. Optionally including the children
606 // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell)
607 bool MakeOutlineSel( SwOutlineNodes::size_type nSttPos
, SwOutlineNodes::size_type nEndPos
,
608 bool bWithChildren
);
610 bool GotoNextOutline();
611 bool GotoPrevOutline();
613 /** Delivers the current shell cursor
615 Some operations have to run on the current cursor ring,
616 some on the m_pTableCursor (if exist) or the current cursor ring and
617 some on the m_pTableCursor or m_pBlockCursor or the current cursor ring.
618 This small function checks the existence and delivers the wished cursor.
621 if the block cursor is of interest or not
623 @return m_pTableCursor if exist,
624 m_pBlockCursor if exist and of interest (param bBlock)
625 otherwise m_pCurrentCursor
627 SwShellCursor
* getShellCursor( bool bBlock
);
628 const SwShellCursor
* getShellCursor( bool bBlock
) const
629 { return (const_cast<SwCursorShell
*>(this))->getShellCursor( bBlock
); }
631 bool IsBlockMode() const { return nullptr != m_pBlockCursor
; }
633 // is the Cursor in a table and is the selection over 2 columns
634 bool IsTableMode() const { return nullptr != m_pTableCursor
; }
636 const SwShellTableCursor
* GetTableCursor() const { return m_pTableCursor
; }
637 SwShellTableCursor
* GetTableCursor() { return m_pTableCursor
; }
638 size_t UpdateTableSelBoxes();
640 bool GotoFootnoteText(); ///< jump from content to footnote
641 bool GotoFootnoteAnchor(); ///< jump from footnote to anchor
642 bool GotoPrevFootnoteAnchor();
643 bool GotoNextFootnoteAnchor();
645 bool GotoFlyAnchor(); ///< jump from the frame to the anchor
646 bool GotoHeaderText(); ///< jump from the content to the header
647 bool GotoFooterText(); ///< jump from the content to the footer
648 // jump to the header/footer of the given or current PageDesc
649 bool SetCursorInHdFt( size_t nDescNo
, bool bInHeader
);
650 // is point of cursor in header/footer. pbInHeader return true if it is
651 // in a headerframe otherwise in a footerframe
652 bool IsInHeaderFooter( bool* pbInHeader
= nullptr ) const;
654 bool GotoNextTOXBase( const OUString
* = nullptr );
655 bool GotoPrevTOXBase( const OUString
* = nullptr );
656 bool GotoTOXMarkBase();
657 // jump to the next or previous index entry
658 bool GotoNxtPrvTOXMark( bool bNext
= true );
659 // jump to the next/previous index mark of this type
660 const SwTOXMark
& GotoTOXMark( const SwTOXMark
& rStart
, SwTOXSearch eDir
);
662 // jump to the next or previous table formula
663 // optionally only to broken formulas
664 bool GotoNxtPrvTableFormula( bool bNext
= true,
665 bool bOnlyErrors
= false );
666 // jump to the next / previous hyperlink - inside text and also
668 bool SelectNxtPrvHyperlink( bool bNext
);
670 bool GotoRefMark( const OUString
& rRefMark
, sal_uInt16 nSubType
,
673 // get the nth character from the start or end of the current selection
674 sal_Unicode
GetChar( bool bEnd
= true, long nOffset
= 0 );
675 bool ExtendSelection( bool bEnd
= true, sal_Int32 nCount
= 1 );
677 // Place only the visible cursor at the given position in the document.
678 // Return false if SPoint was corrected by layout.
679 // (This is needed for displaying the Drag&Drop/Copy-Cursor.)
680 bool SetVisibleCursor( const Point
&rPt
);
681 inline void UnSetVisibleCursor();
683 // jump to the next or previous field of the corresponding type
685 const SwFieldType
* pFieldType
,
687 const SwFieldIds nResType
= SwFieldIds::Unknown
,
688 const bool bAddSetExpressionFieldsToInputFields
= true );
690 bool GotoFormatField( const SwFormatField
& rField
);
692 static SwTextField
* GetTextFieldAtPos(
693 const SwPosition
* pPos
,
694 const bool bIncludeInputFieldAtStart
);
695 static SwField
* GetFieldAtCursor(
696 const SwPaM
* pCursor
,
697 const bool bIncludeInputFieldAtStart
);
698 SwField
* GetCurField( const bool bIncludeInputFieldAtStart
= false ) const;
699 bool CursorInsideInputField() const;
700 static bool PosInsideInputField( const SwPosition
& rPos
);
701 bool DocPtInsideInputField( const Point
& rDocPt
) const;
702 static sal_Int32
StartOfInputFieldAtPos( const SwPosition
& rPos
);
703 static sal_Int32
EndOfInputFieldAtPos( const SwPosition
& rPos
);
705 // Return number of cursors in ring (The flag indicates whether
706 // only cursors containing selections are requested).
707 sal_uInt16
GetCursorCnt( bool bAll
= true ) const;
709 // Char Travelling - methods (in crstrvl1.cxx)
714 bool GoNextSentence();
715 bool GoStartSentence();
716 bool GoEndSentence();
717 bool SelectWord( const Point
* pPt
);
718 bool ExpandToSentenceBorders();
720 // get position from current cursor
721 bool IsStartWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
)const;
722 bool IsEndWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
723 bool IsInWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
724 bool IsStartSentence() const;
725 bool IsEndSentence() const;
726 bool IsSttPara() const;
727 bool IsEndPara() const;
728 bool IsEndOfTable() const; ///< at the very last SwPosition inside a table
729 bool IsStartOfDoc() const;
730 bool IsEndOfDoc() const;
731 bool IsInFrontOfLabel() const;
732 bool IsAtLeftMargin() const { return IsAtLRMargin( true ); }
733 bool IsAtRightMargin() const { return IsAtLRMargin( false, true/*bAPI*/ ); }
735 // delete all created cursors, set the table cursor and the last cursor to
736 // its TextNode (or StartNode?)
737 // They all get created on the next ::GetCursor again
738 // Used for Drag&Drop/Clipboard-Paste in tables
739 bool ParkTableCursor();
741 // Non expanded attributes?
742 bool IsGCAttr() const { return m_bGCAttr
; }
743 void ClearGCAttr() { m_bGCAttr
= false; }
744 void UpdateAttr() { m_bGCAttr
= true; }
746 // is the whole document protected/hidden (for UI...)
747 bool IsAllProtect() const { return m_bAllProtect
; }
749 bool GotoRegion( const OUString
& rName
);
751 // show the current selection
752 virtual void MakeSelVisible();
754 // set the cursor to a NOT protected/hidden node
755 bool FindValidContentNode( bool bOnlyText
);
757 bool GetContentAtPos( const Point
& rPt
,
758 SwContentAtPos
& rContentAtPos
,
759 bool bSetCursor
= false,
760 SwRect
* pFieldRect
= nullptr );
762 const SwPostItField
* GetPostItFieldAtCursor() const;
764 // get smart tags rectangle for the given point
765 void GetSmartTagRect( const Point
& rPt
, SwRect
& rSelectRect
);
767 // get smart tags at current cursor position
768 void GetSmartTagTerm( std::vector
< OUString
>& rSmartTagTypes
,
769 css::uno::Sequence
< css::uno::Reference
< css::container::XStringKeyMap
> >& rStringKeyMaps
,
770 css::uno::Reference
<css::text::XTextRange
>& rRange
) const;
772 bool IsPageAtPos( const Point
&rPt
) const;
774 bool SelectTextAttr( sal_uInt16 nWhich
, bool bExpand
, const SwTextAttr
* pAttr
= nullptr );
775 bool GotoINetAttr( const SwTextINetFormat
& rAttr
);
776 const SwFormatINetFormat
* FindINetAttr( const OUString
& rName
) const;
778 bool SelectText( const sal_Int32 nStart
,
779 const sal_Int32 nEnd
);
781 bool CheckTableBoxContent( const SwPosition
* pPos
= nullptr );
782 void SaveTableBoxContent( const SwPosition
* pPos
= nullptr );
783 void ClearTableBoxContent();
784 bool EndAllTableBoxEdit();
786 void SetSelTableCells( bool bFlag
) { m_bSelTableCells
= bFlag
; }
787 bool IsSelTableCells() const { return m_bSelTableCells
; }
789 bool IsAutoUpdateCells() const { return m_bAutoUpdateCells
; }
790 void SetAutoUpdateCells( bool bFlag
) { m_bAutoUpdateCells
= bFlag
; }
792 bool GetShadowCursorPos( const Point
& rPt
, SwFillMode eFillMode
,
793 SwRect
& rRect
, short& rOrient
);
794 bool SetShadowCursorPos( const Point
& rPt
, SwFillMode eFillMode
);
796 const SwRangeRedline
* SelNextRedline();
797 const SwRangeRedline
* SelPrevRedline();
798 const SwRangeRedline
* GotoRedline( SwRedlineTable::size_type nArrPos
, bool bSelect
);
800 // is cursor or the point in/over a vertical formatted text?
801 bool IsInVerticalText( const Point
* pPt
= nullptr ) const;
802 // is cursor or the point in/over a right to left formatted text?
803 bool IsInRightToLeftText() const;
805 static void FirePageChangeEvent(sal_uInt16 nOldPage
, sal_uInt16 nNewPage
);
806 bool bColumnChange();
807 static void FireSectionChangeEvent(sal_uInt16 nOldSection
, sal_uInt16 nNewSection
);
808 static void FireColumnChangeEvent(sal_uInt16 nOldColumn
, sal_uInt16 nNewColumn
);
809 // If the current cursor position is inside a hidden range, the hidden range
810 // is selected and true is returned:
811 bool SelectHiddenRange();
813 // remove all invalid cursors
814 void ClearUpCursors();
816 void SetMacroExecAllowed( const bool _bMacroExecAllowed
)
818 m_bMacroExecAllowed
= _bMacroExecAllowed
;
820 bool IsMacroExecAllowed()
822 return m_bMacroExecAllowed
;
826 Returns textual description of the current selection.
828 - If the current selection is a multi-selection the result is
830 - Else the result is the text of the selection.
832 @return the textual description of the current selection
834 OUString
GetCursorDescr() const;
836 virtual void dumpAsXml(struct _xmlTextWriter
* pWriter
) const override
;
837 /// Implementation of lok::Document::getPartPageRectangles() for Writer.
838 OUString
getPageRectangles();
840 /// See SwView::NotifyCursor().
841 void NotifyCursor(SfxViewShell
* pViewShell
) const;
845 inline SwMoveFnCollection
const & SwCursorShell::MakeFindRange(
846 SwDocPositions nStt
, SwDocPositions nEnd
, SwPaM
* pPam
) const
848 return m_pCurrentCursor
->MakeFindRange( nStt
, nEnd
, pPam
);
851 inline SwCursor
* SwCursorShell::GetSwCursor() const
853 return static_cast<SwCursor
*>(GetCursor());
856 inline SwPaM
* SwCursorShell::GetStackCursor() const { return m_pStackCursor
; }
858 inline void SwCursorShell::SetMark() { m_pCurrentCursor
->SetMark(); }
860 inline bool SwCursorShell::HasMark() { return( m_pCurrentCursor
->HasMark() ); }
862 inline bool SwCursorShell::IsSelection() const
864 return IsTableMode() || m_pCurrentCursor
->HasMark() ||
865 m_pCurrentCursor
->GetNext() != m_pCurrentCursor
;
867 inline bool SwCursorShell::IsMultiSelection() const
869 return m_pCurrentCursor
->GetNext() != m_pCurrentCursor
;
872 inline bool SwCursorShell::IsSelOnePara() const
874 return !m_pCurrentCursor
->IsMultiSelection() &&
875 m_pCurrentCursor
->GetPoint()->nNode
== m_pCurrentCursor
->GetMark()->nNode
;
878 inline const SwTableNode
* SwCursorShell::IsCursorInTable() const
880 return m_pCurrentCursor
->GetNode().FindTableNode();
883 inline bool SwCursorShell::IsCursorPtAtEnd() const
885 return m_pCurrentCursor
->End() == m_pCurrentCursor
->GetPoint();
888 inline Point
& SwCursorShell::GetCursorDocPos() const
890 return m_pCurrentCursor
->GetPtPos();
893 inline const SwPaM
* SwCursorShell::GetTableCrs() const
895 return m_pTableCursor
;
898 inline SwPaM
* SwCursorShell::GetTableCrs()
900 return m_pTableCursor
;
903 inline void SwCursorShell::UnSetVisibleCursor()
905 m_pVisibleCursor
->Hide();
906 m_pVisibleCursor
->SetDragCursor( false );
909 #endif // _CRSRSH_HXX
911 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */