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