1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <com/sun/star/i18n/WordType.hpp>
24 #include <tools/string.hxx>
25 #include <tools/link.hxx>
26 #include <tools/rtti.hxx>
28 #include <IShellCursorSupplier.hxx>
30 #include <swtypes.hxx> // for SWPOSDOC
31 #include <viewsh.hxx> // for ViewShell
32 #include <calbck.hxx> // for SwClient
33 #include <cshtyp.hxx> // for CursorShell types
34 #include <crstate.hxx> // for CursorMove-States
35 #include <toxe.hxx> // SwTOXSearchDir
36 #include <tblsel.hxx> // SwTblSearchType
40 #include <IDocumentMarkAccess.hxx>
55 class SwShellTableCrsr
;
72 namespace com
{ namespace sun
{ namespace star
{ namespace util
{
76 namespace com
{ namespace sun
{ namespace star
{ namespace text
{
80 namespace com
{ namespace sun
{ namespace star
{ namespace container
{
84 // enum and struct to get information via the Doc-Position
92 SW_CLICKFIELD
= 0x0002,
95 SW_TABLEBOXFML
= 0x0010,
100 SW_NUMLABEL
= 0x0200,
101 SW_CONTENT_CHECK
= 0x0400,
102 SW_SMARTTAG
= 0x0800,
105 ,SW_CURR_ATTRS
= 0x4000 ///< only for debugging
106 ,SW_TABLEBOXVALUE
= 0x8000 ///< only for debugging
112 const SfxPoolItem
* pAttr
;
113 const SwRedline
* pRedl
;
115 const sw::mark::IFieldmark
* pFldmark
;
121 const SwTxtAttr
* pFndTxtAttr
;
123 SwContentAtPos( int eGetAtPos
= 0xffff )
124 : eCntntAtPos( (IsAttrAtPos
)eGetAtPos
)
128 nDist
= 0; // #i23726#
131 bool IsInProtectSect() const;
132 bool IsInRTLText()const;
135 // return values of SetCrsr (can be combined via ||)
136 const int CRSR_POSOLD
= 0x01, // cursor stays at old position
137 CRSR_POSCHG
= 0x02; // position changed by the layout
139 /// Helperfunction to resolve backward references in regular expressions
140 String
*ReplaceBackReferences( const com::sun::star::util::SearchOptions
& rSearchOpt
, SwPaM
* pPam
);
142 class SW_DLLPUBLIC SwCrsrShell
145 , public ::sw::IShellCursorSupplier
147 friend class SwCallLink
;
148 friend class SwVisCrsr
;
149 friend class SwSelPaintRects
;
151 // requires the Crsr as InternalCrsr
152 friend sal_Bool
GetAutoSumSel( const SwCrsrShell
&, SwCellFrms
& );
156 /** for calling UpdateCrsr */
158 UPDOWN
= (1 << 0), ///< keep Up/Down on columns
159 SCROLLWIN
= (1 << 1), ///< scroll window
160 CHKRANGE
= (1 << 2), ///< check overlapping PaMs
161 NOCALRECT
= (1 << 3), ///< don't recalculate CharRect
162 READONLY
= (1 << 4) ///< make visible in spite of Readonly
167 SwRect m_aCharRect
; ///< Char-SRectangle on which the cursor is located
168 Point m_aCrsrHeight
; ///< height & offset from visible Cursor
169 Point m_aOldRBPos
; ///< Right/Bottom of last VisArea
170 // (used in Invalidate by Cursor)
172 Link m_aFlyMacroLnk
; /**< Link will be called, if the Crsr is set
173 into a fly. A macro can be then becalled */
174 Link m_aChgLnk
; /**< link will be called by every attribut/
175 format changes at cursor position.*/
176 Link m_aGrfArrivedLnk
; ///< Link calls to UI if a graphic is arrived
178 SwShellCrsr
* m_pCurCrsr
; ///< current cursor
179 SwShellCrsr
* m_pCrsrStk
; ///< stack for the cursor
180 SwVisCrsr
*m_pVisCrsr
; ///< the visible cursor
182 IBlockCursor
*m_pBlockCrsr
; ///< interface of cursor for block (=rectangular) selection
184 SwShellTableCrsr
* m_pTblCrsr
; /**< table Crsr; only in tables when the
185 selection lays over 2 columns */
187 SwNodeIndex
* m_pBoxIdx
; ///< for recognizing of the changed
188 SwTableBox
* m_pBoxPtr
; ///< table row
190 long m_nUpDownX
; /**< try to move the cursor on up/down always
191 in the same column */
193 sal_uLong m_nAktNode
; // save CursorPos at Start-Action
194 xub_StrLen m_nAktCntnt
;
195 sal_uInt16 m_nAktNdTyp
;
196 bool m_bAktSelection
;
199 * Via the Method SttCrsrMove and EndCrsrMove 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.
204 sal_uInt16 m_nCrsrMove
;
205 sal_uInt16 m_nBasicActionCnt
; ///< Actions which are parenthesized by Basic
206 CrsrMoveState m_eMvState
; ///< Status for Crsr-Travelling - GetCrsrOfst
208 String m_sMarkedListId
;
209 int m_nMarkedListLevel
;
211 sal_Bool m_bHasFocus
: 1; ///< Shell is "active" in a window
212 sal_Bool m_bSVCrsrVis
: 1; ///< SV-Cursor visible/invisible
213 sal_Bool m_bChgCallFlag
: 1; ///< attribute change inside Start- and EndAction
214 sal_Bool m_bVisPortChgd
: 1; ///< in VisPortChg-Call
215 // (used in Invalidate by the Cursor)
217 sal_Bool m_bCallChgLnk
: 1; ///< flag for derived classes
218 // TRUE -> call ChgLnk
219 // access only via SwChgLinkFlag
220 sal_Bool m_bAllProtect
: 1; ///< Flag for areas
221 // TRUE -> everything protected / hidden
222 sal_Bool m_bInCMvVisportChgd
: 1; ///< Flag for CrsrMoves
223 // TRUE -> view was moved
224 sal_Bool m_bGCAttr
: 1; // TRUE -> non expanded attributes exist.
225 sal_Bool m_bIgnoreReadonly
: 1; // TRUE -> make the cursor visible on next
226 // EndAction in spite of Readonly
227 sal_Bool m_bSelTblCells
: 1; // TRUE -> select cells over the InputWin
228 sal_Bool m_bAutoUpdateCells
: 1; // TRUE -> autoformat cells
229 sal_Bool m_bBasicHideCrsr
: 1; // TRUE -> HideCrsr from Basic
230 sal_Bool m_bSetCrsrInReadOnly
: 1;// TRUE -> Cursor is allowed in ReadOnly-Areas
231 sal_Bool m_bOverwriteCrsr
: 1; // sal_True -> show Overwrite Crsr
233 bool m_bMacroExecAllowed
: 1;
235 SW_DLLPRIVATE
void UpdateCrsr( sal_uInt16 eFlags
236 =SwCrsrShell::SCROLLWIN
|SwCrsrShell::CHKRANGE
,
237 sal_Bool bIdleEnd
= sal_False
);
239 SW_DLLPRIVATE
void _ParkPams( SwPaM
* pDelRg
, SwShellCrsr
** ppDelRing
);
241 /** Mark a certain list level of a certain list
243 levels of a certain lists are marked now
245 @param sListId list Id of the list whose level is marked
246 @param nLevel to be marked list level
248 An empty sListId denotes that no level of a list is marked.
250 SW_DLLPRIVATE
void MarkListLevel( const String
& sListId
,
253 // private method(s) accessed from public inline method(s) must be exported.
254 sal_Bool
LeftRight( sal_Bool
, sal_uInt16
, sal_uInt16
, sal_Bool
);
255 SW_DLLPRIVATE sal_Bool
UpDown( sal_Bool
, sal_uInt16
);
256 SW_DLLPRIVATE sal_Bool
LRMargin( sal_Bool
, sal_Bool bAPI
= sal_False
);
257 SW_DLLPRIVATE sal_Bool
IsAtLRMargin( sal_Bool
, sal_Bool bAPI
= sal_False
) const;
259 SW_DLLPRIVATE
short GetTextDirection( const Point
* pPt
= 0 ) const;
261 SW_DLLPRIVATE
bool isInHiddenTxtFrm(SwShellCrsr
* pShellCrsr
);
263 typedef sal_Bool (SwCursor:: *FNCrsr
)();
264 SW_DLLPRIVATE sal_Bool
CallCrsrFN( FNCrsr
);
266 SW_DLLPRIVATE
const SwRedline
* _GotoRedline( sal_uInt16 nArrPos
, sal_Bool bSelect
);
270 inline SwMoveFnCollection
* MakeFindRange( sal_uInt16
, sal_uInt16
, SwPaM
* ) const;
273 * Compare-Methode for the StackCursor and the current Cursor.
274 * The Methods return -1, 0, 1 for lower, equal, greater. The enum
275 * CrsrCompareType says which position is compared.
277 enum CrsrCompareType
{
285 int CompareCursor( CrsrCompareType eType
) const;
287 // set all PaMs in OldNode to NewPos + Offset
288 void PaMCorrAbs(const SwNodeIndex
&rOldNode
, const SwPosition
&rNewPos
,
289 const xub_StrLen nOffset
= 0 );
291 bool _SelTblRowOrCol( bool bRow
, bool bRowSimple
= false );
293 bool SetInFrontOfLabel( bool bNew
);
295 void RefreshBlockCursor();
297 /** Updates the marked list level according to the cursor.
299 SW_DLLPRIVATE
void UpdateMarkedListLevel();
302 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
);
306 SwCrsrShell( SwDoc
& rDoc
, Window
*pWin
, const SwViewOption
*pOpt
= 0 );
307 // disguised copy constructor
308 SwCrsrShell( SwCrsrShell
& rShell
, Window
*pWin
);
309 virtual ~SwCrsrShell();
311 // create new cursor and append the old one
312 virtual SwPaM
& CreateNewShellCursor();
313 virtual SwPaM
& GetCurrentShellCursor();
315 SwPaM
* CreateCrsr();
316 ///< delete the current cursor and make the following into the current
318 ///< transform TableCursor to normal cursor, nullify Tablemode
319 void TblCrsrToCursor();
320 ///< enter block mode, change normal cursor into block cursor
321 void CrsrToBlockCrsr();
322 ///< leave block mode, change block cursor into normal cursor
323 void BlockCrsrToCrsr();
325 // SelAll() selects the document body content
326 // if ExtendedSelect() is called afterwards, the whole nodes array is selected
327 // only for usage in special cases allowed!
328 void ExtendedSelectAll();
330 SwPaM
* GetCrsr( sal_Bool bMakeTblCrsr
= sal_True
) const;
331 inline SwCursor
* GetSwCrsr( sal_Bool bMakeTblCrsr
= sal_True
) const;
332 // return only the current cursor
333 SwShellCrsr
* _GetCrsr() { return m_pCurCrsr
; }
334 const SwShellCrsr
* _GetCrsr() const { return m_pCurCrsr
; }
336 // show passed cursor - for UNO
337 void SetSelection(const SwPaM
& rCrsr
);
339 // remove all cursors from ContentNodes and set to 0
340 void ParkCrsr( const SwNodeIndex
&rIdx
);
342 // return the current cursor stack
343 // (required in EditShell when deleting contents)
344 inline SwPaM
* GetStkCrsr() const;
346 // start parenthesing, hide SV-Cursor and selected areas
348 // end parenthesing, show SV-Cursor and selected areas
349 void EndAction( const sal_Bool bIdleEnd
= sal_False
);
351 // basic cursor travelling
352 long GetUpDownX() const { return m_nUpDownX
; }
354 sal_Bool
Left( sal_uInt16 nCnt
, sal_uInt16 nMode
, sal_Bool bAllowVisual
= sal_False
)
355 { return LeftRight( sal_True
, nCnt
, nMode
, bAllowVisual
); }
356 sal_Bool
Right( sal_uInt16 nCnt
, sal_uInt16 nMode
, sal_Bool bAllowVisual
= sal_False
)
357 { return LeftRight( sal_False
, nCnt
, nMode
, bAllowVisual
); }
358 sal_Bool
Up( sal_uInt16 nCnt
= 1 ) { return UpDown( sal_True
, nCnt
); }
359 sal_Bool
Down( sal_uInt16 nCnt
= 1 ) { return UpDown( sal_False
, nCnt
); }
360 sal_Bool
LeftMargin() { return LRMargin( sal_True
); }
361 sal_Bool
RightMargin(sal_Bool bAPI
= sal_False
) { return LRMargin( sal_False
, bAPI
); }
362 sal_Bool
SttEndDoc( sal_Bool bStt
);
364 sal_Bool
MovePage( SwWhichPage
, SwPosPage
);
365 sal_Bool
MovePara( SwWhichPara
, SwPosPara
);
366 sal_Bool
MoveSection( SwWhichSection
, SwPosSection
);
367 sal_Bool
MoveTable( SwWhichTable
, SwPosTable
);
368 sal_Bool
MoveColumn( SwWhichColumn
, SwPosColumn
);
369 sal_Bool
MoveRegion( SwWhichRegion
, SwPosRegion
);
371 sal_uLong
Find( const com::sun::star::util::SearchOptions
& rSearchOpt
,
372 sal_Bool bSearchInNotes
,
373 SwDocPositions eStart
, SwDocPositions eEnde
,
375 FindRanges eRng
, int bReplace
= sal_False
);
377 sal_uLong
Find( const SwTxtFmtColl
& rFmtColl
,
378 SwDocPositions eStart
, SwDocPositions eEnde
,
380 FindRanges eRng
, const SwTxtFmtColl
* pReplFmt
= 0 );
382 sal_uLong
Find( const SfxItemSet
& rSet
, sal_Bool bNoCollections
,
383 SwDocPositions eStart
, SwDocPositions eEnde
,
386 const com::sun::star::util::SearchOptions
* pSearchOpt
= 0,
387 const SfxItemSet
* rReplSet
= 0 );
389 // Position the Cursor
391 // CRSR_POSCHG: when cursor was corrected from SPoint by the layout
392 // CRSR_POSOLD: when the cursor was not changed
393 int SetCrsr( const Point
&rPt
, sal_Bool bOnlyText
= sal_False
, bool bBlock
= true );
396 * Notification that the visible area was changed. m_aVisArea is reset, then
397 * scrolling is done. The passed Rectangle lays on pixel borders to avoid
400 virtual void VisPortChgd( const SwRect
& );
403 * virtual paint method to make selection visible again after Paint
405 void Paint( const Rectangle
& rRect
);
408 inline void SetMark();
409 inline sal_Bool
HasMark();
414 Ensure point and mark of the current PaM are in a specific order.
416 @param bPointFirst TRUE: If the point is behind the mark then
417 swap the PaM. FALSE: If the mark is behind the point then swap
420 void NormalizePam(sal_Bool bPointFirst
= sal_True
);
423 sal_Bool
ChgCurrPam( const Point
& rPt
,
424 sal_Bool bTstOnly
= sal_True
, // test only, don't set
425 sal_Bool bTstHit
= sal_False
); // only exact matches
428 // story a copy of the cursor in the stack
431 * Delete a cursor (controlled by bOldCrsr)
432 * - from stack or (bOldCrsr = TRUE)
433 * - delete the current one and replace it with the cursor from the
435 * Return: whether there was one left one the stack
437 sal_Bool
Pop( sal_Bool bOldCrsr
= sal_True
);
440 * Delete the topmost from the stack and move its Mark into the current.
446 void EndCrsrMove( const sal_Bool bIdleEnd
= sal_False
);
448 void SttCrsrMove() { ++m_nCrsrMove
; StartAction(); }
449 void EndCrsrMove( const sal_Bool bIdleEnd
= sal_False
)
450 { EndAction( bIdleEnd
); --m_nCrsrMove
; }
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 sal_Bool
HasShFcs() const { return m_bHasFocus
; }
460 void ShGetFcs( sal_Bool bUpdate
= sal_True
);
462 // Methods for displaying or hiding the visible text cursor.
465 // Methods for displaying or hiding the selected ranges with visible cursor.
466 void ShowCrsrs( sal_Bool bCrsrVis
);
469 sal_Bool
IsOverwriteCrsr() const { return m_bOverwriteCrsr
; }
470 void SetOverwriteCrsr( sal_Bool bFlag
) { m_bOverwriteCrsr
= bFlag
; }
472 // Return current frame in which the cursor is placed.
473 SwCntntFrm
*GetCurrFrm( const sal_Bool bCalcFrm
= sal_True
) const;
475 //TRUE if cursor is hidden because of readonly.
476 //FALSE if it is working despite readonly.
477 sal_Bool
IsCrsrReadonly() const;
479 // Cursor is placed in something that is protected or selection contains
480 // something that is protected.
481 sal_Bool
HasReadonlySel(bool bAnnotationMode
= false) const;
483 // Can the cursor be set to read only ranges?
484 sal_Bool
IsReadOnlyAvailable() const { return m_bSetCrsrInReadOnly
; }
485 void SetReadOnlyAvailable( sal_Bool bFlag
);
486 sal_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.
503 // Check if the current cursor contains a selection, i.e.
504 // if Mark is set and SPoint and Mark are different.
505 sal_Bool
HasSelection() const;
507 // Check if a selection exists, i.e. if the current cursor comprises a selection.
508 inline sal_Bool
IsSelection() const;
509 // returns if multiple cursors are available
510 inline sal_Bool
IsMultiSelection() const;
512 // Check if a complete paragraph was selected.
513 sal_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 sal_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 sal_Bool
IsCrsrVisible() const { return VisArea().IsOver( GetCharRect() ); }
532 * Returns SwRect, at which the character is located.
534 sal_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 sal_Bool bAtCrsrPos
= sal_True
, const sal_Bool bCalcFrm
= sal_True
);
541 // Determine how "empty pages" are handled
542 // (used in PhyPage).
543 sal_uInt16
GetNextPrevPageNum( sal_Bool bNext
= sal_True
);
545 // Move cursor at the bginning of page "nPage".
546 sal_Bool
GotoPage( sal_uInt16 nPage
);
548 sal_uInt16
GetPageCnt();
550 sal_Bool
GoNextCrsr();
552 sal_Bool
GoPrevCrsr();
555 ::sw::mark::IMark
* SetBookmark(
557 const OUString
& rName
,
558 const OUString
& rShortName
,
559 IDocumentMarkAccess::MarkType eMark
= IDocumentMarkAccess::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
577 String
GetSelTxt() const;
578 // return only the text starting from the current cursor position (to the
580 String
GetText() const;
582 // Check of SPoint or Mark of current cursor are placed within a table.
583 inline const SwTableNode
* IsCrsrInTbl( sal_Bool bIsPtInTbl
= sal_True
) const;
585 inline Point
& GetCrsrDocPos( sal_Bool bPoint
= sal_True
) const;
586 inline sal_Bool
IsCrsrPtAtEnd() const;
588 inline const SwPaM
* GetTblCrs() const;
589 inline SwPaM
* GetTblCrs();
591 bool IsTblComplexForChart();
592 // get current table selection as text
593 String
GetBoxNms() const;
595 // set Crsr to the next/previous cell
596 sal_Bool
GoNextCell( sal_Bool bAppendLine
= sal_True
);
597 sal_Bool
GoPrevCell();
598 // go to this box (if available and inside of table)
599 bool GotoTable( const String
& rName
);
601 // select a table row, column or box (based on the current cursor)
602 sal_Bool
SelTblRow() { return _SelTblRowOrCol( true ); }
603 sal_Bool
SelTblCol() { return _SelTblRowOrCol( false ); }
604 sal_Bool
SelTblBox();
611 bool GotoOutline( const String
& 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 sal_Bool
MakeOutlineSel( sal_uInt16 nSttPos
, sal_uInt16 nEndPos
,
619 sal_Bool bWithChildren
= sal_False
);
621 sal_Bool
GotoNextOutline();
622 sal_Bool
GotoPrevOutline();
624 /** Delivers the current shell cursor
626 Some operations have to run on the current cursor ring,
627 some on the m_pTblCrsr (if exist) or the current cursor ring and
628 some on the m_pTblCrsr or m_pBlockCrsr or the current cursor ring.
629 This small function checks the existence and delivers the wished cursor.
632 if the block cursor is of interest or not
634 @return m_pTblCrsr if exist,
635 m_pBlockCrsr if exist and of interest (param bBlock)
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 sal_Bool
IsTableMode() const { return 0 != m_pTblCrsr
; }
649 const SwShellTableCrsr
* GetTableCrsr() const { return m_pTblCrsr
; }
650 SwShellTableCrsr
* GetTableCrsr() { return m_pTblCrsr
; }
651 size_t UpdateTblSelBoxes();
653 sal_Bool
GotoFtnTxt(); ///< jump from content to footnote
654 sal_Bool
GotoFtnAnchor(); ///< jump from footnote to anchor
655 sal_Bool
GotoPrevFtnAnchor();
656 sal_Bool
GotoNextFtnAnchor();
658 sal_Bool
GotoFlyAnchor(); ///< jump from the frame to the anchor
659 sal_Bool
GotoHeaderTxt(); ///< jump from the content to the header
660 sal_Bool
GotoFooterTxt(); ///< jump from the content to the footer
661 // jump to the header/footer of the given or current PageDesc
662 sal_Bool
SetCrsrInHdFt( sal_uInt16 nDescNo
= USHRT_MAX
,
663 sal_Bool bInHeader
= sal_True
);
664 // is point of cursor in header/footer. pbInHeader return sal_True if it is
665 // in a headerframe otherwise in a footerframe
666 bool IsInHeaderFooter( sal_Bool
* pbInHeader
= 0 ) const;
668 sal_Bool
GotoNextTOXBase( const String
* = 0 );
669 sal_Bool
GotoPrevTOXBase( const String
* = 0 );
670 sal_Bool
GotoTOXMarkBase();
671 // jump to the next or previous index entry
672 sal_Bool
GotoNxtPrvTOXMark( sal_Bool bNext
= sal_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 sal_Bool
GotoNxtPrvTblFormula( sal_Bool bNext
= sal_True
,
679 sal_Bool bOnlyErrors
= sal_False
);
680 // jump to the next / previous hyperlink - inside text and also
682 bool SelectNxtPrvHyperlink( bool bNext
= true );
684 sal_Bool
GotoRefMark( const String
& 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( sal_Bool bEnd
= sal_True
, long nOffset
= 0 );
689 sal_Bool
ExtendSelection( sal_Bool bEnd
= sal_True
, xub_StrLen 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 sal_Bool
SetVisCrsr( const Point
&rPt
);
695 inline void UnSetVisCrsr();
697 // jump to the next or previous field of the corresponding type
698 sal_Bool
MoveFldType( const SwFieldType
* pFldType
, sal_Bool bNext
,
699 sal_uInt16 nSubType
= USHRT_MAX
,
700 sal_uInt16 nResType
= USHRT_MAX
);
701 sal_Bool
GotoFld( const SwFmtFld
& rFld
);
703 // Return number of cursors in ring (The flag indicates whether
704 // only cursors containing selections are requested).
705 sal_uInt16
GetCrsrCnt( sal_Bool bAll
= sal_True
) const;
707 // Char Travelling - methods (in crstrvl1.cxx)
708 sal_Bool
GoStartWord();
709 sal_Bool
GoEndWord();
710 sal_Bool
GoNextWord();
711 sal_Bool
GoPrevWord();
712 sal_Bool
GoNextSentence();
713 sal_Bool
GoStartSentence();
714 sal_Bool
GoEndSentence();
715 sal_Bool
SelectWord( const Point
* pPt
= 0 );
716 sal_Bool
ExpandToSentenceBorders();
718 // get position from current cursor
719 sal_Bool
IsStartWord( sal_Int16 nWordType
= com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES
)const;
720 sal_Bool
IsEndWord( sal_Int16 nWordType
= com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
721 sal_Bool
IsInWord( sal_Int16 nWordType
= com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
722 sal_Bool
IsStartSentence() const;
723 sal_Bool
IsEndSentence() const;
724 bool IsSttPara() const;
725 bool IsEndPara() const;
726 bool IsEndOfTable() const; ///< at the very last SwPosition inside a table
727 sal_Bool
IsStartOfDoc() const;
728 sal_Bool
IsEndOfDoc() const;
729 bool IsInFrontOfLabel() const;
730 sal_Bool
IsAtLeftMargin() const { return IsAtLRMargin( sal_True
); }
731 sal_Bool
IsAtRightMargin(sal_Bool bAPI
= sal_False
) const { return IsAtLRMargin( sal_False
, bAPI
); }
733 // delete all created cursors, set the table cursor and the last cursor to
734 // its TextNode (or StartNode?)
735 // They all get created on the next ::GetCrsr again
736 // Used for Drag&Drop/Clipboard-Paste in tables
737 sal_Bool
ParkTblCrsr();
739 // Non expanded attributes?
740 sal_Bool
IsGCAttr() const { return m_bGCAttr
; }
741 void ClearGCAttr() { m_bGCAttr
= sal_False
; }
742 void UpdateAttr() { m_bGCAttr
= sal_True
; }
744 // is the whole document protected/hidden (for UI...)
745 sal_Bool
IsAllProtect() const { return m_bAllProtect
; }
747 sal_Bool
BasicActionPend() const { return m_nBasicActionCnt
!= mnStartAction
; }
749 bool GotoRegion( const String
& rName
);
751 // show the current selection
752 virtual void MakeSelVisible();
754 // set the cursor to a NOT protected/hidden node
755 sal_Bool
FindValidCntntNode( sal_Bool bOnlyText
= sal_False
);
757 sal_Bool
GetContentAtPos( const Point
& rPt
,
758 SwContentAtPos
& rCntntAtPos
,
759 sal_Bool bSetCrsr
= sal_False
,
760 SwRect
* pFldRect
= 0 );
762 const SwPostItField
* GetPostItFieldAtCursor() const;
764 // get smart tags at point position
765 void GetSmartTagTerm( const Point
& rPt
,
767 ::com::sun::star::uno::Sequence
< OUString
>& rSmartTagTypes
,
768 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::container::XStringKeyMap
> >& rStringKeyMaps
,
769 ::com::sun::star::uno::Reference
<com::sun::star::text::XTextRange
>& rRange
);
771 // get smart tags at current cursor position
772 void GetSmartTagTerm( ::com::sun::star::uno::Sequence
< OUString
>& rSmartTagTypes
,
773 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::container::XStringKeyMap
> >& rStringKeyMaps
,
774 ::com::sun::star::uno::Reference
<com::sun::star::text::XTextRange
>& rRange
) const;
776 sal_Bool
IsPageAtPos( const Point
&rPt
) const;
778 sal_Bool
SelectTxtAttr( sal_uInt16 nWhich
, sal_Bool bExpand
, const SwTxtAttr
* pAttr
= 0 );
779 bool GotoINetAttr( const SwTxtINetFmt
& rAttr
);
780 const SwFmtINetFmt
* FindINetAttr( const String
& rName
) const;
782 sal_Bool
CheckTblBoxCntnt( const SwPosition
* pPos
= 0 );
783 void SaveTblBoxCntnt( const SwPosition
* pPos
= 0 );
784 void ClearTblBoxCntnt();
785 sal_Bool
EndAllTblBoxEdit();
787 void SetSelTblCells( sal_Bool bFlag
) { m_bSelTblCells
= bFlag
; }
788 sal_Bool
IsSelTblCells() const { return m_bSelTblCells
; }
790 sal_Bool
IsAutoUpdateCells() const { return m_bAutoUpdateCells
; }
791 void SetAutoUpdateCells( sal_Bool bFlag
) { m_bAutoUpdateCells
= bFlag
; }
793 sal_Bool
GetShadowCrsrPos( const Point
& rPt
, SwFillMode eFillMode
,
794 SwRect
& rRect
, short& rOrient
);
795 sal_Bool
SetShadowCrsrPos( const Point
& rPt
, SwFillMode eFillMode
);
797 const SwRedline
* SelNextRedline();
798 const SwRedline
* SelPrevRedline();
799 const SwRedline
* GotoRedline( sal_uInt16 nArrPos
, sal_Bool bSelect
= sal_False
);
801 // is cursor or the point in/over a vertical formatted text?
802 bool IsInVerticalText( const Point
* pPt
= 0 ) const;
803 // is cursor or the point in/over a right to left formatted text?
804 sal_Bool
IsInRightToLeftText( const Point
* pPt
= 0 ) const;
806 // If the current cursor position is inside a hidden range, the hidden range
807 // is selected and true is returned:
808 bool SelectHiddenRange();
810 // remove all invalid cursors
813 inline void SetMacroExecAllowed( const bool _bMacroExecAllowed
)
815 m_bMacroExecAllowed
= _bMacroExecAllowed
;
817 inline bool IsMacroExecAllowed()
819 return m_bMacroExecAllowed
;
823 Returns textual description of the current selection.
825 - If the current selection is a multi-selection the result is
827 - Else the result is the text of the selection.
829 @return the textual description of the current selection
831 String
GetCrsrDescr() const;
833 SwRect
GetRectOfCurrentChar();
837 inline SwMoveFnCollection
* SwCrsrShell::MakeFindRange(
838 sal_uInt16 nStt
, sal_uInt16 nEnd
, SwPaM
* pPam
) const
840 return m_pCurCrsr
->MakeFindRange( (SwDocPositions
)nStt
, (SwDocPositions
)nEnd
, pPam
);
843 inline SwCursor
* SwCrsrShell::GetSwCrsr( sal_Bool bMakeTblCrsr
) const
845 return (SwCursor
*)GetCrsr( bMakeTblCrsr
);
848 inline SwPaM
* SwCrsrShell::GetStkCrsr() const { return m_pCrsrStk
; }
850 inline void SwCrsrShell::SetMark() { m_pCurCrsr
->SetMark(); }
852 inline sal_Bool
SwCrsrShell::HasMark() { return( m_pCurCrsr
->HasMark() ); }
854 inline sal_Bool
SwCrsrShell::IsSelection() const
856 return IsTableMode() || m_pCurCrsr
->HasMark() ||
857 m_pCurCrsr
->GetNext() != m_pCurCrsr
;
859 inline sal_Bool
SwCrsrShell::IsMultiSelection() const
861 return m_pCurCrsr
->GetNext() != m_pCurCrsr
;
864 inline sal_Bool
SwCrsrShell::IsSelOnePara() const
866 return m_pCurCrsr
== m_pCurCrsr
->GetNext() &&
867 m_pCurCrsr
->GetPoint()->nNode
== m_pCurCrsr
->GetMark()->nNode
;
870 inline const SwTableNode
* SwCrsrShell::IsCrsrInTbl( sal_Bool bIsPtInTbl
) const
872 return m_pCurCrsr
->GetNode( bIsPtInTbl
)->FindTableNode();
875 inline sal_Bool
SwCrsrShell::IsCrsrPtAtEnd() const
877 return m_pCurCrsr
->End() == m_pCurCrsr
->GetPoint();
880 inline Point
& SwCrsrShell::GetCrsrDocPos( sal_Bool bPoint
) const
882 return bPoint
? m_pCurCrsr
->GetPtPos() : m_pCurCrsr
->GetMkPos();
885 inline const SwPaM
* SwCrsrShell::GetTblCrs() const
890 inline SwPaM
* SwCrsrShell::GetTblCrs()
895 inline void SwCrsrShell::UnSetVisCrsr()
898 m_pVisCrsr
->SetDragCrsr( false );
901 #endif // _CRSRSH_HXX
903 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */