update emoji autocorrect entries from po-files
[LibreOffice.git] / sw / inc / crsrsh.hxx
blob073a8dfb1d8d62658020464d864b0d27ac52f9b1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_CRSRSH_HXX
20 #define INCLUDED_SW_INC_CRSRSH_HXX
22 #include <com/sun/star/i18n/WordType.hpp>
24 #include <rtl/ustring.hxx>
25 #include <tools/link.hxx>
26 #include <tools/rtti.hxx>
27 #include <vcl/keycod.hxx>
29 #include <IShellCursorSupplier.hxx>
30 #include "swdllapi.h"
31 #include <swtypes.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 <IDocumentMarkAccess.hxx>
42 class SfxItemSet;
43 class SfxPoolItem;
44 class SwContentFrm;
45 class SwCrsrShell;
46 class SwCursor;
47 class SwField;
48 class SwFieldType;
49 class SwFormat;
50 class SwFormatField;
51 class SwNodeIndex;
52 class SwPaM;
53 class SwShellCrsr;
54 class SwShellTableCrsr;
55 class SwTableNode;
56 class SwTextFormatColl;
57 class SwVisCrsr;
58 class SwTextINetFormat;
59 class SwFormatINetFormat;
60 class SwTextAttr;
61 class SwTableBox;
62 class SwTOXMark;
63 class SwRangeRedline;
64 class IBlockCursor;
65 class SwContentNode;
66 class SwPostItField;
67 class SwTextField;
68 struct SwPosition;
70 namespace com { namespace sun { namespace star { namespace util {
71 struct SearchOptions;
72 } } } }
74 namespace com { namespace sun { namespace star { namespace text {
75 class XTextRange;
76 }}}}
78 namespace com { namespace sun { namespace star { namespace container {
79 class XStringKeyMap;
80 }}}}
82 // enum and struct to get information via the Doc-Position
84 struct SwContentAtPos
86 enum IsAttrAtPos
88 SW_NOTHING = 0x0000,
89 SW_FIELD = 0x0001,
90 SW_CLICKFIELD = 0x0002,
91 SW_FTN = 0x0004,
92 SW_INETATTR = 0x0008,
93 SW_TABLEBOXFML = 0x0010,
94 SW_REDLINE = 0x0020,
95 SW_OUTLINE = 0x0040,
96 SW_TOXMARK = 0x0080,
97 SW_REFMARK = 0x0100,
98 SW_NUMLABEL = 0x0200,
99 SW_CONTENT_CHECK = 0x0400,
100 SW_SMARTTAG = 0x0800,
101 SW_FORMCTRL = 0x1000
102 #ifdef DBG_UTIL
103 ,SW_CURR_ATTRS = 0x4000 ///< only for debugging
104 ,SW_TABLEBOXVALUE = 0x8000 ///< only for debugging
105 #endif
106 } eContentAtPos;
108 union {
109 const SwField* pField;
110 const SfxPoolItem* pAttr;
111 const SwRangeRedline* pRedl;
112 SwContentNode * pNode;
113 const sw::mark::IFieldmark* pFieldmark;
114 } aFnd;
116 int nDist;
118 OUString sStr;
119 const SwTextAttr* pFndTextAttr;
121 SwContentAtPos( int eGetAtPos = 0xffff )
122 : eContentAtPos( (IsAttrAtPos)eGetAtPos )
124 aFnd.pField = 0;
125 pFndTextAttr = 0;
126 nDist = 0; // #i23726#
129 bool IsInProtectSect() const;
130 bool IsInRTLText()const;
133 // return values of SetCrsr (can be combined via ||)
134 const int CRSR_POSOLD = 0x01, // cursor stays at old position
135 CRSR_POSCHG = 0x02; // position changed by the layout
137 /// Helperfunction to resolve backward references in regular expressions
138 OUString *ReplaceBackReferences( const com::sun::star::util::SearchOptions& rSearchOpt, SwPaM* pPam );
140 class SW_DLLPUBLIC SwCrsrShell
141 : public SwViewShell
142 , public SwModify
143 , public ::sw::IShellCursorSupplier
145 friend class SwCallLink;
146 friend class SwVisCrsr;
147 friend class SwSelPaintRects;
149 // requires the Crsr as InternalCrsr
150 friend bool GetAutoSumSel( const SwCrsrShell&, SwCellFrms& );
152 public:
154 /** for calling UpdateCrsr */
155 enum CrsrFlag {
156 UPDOWN = (1 << 0), ///< keep Up/Down on columns
157 SCROLLWIN = (1 << 1), ///< scroll window
158 CHKRANGE = (1 << 2), ///< check overlapping PaMs
159 NOCALRECT = (1 << 3), ///< don't recalculate CharRect
160 READONLY = (1 << 4) ///< make visible in spite of Readonly
163 private:
165 SwRect m_aCharRect; ///< Char-SRectangle on which the cursor is located
166 Point m_aCrsrHeight; ///< height & offset from visible Cursor
167 Point m_aOldRBPos; ///< Right/Bottom of last VisArea
168 // (used in Invalidate by Cursor)
170 Link<> m_aFlyMacroLnk; /**< Link will be called, if the Crsr is set
171 into a fly. A macro can be then becalled */
172 Link<> m_aChgLnk; /**< link will be called by every attribute/
173 format changes at cursor position.*/
174 Link<> m_aGrfArrivedLnk; ///< Link calls to UI if a graphic is arrived
176 SwShellCrsr* m_pCurCrsr; ///< current cursor
177 SwShellCrsr* m_pCrsrStk; ///< stack for the cursor
178 SwVisCrsr *m_pVisCrsr; ///< the visible cursor
180 IBlockCursor *m_pBlockCrsr; ///< interface of cursor for block (=rectangular) selection
182 SwShellTableCrsr* m_pTableCrsr; /**< table Crsr; only in tables when the
183 selection lays over 2 columns */
185 SwNodeIndex* m_pBoxIdx; ///< for recognizing of the changed
186 SwTableBox* m_pBoxPtr; ///< table row
188 long m_nUpDownX; /**< try to move the cursor on up/down always
189 in the same column */
190 long m_nLeftFrmPos;
191 sal_uLong m_nAktNode; // save CursorPos at Start-Action
192 sal_Int32 m_nAktContent;
193 sal_uInt16 m_nAktNdTyp;
194 bool m_bAktSelection;
197 * Via the Method SttCrsrMove and EndCrsrMove this counter gets
198 * incremented/decremented. As long as the counter is inequal to 0, the
199 * current Cursor gets no update. This way, "complicated" cursor movements
200 * (via Find()) can be realised.
202 sal_uInt16 m_nCrsrMove;
203 sal_uInt16 m_nBasicActionCnt; ///< Actions which are parenthesized by Basic
204 CrsrMoveState m_eMvState; ///< Status for Crsr-Travelling - GetCrsrOfst
206 OUString m_sMarkedListId;
207 int m_nMarkedListLevel;
209 bool m_bHasFocus : 1; ///< Shell is "active" in a window
210 bool m_bSVCrsrVis : 1; ///< SV-Cursor visible/invisible
211 bool m_bChgCallFlag : 1; ///< attribute change inside Start- and EndAction
212 bool m_bVisPortChgd : 1; ///< in VisPortChg-Call
213 // (used in Invalidate by the Cursor)
215 bool m_bCallChgLnk : 1; ///< flag for derived classes
216 // true -> call ChgLnk
217 // access only via SwChgLinkFlag
218 bool m_bAllProtect : 1; ///< Flag for areas
219 // true -> everything protected / hidden
220 bool m_bInCMvVisportChgd : 1; ///< Flag for CrsrMoves
221 // true -> view was moved
222 bool m_bGCAttr : 1; // true -> non expanded attributes exist.
223 bool m_bIgnoreReadonly : 1; // true -> make the cursor visible on next
224 // EndAction in spite of Readonly
225 bool m_bSelTableCells : 1; // true -> select cells over the InputWin
226 bool m_bAutoUpdateCells : 1; // true -> autoformat cells
227 bool m_bBasicHideCrsr : 1; // true -> HideCrsr from Basic
228 bool m_bSetCrsrInReadOnly : 1;// true -> Cursor is allowed in ReadOnly-Areas
229 bool m_bOverwriteCrsr : 1; // true -> show Overwrite Crsr
231 bool m_bMacroExecAllowed : 1;
233 SwFrm* m_oldColFrm;
235 SAL_DLLPRIVATE void UpdateCrsr(
236 sal_uInt16 eFlags = SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE,
237 bool bIdleEnd = false );
239 SAL_DLLPRIVATE void MoveCrsrToNum();
241 SAL_DLLPRIVATE void _ParkPams( SwPaM* pDelRg, SwShellCrsr** ppDelRing );
243 /** Mark a certain list level of a certain list
245 levels of a certain lists are marked now
247 @param sListId list Id of the list whose level is marked
248 @param nLevel to be marked list level
250 An empty sListId denotes that no level of a list is marked.
252 SAL_DLLPRIVATE void MarkListLevel( const OUString& sListId,
253 const int nLevel );
255 // private method(s) accessed from public inline method(s) must be exported.
256 bool LeftRight( bool, sal_uInt16, sal_uInt16, bool );
257 SAL_DLLPRIVATE bool UpDown( bool, sal_uInt16 );
258 SAL_DLLPRIVATE bool LRMargin( bool, bool bAPI = false );
259 SAL_DLLPRIVATE bool IsAtLRMargin( bool, bool bAPI = false ) const;
261 SAL_DLLPRIVATE short GetTextDirection( const Point* pPt = 0 ) const;
263 SAL_DLLPRIVATE bool isInHiddenTextFrm(SwShellCrsr* pShellCrsr);
265 typedef bool (SwCursor:: *FNCrsr)();
266 SAL_DLLPRIVATE bool CallCrsrFN( FNCrsr );
268 SAL_DLLPRIVATE const SwRangeRedline* _GotoRedline( sal_uInt16 nArrPos, bool bSelect );
270 protected:
272 inline SwMoveFnCollection* MakeFindRange( sal_uInt16, sal_uInt16, SwPaM* ) const;
275 * Compare-Methode for the StackCursor and the current Cursor.
276 * The Methods return -1, 0, 1 for lower, equal, greater. The enum
277 * CrsrCompareType says which position is compared.
279 enum CrsrCompareType {
280 StackPtStackMk,
281 StackPtCurrPt,
282 StackPtCurrMk,
283 StackMkCurrPt,
284 StackMkCurrMk,
285 CurrPtCurrMk
287 int CompareCursor( CrsrCompareType eType ) const;
289 // set all PaMs in OldNode to NewPos + Offset
290 void PaMCorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos,
291 const sal_Int32 nOffset = 0 );
293 bool _SelTableRowOrCol( bool bRow, bool bRowSimple = false );
295 bool SetInFrontOfLabel( bool bNew );
297 void RefreshBlockCursor();
299 /** Updates the marked list level according to the cursor.
301 SAL_DLLPRIVATE void UpdateMarkedListLevel();
303 protected:
304 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
306 public:
307 TYPEINFO_OVERRIDE();
308 SwCrsrShell( SwDoc& rDoc, vcl::Window *pWin, const SwViewOption *pOpt = 0 );
309 // disguised copy constructor
310 SwCrsrShell( SwCrsrShell& rShell, vcl::Window *pWin );
311 virtual ~SwCrsrShell();
313 // create new cursor and append the old one
314 virtual SwPaM & CreateNewShellCursor() SAL_OVERRIDE;
315 virtual SwPaM & GetCurrentShellCursor() SAL_OVERRIDE;
317 SwPaM * CreateCrsr();
318 ///< delete the current cursor and make the following into the current
319 bool DestroyCrsr();
320 ///< transform TableCursor to normal cursor, nullify Tablemode
321 void TableCrsrToCursor();
322 ///< enter block mode, change normal cursor into block cursor
323 void CrsrToBlockCrsr();
324 ///< leave block mode, change block cursor into normal cursor
325 void BlockCrsrToCrsr();
327 // SelAll() selects the document body content
328 // if ExtendedSelect() is called afterwards, the whole nodes array is selected
329 // only for usage in special cases allowed!
330 void ExtendedSelectAll(bool bFootnotes = true);
331 /// If ExtendedSelectAll() was called and selection didn't change since then.
332 bool ExtendedSelectedAll(bool bFootnotes = true);
333 /// If document body starts with a table.
334 bool StartsWithTable();
336 SwPaM* GetCrsr( bool bMakeTableCrsr = true ) const;
337 inline SwCursor* GetSwCrsr( bool bMakeTableCrsr = true ) const;
338 // return only the current cursor
339 SwShellCrsr* _GetCrsr() { return m_pCurCrsr; }
340 const SwShellCrsr* _GetCrsr() const { return m_pCurCrsr; }
342 // show passed cursor - for UNO
343 void SetSelection(const SwPaM& rCrsr);
345 // remove all cursors from ContentNodes and set to 0
346 void ParkCrsr( const SwNodeIndex &rIdx );
348 // return the current cursor stack
349 // (required in EditShell when deleting contents)
350 inline SwPaM* GetStkCrsr() const;
352 // start parenthesing, hide SV-Cursor and selected areas
353 void StartAction();
354 // end parenthesing, show SV-Cursor and selected areas
355 void EndAction( const bool bIdleEnd = false, const bool DoSetPosX = false );
357 // basic cursor travelling
358 long GetUpDownX() const { return m_nUpDownX; }
360 bool Left( sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual = false )
361 { return LeftRight( true, nCnt, nMode, bAllowVisual ); }
362 bool Right( sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual = false )
363 { return LeftRight( false, nCnt, nMode, bAllowVisual ); }
364 bool Up( sal_uInt16 nCnt = 1 ) { return UpDown( true, nCnt ); }
365 bool Down( sal_uInt16 nCnt = 1 ) { return UpDown( false, nCnt ); }
366 bool LeftMargin() { return LRMargin( true ); }
367 bool RightMargin(bool bAPI = false) { return LRMargin( false, bAPI ); }
368 bool SttEndDoc( bool bStt );
370 bool MovePage( SwWhichPage, SwPosPage );
371 bool MovePara( SwWhichPara, SwPosPara );
372 bool MoveSection( SwWhichSection, SwPosSection );
373 bool MoveTable( SwWhichTable, SwPosTable );
374 bool MoveColumn( SwWhichColumn, SwPosColumn );
375 bool MoveRegion( SwWhichRegion, SwPosRegion );
377 sal_uLong Find( const com::sun::star::util::SearchOptions& rSearchOpt,
378 bool bSearchInNotes,
379 SwDocPositions eStart, SwDocPositions eEnd,
380 bool& bCancel,
381 FindRanges eRng, bool bReplace = false );
383 sal_uLong Find( const SwTextFormatColl& rFormatColl,
384 SwDocPositions eStart, SwDocPositions eEnd,
385 bool& bCancel,
386 FindRanges eRng, const SwTextFormatColl* pReplFormat = 0 );
388 sal_uLong Find( const SfxItemSet& rSet, bool bNoCollections,
389 SwDocPositions eStart, SwDocPositions eEnd,
390 bool& bCancel,
391 FindRanges eRng,
392 const com::sun::star::util::SearchOptions* pSearchOpt = 0,
393 const SfxItemSet* rReplSet = 0 );
395 // Position the Cursor
396 // return values:
397 // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
398 // CRSR_POSOLD: when the cursor was not changed
399 int SetCrsr( const Point &rPt, bool bOnlyText = false, bool bBlock = true );
402 * Notification that the visible area was changed. m_aVisArea is reset, then
403 * scrolling is done. The passed Rectangle lays on pixel borders to avoid
404 * pixel errors.
406 virtual void VisPortChgd( const SwRect & ) SAL_OVERRIDE;
409 * virtual paint method to make selection visible again after Paint
411 void Paint(vcl::RenderContext& rRenderContext, const Rectangle & rRect) SAL_OVERRIDE;
413 // Areas
414 inline void SetMark();
415 inline bool HasMark();
417 void ClearMark();
420 Ensure point and mark of the current PaM are in a specific order.
422 @param bPointFirst true: If the point is behind the mark then
423 swap the PaM. false: If the mark is behind the point then swap
424 the PaM.
426 void NormalizePam(bool bPointFirst = true);
428 void SwapPam();
429 bool ChgCurrPam( const Point & rPt,
430 bool bTstOnly = true, // test only, don't set
431 bool bTstHit = false ); // only exact matches
432 void KillPams();
434 // story a copy of the cursor in the stack
435 void Push();
437 * Delete a cursor (controlled by bOldCrsr)
438 * - from stack or (bOldCrsr = true)
439 * - delete the current one and replace it with the cursor from the
440 * stack
441 * Return: whether there was one left one the stack
443 bool Pop( bool bOldCrsr = true );
445 * Combine 2 Cursors.
446 * Delete the topmost from the stack and move its Mark into the current.
448 void Combine();
450 void SttCrsrMove();
451 void EndCrsrMove( const bool bIdleEnd = false );
454 * When the focus is lost the selected ranges are not displayed anymore.
455 * On the other hand, on receiving the focus all selected ranges are displayed again
456 * (ranges must be recalculated!).
458 bool HasShFcs() const { return m_bHasFocus; }
459 void ShLooseFcs();
460 void ShGetFcs( bool bUpdate = true );
462 // Methods for displaying or hiding the visible text cursor.
463 void ShowCrsr();
464 void HideCrsr();
465 // Methods for displaying or hiding the selected ranges with visible cursor.
466 void ShowCrsrs( bool bCrsrVis );
467 void HideCrsrs();
469 bool IsOverwriteCrsr() const { return m_bOverwriteCrsr; }
470 void SetOverwriteCrsr( bool bFlag ) { m_bOverwriteCrsr = bFlag; }
472 // Return current frame in which the cursor is placed.
473 SwContentFrm *GetCurrFrm( const bool bCalcFrm = true ) const;
475 //true if cursor is hidden because of readonly.
476 //false if it is working despite readonly.
477 bool IsCrsrReadonly() const;
479 // Cursor is placed in something that is protected or selection contains
480 // something that is protected.
481 bool HasReadonlySel(bool bAnnotationMode = false) const;
483 // Can the cursor be set to read only ranges?
484 bool IsReadOnlyAvailable() const { return m_bSetCrsrInReadOnly; }
485 void SetReadOnlyAvailable( bool bFlag );
486 bool IsOverReadOnlyPos( const Point& rPt ) const;
488 // Methods for aFlyMacroLnk.
489 void SetFlyMacroLnk( const Link<>& rLnk ) { m_aFlyMacroLnk = rLnk; }
490 const Link<>& GetFlyMacroLnk() const { return m_aFlyMacroLnk; }
492 // Methods returning/altering link for changes of attributes/formates.
493 void SetChgLnk( const Link<> &rLnk ) { m_aChgLnk = rLnk; }
494 const Link<>& GetChgLnk() const { return m_aChgLnk; }
496 // Methods returning/altering ling for "graphic completely loaded".
497 void SetGrfArrivedLnk( const Link<> &rLnk ) { m_aGrfArrivedLnk = rLnk; }
498 const Link<>& GetGrfArrivedLnk() const { return m_aGrfArrivedLnk; }
500 //Call ChgLink. When within an action calling will be delayed.
501 void CallChgLnk();
503 // Check if the current cursor contains a selection, i.e.
504 // if Mark is set and SPoint and Mark are different.
505 bool HasSelection() const;
507 // Check if a selection exists, i.e. if the current cursor comprises a selection.
508 inline bool IsSelection() const;
509 // returns if multiple cursors are available
510 inline bool IsMultiSelection() const;
512 // Check if a complete paragraph was selected.
513 bool IsSelFullPara() const;
515 // Check if selection is within one paragraph.
517 //Should WaitPtr be activated for Clipboard.
518 bool ShouldWait() const;
520 // Check if selection is within one paragraph.
521 inline bool IsSelOnePara() const;
524 * Returns SRectangle, at which the cursor is located.
526 const SwRect &GetCharRect() const { return m_aCharRect; }
528 * Returns if cursor is wholly or partly within visible range.
530 bool IsCrsrVisible() const { return VisArea().IsOver( GetCharRect() ); }
532 * Returns SwRect, at which the character is located.
534 bool GetCharRectAt(SwRect& rRect, const SwPosition* pPos);
536 // Return current page number:
537 // true: in which cursor is located.
538 // false: which is visible at the upper margin.
539 void GetPageNum( sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum,
540 bool bAtCrsrPos = true, const bool bCalcFrm = true );
541 // Determine how "empty pages" are handled
542 // (used in PhyPage).
543 sal_uInt16 GetNextPrevPageNum( bool bNext = true );
545 // Move cursor at the bginning of page "nPage".
546 bool GotoPage( sal_uInt16 nPage );
548 sal_uInt16 GetPageCnt();
550 bool GoNextCrsr();
552 bool GoPrevCrsr();
554 // at CurCrsr.SPoint
555 ::sw::mark::IMark* SetBookmark(
556 const vcl::KeyCode&,
557 const OUString& rName,
558 const OUString& rShortName,
559 IDocumentMarkAccess::MarkType eMark = IDocumentMarkAccess::MarkType::BOOKMARK);
560 bool GotoMark( const ::sw::mark::IMark* const pMark ); // sets CurCrsr.SPoint
561 bool GotoMark( const ::sw::mark::IMark* const pMark, bool bAtStart );
562 bool GoNextBookmark(); // true, if there was one
563 bool GoPrevBookmark();
565 bool IsFormProtected();
566 ::sw::mark::IFieldmark* GetCurrentFieldmark();
567 ::sw::mark::IFieldmark* GetFieldmarkAfter();
568 ::sw::mark::IFieldmark* GetFieldmarkBefore();
569 bool GotoFieldmark( const ::sw::mark::IFieldmark* const pMark );
571 // update Cursr, i.e. reset it into content should only be called when the
572 // cursor was set to a random position e.g. when deleting frames
573 void UpdateCrsrPos();
575 // get the selected text at the current cursor. it will be filled with
576 // fields etc.
577 OUString GetSelText() const;
578 // return only the text starting from the current cursor position (to the
579 // end of the node)
580 OUString GetText() const;
582 // Check of SPoint or Mark of current cursor are placed within a table.
583 inline const SwTableNode* IsCrsrInTable( bool bIsPtInTable = true ) const;
585 inline Point& GetCrsrDocPos( bool bPoint = true ) const;
586 inline bool IsCrsrPtAtEnd() const;
588 inline const SwPaM* GetTableCrs() const;
589 inline SwPaM* GetTableCrs();
591 bool IsTableComplexForChart();
592 // get current table selection as text
593 OUString GetBoxNms() const;
595 // set Crsr to the next/previous cell
596 bool GoNextCell( bool bAppendLine = true );
597 bool GoPrevCell();
598 // go to this box (if available and inside of table)
599 bool GotoTable( const OUString& rName );
601 // select a table row, column or box (based on the current cursor)
602 bool SelTableRow() { return _SelTableRowOrCol( true ); }
603 bool SelTableCol() { return _SelTableRowOrCol( false ); }
604 bool SelTableBox();
606 bool SelTable();
608 bool GotoNextNum();
609 bool GotoPrevNum();
611 bool GotoOutline( const OUString& rName );
612 // to the next/previous or the given OutlineNode
613 void GotoOutline( sal_uInt16 nIdx );
614 // find the "outline position" in the nodes array of the current chapter
615 sal_uInt16 GetOutlinePos( sal_uInt8 nLevel = UCHAR_MAX );
616 // select the given range of OutlineNodes. Optionally including the children
617 // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell)
618 bool MakeOutlineSel( sal_uInt16 nSttPos, sal_uInt16 nEndPos,
619 bool bWithChildren = false );
621 bool GotoNextOutline();
622 bool GotoPrevOutline();
624 /** Delivers the current shell cursor
626 Some operations have to run on the current cursor ring,
627 some on the m_pTableCrsr (if exist) or the current cursor ring and
628 some on the m_pTableCrsr or m_pBlockCrsr or the current cursor ring.
629 This small function checks the existence and delivers the wished cursor.
631 @param bBlock [bool]
632 if the block cursor is of interest or not
634 @return m_pTableCrsr if exist,
635 m_pBlockCrsr if exist and of interest (param bBlock)
636 otherwise m_pCurCrsr
638 SwShellCrsr* getShellCrsr( bool bBlock );
639 const SwShellCrsr* getShellCrsr( bool bBlock ) const
640 { return (const_cast<SwCrsrShell*>(this))->getShellCrsr( bBlock ); }
642 bool IsBlockMode() const { return 0 != m_pBlockCrsr; }
643 const IBlockCursor* GetBlockCrsr() const { return m_pBlockCrsr; }
644 IBlockCursor* GetBlockCrsr() { return m_pBlockCrsr; }
646 // is the Crsr in a table and is the selection over 2 columns
647 bool IsTableMode() const { return 0 != m_pTableCrsr; }
649 const SwShellTableCrsr* GetTableCrsr() const { return m_pTableCrsr; }
650 SwShellTableCrsr* GetTableCrsr() { return m_pTableCrsr; }
651 size_t UpdateTableSelBoxes();
653 bool GotoFootnoteText(); ///< jump from content to footnote
654 bool GotoFootnoteAnchor(); ///< jump from footnote to anchor
655 bool GotoPrevFootnoteAnchor();
656 bool GotoNextFootnoteAnchor();
658 bool GotoFlyAnchor(); ///< jump from the frame to the anchor
659 bool GotoHeaderText(); ///< jump from the content to the header
660 bool GotoFooterText(); ///< jump from the content to the footer
661 // jump to the header/footer of the given or current PageDesc
662 bool SetCrsrInHdFt( size_t nDescNo = SIZE_MAX,
663 bool bInHeader = true );
664 // is point of cursor in header/footer. pbInHeader return true if it is
665 // in a headerframe otherwise in a footerframe
666 bool IsInHeaderFooter( bool* pbInHeader = 0 ) const;
668 bool GotoNextTOXBase( const OUString* = 0 );
669 bool GotoPrevTOXBase( const OUString* = 0 );
670 bool GotoTOXMarkBase();
671 // jump to the next or previous index entry
672 bool GotoNxtPrvTOXMark( bool bNext = true );
673 // jump to the next/previous index mark of this type
674 const SwTOXMark& GotoTOXMark( const SwTOXMark& rStart, SwTOXSearch eDir );
676 // jump to the next or previous table formula
677 // optionally only to broken formulas
678 bool GotoNxtPrvTableFormula( bool bNext = true,
679 bool bOnlyErrors = false );
680 // jump to the next / previous hyperlink - inside text and also
681 // on graphics
682 bool SelectNxtPrvHyperlink( bool bNext = true );
684 bool GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType = 0,
685 sal_uInt16 nSeqNo = 0 );
687 // get the nth character from the start or end of the current selection
688 sal_Unicode GetChar( bool bEnd = true, long nOffset = 0 );
689 bool ExtendSelection( bool bEnd = true, sal_Int32 nCount = 1 );
691 // Place only the visible cursor at the given position in the document.
692 // Return false if SPoint was corrected by layout.
693 // (This is needed for displaying the Drag&Drop/Copy-Cursor.)
694 bool SetVisCrsr( const Point &rPt );
695 inline void UnSetVisCrsr();
697 // jump to the next or previous field of the corresponding type
698 bool MoveFieldType(
699 const SwFieldType* pFieldType,
700 const bool bNext,
701 const sal_uInt16 nResType = USHRT_MAX,
702 const bool bAddSetExpressionFieldsToInputFields = true );
704 bool GotoFormatField( const SwFormatField& rField );
706 static SwTextField* GetTextFieldAtPos(
707 const SwPosition* pPos,
708 const bool bIncludeInputFieldAtStart );
709 static SwField* GetFieldAtCrsr(
710 const SwPaM* pCrsr,
711 const bool bIncludeInputFieldAtStart );
712 SwField* GetCurField( const bool bIncludeInputFieldAtStart = false ) const;
713 bool CrsrInsideInputField() const;
714 static bool PosInsideInputField( const SwPosition& rPos );
715 bool DocPtInsideInputField( const Point& rDocPt ) const;
716 static sal_Int32 StartOfInputFieldAtPos( const SwPosition& rPos );
717 static sal_Int32 EndOfInputFieldAtPos( const SwPosition& rPos );
719 // Return number of cursors in ring (The flag indicates whether
720 // only cursors containing selections are requested).
721 sal_uInt16 GetCrsrCnt( bool bAll = true ) const;
723 // Char Travelling - methods (in crstrvl1.cxx)
724 bool GoStartWord();
725 bool GoEndWord();
726 bool GoNextWord();
727 bool GoPrevWord();
728 bool GoNextSentence();
729 bool GoStartSentence();
730 bool GoEndSentence();
731 bool SelectWord( const Point* pPt = 0 );
732 bool ExpandToSentenceBorders();
734 // get position from current cursor
735 bool IsStartWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES )const;
736 bool IsEndWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
737 bool IsInWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const;
738 bool IsStartSentence() const;
739 bool IsEndSentence() const;
740 bool IsSttPara() const;
741 bool IsEndPara() const;
742 bool IsEndOfTable() const; ///< at the very last SwPosition inside a table
743 bool IsStartOfDoc() const;
744 bool IsEndOfDoc() const;
745 bool IsInFrontOfLabel() const;
746 bool IsAtLeftMargin() const { return IsAtLRMargin( true ); }
747 bool IsAtRightMargin(bool bAPI = false) const { return IsAtLRMargin( false, bAPI ); }
749 // delete all created cursors, set the table cursor and the last cursor to
750 // its TextNode (or StartNode?)
751 // They all get created on the next ::GetCrsr again
752 // Used for Drag&Drop/Clipboard-Paste in tables
753 bool ParkTableCrsr();
755 // Non expanded attributes?
756 bool IsGCAttr() const { return m_bGCAttr; }
757 void ClearGCAttr() { m_bGCAttr = false; }
758 void UpdateAttr() { m_bGCAttr = true; }
760 // is the whole document protected/hidden (for UI...)
761 bool IsAllProtect() const { return m_bAllProtect; }
763 bool BasicActionPend() const { return m_nBasicActionCnt != mnStartAction; }
765 bool GotoRegion( const OUString& rName );
767 // show the current selection
768 virtual void MakeSelVisible();
770 // set the cursor to a NOT protected/hidden node
771 bool FindValidContentNode( bool bOnlyText = false );
773 bool GetContentAtPos( const Point& rPt,
774 SwContentAtPos& rContentAtPos,
775 bool bSetCrsr = false,
776 SwRect* pFieldRect = 0 );
778 const SwPostItField* GetPostItFieldAtCursor() const;
780 // get smart tags at point position
781 void GetSmartTagTerm( const Point& rPt,
782 SwRect& rSelectRect,
783 ::com::sun::star::uno::Sequence< OUString >& rSmartTagTypes,
784 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > >& rStringKeyMaps,
785 ::com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rRange );
787 // get smart tags at current cursor position
788 void GetSmartTagTerm( ::com::sun::star::uno::Sequence< OUString >& rSmartTagTypes,
789 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > >& rStringKeyMaps,
790 ::com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rRange ) const;
792 bool IsPageAtPos( const Point &rPt ) const;
794 bool SelectTextAttr( sal_uInt16 nWhich, bool bExpand, const SwTextAttr* pAttr = 0 );
795 bool GotoINetAttr( const SwTextINetFormat& rAttr );
796 const SwFormatINetFormat* FindINetAttr( const OUString& rName ) const;
798 bool SelectText( const sal_Int32 nStart,
799 const sal_Int32 nEnd );
801 bool CheckTableBoxContent( const SwPosition* pPos = 0 );
802 void SaveTableBoxContent( const SwPosition* pPos = 0 );
803 void ClearTableBoxContent();
804 bool EndAllTableBoxEdit();
806 void SetSelTableCells( bool bFlag ) { m_bSelTableCells = bFlag; }
807 bool IsSelTableCells() const { return m_bSelTableCells; }
809 bool IsAutoUpdateCells() const { return m_bAutoUpdateCells; }
810 void SetAutoUpdateCells( bool bFlag ) { m_bAutoUpdateCells = bFlag; }
812 bool GetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode,
813 SwRect& rRect, short& rOrient );
814 bool SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode );
816 const SwRangeRedline* SelNextRedline();
817 const SwRangeRedline* SelPrevRedline();
818 const SwRangeRedline* GotoRedline( sal_uInt16 nArrPos, bool bSelect = false );
820 // is cursor or the point in/over a vertical formatted text?
821 bool IsInVerticalText( const Point* pPt = 0 ) const;
822 // is cursor or the point in/over a right to left formatted text?
823 bool IsInRightToLeftText( const Point* pPt = 0 ) const;
825 static void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage);
826 bool bColumnChange();
827 static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection);
828 static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn);
829 // If the current cursor position is inside a hidden range, the hidden range
830 // is selected and true is returned:
831 bool SelectHiddenRange();
833 // remove all invalid cursors
834 void ClearUpCrsrs();
836 inline void SetMacroExecAllowed( const bool _bMacroExecAllowed )
838 m_bMacroExecAllowed = _bMacroExecAllowed;
840 inline bool IsMacroExecAllowed()
842 return m_bMacroExecAllowed;
846 Returns textual description of the current selection.
848 - If the current selection is a multi-selection the result is
849 STR_MULTISEL.
850 - Else the result is the text of the selection.
852 @return the textual description of the current selection
854 OUString GetCrsrDescr() const;
857 // Cursor Inlines:
858 inline SwMoveFnCollection* SwCrsrShell::MakeFindRange(
859 sal_uInt16 nStt, sal_uInt16 nEnd, SwPaM* pPam ) const
861 return m_pCurCrsr->MakeFindRange( (SwDocPositions)nStt, (SwDocPositions)nEnd, pPam );
864 inline SwCursor* SwCrsrShell::GetSwCrsr( bool bMakeTableCrsr ) const
866 return static_cast<SwCursor*>(GetCrsr( bMakeTableCrsr ));
869 inline SwPaM* SwCrsrShell::GetStkCrsr() const { return m_pCrsrStk; }
871 inline void SwCrsrShell::SetMark() { m_pCurCrsr->SetMark(); }
873 inline bool SwCrsrShell::HasMark() { return( m_pCurCrsr->HasMark() ); }
875 inline bool SwCrsrShell::IsSelection() const
877 return IsTableMode() || m_pCurCrsr->HasMark() ||
878 m_pCurCrsr->GetNext() != m_pCurCrsr;
880 inline bool SwCrsrShell::IsMultiSelection() const
882 return m_pCurCrsr->GetNext() != m_pCurCrsr;
885 inline bool SwCrsrShell::IsSelOnePara() const
887 return !m_pCurCrsr->IsMultiSelection() &&
888 m_pCurCrsr->GetPoint()->nNode == m_pCurCrsr->GetMark()->nNode;
891 inline const SwTableNode* SwCrsrShell::IsCrsrInTable( bool bIsPtInTable ) const
893 return m_pCurCrsr->GetNode( bIsPtInTable ).FindTableNode();
896 inline bool SwCrsrShell::IsCrsrPtAtEnd() const
898 return m_pCurCrsr->End() == m_pCurCrsr->GetPoint();
901 inline Point& SwCrsrShell::GetCrsrDocPos( bool bPoint ) const
903 return bPoint ? m_pCurCrsr->GetPtPos() : m_pCurCrsr->GetMkPos();
906 inline const SwPaM* SwCrsrShell::GetTableCrs() const
908 return m_pTableCrsr;
911 inline SwPaM* SwCrsrShell::GetTableCrs()
913 return m_pTableCrsr;
916 inline void SwCrsrShell::UnSetVisCrsr()
918 m_pVisCrsr->Hide();
919 m_pVisCrsr->SetDragCrsr( false );
922 #endif // _CRSRSH_HXX
924 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */