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