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