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