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 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 Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 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 SwPaM & CreateNewShellCursor() override;
306  virtual SwPaM & 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  SwPaM* GetCursor( bool bMakeTableCursor = true ) const;
328  inline SwCursor* GetSwCursor() const;
329  // return only the current cursor
330  SwShellCursor* GetCursor_() { return m_pCurrentCursor; }
331  const SwShellCursor* GetCursor_() const { return m_pCurrentCursor; }
332 
333  // show passed cursor - for UNO
334  void SetSelection(const SwPaM& rCursor);
335 
336  // remove all cursors from ContentNodes and set to 0
337  void ParkCursor( const SwNodeIndex &rIdx );
338 
339  // return the current cursor stack
340  // (required in EditShell when deleting contents)
341  inline SwPaM* GetStackCursor() const;
342 
343  // start parenthesing, hide SV-Cursor and selected areas
344  void StartAction();
345  // end parenthesing, show SV-Cursor and selected areas
346  void EndAction( const bool bIdleEnd = false, const bool DoSetPosX = false );
347 
348  // basic cursor travelling
349  long GetUpDownX() const { return m_nUpDownX; }
350 
351  bool Left( sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual = false )
352  { return LeftRight( true, nCnt, nMode, bAllowVisual ); }
353  bool Right( sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual = false )
354  { return LeftRight( false, nCnt, nMode, bAllowVisual ); }
355  bool Up( sal_uInt16 nCnt = 1 ) { return UpDown( true, nCnt ); }
356  bool Down( sal_uInt16 nCnt = 1 ) { return UpDown( false, nCnt ); }
357  bool LeftMargin() { return LRMargin( true ); }
358  bool RightMargin(bool bAPI = false) { return LRMargin( false, bAPI ); }
359  bool SttEndDoc( bool bStt );
360 
361  bool MovePage( SwWhichPage, SwPosPage );
362  bool MovePara( SwWhichPara, SwMoveFnCollection const & );
363  bool MoveSection( SwWhichSection, SwMoveFnCollection const & );
364  bool MoveTable( SwWhichTable, SwMoveFnCollection const & );
365  void MoveColumn( SwWhichColumn, SwPosColumn );
366  bool MoveRegion( SwWhichRegion, SwMoveFnCollection const & );
367 
368  // note: DO NOT call it FindText because windows.h
369  sal_uLong Find_Text( const i18nutil::SearchOptions2& rSearchOpt,
370  bool bSearchInNotes,
371  SwDocPositions eStart, SwDocPositions eEnd,
372  bool& bCancel,
373  FindRanges eRng, bool bReplace = false );
374 
375  sal_uLong FindFormat( const SwTextFormatColl& rFormatColl,
376  SwDocPositions eStart, SwDocPositions eEnd,
377  bool& bCancel,
378  FindRanges eRng, const SwTextFormatColl* pReplFormat );
379 
380  sal_uLong FindAttrs( const SfxItemSet& rSet, bool bNoCollections,
381  SwDocPositions eStart, SwDocPositions eEnd,
382  bool& bCancel,
383  FindRanges eRng,
384  const i18nutil::SearchOptions2* pSearchOpt,
385  const SfxItemSet* rReplSet );
386 
387  // Position the Cursor
388  // return values:
389  // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
390  // CRSR_POSOLD: when the cursor was not changed
391  int SetCursor( const Point &rPt, bool bOnlyText = false, bool bBlock = true );
392 
393  /*
394  * Notification that the visible area was changed. m_aVisArea is reset, then
395  * scrolling is done. The passed Rectangle lays on pixel borders to avoid
396  * pixel errors.
397  */
398  virtual void VisPortChgd( const SwRect & ) override;
399 
400  /*
401  * virtual paint method to make selection visible again after Paint
402  */
403  void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle & rRect) override;
404 
405  // Areas
406  inline void SetMark();
407  inline bool HasMark();
408 
409  void ClearMark();
410 
418  void NormalizePam(bool bPointFirst = true);
419 
420  void SwapPam();
421  bool TestCurrPam( const Point & rPt,
422  bool bTstHit = false); // only exact matches
423  void KillPams();
424 
426  void Push();
427  enum class PopMode { DeleteCurrent, DeleteStack };
428  /*
429  * Delete a cursor
430  * - either from the top of the stack
431  * - or delete the current one and replace it with the cursor from the
432  * stack
433  * @return <true> if there was one on the stack, <false> otherwise
434  */
435  bool Pop(PopMode);
436  /*
437  * Combine 2 Cursors.
438  * Delete the topmost from the stack and move its Mark into the current.
439  */
440  void Combine();
441 
442  void SttCursorMove();
443  void EndCursorMove( const bool bIdleEnd = false );
444 
445  /*
446  * When the focus is lost the selected ranges are not displayed anymore.
447  * On the other hand, on receiving the focus all selected ranges are displayed again
448  * (ranges must be recalculated!).
449  */
450  bool HasShellFocus() const { return m_bHasFocus; }
451  void ShellLoseFocus();
452  void ShellGetFocus();
453 
454  // Methods for displaying or hiding the visible text cursor.
455  void ShowCursor();
456  void HideCursor();
457  // Methods for displaying or hiding the selected ranges with visible cursor.
458  void ShowCursors( bool bCursorVis );
459  void HideCursors();
460 
461  bool IsOverwriteCursor() const { return m_bOverwriteCursor; }
462  void SetOverwriteCursor( bool bFlag ) { m_bOverwriteCursor = bFlag; }
463 
464  // Return current frame in which the cursor is placed.
465  SwContentFrame *GetCurrFrame( const bool bCalcFrame = true ) const;
466 
467  //true if cursor is hidden because of readonly.
468  //false if it is working despite readonly.
469  bool IsCursorReadonly() const;
470 
471  // Cursor is placed in something that is protected or selection contains
472  // something that is protected.
473  bool HasReadonlySel() const;
474 
475  // Can the cursor be set to read only ranges?
476  bool IsReadOnlyAvailable() const { return m_bSetCursorInReadOnly; }
477  void SetReadOnlyAvailable( bool bFlag );
478  bool IsOverReadOnlyPos( const Point& rPt ) const;
479 
480  // Methods for aFlyMacroLnk.
481  void SetFlyMacroLnk( const Link<const SwFlyFrameFormat*,void>& rLnk ) { m_aFlyMacroLnk = rLnk; }
482  const Link<const SwFlyFrameFormat*,void>& GetFlyMacroLnk() const { return m_aFlyMacroLnk; }
483 
484  // Methods returning/altering link for changes of attributes/formats.
485  void SetChgLnk( const Link<SwCursorShell*,void> &rLnk ) { m_aChgLnk = rLnk; }
486  const Link<SwCursorShell*,void>& GetChgLnk() const { return m_aChgLnk; }
487 
488  // Methods returning/altering ling for "graphic completely loaded".
489  void SetGrfArrivedLnk( const Link<SwCursorShell&,void> &rLnk ) { m_aGrfArrivedLnk = rLnk; }
490  const Link<SwCursorShell&,void>& GetGrfArrivedLnk() const { return m_aGrfArrivedLnk; }
491 
492  //Call ChgLink. When within an action calling will be delayed.
493  void CallChgLnk();
494 
495  // Check if the current cursor contains a selection, i.e.
496  // if Mark is set and SPoint and Mark are different.
497  bool HasSelection() const;
498 
499  // Check if a selection exists, i.e. if the current cursor comprises a selection.
500  inline bool IsSelection() const;
501  // returns if multiple cursors are available
502  inline bool IsMultiSelection() const;
503 
504  // Check if a complete paragraph was selected.
505  bool IsSelFullPara() const;
506 
507  // Check if selection is within one paragraph.
508 
509  //Should WaitPtr be activated for Clipboard.
510  bool ShouldWait() const;
511 
512  // Check if selection is within one paragraph.
513  bool IsSelOnePara() const;
514 
515  /*
516  * Returns SRectangle, at which the cursor is located.
517  */
518  const SwRect &GetCharRect() const { return m_aCharRect; }
519  /*
520  * Returns if cursor is wholly or partly within visible range.
521  */
522  bool IsCursorVisible() const { return VisArea().IsOver( GetCharRect() ); }
523  /*
524  * Returns SwRect, at which the character is located.
525  */
526  void GetCharRectAt(SwRect& rRect, const SwPosition* pPos);
527 
528  // Return current page number:
529  // true: in which cursor is located.
530  // false: which is visible at the upper margin.
531  void GetPageNum( sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum,
532  bool bAtCursorPos = true, const bool bCalcFrame = true );
533  // Returns current page's sequential number (1-based),in which cursor is located, ignoring autoinserted empty pages.
534  // Returns 0 on error
535  sal_uInt16 GetPageNumSeqNonEmpty();
536  // Determine how "empty pages" are handled
537  // (used in PhyPage).
538  sal_uInt16 GetNextPrevPageNum( bool bNext = true );
539 
540  // Move cursor at the beginning of page "nPage".
541  bool GotoPage( sal_uInt16 nPage );
542 
543  sal_uInt16 GetPageCnt();
544 
545  bool GoNextCursor();
546 
547  bool GoPrevCursor();
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 );
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 );
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 
692  // jump to the next or previous field of the corresponding type
693  bool MoveFieldType(
694  const SwFieldType* pFieldType,
695  const bool bNext,
696  const SwFieldIds nResType = SwFieldIds::Unknown,
697  const bool bAddSetExpressionFieldsToInputFields = true );
698 
699  bool GotoFormatField( const SwFormatField& rField );
700 
701  static SwTextField* GetTextFieldAtPos(
702  const SwPosition* pPos,
703  const bool bIncludeInputFieldAtStart );
704  static SwTextField* GetTextFieldAtCursor(
705  const SwPaM* pCursor,
706  const bool bIncludeInputFieldAtStart );
707  static SwField* GetFieldAtCursor(
708  const SwPaM* pCursor,
709  const bool bIncludeInputFieldAtStart );
710  SwField* GetCurField( const bool bIncludeInputFieldAtStart = false ) const;
711  bool CursorInsideInputField() const;
712  static bool PosInsideInputField( const SwPosition& rPos );
713  bool DocPtInsideInputField( const Point& rDocPt ) const;
714  static sal_Int32 StartOfInputFieldAtPos( const SwPosition& rPos );
715  static sal_Int32 EndOfInputFieldAtPos( const SwPosition& rPos );
716 
717  // Return number of cursors in ring (The flag indicates whether
718  // only cursors containing selections are requested).
719  sal_uInt16 GetCursorCnt( bool bAll = true ) const;
720 
721  // Char Travelling - methods (in crstrvl1.cxx)
722  bool GoStartWord();
723  bool GoEndWord();
724  bool GoNextWord();
725  bool GoPrevWord();
726  bool GoNextSentence();
727  bool GoStartSentence();
728  bool GoEndSentence();
729  bool SelectWord( const Point* pPt );
730  void ExpandToSentenceBorders();
731 
732  // get position from current cursor
733  bool IsStartWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES )const;
734  bool IsEndWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
735  bool IsInWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
736  bool IsStartSentence() const;
737  bool IsEndSentence() const;
738  bool IsSttPara() const;
739  bool IsEndPara() const;
740  bool IsEndOfTable() const;
741  bool IsStartOfDoc() const;
742  bool IsEndOfDoc() const;
743  bool IsInFrontOfLabel() const;
744  bool IsAtLeftMargin() const { return IsAtLRMargin( true ); }
745  bool IsAtRightMargin() const { return IsAtLRMargin( false, true/*bAPI*/ ); }
746 
747  // delete all created cursors, set the table cursor and the last cursor to
748  // its TextNode (or StartNode?)
749  // They all get created on the next ::GetCursor again
750  // Used for Drag&Drop/Clipboard-Paste in tables
751  bool ParkTableCursor();
752 
753  // Non expanded attributes?
754  bool IsGCAttr() const { return m_bGCAttr; }
755  void ClearGCAttr() { m_bGCAttr = false; }
756  void UpdateAttr() { m_bGCAttr = true; }
757 
758  // is the whole document protected/hidden (for UI...)
759  bool IsAllProtect() const { return m_bAllProtect; }
760 
761  bool GotoRegion( const OUString& rName );
762 
763  // show the current selection
764  virtual void MakeSelVisible();
765 
766  // set the cursor to a NOT protected/hidden node
767  bool FindValidContentNode( bool bOnlyText );
768 
769  bool GetContentAtPos( const Point& rPt,
770  SwContentAtPos& rContentAtPos,
771  bool bSetCursor = false,
772  SwRect* pFieldRect = nullptr );
773 
774  const SwPostItField* GetPostItFieldAtCursor() const;
775 
776  // get smart tags rectangle for the given point
777  void GetSmartTagRect( const Point& rPt, SwRect& rSelectRect );
778 
779  // get smart tags at current cursor position
780  void GetSmartTagTerm( std::vector< OUString >& rSmartTagTypes,
781  css::uno::Sequence< css::uno::Reference< css::container::XStringKeyMap > >& rStringKeyMaps,
782  css::uno::Reference<css::text::XTextRange>& rRange ) const;
783 
784  bool IsPageAtPos( const Point &rPt ) const;
785 
786  bool SelectTextAttr( sal_uInt16 nWhich, bool bExpand, const SwTextAttr* pAttr = nullptr );
787  bool GotoINetAttr( const SwTextINetFormat& rAttr );
788  const SwFormatINetFormat* FindINetAttr( const OUString& rName ) const;
789 
790  bool SelectText( const sal_Int32 nStart,
791  const sal_Int32 nEnd );
792 
793  bool CheckTableBoxContent( const SwPosition* pPos = nullptr );
794  void SaveTableBoxContent( const SwPosition* pPos = nullptr );
795  void ClearTableBoxContent();
796  bool EndAllTableBoxEdit();
797 
798  void SetSelTableCells( bool bFlag ) { m_bSelTableCells = bFlag; }
799  bool IsSelTableCells() const { return m_bSelTableCells; }
800 
801  bool IsAutoUpdateCells() const { return m_bAutoUpdateCells; }
802  void SetAutoUpdateCells( bool bFlag ) { m_bAutoUpdateCells = bFlag; }
803 
804  bool GetShadowCursorPos( const Point& rPt, SwFillMode eFillMode,
805  SwRect& rRect, sal_Int16& rOrient );
806  bool SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode );
807 
808  const SwRangeRedline* SelNextRedline();
809  const SwRangeRedline* SelPrevRedline();
810  const SwRangeRedline* GotoRedline( SwRedlineTable::size_type nArrPos, bool bSelect );
811 
812  SAL_DLLPRIVATE SvxFrameDirection GetTextDirection( const Point* pPt = nullptr ) const;
813  // is cursor or the point in/over a vertical formatted text?
814  bool IsInVerticalText( const Point* pPt = nullptr ) const;
815  // is cursor or the point in/over a right to left formatted text?
816  bool IsInRightToLeftText() const;
817 
818  static void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage);
819  bool bColumnChange();
820  static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection);
821  static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn);
822  // If the current cursor position is inside a hidden range, the hidden range
823  // is selected and true is returned:
824  bool SelectHiddenRange();
825 
826  // remove all invalid cursors
827  void ClearUpCursors();
828 
829  void SetMacroExecAllowed( const bool _bMacroExecAllowed )
830  {
831  m_bMacroExecAllowed = _bMacroExecAllowed;
832  }
834  {
835  return m_bMacroExecAllowed;
836  }
837 
847  OUString GetCursorDescr() const;
848 
849  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
851  OUString getPageRectangles();
852 
854  void NotifyCursor(SfxViewShell* pViewShell) const;
855 };
856 
857 // Cursor Inlines:
859  SwDocPositions nStt, SwDocPositions nEnd, SwPaM* pPam ) const
860 {
861  return m_pCurrentCursor->MakeFindRange( nStt, nEnd, pPam );
862 }
863 
865 {
866  return static_cast<SwCursor*>(GetCursor());
867 }
868 
870 
872 
873 inline bool SwCursorShell::HasMark() { return m_pCurrentCursor->HasMark(); }
874 
875 inline bool SwCursorShell::IsSelection() const
876 {
877  return IsTableMode() || m_pCurrentCursor->HasMark() ||
879 }
881 {
883 }
884 
886 {
888 }
889 
891 {
893 }
894 
896 {
897  return m_pCurrentCursor->GetPtPos();
898 }
899 
900 inline const SwPaM* SwCursorShell::GetTableCrs() const
901 {
902  return m_pTableCursor;
903 }
904 
906 {
907  return m_pTableCursor;
908 }
909 
911 {
914 }
915 
916 #endif // _CRSRSH_HXX
917 
918 /* 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:489
bool IsAutoUpdateCells() const
Definition: crsrsh.hxx:801
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
void ClearGCAttr()
Definition: crsrsh.hxx:755
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor >> &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
Definition: autofmt.cxx:1127
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:353
const Link< SwCursorShell &, void > & GetGrfArrivedLnk() const
Definition: crsrsh.hxx:490
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:185
void SetAutoUpdateCells(bool bFlag)
Definition: crsrsh.hxx:802
check overlapping PaMs
Definition: crsrsh.hxx:158
virtual SwPaM & CreateNewShellCursor()=0
bool IsTableMode() const
Definition: crsrsh.hxx:643
bool IsAllProtect() const
Definition: crsrsh.hxx:759
bool SelTableRow()
Definition: crsrsh.hxx:600
void SetFlyMacroLnk(const Link< const SwFlyFrameFormat *, void > &rLnk)
Definition: crsrsh.hxx:481
void SetMacroExecAllowed(const bool _bMacroExecAllowed)
Definition: crsrsh.hxx:829
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:1091
sal_uIntPtr sal_uLong
const SfxPoolItem * pAttr
Definition: crsrsh.hxx:100
const SwShellCursor * GetCursor_() const
Definition: crsrsh.hxx:331
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:573
void SetChgLnk(const Link< SwCursorShell *, void > &rLnk)
Definition: crsrsh.hxx:485
SwCursor * GetSwCursor() const
Definition: crsrsh.hxx:864
Definition: doc.hxx:185
SwShellCursor * m_pStackCursor
stack for the cursor
Definition: crsrsh.hxx:180
const SwShellTableCursor * GetTableCursor() const
Definition: crsrsh.hxx:645
sal_uInt16 m_nCursorMove
Definition: crsrsh.hxx:204
void UpdateAttr()
Definition: crsrsh.hxx:756
bool Left(sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:351
virtual void VisPortChgd(const SwRect &)
Definition: viewsh.cxx:1081
SvxFrameDirection
SwFrame * m_oldColFrame
Definition: crsrsh.hxx:234
Dialog to specify the properties of drop-down form field.
Definition: accframe.hxx:34
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
bool HasShellFocus() const
Definition: crsrsh.hxx:450
SwPaM * GetStackCursor() const
Definition: crsrsh.hxx:869
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
long GetUpDownX() const
Definition: crsrsh.hxx:349
SwMoveFnCollection const & MakeFindRange(SwDocPositions, SwDocPositions, SwPaM *) const
Definition: crsrsh.hxx:858
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:356
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:462
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:601
Point m_aOldRBPos
Right/Bottom of last VisArea.
Definition: crsrsh.hxx:170
SwFillMode
Definition: crstate.hxx:26
const Link< SwCursorShell *, void > & GetChgLnk() const
Definition: crsrsh.hxx:486
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:482
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:330
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:875
bool LeftMargin()
Definition: crsrsh.hxx:357
const SwTableNode * IsCursorInTable() const
Definition: crsrsh.hxx:885
SwNodeType
Definition: ndtyp.hxx:28
bool(* SwWhichPara)(SwPaM &, SwMoveFnCollection const &)
Definition: cshtyp.hxx:43
const SwPaM * GetTableCrs() const
Definition: crsrsh.hxx:900
const SwRect & VisArea() const
Definition: viewsh.cxx:570
const SwField * pField
Definition: crsrsh.hxx:99
bool Up(sal_uInt16 nCnt=1)
Definition: crsrsh.hxx:355
const SwShellCursor * getShellCursor(bool bBlock) const
Definition: crsrsh.hxx:637
const SwPosition * GetPoint() const
Definition: pam.hxx:207
bool IsGCAttr() const
Definition: crsrsh.hxx:754
bool IsBlockMode() const
Definition: crsrsh.hxx:640
SwLayoutFrame *(* SwWhichPage)(const SwLayoutFrame *)
Definition: cshtyp.hxx:34
vector_type::size_type size_type
Definition: docary.hxx:331
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
bool RightMargin(bool bAPI=false)
Definition: crsrsh.hxx:358
void SetMark()
Definition: crsrsh.hxx:871
Marks a node in the document model.
Definition: ndindex.hxx:31
SwContentNode * pNode
Definition: crsrsh.hxx:102
bool IsOverwriteCursor() const
Definition: crsrsh.hxx:461
bool IsSelTableCells() const
Definition: crsrsh.hxx:799
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:1023
#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:873
CursorMoveState
Definition: crstate.hxx:119
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:833
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:880
bool IsReadOnlyAvailable() const
Definition: crsrsh.hxx:476
bool IsAtRightMargin() const
Definition: crsrsh.hxx:745
SwContentFrame *(* SwPosPage)(const SwLayoutFrame *)
Definition: cshtyp.hxx:38
sal_uLong m_nCurrentNode
Definition: crsrsh.hxx:194
bool IsCursorVisible() const
Definition: crsrsh.hxx:522
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:646
virtual SwPaM & GetCurrentShellCursor()=0
unsigned char sal_uInt8
bool IsCursorPtAtEnd() const
Definition: crsrsh.hxx:890
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:1761
const SwRect & GetCharRect() const
Definition: crsrsh.hxx:518
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:910
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:798
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:128
SwContentAtPos(IsAttrAtPos eGetAtPos)
Definition: crsrsh.hxx:110
bool IsAtLeftMargin() const
Definition: crsrsh.hxx:744
Point & GetCursorDocPos() const
Definition: crsrsh.hxx:895
Access to the block cursor.
Definition: BlockCursor.hxx:38
bool(* SwWhichSection)(SwPaM &, SwMoveFnCollection const &)
Definition: cshtyp.hxx:51
only for debugging
union SwContentAtPos::@25 aFnd