LibreOffice Module sw (master) 1
crsrsh.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SW_INC_CRSRSH_HXX
20#define INCLUDED_SW_INC_CRSRSH_HXX
21
22#include <com/sun/star/i18n/WordType.hpp>
23
24#include <rtl/ustring.hxx>
25#include <tools/link.hxx>
26#include <vcl/keycod.hxx>
28
29#ifdef SW_DLLIMPLEMENTATION
30#include <TextFrameIndex.hxx>
31#endif
33#include "swdllapi.h"
34#include "docary.hxx"
35#include "viewsh.hxx"
36#include "calbck.hxx"
37#include "cshtyp.hxx"
38#include "crstate.hxx"
39#include "toxe.hxx"
40#include "tblsel.hxx"
41#include "viscrs.hxx"
42#include "node.hxx"
43#include "fldbas.hxx"
45#include <optional>
46
47class SfxItemSet;
48class SfxPoolItem;
49class SwCallLink;
50class SwContentFrame;
51class SwUnoCursor;
52class SwFormatField;
56class SwTextAttr;
57class SwTableBox;
58class SwTOXMark;
59class SwRangeRedline;
60class SwBlockCursor;
61class SwPostItField;
62class SwTextField;
63class SwTextFootnote;
65
66namespace i18nutil {
67 struct SearchOptions2;
68}
69namespace com::sun::star::text { class XTextRange; }
70namespace com::sun::star::container { class XStringKeyMap; }
71
72// enum and struct to get information via the Doc-Position
73
74enum class IsAttrAtPos
75{
76 NONE = 0x0000,
77 Field = 0x0001,
78 ClickField = 0x0002,
79 Ftn = 0x0004,
80 InetAttr = 0x0008,
81 TableBoxFml = 0x0010,
82 Redline = 0x0020,
83 Outline = 0x0040,
84 ToxMark = 0x0080,
85 RefMark = 0x0100,
86 NumLabel = 0x0200,
87 ContentCheck = 0x0400,
88 SmartTag = 0x0800,
89 FormControl = 0x1000,
90 TableRedline = 0x2000
91#ifdef DBG_UTIL
92 ,CurrAttrs = 0x4000
93 ,TableBoxValue = 0x8000
94#endif
95 , ContentControl = 0x10000
96};
97namespace o3tl {
98 template<> struct typed_flags<IsAttrAtPos> : is_typed_flags<IsAttrAtPos, 0x1ffff> {};
99}
100
102{
103 union {
111 int nDist;
112 OUString sStr;
114
116 : eContentAtPos( eGetAtPos )
117 {
118 aFnd.pField = nullptr;
119 pFndTextAttr = nullptr;
120 nDist = 0; // #i23726#
121 }
122
123 bool IsInProtectSect() const;
124 bool IsInRTLText() const;
125};
126
127// return values of SetCursor (can be combined via ||)
128const int CRSR_POSOLD = 0x01, // cursor stays at old position
129 CRSR_POSCHG = 0x02; // position changed by the layout
130
131namespace sw {
132
133bool ReplaceImpl(SwPaM & rCursor, OUString const& rReplacement,
134 bool const bRegExp, SwDoc & rDoc, SwRootFrame const*const pLayout);
135
137std::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
138 SwPaM* pPam, SwRootFrame const* pLayout );
139
140bool GetRanges(std::vector<std::shared_ptr<SwUnoCursor>> & rRanges,
141 SwDoc & rDoc, SwPaM const& rDelPam);
142
143} // namespace sw
144
146 : public SwViewShell
149{
150 friend class SwCallLink;
151 friend class SwVisibleCursor;
152 friend class SwSelPaintRects;
153
154 // requires the Cursor as InternalCursor
155 friend bool GetAutoSumSel( const SwCursorShell&, SwCellFrames& );
156
157public:
158
161 UPDOWN = (1 << 0),
162 SCROLLWIN = (1 << 1),
163 CHKRANGE = (1 << 2),
164 READONLY = (1 << 3)
165 };
166
167 SAL_DLLPRIVATE void UpdateCursor(
169 bool bIdleEnd = false );
170
171private:
172
176 // (used in Invalidate by Cursor)
177
183
187
189
195
199 SwNodeOffset m_nCurrentNode; // save CursorPos at Start-Action
202
203 /*
204 * Via the Method SttCursorMove and EndCursorMove this counter gets
205 * incremented/decremented. As long as the counter is inequal to 0, the
206 * current Cursor gets no update. This way, "complicated" cursor movements
207 * (via Find()) can be realised.
208 */
209 sal_uInt16 m_nCursorMove;
212
215
216 bool m_bHasFocus : 1;
217 bool m_bSVCursorVis : 1;
218 bool m_bChgCallFlag : 1;
219 bool m_bVisPortChgd : 1;
220 // (used in Invalidate by the Cursor)
221
222 bool m_bCallChgLnk : 1;
223 // true -> call ChgLnk
224 // access only via SwChgLinkFlag
225 bool m_bAllProtect : 1;
226 // true -> everything protected / hidden
228 // true -> view was moved
229 bool m_bGCAttr : 1; // true -> non expanded attributes exist.
230 bool m_bIgnoreReadonly : 1; // true -> make the cursor visible on next
231 // EndAction in spite of Readonly
232 bool m_bSelTableCells : 1; // true -> select cells over the InputWin
233 bool m_bAutoUpdateCells : 1; // true -> autoformat cells
234 bool m_bBasicHideCursor : 1; // true -> HideCursor from Basic
235 bool m_bSetCursorInReadOnly : 1;// true -> Cursor is allowed in ReadOnly-Areas
236 bool m_bOverwriteCursor : 1; // true -> show Overwrite Cursor
237
239
241
242 SAL_DLLPRIVATE void MoveCursorToNum();
243
244 SAL_DLLPRIVATE void ParkPams( SwPaM* pDelRg, SwShellCursor** ppDelRing );
245
255 SAL_DLLPRIVATE void MarkListLevel( const OUString& sListId,
256 const int nLevel );
257
258 // private method(s) accessed from public inline method(s) must be exported.
259 bool LeftRight( bool, sal_uInt16, SwCursorSkipMode, bool );
260 SAL_DLLPRIVATE bool UpDown( bool, sal_uInt16 );
261 SAL_DLLPRIVATE bool LRMargin( bool, bool bAPI = false );
262 SAL_DLLPRIVATE bool IsAtLRMargin( bool, bool bAPI = false ) const;
263
264 SAL_DLLPRIVATE bool isInHiddenTextFrame(SwShellCursor* pShellCursor);
265
266 SAL_DLLPRIVATE bool GoStartWordImpl();
267 SAL_DLLPRIVATE bool GoEndWordImpl();
268 SAL_DLLPRIVATE bool GoNextWordImpl();
269 SAL_DLLPRIVATE bool GoPrevWordImpl();
270 SAL_DLLPRIVATE bool GoNextSentenceImpl();
271 SAL_DLLPRIVATE bool GoEndSentenceImpl();
272 SAL_DLLPRIVATE bool GoStartSentenceImpl();
273
274 typedef bool (SwCursor::*FNCursor)();
275 typedef bool (SwCursorShell::*FNCursorShell)();
276 SAL_DLLPRIVATE bool CallCursorFN( FNCursor );
277 SAL_DLLPRIVATE bool CallCursorShellFN( FNCursorShell );
278
279 SAL_DLLPRIVATE const SwRangeRedline* GotoRedline_( SwRedlineTable::size_type nArrPos, bool bSelect );
280
281 SAL_DLLPRIVATE void sendLOKCursorUpdates();
282protected:
283
284 inline SwMoveFnCollection const & MakeFindRange( SwDocPositions, SwDocPositions, SwPaM* ) const;
285
286 /*
287 * Compare-Method for the StackCursor and the current Cursor.
288 * The Methods return -1, 0, 1 for lower, equal, greater.
289 */
290 int CompareCursorStackMkCurrPt() const;
291
292 bool SelTableRowOrCol( bool bRow, bool bRowSimple = false );
293
294 bool SetInFrontOfLabel( bool bNew );
295
296 void RefreshBlockCursor();
297
300 SAL_DLLPRIVATE void UpdateMarkedListLevel();
301
302protected:
303 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
304
305public:
306 SwCursorShell( SwDoc& rDoc, vcl::Window *pWin, const SwViewOption *pOpt );
307 // disguised copy constructor
308 SwCursorShell( SwCursorShell& rShell, vcl::Window *pWin );
309 virtual ~SwCursorShell() override;
310
311 // create new cursor and append the old one
312 virtual SwCursor & CreateNewShellCursor() override;
313 virtual SwCursor & GetCurrentShellCursor() override;
314
315 SwPaM * CreateCursor();
317 void DestroyCursor();
319 void TableCursorToCursor();
321 void CursorToBlockCursor();
323 void BlockCursorToCursor();
324
325 // SelAll() selects the document body content
326 // if ExtendedSelect() is called afterwards, the whole nodes array is selected
327 // only for usage in special cases allowed!
328 void ExtendedSelectAll(bool bFootnotes = true);
330 bool ExtendedSelectedAll();
332 bool StartsWithTable();
333
334 SwCursor* GetCursor( bool bMakeTableCursor = true ) const;
335 // return only the current cursor
336 SwShellCursor* GetCursor_() { return m_pCurrentCursor; }
337 const SwShellCursor* GetCursor_() const { return m_pCurrentCursor; }
338
339 // show passed cursor - for UNO
340 void SetSelection(const SwPaM& rCursor);
341
342 // remove all cursors from ContentNodes and set to 0
343 void ParkCursor( const SwNode &rIdx );
344
345 // return the current cursor stack
346 // (required in EditShell when deleting contents)
347 inline SwPaM* GetStackCursor() const;
348
349 // start parenthesing, hide SV-Cursor and selected areas
350 void StartAction();
351 // end parenthesing, show SV-Cursor and selected areas
352 void EndAction( const bool bIdleEnd = false );
353
354 // basic cursor travelling
355 tools::Long GetUpDownX() const { return m_nUpDownX; }
356
357 bool Left( sal_uInt16 nCnt, SwCursorSkipMode nMode, bool bAllowVisual = false )
358 { return LeftRight( true, nCnt, nMode, bAllowVisual ); }
359 bool Right( sal_uInt16 nCnt, SwCursorSkipMode nMode, bool bAllowVisual = false )
360 { return LeftRight( false, nCnt, nMode, bAllowVisual ); }
361 bool Up( sal_uInt16 nCnt = 1 ) { return UpDown( true, nCnt ); }
362 bool Down( sal_uInt16 nCnt = 1 ) { return UpDown( false, nCnt ); }
363 bool LeftMargin() { return LRMargin( true ); }
364 bool RightMargin(bool bAPI = false) { return LRMargin( false, bAPI ); }
365 bool SttEndDoc( bool bStt );
366
367 bool MovePage( SwWhichPage, SwPosPage );
368 bool MovePara( SwWhichPara, SwMoveFnCollection const & );
369 bool MoveSection( SwWhichSection, SwMoveFnCollection const & );
370 bool MoveTable( SwWhichTable, SwMoveFnCollection const & );
371 void MoveColumn( SwWhichColumn, SwPosColumn );
372 bool MoveRegion( SwWhichRegion, SwMoveFnCollection const & );
373
374 // note: DO NOT call it FindText because windows.h
375 sal_Int32 Find_Text( const i18nutil::SearchOptions2& rSearchOpt,
376 bool bSearchInNotes,
377 SwDocPositions eStart, SwDocPositions eEnd,
378 bool& bCancel,
379 FindRanges eRng, bool bReplace = false );
380
381 sal_Int32 FindFormat( const SwTextFormatColl& rFormatColl,
382 SwDocPositions eStart, SwDocPositions eEnd,
383 bool& bCancel,
384 FindRanges eRng, const SwTextFormatColl* pReplFormat );
385
386 sal_Int32 FindAttrs( const SfxItemSet& rSet, bool bNoCollections,
387 SwDocPositions eStart, SwDocPositions eEnd,
388 bool& bCancel,
389 FindRanges eRng,
390 const i18nutil::SearchOptions2* pSearchOpt,
391 const SfxItemSet* rReplSet );
392
393 // Position the Cursor
394 // return values:
395 // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
396 // CRSR_POSOLD: when the cursor was not changed
397 int SetCursor( const Point &rPt, bool bOnlyText = false, bool bBlock = true );
398
399 /*
400 * Notification that the visible area was changed. m_aVisArea is reset, then
401 * scrolling is done. The passed Rectangle lays on pixel borders to avoid
402 * pixel errors.
403 */
404 virtual void VisPortChgd( const SwRect & ) override;
405
406 /*
407 * virtual paint method to make selection visible again after Paint
408 */
409 void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle & rRect) override;
410
411 // Areas
412 inline void SetMark();
413 inline bool HasMark() const;
414
415 void ClearMark();
416
424 void NormalizePam(bool bPointFirst = true);
425
426 void SwapPam();
427 bool TestCurrPam( const Point & rPt,
428 bool bTstHit = false); // only exact matches
429 void KillPams();
430
432 void Push();
433 enum class PopMode { DeleteCurrent, DeleteStack };
434 /*
435 * Delete a cursor
436 * - either from the top of the stack
437 * - or delete the current one and replace it with the cursor from the
438 * stack
439 * @return <true> if there was one on the stack, <false> otherwise
440 */
441 bool Pop(PopMode, ::std::optional<SwCallLink>& roLink);
442 bool Pop(PopMode);
443 /*
444 * Combine 2 Cursors.
445 * Delete the topmost from the stack and move its Mark into the current.
446 */
447 void Combine();
448
449 void SttCursorMove();
450 void EndCursorMove( const bool bIdleEnd = false );
451
452 /*
453 * When the focus is lost the selected ranges are not displayed anymore.
454 * On the other hand, on receiving the focus all selected ranges are displayed again
455 * (ranges must be recalculated!).
456 */
457 bool HasShellFocus() const { return m_bHasFocus; }
458 void ShellLoseFocus();
459 void ShellGetFocus();
460
461 // Methods for displaying or hiding the visible text cursor.
462 void ShowCursor();
463 void HideCursor();
464 // Methods for displaying or hiding the selected ranges with visible cursor.
465 void ShowCursors( bool bCursorVis );
466 void HideCursors();
467
468 bool IsOverwriteCursor() const { return m_bOverwriteCursor; }
469 void SetOverwriteCursor( bool bFlag ) { m_bOverwriteCursor = bFlag; }
470
471 // Return current frame in which the cursor is placed.
472 SwContentFrame *GetCurrFrame( const bool bCalcFrame = true ) const;
473
474 //true if cursor is hidden because of readonly.
475 //false if it is working despite readonly.
476 bool IsCursorReadonly() const;
477
478 // Cursor is placed in something that is protected or selection contains
479 // something that is protected.
480 bool HasReadonlySel(bool isReplace = false) const;
481
482 // Can the cursor be set to read only ranges?
483 bool IsReadOnlyAvailable() const { return m_bSetCursorInReadOnly; }
484 void SetReadOnlyAvailable( bool bFlag );
485 bool IsOverReadOnlyPos( const Point& rPt ) const;
486
487 // Methods for aFlyMacroLnk.
488 void SetFlyMacroLnk( const Link<const SwFlyFrameFormat*,void>& rLnk ) { m_aFlyMacroLnk = rLnk; }
489 const Link<const SwFlyFrameFormat*,void>& GetFlyMacroLnk() const { return m_aFlyMacroLnk; }
490
491 // Methods returning/altering link for changes of attributes/formats.
492 void SetChgLnk( const Link<LinkParamNone*,void> &rLnk ) { m_aChgLnk = rLnk; }
493 const Link<LinkParamNone*,void>& GetChgLnk() const { return m_aChgLnk; }
494
495 // Methods returning/altering link for "graphic completely loaded".
496 void SetGrfArrivedLnk( const Link<SwCursorShell&,void> &rLnk ) { m_aGrfArrivedLnk = rLnk; }
497 const Link<SwCursorShell&,void>& GetGrfArrivedLnk() const { return m_aGrfArrivedLnk; }
498
499 //Call ChgLink. When within an action calling will be delayed.
500 void CallChgLnk();
501
502 // Check if the current cursor contains a selection, i.e.
503 // if Mark is set and SPoint and Mark are different.
504 bool HasSelection() const;
505
506 // Check if a selection exists, i.e. if the current cursor comprises a selection.
507 inline bool IsSelection() const;
508 // returns if multiple cursors are available
509 inline bool IsMultiSelection() const;
510
511 // Check if a complete paragraph was selected.
512 bool IsSelFullPara() const;
513
514 // Check if selection is within one paragraph.
515
516 //Should WaitPtr be activated for Clipboard.
517 bool ShouldWait() const;
518
519 // Check if selection is within one paragraph.
520 bool IsSelOnePara() const;
521
522 /*
523 * Returns SRectangle, at which the cursor is located.
524 */
525 const SwRect &GetCharRect() const { return m_aCharRect; }
526 /*
527 * Returns if cursor is wholly or partly within visible range.
528 */
529 bool IsCursorVisible() const { return VisArea().Overlaps( GetCharRect() ); }
530 /*
531 * Returns SwRect, at which the character is located.
532 */
533 void GetCharRectAt(SwRect& rRect, const SwPosition* pPos);
534
535 // Return current page number:
536 // true: in which cursor is located.
537 // false: which is visible at the upper margin.
538 void GetPageNum( sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum,
539 bool bAtCursorPos = true, const bool bCalcFrame = true );
540 // Returns current page's sequential number (1-based),in which cursor is located, ignoring autoinserted empty pages.
541 // Returns 0 on error
542 sal_uInt16 GetPageNumSeqNonEmpty();
543 // Determine how "empty pages" are handled
544 // (used in PhyPage).
545 sal_uInt16 GetNextPrevPageNum( bool bNext = true );
546
547 // Move cursor at the beginning of page "nPage".
548 bool GotoPage( sal_uInt16 nPage );
549
550 sal_uInt16 GetPageCnt();
551
552 bool GoNextCursor();
553
554 bool GoPrevCursor();
555
556 void GoNextPrevCursorSetSearchLabel(const bool bNext);
557
558 // at CurrentCursor.SPoint
559 ::sw::mark::IMark* SetBookmark(
560 const vcl::KeyCode&,
561 const OUString& rName,
563 ::sw::mark::IMark* SetBookmark2(
564 const vcl::KeyCode&,
565 const OUString& rName,
566 bool bHide,
567 const OUString& rCondition);
568 bool GotoMark( const ::sw::mark::IMark* const pMark ); // sets CurrentCursor.SPoint
569 bool GotoMark( const ::sw::mark::IMark* const pMark, bool bAtStart );
570 bool GoNextBookmark(); // true, if there was one
571 bool GoPrevBookmark();
572
573 bool IsFormProtected();
574 ::sw::mark::IFieldmark* GetCurrentFieldmark();
575 ::sw::mark::IFieldmark* GetFieldmarkAfter();
576 ::sw::mark::IFieldmark* GetFieldmarkBefore();
577 bool GotoFieldmark( const ::sw::mark::IFieldmark* const pMark );
578
579 // update Cursr, i.e. reset it into content should only be called when the
580 // cursor was set to a random position e.g. when deleting frames
581 void UpdateCursorPos();
582
583 // get the selected text at the current cursor. It will be filled with
584 // fields etc.
585 OUString GetSelText() const;
586
587 // Check of SPoint or Mark of current cursor are placed within a table.
588 inline const SwTableNode* IsCursorInTable() const;
589
590 bool IsCursorInFootnote() const;
591
592 inline Point& GetCursorDocPos() const;
593 inline bool IsCursorPtAtEnd() const;
594
595 inline const SwPaM* GetTableCrs() const;
596 inline SwPaM* GetTableCrs();
597
598 bool IsTableComplexForChart();
599 // get current table selection as text
600 OUString GetBoxNms() const;
601
602 // set Cursor to the next/previous cell
603 bool GoNextCell( bool bAppendLine = true );
604 bool GoPrevCell();
605 // go to this box (if available and inside of table)
606 bool GotoTable( const OUString& rName );
607
608 // select a table row, column or box (based on the current cursor)
609 bool SelTableRow() { return SelTableRowOrCol( true ); }
610 bool SelTableCol() { return SelTableRowOrCol( false ); }
611 bool SelTableBox();
612
613 bool SelTable();
614
615 void GotoNextNum();
616 void GotoPrevNum();
617
618 bool GotoOutline( const OUString& rName );
619 // to the next/previous or the given OutlineNode
620 void GotoOutline( SwOutlineNodes::size_type nIdx );
621 // find the "outline position" in the nodes array of the current chapter
622 SwOutlineNodes::size_type GetOutlinePos(sal_uInt8 nLevel = UCHAR_MAX, SwPaM* pPaM = nullptr);
623 // select the given range of OutlineNodes. Optionally including the children
624 // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell)
625 void MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos,
626 bool bWithChildren, bool bKillPams = true );
627
628 bool GotoNextOutline();
629 bool GotoPrevOutline();
630
645 SwShellCursor* getShellCursor( bool bBlock );
646 const SwShellCursor* getShellCursor( bool bBlock ) const
647 { return const_cast<SwCursorShell*>(this)->getShellCursor( bBlock ); }
648
649 bool IsBlockMode() const { return nullptr != m_pBlockCursor; }
650
651 // is the Cursor in a table and is the selection over 2 columns
652 bool IsTableMode() const { return nullptr != m_pTableCursor; }
653
654 const SwShellTableCursor* GetTableCursor() const { return m_pTableCursor; }
655 SwShellTableCursor* GetTableCursor() { return m_pTableCursor; }
656 size_t UpdateTableSelBoxes();
657
658 bool GotoFootnoteText();
659 bool GotoFootnoteAnchor();
660 bool GotoPrevFootnoteAnchor();
661 bool GotoNextFootnoteAnchor();
662
663 void GotoFlyAnchor();
664 bool GotoHeaderText();
665 bool GotoFooterText();
666 // jump to the header/footer of the given or current PageDesc
667 bool SetCursorInHdFt( size_t nDescNo, bool bInHeader );
668 // is point of cursor in header/footer. pbInHeader return true if it is
669 // in a headerframe otherwise in a footerframe
670 bool IsInHeaderFooter( bool* pbInHeader = nullptr ) const;
671
672 bool GotoNextTOXBase( const OUString* = nullptr );
673 bool GotoPrevTOXBase( const OUString* = nullptr );
674 void GotoTOXMarkBase();
675 // jump to the next or previous index entry
676 bool GotoNxtPrvTOXMark( bool bNext = true );
677 // jump to the next/previous index mark of this type
678 const SwTOXMark& GotoTOXMark( const SwTOXMark& rStart, SwTOXSearch eDir );
679
680 // jump to the next or previous table formula
681 // optionally only to broken formulas
682 bool GotoNxtPrvTableFormula( bool bNext = true,
683 bool bOnlyErrors = false );
684 // jump to the next / previous hyperlink - inside text and also
685 // on graphics
686 bool SelectNxtPrvHyperlink( bool bNext );
687
688 bool GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType,
689 sal_uInt16 nSeqNo );
690
691 // get the nth character from the start or end of the current selection
692 sal_Unicode GetChar( bool bEnd = true, tools::Long nOffset = 0 );
693 bool ExtendSelection( bool bEnd = true, sal_Int32 nCount = 1 );
694
695 // Place only the visible cursor at the given position in the document.
696 // Return false if SPoint was corrected by layout.
697 // (This is needed for displaying the Drag&Drop/Copy-Cursor.)
698 bool SetVisibleCursor( const Point &rPt );
699 inline void UnSetVisibleCursor();
700 SwVisibleCursor* GetVisibleCursor() const;
701
702 // jump to the next or previous field of the corresponding type
703 bool MoveFieldType(
704 const SwFieldType* pFieldType,
705 const bool bNext,
706 const SwFieldIds nResType = SwFieldIds::Unknown,
707 const bool bAddSetExpressionFieldsToInputFields = true );
708
709 bool GotoFormatField( const SwFormatField& rField );
710
711 bool GotoFormatContentControl(const SwFormatContentControl& rContentControl);
712
713 static SwTextField* GetTextFieldAtPos(
714 const SwPosition* pPos,
715 const bool bIncludeInputFieldAtStart );
716 static SwTextField* GetTextFieldAtCursor(
717 const SwPaM* pCursor,
718 const bool bIncludeInputFieldAtStart );
719 static SwField* GetFieldAtCursor(
720 const SwPaM* pCursor,
721 const bool bIncludeInputFieldAtStart );
722 SwField* GetCurField( const bool bIncludeInputFieldAtStart = false ) const;
723 bool CursorInsideInputField() const;
724 SwTextContentControl* CursorInsideContentControl() const;
725 static bool PosInsideInputField( const SwPosition& rPos );
726 bool DocPtInsideInputField( const Point& rDocPt ) const;
727 static sal_Int32 StartOfInputFieldAtPos( const SwPosition& rPos );
728 static sal_Int32 EndOfInputFieldAtPos( const SwPosition& rPos );
729
730 // Return number of cursors in ring (The flag indicates whether
731 // only cursors containing selections are requested).
732 sal_uInt16 GetCursorCnt( bool bAll = true ) const;
733
734 // Char Travelling - methods (in crstrvl1.cxx)
735 bool GoStartWord();
736 bool GoEndWord();
737 bool GoNextWord();
738 bool GoPrevWord();
739 bool GoNextSentence();
740 bool GoStartSentence();
741 bool GoEndSentence();
742 bool SelectWord( const Point* pPt );
743 void ExpandToSentenceBorders();
744
745 // get position from current cursor
746 bool IsStartWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES )const;
747 bool IsEndWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
748 bool IsInWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
749 bool IsStartSentence() const;
750 bool IsEndSentence() const;
751 bool IsSttPara() const;
752 bool IsEndPara() const;
753 bool IsEndOfTable() const;
754 bool IsStartOfDoc() const;
755 bool IsEndOfDoc() const;
756 bool IsInFrontOfLabel() const;
757 bool IsAtLeftMargin() const { return IsAtLRMargin( true ); }
758 bool IsAtRightMargin() const { return IsAtLRMargin( false, true/*bAPI*/ ); }
759
760 // delete all created cursors, set the table cursor and the last cursor to
761 // its TextNode (or StartNode?)
762 // They all get created on the next ::GetCursor again
763 // Used for Drag&Drop/Clipboard-Paste in tables
764 bool ParkTableCursor();
765
766 // Non expanded attributes?
767 bool IsGCAttr() const { return m_bGCAttr; }
768 void ClearGCAttr() { m_bGCAttr = false; }
769 void UpdateAttr() { m_bGCAttr = true; }
770
771 // is the whole document protected/hidden (for UI...)
772 bool IsAllProtect() const { return m_bAllProtect; }
773
774 bool GotoRegion( std::u16string_view rName );
775
776 // show the current selection
777 virtual void MakeSelVisible();
778
779 // set the cursor to a NOT protected/hidden node
780 bool FindValidContentNode( bool bOnlyText );
781
782 bool GetContentAtPos( const Point& rPt,
783 SwContentAtPos& rContentAtPos,
784 bool bSetCursor = false,
785 SwRect* pFieldRect = nullptr );
786
787 const SwPostItField* GetPostItFieldAtCursor() const;
788
789 // get smart tags rectangle for the given point
790 void GetSmartTagRect( const Point& rPt, SwRect& rSelectRect );
791
792 // get smart tags at current cursor position
793 void GetSmartTagTerm( std::vector< OUString >& rSmartTagTypes,
794 css::uno::Sequence< css::uno::Reference< css::container::XStringKeyMap > >& rStringKeyMaps,
795 css::uno::Reference<css::text::XTextRange>& rRange ) const;
796
797 bool IsPageAtPos( const Point &rPt ) const;
798
799 bool SelectTextAttr( sal_uInt16 nWhich, bool bExpand, const SwTextAttr* pAttr = nullptr );
800 bool GotoINetAttr( const SwTextINetFormat& rAttr );
801 const SwFormatINetFormat* FindINetAttr( std::u16string_view rName ) const;
802
803 bool SelectTextModel(sal_Int32 nStart, sal_Int32 nEnd);
804#ifdef SW_DLLIMPLEMENTATION
805 bool SelectTextView(TextFrameIndex nStart, TextFrameIndex nEnd);
806 // result is only valid while cursor isn't moved!
807 TextFrameIndex GetCursorPointAsViewIndex() const;
808#endif
809
810 bool CheckTableBoxContent( const SwPosition* pPos = nullptr );
811 void SaveTableBoxContent( const SwPosition* pPos = nullptr );
812 void ClearTableBoxContent();
813 bool EndAllTableBoxEdit();
814
815 void SetSelTableCells( bool bFlag ) { m_bSelTableCells = bFlag; }
816 bool IsSelTableCells() const { return m_bSelTableCells; }
817
818 void UnsetEnhancedTableSelection() { m_eEnhancedTableSel = SwTable::SEARCH_NONE; }
819 SwTable::SearchType GetEnhancedTableSelection() const { return m_eEnhancedTableSel; }
820
821 bool IsAutoUpdateCells() const { return m_bAutoUpdateCells; }
822 void SetAutoUpdateCells( bool bFlag ) { m_bAutoUpdateCells = bFlag; }
823
824 bool GetShadowCursorPos( const Point& rPt, SwFillMode eFillMode,
825 SwRect& rRect, sal_Int16& rOrient );
826 bool SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode );
827
828 const SwRangeRedline* SelNextRedline();
829 const SwRangeRedline* SelPrevRedline();
830 const SwRangeRedline* GotoRedline( SwRedlineTable::size_type nArrPos, bool bSelect );
831
832 bool GotoFootnoteAnchor(const SwTextFootnote& rTextFootnote);
833
834 SAL_DLLPRIVATE SvxFrameDirection GetTextDirection( const Point* pPt = nullptr ) const;
835 // is cursor or the point in/over a vertical formatted text?
836 bool IsInVerticalText( const Point* pPt = nullptr ) const;
837 // is cursor or the point in/over a right to left formatted text?
838 bool IsInRightToLeftText() const;
839
840 static void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage);
841 bool bColumnChange();
842 static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection);
843 static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn);
844 // If the current cursor position is inside a hidden range, the hidden range
845 // is selected and true is returned:
846 bool SelectHiddenRange();
847
848 // remove all invalid cursors
849 void ClearUpCursors();
850
851 void SetMacroExecAllowed( const bool _bMacroExecAllowed )
852 {
853 m_bMacroExecAllowed = _bMacroExecAllowed;
854 }
856 {
857 return m_bMacroExecAllowed;
858 }
859
869 OUString GetCursorDescr() const;
870
871 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
873 OUString getPageRectangles();
874
876 void NotifyCursor(SfxViewShell* pViewShell) const;
877};
878
879// Cursor Inlines:
881 SwDocPositions nStt, SwDocPositions nEnd, SwPaM* pPam ) const
882{
883 return m_pCurrentCursor->MakeFindRange( nStt, nEnd, pPam );
884}
885
887
889
890inline bool SwCursorShell::HasMark() const { return m_pCurrentCursor->HasMark(); }
891
892inline bool SwCursorShell::IsSelection() const
893{
894 return IsTableMode() || m_pCurrentCursor->HasMark() ||
896}
898{
900}
901
903{
905}
906
908{
910}
911
913{
914 return m_pCurrentCursor->GetPtPos();
915}
916
918{
919 return m_pTableCursor;
920}
921
923{
924 return m_pTableCursor;
925}
926
928{
931}
932
933#endif // _CRSRSH_HXX
934
935/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
Access to the block cursor.
Definition: BlockCursor.hxx:40
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
tools::Long m_nLeftFramePos
Definition: crsrsh.hxx:198
bool Pop(PopMode, ::std::optional< SwCallLink > &roLink)
tools::Long GetUpDownX() const
Definition: crsrsh.hxx:355
bool IsAtLeftMargin() const
Definition: crsrsh.hxx:757
void SetAutoUpdateCells(bool bFlag)
Definition: crsrsh.hxx:822
const SwPaM * GetTableCrs() const
Definition: crsrsh.hxx:917
bool m_bSetCursorInReadOnly
Definition: crsrsh.hxx:235
bool LeftMargin()
Definition: crsrsh.hxx:363
bool m_bMacroExecAllowed
Definition: crsrsh.hxx:238
void SetOverwriteCursor(bool bFlag)
Definition: crsrsh.hxx:469
bool IsReadOnlyAvailable() const
Definition: crsrsh.hxx:483
void SetMacroExecAllowed(const bool _bMacroExecAllowed)
Definition: crsrsh.hxx:851
const SwTableNode * IsCursorInTable() const
Definition: crsrsh.hxx:902
bool m_bInCMvVisportChgd
Flag for CursorMoves.
Definition: crsrsh.hxx:227
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:336
bool m_bIgnoreReadonly
Definition: crsrsh.hxx:230
void ClearGCAttr()
Definition: crsrsh.hxx:768
const SwRect & GetCharRect() const
Definition: crsrsh.hxx:525
const Link< LinkParamNone *, void > & GetChgLnk() const
Definition: crsrsh.hxx:493
bool IsMacroExecAllowed() const
Definition: crsrsh.hxx:855
Point & GetCursorDocPos() const
Definition: crsrsh.hxx:912
Point m_aOldRBPos
Right/Bottom of last VisArea.
Definition: crsrsh.hxx:175
SwTable::SearchType m_eEnhancedTableSel
Definition: crsrsh.hxx:211
SwPaM * GetStackCursor() const
Definition: crsrsh.hxx:886
tools::Long m_nUpDownX
try to move the cursor on up/down always in the same column
Definition: crsrsh.hxx:196
SwNodeIndex * m_pBoxIdx
for recognizing of the changed
Definition: crsrsh.hxx:193
bool m_bChgCallFlag
attribute change inside Start- and EndAction
Definition: crsrsh.hxx:218
const SwShellCursor * GetCursor_() const
Definition: crsrsh.hxx:337
void SetFlyMacroLnk(const Link< const SwFlyFrameFormat *, void > &rLnk)
Definition: crsrsh.hxx:488
bool IsMultiSelection() const
Definition: crsrsh.hxx:897
CursorMoveState m_eMvState
Status for Cursor-Travelling - GetModelPositionForViewPoint.
Definition: crsrsh.hxx:210
bool IsCursorVisible() const
Definition: crsrsh.hxx:529
Point m_aCursorHeight
height & offset from visible Cursor
Definition: crsrsh.hxx:174
SwBlockCursor * m_pBlockCursor
interface of cursor for block (=rectangular) selection
Definition: crsrsh.hxx:188
bool m_bAllProtect
Flag for areas.
Definition: crsrsh.hxx:225
bool RightMargin(bool bAPI=false)
Definition: crsrsh.hxx:364
bool IsSelTableCells() const
Definition: crsrsh.hxx:816
bool m_bSelTableCells
Definition: crsrsh.hxx:232
SwShellTableCursor * GetTableCursor()
Definition: crsrsh.hxx:655
void SetSelTableCells(bool bFlag)
Definition: crsrsh.hxx:815
bool m_bGCAttr
Definition: crsrsh.hxx:229
bool m_bCallChgLnk
flag for derived classes
Definition: crsrsh.hxx:222
bool IsSelection() const
Definition: crsrsh.hxx:892
SwTableBox * m_pBoxPtr
table row
Definition: crsrsh.hxx:194
int m_nMarkedListLevel
Definition: crsrsh.hxx:214
void UpdateAttr()
Definition: crsrsh.hxx:769
SwMoveFnCollection const & MakeFindRange(SwDocPositions, SwDocPositions, SwPaM *) const
Definition: crsrsh.hxx:880
bool HasMark() const
Definition: crsrsh.hxx:890
Link< const SwFlyFrameFormat *, void > m_aFlyMacroLnk
Link will be called, if the Cursor is set into a fly.
Definition: crsrsh.hxx:178
const SwShellTableCursor * GetTableCursor() const
Definition: crsrsh.hxx:654
sal_uInt16 m_nCursorMove
Definition: crsrsh.hxx:209
void UnsetEnhancedTableSelection()
Definition: crsrsh.hxx:818
bool m_bBasicHideCursor
Definition: crsrsh.hxx:234
bool Right(sal_uInt16 nCnt, SwCursorSkipMode nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:359
SwVisibleCursor * m_pVisibleCursor
the visible cursor
Definition: crsrsh.hxx:186
SwShellCursor * m_pStackCursor
stack for the cursor
Definition: crsrsh.hxx:185
bool IsAtRightMargin() const
Definition: crsrsh.hxx:758
const Link< const SwFlyFrameFormat *, void > & GetFlyMacroLnk() const
Definition: crsrsh.hxx:489
const Link< SwCursorShell &, void > & GetGrfArrivedLnk() const
Definition: crsrsh.hxx:497
void SetMark()
Definition: crsrsh.hxx:888
bool IsAutoUpdateCells() const
Definition: crsrsh.hxx:821
bool Down(sal_uInt16 nCnt=1)
Definition: crsrsh.hxx:362
const SwShellCursor * getShellCursor(bool bBlock) const
Definition: crsrsh.hxx:646
Link< SwCursorShell &, void > m_aGrfArrivedLnk
Link calls to UI if a graphic is arrived.
Definition: crsrsh.hxx:182
SwNodeType m_nCurrentNdTyp
Definition: crsrsh.hxx:201
bool IsOverwriteCursor() const
Definition: crsrsh.hxx:468
bool SelTableCol()
Definition: crsrsh.hxx:610
bool m_bSVCursorVis
SV-Cursor visible/invisible.
Definition: crsrsh.hxx:217
bool IsGCAttr() const
Definition: crsrsh.hxx:767
OUString m_sMarkedListId
table rows or columns selected by not cell by cell
Definition: crsrsh.hxx:213
SwRect m_aCharRect
Char-SRectangle on which the cursor is located.
Definition: crsrsh.hxx:173
SwTable::SearchType GetEnhancedTableSelection() const
Definition: crsrsh.hxx:819
SwShellTableCursor * m_pTableCursor
table Cursor; only in tables when the selection lays over 2 columns
Definition: crsrsh.hxx:190
void SetChgLnk(const Link< LinkParamNone *, void > &rLnk)
Definition: crsrsh.hxx:492
CursorFlag
for calling UpdateCursor
Definition: crsrsh.hxx:160
@ CHKRANGE
check overlapping PaMs
Definition: crsrsh.hxx:163
@ SCROLLWIN
scroll window
Definition: crsrsh.hxx:162
bool Left(sal_uInt16 nCnt, SwCursorSkipMode nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:357
bool HasShellFocus() const
Definition: crsrsh.hxx:457
void SetGrfArrivedLnk(const Link< SwCursorShell &, void > &rLnk)
Definition: crsrsh.hxx:496
bool SelTableRow()
Definition: crsrsh.hxx:609
SwNodeOffset m_nCurrentNode
Definition: crsrsh.hxx:199
Link< LinkParamNone *, void > m_aChgLnk
link will be called by every attribute/ format changes at cursor position.
Definition: crsrsh.hxx:180
SwFrame * m_oldColFrame
Definition: crsrsh.hxx:240
bool m_bHasFocus
Shell is "active" in a window.
Definition: crsrsh.hxx:216
SwShellCursor * m_pCurrentCursor
current cursor
Definition: crsrsh.hxx:184
bool m_bOverwriteCursor
Definition: crsrsh.hxx:236
bool m_bAutoUpdateCells
Definition: crsrsh.hxx:233
bool IsCursorPtAtEnd() const
Definition: crsrsh.hxx:907
bool IsTableMode() const
Definition: crsrsh.hxx:652
bool Up(sal_uInt16 nCnt=1)
Definition: crsrsh.hxx:361
bool IsBlockMode() const
Definition: crsrsh.hxx:649
sal_Int32 m_nCurrentContent
Definition: crsrsh.hxx:200
bool IsAllProtect() const
Definition: crsrsh.hxx:772
void UnSetVisibleCursor()
Definition: crsrsh.hxx:927
bool m_bVisPortChgd
in VisPortChg-Call
Definition: crsrsh.hxx:219
SwMoveFnCollection const & MakeFindRange(SwDocPositions, SwDocPositions, SwPaM *) const
set range for search in document
Definition: swcrsr.cxx:739
Definition: doc.hxx:192
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
Base class of all fields.
Definition: fldbas.hxx:292
SfxPoolItem subclass that wraps an SwContentControl.
Base class of the Writer layout elements.
Definition: frame.hxx:315
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:303
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:84
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:370
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
SwNode & GetPointNode() const
Definition: pam.hxx:283
const SwPosition * End() const
Definition: pam.hxx:271
const SwPosition * GetPoint() const
Definition: pam.hxx:261
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:259
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
bool Overlaps(const SwRect &rRect) const
Definition: swrect.hxx:374
vector_type::size_type size_type
Definition: docary.hxx:222
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwSelPaintRects is a base class of SwShellCursor, which stores the overlay for the cursor/selection: ...
Definition: viscrs.hxx:80
SwShellCursor * GetNext()
Definition: viscrs.hxx:185
const Point & GetPtPos() const
Definition: viscrs.hxx:162
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:892
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:419
@ SEARCH_NONE
Definition: swtable.hxx:146
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
Represents the style of a paragraph.
Definition: fmtcol.hxx:59
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: viewsh.cxx:142
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: viewsh.cxx:1860
void StartAction()
Definition: viewsh.hxx:605
void EndAction(const bool bIdleEnd=false)
Definition: viewsh.hxx:610
const SwRect & VisArea() const
Definition: viewsh.cxx:630
virtual void VisPortChgd(const SwRect &)
Definition: viewsh.cxx:1174
void SetDragCursor(bool bFlag=true)
Definition: viscrs.hxx:62
The Undo actions need to create new Shell cursors.
virtual SwCursor & GetCurrentShellCursor()=0
virtual SwCursor & CreateNewShellCursor()=0
const int CRSR_POSCHG
Definition: crsrsh.hxx:129
IsAttrAtPos
Definition: crsrsh.hxx:75
@ CurrAttrs
only for debugging
@ TableBoxValue
only for debugging
const int CRSR_POSOLD
Definition: crsrsh.hxx:128
SwFillMode
Definition: crstate.hxx:29
CursorMoveState
Definition: crstate.hxx:122
bool(* SwWhichTable)(SwPaM &, SwMoveFnCollection const &, bool bInReadOnly)
Definition: cshtyp.hxx:58
SwContentFrame *(* SwPosColumn)(const SwLayoutFrame *)
Definition: cshtyp.hxx:67
bool(* SwWhichPara)(SwPaM &, SwMoveFnCollection const &)
Definition: cshtyp.hxx:43
SwDocPositions
Definition: cshtyp.hxx:104
SwLayoutFrame *(* SwWhichColumn)(const SwLayoutFrame *)
Definition: cshtyp.hxx:66
FindRanges
Definition: cshtyp.hxx:91
bool(* SwWhichRegion)(SwPaM &, SwMoveFnCollection const &, bool bInReadOnly)
Definition: cshtyp.hxx:75
SwLayoutFrame *(* SwWhichPage)(const SwLayoutFrame *)
Definition: cshtyp.hxx:34
SwContentFrame *(* SwPosPage)(const SwLayoutFrame *)
Definition: cshtyp.hxx:38
bool(* SwWhichSection)(SwPaM &, SwMoveFnCollection const &)
Definition: cshtyp.hxx:51
SwFieldIds
Definition: fldbas.hxx:45
SvxFrameDirection
NONE
Dialog to specify the properties of date form field.
std::optional< OUString > ReplaceBackReferences(const i18nutil::SearchOptions2 &rSearchOpt, SwPaM *const pPam, SwRootFrame const *const pLayout)
Helperfunction to resolve backward references in regular expressions.
Definition: findtxt.cxx:1107
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor > > &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
Definition: autofmt.cxx:1112
bool ReplaceImpl(SwPaM &rCursor, OUString const &rReplacement, bool const bRegExp, SwDoc &rDoc, SwRootFrame const *const pLayout)
Definition: findtxt.cxx:1039
long Long
SwNodeType
Definition: ndtyp.hxx:28
const SwRangeRedline * pRedl
Definition: crsrsh.hxx:106
union SwContentAtPos::@24 aFnd
SwContentNode * pNode
Definition: crsrsh.hxx:107
bool IsInProtectSect() const
is the node in a protected section?
Definition: crstrvl.cxx:1970
const SfxPoolItem * pAttr
Definition: crsrsh.hxx:105
bool IsInRTLText() const
Definition: crstrvl.cxx:2004
SwContentAtPos(IsAttrAtPos eGetAtPos)
Definition: crsrsh.hxx:115
OUString sStr
Definition: crsrsh.hxx:112
const SwField * pField
Definition: crsrsh.hxx:104
const SwTextAttr * pFndTextAttr
Definition: crsrsh.hxx:113
IsAttrAtPos eContentAtPos
Definition: crsrsh.hxx:110
const sw::mark::IFieldmark * pFieldmark
Definition: crsrsh.hxx:108
Marks a position in the document model.
Definition: pam.hxx:37
SwCursorSkipMode
Definition: swcrsr.hxx:65
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool GetAutoSumSel(const SwCursorShell &rShell, SwCellFrames &rBoxes)
Definition: tblsel.cxx:691
std::deque< SwCellFrame * > SwCellFrames
Definition: tblsel.hxx:41
SwTOXSearch
Definition: toxe.hxx:23
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
constexpr OUStringLiteral UPDOWN(u"UpDown")