nss: upgrade to release 3.73
[LibreOffice.git] / sw / inc / crsrsh.hxx
blobdaf77e04c760c3f4ae5fe692508ebd00b275efc3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
30 #include "swdllapi.h"
31 #include "docary.hxx"
32 #include "viewsh.hxx"
33 #include "calbck.hxx"
34 #include "cshtyp.hxx"
35 #include "crstate.hxx"
36 #include "toxe.hxx"
37 #include "tblsel.hxx"
38 #include "viscrs.hxx"
39 #include "node.hxx"
40 #include "fldbas.hxx"
41 #include "IDocumentMarkAccess.hxx"
43 class SfxItemSet;
44 class SfxPoolItem;
45 class SwContentFrame;
46 class SwUnoCursor;
47 class SwFormatField;
48 class SwTextFormatColl;
49 class SwTextINetFormat;
50 class SwFormatINetFormat;
51 class SwTextAttr;
52 class SwTableBox;
53 class SwTOXMark;
54 class SwRangeRedline;
55 class SwBlockCursor;
56 class SwPostItField;
57 class SwTextField;
59 namespace i18nutil {
60 struct SearchOptions2;
62 namespace com::sun::star::text { class XTextRange; }
63 namespace com::sun::star::container { class XStringKeyMap; }
65 // enum and struct to get information via the Doc-Position
67 enum class IsAttrAtPos
69 NONE = 0x0000,
70 Field = 0x0001,
71 ClickField = 0x0002,
72 Ftn = 0x0004,
73 InetAttr = 0x0008,
74 TableBoxFml = 0x0010,
75 Redline = 0x0020,
76 Outline = 0x0040,
77 ToxMark = 0x0080,
78 RefMark = 0x0100,
79 NumLabel = 0x0200,
80 ContentCheck = 0x0400,
81 SmartTag = 0x0800,
82 FormControl = 0x1000
83 #ifdef DBG_UTIL
84 ,CurrAttrs = 0x2000 ///< only for debugging
85 ,TableBoxValue = 0x4000 ///< only for debugging
86 #endif
88 namespace o3tl {
89 template<> struct typed_flags<IsAttrAtPos> : is_typed_flags<IsAttrAtPos, 0x7fff> {};
92 struct SwContentAtPos
94 union {
95 const SwField* pField;
96 const SfxPoolItem* pAttr;
97 const SwRangeRedline* pRedl;
98 SwContentNode * pNode;
99 const sw::mark::IFieldmark* pFieldmark;
100 } aFnd;
101 IsAttrAtPos eContentAtPos;
102 int nDist;
103 OUString sStr;
104 const SwTextAttr* pFndTextAttr;
106 SwContentAtPos( IsAttrAtPos eGetAtPos )
107 : eContentAtPos( eGetAtPos )
109 aFnd.pField = nullptr;
110 pFndTextAttr = nullptr;
111 nDist = 0; // #i23726#
114 bool IsInProtectSect() const;
115 bool IsInRTLText() const;
118 // return values of SetCursor (can be combined via ||)
119 const int CRSR_POSOLD = 0x01, // cursor stays at old position
120 CRSR_POSCHG = 0x02; // position changed by the layout
122 namespace sw {
124 bool ReplaceImpl(SwPaM & rCursor, OUString const& rReplacement,
125 bool const bRegExp, SwDoc & rDoc, SwRootFrame const*const pLayout);
127 /// Helperfunction to resolve backward references in regular expressions
128 std::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
129 SwPaM* pPam, SwRootFrame const* pLayout );
131 bool GetRanges(std::vector<std::shared_ptr<SwUnoCursor>> & rRanges,
132 SwDoc & rDoc, SwPaM const& rDelPam);
134 } // namespace sw
136 class SW_DLLPUBLIC SwCursorShell
137 : public SwViewShell
138 , public sw::BroadcastingModify
139 , public ::sw::IShellCursorSupplier
141 friend class SwCallLink;
142 friend class SwVisibleCursor;
143 friend class SwSelPaintRects;
145 // requires the Cursor as InternalCursor
146 friend bool GetAutoSumSel( const SwCursorShell&, SwCellFrames& );
148 public:
150 /** for calling UpdateCursor */
151 enum CursorFlag {
152 UPDOWN = (1 << 0), ///< keep Up/Down on columns
153 SCROLLWIN = (1 << 1), ///< scroll window
154 CHKRANGE = (1 << 2), ///< check overlapping PaMs
155 READONLY = (1 << 3) ///< make visible in spite of Readonly
158 SAL_DLLPRIVATE void UpdateCursor(
159 sal_uInt16 eFlags = SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE,
160 bool bIdleEnd = false );
162 private:
164 SwRect m_aCharRect; ///< Char-SRectangle on which the cursor is located
165 Point m_aCursorHeight; ///< height & offset from visible Cursor
166 Point m_aOldRBPos; ///< Right/Bottom of last VisArea
167 // (used in Invalidate by Cursor)
169 Link<const SwFlyFrameFormat*,void> m_aFlyMacroLnk; /**< Link will be called, if the Cursor is set
170 into a fly. A macro can then be called */
171 Link<LinkParamNone*,void> m_aChgLnk; /**< link will be called by every attribute/
172 format changes at cursor position.*/
173 Link<SwCursorShell&,void> m_aGrfArrivedLnk; ///< Link calls to UI if a graphic is arrived
175 SwShellCursor* m_pCurrentCursor; ///< current cursor
176 SwShellCursor* m_pStackCursor; ///< stack for the cursor
177 SwVisibleCursor *m_pVisibleCursor; ///< the visible cursor
179 SwBlockCursor *m_pBlockCursor; ///< interface of cursor for block (=rectangular) selection
181 SwShellTableCursor* m_pTableCursor; /**< table Cursor; only in tables when the
182 selection lays over 2 columns */
184 SwNodeIndex* m_pBoxIdx; ///< for recognizing of the changed
185 SwTableBox* m_pBoxPtr; ///< table row
187 tools::Long m_nUpDownX; /**< try to move the cursor on up/down always
188 in the same column */
189 tools::Long m_nLeftFramePos;
190 sal_uLong m_nCurrentNode; // save CursorPos at Start-Action
191 sal_Int32 m_nCurrentContent;
192 SwNodeType m_nCurrentNdTyp;
195 * Via the Method SttCursorMove and EndCursorMove this counter gets
196 * incremented/decremented. As long as the counter is inequal to 0, the
197 * current Cursor gets no update. This way, "complicated" cursor movements
198 * (via Find()) can be realised.
200 sal_uInt16 m_nCursorMove;
201 CursorMoveState m_eMvState; ///< Status for Cursor-Travelling - GetModelPositionForViewPoint
202 SwTable::SearchType m_eEnhancedTableSel; /// table rows or columns selected by not cell by cell
204 OUString m_sMarkedListId;
205 int m_nMarkedListLevel;
207 bool m_bHasFocus : 1; ///< Shell is "active" in a window
208 bool m_bSVCursorVis : 1; ///< SV-Cursor visible/invisible
209 bool m_bChgCallFlag : 1; ///< attribute change inside Start- and EndAction
210 bool m_bVisPortChgd : 1; ///< in VisPortChg-Call
211 // (used in Invalidate by the Cursor)
213 bool m_bCallChgLnk : 1; ///< flag for derived classes
214 // true -> call ChgLnk
215 // access only via SwChgLinkFlag
216 bool m_bAllProtect : 1; ///< Flag for areas
217 // true -> everything protected / hidden
218 bool m_bInCMvVisportChgd : 1; ///< Flag for CursorMoves
219 // true -> view was moved
220 bool m_bGCAttr : 1; // true -> non expanded attributes exist.
221 bool m_bIgnoreReadonly : 1; // true -> make the cursor visible on next
222 // EndAction in spite of Readonly
223 bool m_bSelTableCells : 1; // true -> select cells over the InputWin
224 bool m_bAutoUpdateCells : 1; // true -> autoformat cells
225 bool m_bBasicHideCursor : 1; // true -> HideCursor from Basic
226 bool m_bSetCursorInReadOnly : 1;// true -> Cursor is allowed in ReadOnly-Areas
227 bool m_bOverwriteCursor : 1; // true -> show Overwrite Cursor
229 bool m_bMacroExecAllowed : 1;
231 SwFrame* m_oldColFrame;
233 SAL_DLLPRIVATE void MoveCursorToNum();
235 SAL_DLLPRIVATE void ParkPams( SwPaM* pDelRg, SwShellCursor** ppDelRing );
237 /** Mark a certain list level of a certain list
239 levels of a certain lists are marked now
241 @param sListId list Id of the list whose level is marked
242 @param nLevel to be marked list level
244 An empty sListId denotes that no level of a list is marked.
246 SAL_DLLPRIVATE void MarkListLevel( const OUString& sListId,
247 const int nLevel );
249 // private method(s) accessed from public inline method(s) must be exported.
250 bool LeftRight( bool, sal_uInt16, sal_uInt16, bool );
251 SAL_DLLPRIVATE bool UpDown( bool, sal_uInt16 );
252 SAL_DLLPRIVATE bool LRMargin( bool, bool bAPI = false );
253 SAL_DLLPRIVATE bool IsAtLRMargin( bool, bool bAPI = false ) const;
255 SAL_DLLPRIVATE bool isInHiddenTextFrame(SwShellCursor* pShellCursor);
257 SAL_DLLPRIVATE bool GoStartWordImpl();
258 SAL_DLLPRIVATE bool GoEndWordImpl();
259 SAL_DLLPRIVATE bool GoNextWordImpl();
260 SAL_DLLPRIVATE bool GoPrevWordImpl();
261 SAL_DLLPRIVATE bool GoNextSentenceImpl();
262 SAL_DLLPRIVATE bool GoEndSentenceImpl();
263 SAL_DLLPRIVATE bool GoStartSentenceImpl();
265 typedef bool (SwCursor::*FNCursor)();
266 typedef bool (SwCursorShell::*FNCursorShell)();
267 SAL_DLLPRIVATE bool CallCursorFN( FNCursor );
268 SAL_DLLPRIVATE bool CallCursorShellFN( FNCursorShell );
270 SAL_DLLPRIVATE const SwRangeRedline* GotoRedline_( SwRedlineTable::size_type nArrPos, bool bSelect );
272 SAL_DLLPRIVATE void sendLOKCursorUpdates();
273 protected:
275 inline SwMoveFnCollection const & MakeFindRange( SwDocPositions, SwDocPositions, SwPaM* ) const;
278 * Compare-Method for the StackCursor and the current Cursor.
279 * The Methods return -1, 0, 1 for lower, equal, greater.
281 int CompareCursorStackMkCurrPt() const;
283 bool SelTableRowOrCol( bool bRow, bool bRowSimple = false );
285 bool SetInFrontOfLabel( bool bNew );
287 void RefreshBlockCursor();
289 /** Updates the marked list level according to the cursor.
291 SAL_DLLPRIVATE void UpdateMarkedListLevel();
293 protected:
294 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
296 public:
297 SwCursorShell( SwDoc& rDoc, vcl::Window *pWin, const SwViewOption *pOpt );
298 // disguised copy constructor
299 SwCursorShell( SwCursorShell& rShell, vcl::Window *pWin );
300 virtual ~SwCursorShell() override;
302 // create new cursor and append the old one
303 virtual SwPaM & CreateNewShellCursor() override;
304 virtual SwPaM & GetCurrentShellCursor() override;
306 SwPaM * CreateCursor();
307 ///< delete the current cursor and make the following into the current
308 void DestroyCursor();
309 ///< transform TableCursor to normal cursor, nullify Tablemode
310 void TableCursorToCursor();
311 ///< enter block mode, change normal cursor into block cursor
312 void CursorToBlockCursor();
313 ///< leave block mode, change block cursor into normal cursor
314 void BlockCursorToCursor();
316 // SelAll() selects the document body content
317 // if ExtendedSelect() is called afterwards, the whole nodes array is selected
318 // only for usage in special cases allowed!
319 void ExtendedSelectAll(bool bFootnotes = true);
320 /// If ExtendedSelectAll() was called and selection didn't change since then.
321 bool ExtendedSelectedAll();
322 /// If document body starts with a table.
323 bool StartsWithTable();
325 SwPaM* GetCursor( bool bMakeTableCursor = true ) const;
326 inline SwCursor* GetSwCursor() const;
327 // return only the current cursor
328 SwShellCursor* GetCursor_() { return m_pCurrentCursor; }
329 const SwShellCursor* GetCursor_() const { return m_pCurrentCursor; }
331 // show passed cursor - for UNO
332 void SetSelection(const SwPaM& rCursor);
334 // remove all cursors from ContentNodes and set to 0
335 void ParkCursor( const SwNodeIndex &rIdx );
337 // return the current cursor stack
338 // (required in EditShell when deleting contents)
339 inline SwPaM* GetStackCursor() const;
341 // start parenthesing, hide SV-Cursor and selected areas
342 void StartAction();
343 // end parenthesing, show SV-Cursor and selected areas
344 void EndAction( const bool bIdleEnd = false );
346 // basic cursor travelling
347 tools::Long GetUpDownX() const { return m_nUpDownX; }
349 bool Left( sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual = false )
350 { return LeftRight( true, nCnt, nMode, bAllowVisual ); }
351 bool Right( sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual = false )
352 { return LeftRight( false, nCnt, nMode, bAllowVisual ); }
353 bool Up( sal_uInt16 nCnt = 1 ) { return UpDown( true, nCnt ); }
354 bool Down( sal_uInt16 nCnt = 1 ) { return UpDown( false, nCnt ); }
355 bool LeftMargin() { return LRMargin( true ); }
356 bool RightMargin(bool bAPI = false) { return LRMargin( false, bAPI ); }
357 bool SttEndDoc( bool bStt );
359 bool MovePage( SwWhichPage, SwPosPage );
360 bool MovePara( SwWhichPara, SwMoveFnCollection const & );
361 bool MoveSection( SwWhichSection, SwMoveFnCollection const & );
362 bool MoveTable( SwWhichTable, SwMoveFnCollection const & );
363 void MoveColumn( SwWhichColumn, SwPosColumn );
364 bool MoveRegion( SwWhichRegion, SwMoveFnCollection const & );
366 // note: DO NOT call it FindText because windows.h
367 sal_uLong Find_Text( const i18nutil::SearchOptions2& rSearchOpt,
368 bool bSearchInNotes,
369 SwDocPositions eStart, SwDocPositions eEnd,
370 bool& bCancel,
371 FindRanges eRng, bool bReplace = false );
373 sal_uLong FindFormat( const SwTextFormatColl& rFormatColl,
374 SwDocPositions eStart, SwDocPositions eEnd,
375 bool& bCancel,
376 FindRanges eRng, const SwTextFormatColl* pReplFormat );
378 sal_uLong FindAttrs( const SfxItemSet& rSet, bool bNoCollections,
379 SwDocPositions eStart, SwDocPositions eEnd,
380 bool& bCancel,
381 FindRanges eRng,
382 const i18nutil::SearchOptions2* pSearchOpt,
383 const SfxItemSet* rReplSet );
385 // Position the Cursor
386 // return values:
387 // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
388 // CRSR_POSOLD: when the cursor was not changed
389 int SetCursor( const Point &rPt, bool bOnlyText = false, bool bBlock = true );
392 * Notification that the visible area was changed. m_aVisArea is reset, then
393 * scrolling is done. The passed Rectangle lays on pixel borders to avoid
394 * pixel errors.
396 virtual void VisPortChgd( const SwRect & ) override;
399 * virtual paint method to make selection visible again after Paint
401 void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle & rRect) override;
403 // Areas
404 inline void SetMark();
405 inline bool HasMark() const;
407 void ClearMark();
410 Ensure point and mark of the current PaM are in a specific order.
412 @param bPointFirst true: If the point is behind the mark then
413 swap the PaM. false: If the mark is behind the point then swap
414 the PaM.
416 void NormalizePam(bool bPointFirst = true);
418 void SwapPam();
419 bool TestCurrPam( const Point & rPt,
420 bool bTstHit = false); // only exact matches
421 void KillPams();
423 /// store a copy of the current cursor on the cursor stack
424 void Push();
425 enum class PopMode { DeleteCurrent, DeleteStack };
427 * Delete a cursor
428 * - either from the top of the stack
429 * - or delete the current one and replace it with the cursor from the
430 * stack
431 * @return <true> if there was one on the stack, <false> otherwise
433 bool Pop(PopMode);
435 * Combine 2 Cursors.
436 * Delete the topmost from the stack and move its Mark into the current.
438 void Combine();
440 void SttCursorMove();
441 void EndCursorMove( const bool bIdleEnd = false );
444 * When the focus is lost the selected ranges are not displayed anymore.
445 * On the other hand, on receiving the focus all selected ranges are displayed again
446 * (ranges must be recalculated!).
448 bool HasShellFocus() const { return m_bHasFocus; }
449 void ShellLoseFocus();
450 void ShellGetFocus();
452 // Methods for displaying or hiding the visible text cursor.
453 void ShowCursor();
454 void HideCursor();
455 // Methods for displaying or hiding the selected ranges with visible cursor.
456 void ShowCursors( bool bCursorVis );
457 void HideCursors();
459 bool IsOverwriteCursor() const { return m_bOverwriteCursor; }
460 void SetOverwriteCursor( bool bFlag ) { m_bOverwriteCursor = bFlag; }
462 // Return current frame in which the cursor is placed.
463 SwContentFrame *GetCurrFrame( const bool bCalcFrame = true ) const;
465 //true if cursor is hidden because of readonly.
466 //false if it is working despite readonly.
467 bool IsCursorReadonly() const;
469 // Cursor is placed in something that is protected or selection contains
470 // something that is protected.
471 bool HasReadonlySel() const;
473 // Can the cursor be set to read only ranges?
474 bool IsReadOnlyAvailable() const { return m_bSetCursorInReadOnly; }
475 void SetReadOnlyAvailable( bool bFlag );
476 bool IsOverReadOnlyPos( const Point& rPt ) const;
478 // Methods for aFlyMacroLnk.
479 void SetFlyMacroLnk( const Link<const SwFlyFrameFormat*,void>& rLnk ) { m_aFlyMacroLnk = rLnk; }
480 const Link<const SwFlyFrameFormat*,void>& GetFlyMacroLnk() const { return m_aFlyMacroLnk; }
482 // Methods returning/altering link for changes of attributes/formats.
483 void SetChgLnk( const Link<LinkParamNone*,void> &rLnk ) { m_aChgLnk = rLnk; }
484 const Link<LinkParamNone*,void>& GetChgLnk() const { return m_aChgLnk; }
486 // Methods returning/altering link for "graphic completely loaded".
487 void SetGrfArrivedLnk( const Link<SwCursorShell&,void> &rLnk ) { m_aGrfArrivedLnk = rLnk; }
488 const Link<SwCursorShell&,void>& GetGrfArrivedLnk() const { return m_aGrfArrivedLnk; }
490 //Call ChgLink. When within an action calling will be delayed.
491 void CallChgLnk();
493 // Check if the current cursor contains a selection, i.e.
494 // if Mark is set and SPoint and Mark are different.
495 bool HasSelection() const;
497 // Check if a selection exists, i.e. if the current cursor comprises a selection.
498 inline bool IsSelection() const;
499 // returns if multiple cursors are available
500 inline bool IsMultiSelection() const;
502 // Check if a complete paragraph was selected.
503 bool IsSelFullPara() const;
505 // Check if selection is within one paragraph.
507 //Should WaitPtr be activated for Clipboard.
508 bool ShouldWait() const;
510 // Check if selection is within one paragraph.
511 bool IsSelOnePara() const;
514 * Returns SRectangle, at which the cursor is located.
516 const SwRect &GetCharRect() const { return m_aCharRect; }
518 * Returns if cursor is wholly or partly within visible range.
520 bool IsCursorVisible() const { return VisArea().IsOver( GetCharRect() ); }
522 * Returns SwRect, at which the character is located.
524 void GetCharRectAt(SwRect& rRect, const SwPosition* pPos);
526 // Return current page number:
527 // true: in which cursor is located.
528 // false: which is visible at the upper margin.
529 void GetPageNum( sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum,
530 bool bAtCursorPos = true, const bool bCalcFrame = true );
531 // Returns current page's sequential number (1-based),in which cursor is located, ignoring autoinserted empty pages.
532 // Returns 0 on error
533 sal_uInt16 GetPageNumSeqNonEmpty();
534 // Determine how "empty pages" are handled
535 // (used in PhyPage).
536 sal_uInt16 GetNextPrevPageNum( bool bNext = true );
538 // Move cursor at the beginning of page "nPage".
539 bool GotoPage( sal_uInt16 nPage );
541 sal_uInt16 GetPageCnt();
543 bool GoNextCursor();
545 bool GoPrevCursor();
547 bool GoNextPrevCursorSetSearchLabel(const bool bNext);
549 // at CurrentCursor.SPoint
550 ::sw::mark::IMark* SetBookmark(
551 const vcl::KeyCode&,
552 const OUString& rName,
553 IDocumentMarkAccess::MarkType eMark = IDocumentMarkAccess::MarkType::BOOKMARK);
554 ::sw::mark::IMark* SetBookmark2(
555 const vcl::KeyCode&,
556 const OUString& rName,
557 bool bHide,
558 const OUString& rCondition);
559 bool GotoMark( const ::sw::mark::IMark* const pMark ); // sets CurrentCursor.SPoint
560 bool GotoMark( const ::sw::mark::IMark* const pMark, bool bAtStart );
561 bool GoNextBookmark(); // true, if there was one
562 bool GoPrevBookmark();
564 bool IsFormProtected();
565 ::sw::mark::IFieldmark* GetCurrentFieldmark();
566 ::sw::mark::IFieldmark* GetFieldmarkAfter();
567 ::sw::mark::IFieldmark* GetFieldmarkBefore();
568 bool GotoFieldmark( const ::sw::mark::IFieldmark* const pMark );
570 // update Cursr, i.e. reset it into content should only be called when the
571 // cursor was set to a random position e.g. when deleting frames
572 void UpdateCursorPos();
574 // get the selected text at the current cursor. It will be filled with
575 // fields etc.
576 OUString GetSelText() const;
578 // Check of SPoint or Mark of current cursor are placed within a table.
579 inline const SwTableNode* IsCursorInTable() const;
581 bool IsCursorInFootnote() const;
583 inline Point& GetCursorDocPos() const;
584 inline bool IsCursorPtAtEnd() const;
586 inline const SwPaM* GetTableCrs() const;
587 inline SwPaM* GetTableCrs();
589 bool IsTableComplexForChart();
590 // get current table selection as text
591 OUString GetBoxNms() const;
593 // set Cursor to the next/previous cell
594 bool GoNextCell( bool bAppendLine = true );
595 bool GoPrevCell();
596 // go to this box (if available and inside of table)
597 bool GotoTable( const OUString& rName );
599 // select a table row, column or box (based on the current cursor)
600 bool SelTableRow() { return SelTableRowOrCol( true ); }
601 bool SelTableCol() { return SelTableRowOrCol( false ); }
602 bool SelTableBox();
604 bool SelTable();
606 void GotoNextNum();
607 void GotoPrevNum();
609 bool GotoOutline( const OUString& rName );
610 // to the next/previous or the given OutlineNode
611 void GotoOutline( SwOutlineNodes::size_type nIdx );
612 // find the "outline position" in the nodes array of the current chapter
613 SwOutlineNodes::size_type GetOutlinePos(sal_uInt8 nLevel = UCHAR_MAX, SwPaM* pPaM = nullptr);
614 // select the given range of OutlineNodes. Optionally including the children
615 // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell)
616 bool MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos,
617 bool bWithChildren, bool bKillPams = true );
619 bool GotoNextOutline();
620 bool GotoPrevOutline();
622 /** Delivers the current shell cursor
624 Some operations have to run on the current cursor ring,
625 some on the m_pTableCursor (if exist) or the current cursor ring and
626 some on the m_pTableCursor or m_pBlockCursor or the current cursor ring.
627 This small function checks the existence and delivers the wished cursor.
629 @param bBlock [bool]
630 if the block cursor is of interest or not
632 @return m_pTableCursor if exist,
633 m_pBlockCursor if exist and of interest (param bBlock)
634 otherwise m_pCurrentCursor
636 SwShellCursor* getShellCursor( bool bBlock );
637 const SwShellCursor* getShellCursor( bool bBlock ) const
638 { return const_cast<SwCursorShell*>(this)->getShellCursor( bBlock ); }
640 bool IsBlockMode() const { return nullptr != m_pBlockCursor; }
642 // is the Cursor in a table and is the selection over 2 columns
643 bool IsTableMode() const { return nullptr != m_pTableCursor; }
645 const SwShellTableCursor* GetTableCursor() const { return m_pTableCursor; }
646 SwShellTableCursor* GetTableCursor() { return m_pTableCursor; }
647 size_t UpdateTableSelBoxes();
649 bool GotoFootnoteText(); ///< jump from content to footnote
650 bool GotoFootnoteAnchor(); ///< jump from footnote to anchor
651 bool GotoPrevFootnoteAnchor();
652 bool GotoNextFootnoteAnchor();
654 void GotoFlyAnchor(); ///< jump from the frame to the anchor
655 bool GotoHeaderText(); ///< jump from the content to the header
656 bool GotoFooterText(); ///< jump from the content to the footer
657 // jump to the header/footer of the given or current PageDesc
658 bool SetCursorInHdFt( size_t nDescNo, bool bInHeader );
659 // is point of cursor in header/footer. pbInHeader return true if it is
660 // in a headerframe otherwise in a footerframe
661 bool IsInHeaderFooter( bool* pbInHeader = nullptr ) const;
663 bool GotoNextTOXBase( const OUString* = nullptr );
664 bool GotoPrevTOXBase( const OUString* = nullptr );
665 void GotoTOXMarkBase();
666 // jump to the next or previous index entry
667 bool GotoNxtPrvTOXMark( bool bNext = true );
668 // jump to the next/previous index mark of this type
669 const SwTOXMark& GotoTOXMark( const SwTOXMark& rStart, SwTOXSearch eDir );
671 // jump to the next or previous table formula
672 // optionally only to broken formulas
673 bool GotoNxtPrvTableFormula( bool bNext = true,
674 bool bOnlyErrors = false );
675 // jump to the next / previous hyperlink - inside text and also
676 // on graphics
677 bool SelectNxtPrvHyperlink( bool bNext );
679 bool GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType,
680 sal_uInt16 nSeqNo );
682 // get the nth character from the start or end of the current selection
683 sal_Unicode GetChar( bool bEnd = true, tools::Long nOffset = 0 );
684 bool ExtendSelection( bool bEnd = true, sal_Int32 nCount = 1 );
686 // Place only the visible cursor at the given position in the document.
687 // Return false if SPoint was corrected by layout.
688 // (This is needed for displaying the Drag&Drop/Copy-Cursor.)
689 bool SetVisibleCursor( const Point &rPt );
690 inline void UnSetVisibleCursor();
691 SwVisibleCursor* GetVisibleCursor() const;
693 // jump to the next or previous field of the corresponding type
694 bool MoveFieldType(
695 const SwFieldType* pFieldType,
696 const bool bNext,
697 const SwFieldIds nResType = SwFieldIds::Unknown,
698 const bool bAddSetExpressionFieldsToInputFields = true );
700 bool GotoFormatField( const SwFormatField& rField );
702 static SwTextField* GetTextFieldAtPos(
703 const SwPosition* pPos,
704 const bool bIncludeInputFieldAtStart );
705 static SwTextField* GetTextFieldAtCursor(
706 const SwPaM* pCursor,
707 const bool bIncludeInputFieldAtStart );
708 static SwField* GetFieldAtCursor(
709 const SwPaM* pCursor,
710 const bool bIncludeInputFieldAtStart );
711 SwField* GetCurField( const bool bIncludeInputFieldAtStart = false ) const;
712 bool CursorInsideInputField() const;
713 static bool PosInsideInputField( const SwPosition& rPos );
714 bool DocPtInsideInputField( const Point& rDocPt ) const;
715 static sal_Int32 StartOfInputFieldAtPos( const SwPosition& rPos );
716 static sal_Int32 EndOfInputFieldAtPos( const SwPosition& rPos );
718 // Return number of cursors in ring (The flag indicates whether
719 // only cursors containing selections are requested).
720 sal_uInt16 GetCursorCnt( bool bAll = true ) const;
722 // Char Travelling - methods (in crstrvl1.cxx)
723 bool GoStartWord();
724 bool GoEndWord();
725 bool GoNextWord();
726 bool GoPrevWord();
727 bool GoNextSentence();
728 bool GoStartSentence();
729 bool GoEndSentence();
730 bool SelectWord( const Point* pPt );
731 void ExpandToSentenceBorders();
733 // get position from current cursor
734 bool IsStartWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES )const;
735 bool IsEndWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
736 bool IsInWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
737 bool IsStartSentence() const;
738 bool IsEndSentence() const;
739 bool IsSttPara() const;
740 bool IsEndPara() const;
741 bool IsEndOfTable() const; ///< at the very last SwPosition inside a table
742 bool IsStartOfDoc() const;
743 bool IsEndOfDoc() const;
744 bool IsInFrontOfLabel() const;
745 bool IsAtLeftMargin() const { return IsAtLRMargin( true ); }
746 bool IsAtRightMargin() const { return IsAtLRMargin( false, true/*bAPI*/ ); }
748 // delete all created cursors, set the table cursor and the last cursor to
749 // its TextNode (or StartNode?)
750 // They all get created on the next ::GetCursor again
751 // Used for Drag&Drop/Clipboard-Paste in tables
752 bool ParkTableCursor();
754 // Non expanded attributes?
755 bool IsGCAttr() const { return m_bGCAttr; }
756 void ClearGCAttr() { m_bGCAttr = false; }
757 void UpdateAttr() { m_bGCAttr = true; }
759 // is the whole document protected/hidden (for UI...)
760 bool IsAllProtect() const { return m_bAllProtect; }
762 bool GotoRegion( const OUString& rName );
764 // show the current selection
765 virtual void MakeSelVisible();
767 // set the cursor to a NOT protected/hidden node
768 bool FindValidContentNode( bool bOnlyText );
770 bool GetContentAtPos( const Point& rPt,
771 SwContentAtPos& rContentAtPos,
772 bool bSetCursor = false,
773 SwRect* pFieldRect = nullptr );
775 const SwPostItField* GetPostItFieldAtCursor() const;
777 // get smart tags rectangle for the given point
778 void GetSmartTagRect( const Point& rPt, SwRect& rSelectRect );
780 // get smart tags at current cursor position
781 void GetSmartTagTerm( std::vector< OUString >& rSmartTagTypes,
782 css::uno::Sequence< css::uno::Reference< css::container::XStringKeyMap > >& rStringKeyMaps,
783 css::uno::Reference<css::text::XTextRange>& rRange ) const;
785 bool IsPageAtPos( const Point &rPt ) const;
787 bool SelectTextAttr( sal_uInt16 nWhich, bool bExpand, const SwTextAttr* pAttr = nullptr );
788 bool GotoINetAttr( const SwTextINetFormat& rAttr );
789 const SwFormatINetFormat* FindINetAttr( const OUString& rName ) const;
791 bool SelectText( const sal_Int32 nStart,
792 const sal_Int32 nEnd );
794 bool CheckTableBoxContent( const SwPosition* pPos = nullptr );
795 void SaveTableBoxContent( const SwPosition* pPos = nullptr );
796 void ClearTableBoxContent();
797 bool EndAllTableBoxEdit();
799 void SetSelTableCells( bool bFlag ) { m_bSelTableCells = bFlag; }
800 bool IsSelTableCells() const { return m_bSelTableCells; }
802 void UnsetEnhancedTableSelection() { m_eEnhancedTableSel = SwTable::SEARCH_NONE; }
803 SwTable::SearchType GetEnhancedTableSelection() const { return m_eEnhancedTableSel; }
805 bool IsAutoUpdateCells() const { return m_bAutoUpdateCells; }
806 void SetAutoUpdateCells( bool bFlag ) { m_bAutoUpdateCells = bFlag; }
808 bool GetShadowCursorPos( const Point& rPt, SwFillMode eFillMode,
809 SwRect& rRect, sal_Int16& rOrient );
810 bool SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode );
812 const SwRangeRedline* SelNextRedline();
813 const SwRangeRedline* SelPrevRedline();
814 const SwRangeRedline* GotoRedline( SwRedlineTable::size_type nArrPos, bool bSelect );
816 SAL_DLLPRIVATE SvxFrameDirection GetTextDirection( const Point* pPt = nullptr ) const;
817 // is cursor or the point in/over a vertical formatted text?
818 bool IsInVerticalText( const Point* pPt = nullptr ) const;
819 // is cursor or the point in/over a right to left formatted text?
820 bool IsInRightToLeftText() const;
822 static void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage);
823 bool bColumnChange();
824 static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection);
825 static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn);
826 // If the current cursor position is inside a hidden range, the hidden range
827 // is selected and true is returned:
828 bool SelectHiddenRange();
830 // remove all invalid cursors
831 void ClearUpCursors();
833 void SetMacroExecAllowed( const bool _bMacroExecAllowed )
835 m_bMacroExecAllowed = _bMacroExecAllowed;
837 bool IsMacroExecAllowed() const
839 return m_bMacroExecAllowed;
843 Returns textual description of the current selection.
845 - If the current selection is a multi-selection the result is
846 STR_MULTISEL.
847 - Else the result is the text of the selection.
849 @return the textual description of the current selection
851 OUString GetCursorDescr() const;
853 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
854 /// Implementation of lok::Document::getPartPageRectangles() for Writer.
855 OUString getPageRectangles();
857 /// See SwView::NotifyCursor().
858 void NotifyCursor(SfxViewShell* pViewShell) const;
861 // Cursor Inlines:
862 inline SwMoveFnCollection const & SwCursorShell::MakeFindRange(
863 SwDocPositions nStt, SwDocPositions nEnd, SwPaM* pPam ) const
865 return m_pCurrentCursor->MakeFindRange( nStt, nEnd, pPam );
868 inline SwCursor* SwCursorShell::GetSwCursor() const
870 return static_cast<SwCursor*>(GetCursor());
873 inline SwPaM* SwCursorShell::GetStackCursor() const { return m_pStackCursor; }
875 inline void SwCursorShell::SetMark() { m_pCurrentCursor->SetMark(); }
877 inline bool SwCursorShell::HasMark() const { return m_pCurrentCursor->HasMark(); }
879 inline bool SwCursorShell::IsSelection() const
881 return IsTableMode() || m_pCurrentCursor->HasMark() ||
882 m_pCurrentCursor->GetNext() != m_pCurrentCursor;
884 inline bool SwCursorShell::IsMultiSelection() const
886 return m_pCurrentCursor->GetNext() != m_pCurrentCursor;
889 inline const SwTableNode* SwCursorShell::IsCursorInTable() const
891 return m_pCurrentCursor->GetNode().FindTableNode();
894 inline bool SwCursorShell::IsCursorPtAtEnd() const
896 return m_pCurrentCursor->End() == m_pCurrentCursor->GetPoint();
899 inline Point& SwCursorShell::GetCursorDocPos() const
901 return m_pCurrentCursor->GetPtPos();
904 inline const SwPaM* SwCursorShell::GetTableCrs() const
906 return m_pTableCursor;
909 inline SwPaM* SwCursorShell::GetTableCrs()
911 return m_pTableCursor;
914 inline void SwCursorShell::UnSetVisibleCursor()
916 m_pVisibleCursor->Hide();
917 m_pVisibleCursor->SetDragCursor( false );
920 #endif // _CRSRSH_HXX
922 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */