update dev300-m58
[ooovba.git] / sw / inc / swcrsr.hxx
blob40d605b57ce6b701ea91f6338bb7e4201f0fe91c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swcrsr.hxx,v $
10 * $Revision: 1.22 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SWCRSR_HXX
31 #define _SWCRSR_HXX
32 #include <com/sun/star/i18n/WordType.hpp>
33 #include <pam.hxx>
34 #include <tblsel.hxx>
35 #include <cshtyp.hxx>
38 struct _SwCursor_SavePos;
40 namespace com { namespace sun { namespace star { namespace util {
41 struct SearchOptions;
42 } } } }
45 // ein Basis-Struktur fuer die Parameter der Find-Methoden
46 // return - Werte vom Found-Aufruf.
47 const int FIND_NOT_FOUND = 0;
48 const int FIND_FOUND = 1;
49 const int FIND_NO_RING = 2;
51 struct SwFindParas
53 virtual int Find( SwPaM*, SwMoveFn, const SwPaM*, BOOL ) = 0;
54 virtual int IsReplaceMode() const = 0;
57 typedef USHORT SwCursorSelOverFlags;
58 namespace nsSwCursorSelOverFlags
60 const SwCursorSelOverFlags SELOVER_NONE = 0x00;
61 const SwCursorSelOverFlags SELOVER_CHECKNODESSECTION = 0x01;
62 const SwCursorSelOverFlags SELOVER_TOGGLE = 0x02;
63 const SwCursorSelOverFlags SELOVER_ENABLEREVDIREKTION = 0x04;
64 const SwCursorSelOverFlags SELOVER_CHANGEPOS = 0x08;
67 class SwCursor : public SwPaM
69 friend class SwCrsrSaveState;
71 _SwCursor_SavePos* pSavePos;
72 long mnRowSpanOffset; // required for travelling in tabs with rowspans
73 BYTE nCursorBidiLevel; // bidi level of the cursor
74 bool mbColumnSelection; // true: cursor is aprt of a column selection
76 ULONG FindAll( SwFindParas& , SwDocPositions, SwDocPositions, FindRanges, BOOL& bCancel );
78 using SwPaM::Find;
80 protected:
81 virtual _SwCursor_SavePos* CreateNewSavePos() const;
82 void SaveState();
83 void RestoreState();
85 const _SwCursor_SavePos* GetSavePos() const { return pSavePos; }
87 virtual const SwCntntFrm* DoSetBidiLevelLeftRight(
88 BOOL & io_rbLeft, BOOL bVisualAllowed, BOOL bInsertCrsr);
89 virtual void DoSetBidiLevelUpDown();
90 virtual bool IsSelOvrCheck(int eFlags);
92 public:
93 // single argument ctors shall be explicit.
94 SwCursor( const SwPosition &rPos, SwPaM* pRing, bool bColumnSel );
95 virtual ~SwCursor();
97 // @@@ semantic: no copy ctor.
98 SwCursor( SwCursor& rCpy);
99 private:
100 // forbidden and not implemented.
101 //SwCursor( const SwCursor& );
102 // @@@ used e.g. in core/frmedt/fetab.cxx @@@
103 // SwCursor & operator= ( const SwCursor& );
104 public:
106 virtual SwCursor* Create( SwPaM* pRing = 0 ) const;
108 virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO
109 virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
111 void FillFindPos( SwDocPositions ePos, SwPosition& rPos ) const;
112 SwMoveFnCollection* MakeFindRange( SwDocPositions, SwDocPositions,
113 SwPaM* ) const;
116 ULONG Find( const com::sun::star::util::SearchOptions& rSearchOpt,
117 BOOL bSearchInNotes,
118 SwDocPositions nStart, SwDocPositions nEnde,
119 BOOL& bCancel,
120 FindRanges = FND_IN_BODY,
121 int bReplace = FALSE );
122 ULONG Find( const SwTxtFmtColl& rFmtColl,
123 SwDocPositions nStart, SwDocPositions nEnde,
124 BOOL& bCancel,
125 FindRanges = FND_IN_BODY,
126 const SwTxtFmtColl* pReplFmt = 0 );
127 ULONG Find( const SfxItemSet& rSet, BOOL bNoCollections,
128 SwDocPositions nStart, SwDocPositions nEnde,
129 BOOL& bCancel,
130 FindRanges = FND_IN_BODY,
131 const com::sun::star::util::SearchOptions* pSearchOpt = 0,
132 const SfxItemSet* rReplSet = 0 );
134 // UI versions
135 BOOL IsStartWord() const;
136 BOOL IsEndWord() const;
137 BOOL IsStartEndSentence( bool bEnd ) const;
138 BOOL IsInWord() const;
139 BOOL GoStartWord();
140 BOOL GoEndWord();
141 BOOL GoNextWord();
142 BOOL GoPrevWord();
143 BOOL SelectWord( const Point* pPt = 0 );
145 // API versions of above functions (will be used with a different
146 // WordType for the break iterator)
147 BOOL IsStartWordWT( sal_Int16 nWordType ) const;
148 BOOL IsEndWordWT( sal_Int16 nWordType ) const;
149 BOOL IsInWordWT( sal_Int16 nWordType ) const;
150 BOOL GoStartWordWT( sal_Int16 nWordType );
151 BOOL GoEndWordWT( sal_Int16 nWordType );
152 BOOL GoNextWordWT( sal_Int16 nWordType );
153 BOOL GoPrevWordWT( sal_Int16 nWordType );
154 BOOL SelectWordWT( sal_Int16 nWordType, const Point* pPt = 0 );
156 enum SentenceMoveType
158 NEXT_SENT,
159 PREV_SENT,
160 START_SENT,
161 END_SENT
163 BOOL GoSentence(SentenceMoveType eMoveType);
164 BOOL GoNextSentence(){return GoSentence(NEXT_SENT);}
165 BOOL GoEndSentence(){return GoSentence(END_SENT);}
166 BOOL GoPrevSentence(){return GoSentence(PREV_SENT);}
167 BOOL GoStartSentence(){return GoSentence(START_SENT);}
169 virtual BOOL LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode,
170 BOOL bAllowVisual, BOOL bSkipHidden, BOOL bInsertCrsr );
171 BOOL UpDown( BOOL bUp, USHORT nCnt, Point* pPt, long nUpDownX );
172 BOOL LeftRightMargin( BOOL bLeftMargin, BOOL bAPI = FALSE );
173 BOOL IsAtLeftRightMargin( BOOL bLeftMargin, BOOL bAPI = FALSE ) const;
174 BOOL SttEndDoc( BOOL bSttDoc );
175 BOOL GoPrevNextCell( BOOL bNext, USHORT nCnt );
177 BOOL Left( USHORT nCnt, USHORT nMode, BOOL bAllowVisual, BOOL bSkipHidden )
178 { return LeftRight( TRUE, nCnt, nMode, bAllowVisual, bSkipHidden, FALSE ); }
179 BOOL Right( USHORT nCnt, USHORT nMode, BOOL bAllowVisual, BOOL bSkipHidden )
180 { return LeftRight( FALSE, nCnt, nMode, bAllowVisual, bSkipHidden, FALSE ); }
181 BOOL GoNextCell( USHORT nCnt = 1 ) { return GoPrevNextCell( TRUE, nCnt ); }
182 BOOL GoPrevCell( USHORT nCnt = 1 ) { return GoPrevNextCell( FALSE, nCnt ); }
183 virtual BOOL GotoTable( const String& rName );
184 BOOL GotoTblBox( const String& rName );
185 BOOL GotoRegion( const String& rName );
186 BOOL GotoFtnAnchor();
187 BOOL GotoFtnTxt();
188 BOOL GotoNextFtnAnchor();
189 BOOL GotoPrevFtnAnchor();
190 BOOL GotoNextFtnCntnt();
191 BOOL GotoPrevFtnCntnt();
193 BOOL MovePara( SwWhichPara, SwPosPara );
194 BOOL MoveSection( SwWhichSection, SwPosSection );
195 BOOL MoveTable( SwWhichTable, SwPosTable );
196 BOOL MoveRegion( SwWhichRegion, SwPosRegion );
199 // gibt es eine Selection vom Content in die Tabelle
200 // Return Wert gibt an, ob der Crsr auf der alten Position verbleibt
201 virtual BOOL IsSelOvr( int eFlags =
202 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
203 nsSwCursorSelOverFlags::SELOVER_TOGGLE |
204 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ));
205 virtual BOOL IsInProtectTable( BOOL bMove = FALSE,
206 BOOL bChgCrsr = TRUE );
207 BOOL IsNoCntnt() const;
209 void RestoreSavePos(); // Point auf die SavePos setzen
211 // TRUE: an die Position kann der Cursor gesetzt werden
212 virtual BOOL IsAtValidPos( BOOL bPoint = TRUE ) const;
214 // darf der Cursor in ReadOnlyBereiche?
215 virtual bool IsReadOnlyAvailable() const;
217 virtual BOOL IsSkipOverProtectSections() const;
218 virtual BOOL IsSkipOverHiddenSections() const;
220 BYTE GetCrsrBidiLevel() const { return nCursorBidiLevel; }
221 void SetCrsrBidiLevel( BYTE nNewLevel ) { nCursorBidiLevel = nNewLevel; }
223 bool IsColumnSelection() const { return mbColumnSelection; }
224 void SetColumnSelection( bool bNew ) { mbColumnSelection = bNew; }
226 long GetCrsrRowSpanOffset() const { return mnRowSpanOffset; }
227 void SetCrsrRowSpanOffset( long nNew ) { mnRowSpanOffset = nNew; }
229 DECL_FIXEDMEMPOOL_NEWDEL( SwCursor )
233 class SwCrsrSaveState
235 SwCursor& rCrsr;
236 public:
237 SwCrsrSaveState( SwCursor& rC ) : rCrsr( rC ) { rC.SaveState(); }
238 ~SwCrsrSaveState() { rCrsr.RestoreState(); }
241 struct _SwCursor_SavePos
243 ULONG nNode;
244 xub_StrLen nCntnt;
245 _SwCursor_SavePos* pNext;
247 _SwCursor_SavePos( const SwCursor& rCrsr )
248 : nNode( rCrsr.GetPoint()->nNode.GetIndex() ),
249 nCntnt( rCrsr.GetPoint()->nContent.GetIndex() ),
250 pNext( 0 )
252 virtual ~_SwCursor_SavePos() {}
254 DECL_FIXEDMEMPOOL_NEWDEL( _SwCursor_SavePos )
259 class SwTableCursor : public virtual SwCursor
262 protected:
263 ULONG nTblPtNd, nTblMkNd;
264 xub_StrLen nTblPtCnt, nTblMkCnt;
265 SwSelBoxes aSelBoxes;
266 BOOL bChg : 1;
267 BOOL bParked : 1; // Tabellen-Cursor wurde geparkt
269 virtual bool IsSelOvrCheck(int eFlags);
271 public:
272 SwTableCursor( const SwPosition &rPos, SwPaM* pRing = 0 );
273 SwTableCursor( SwTableCursor& );
274 virtual ~SwTableCursor();
276 virtual BOOL LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode,
277 BOOL bAllowVisual, BOOL bSkipHidden, BOOL bInsertCrsr );
278 virtual BOOL GotoTable( const String& rName );
280 void InsertBox( const SwTableBox& rTblBox );
281 void DeleteBox( USHORT nPos ) { aSelBoxes.Remove( nPos ); bChg = TRUE; }
282 USHORT GetBoxesCount() const { return aSelBoxes.Count(); }
283 const SwSelBoxes& GetBoxes() const { return aSelBoxes; }
285 // Baut fuer alle Boxen die Cursor auf
286 SwCursor* MakeBoxSels( SwCursor* pAktCrsr );
287 // sind irgendwelche Boxen mit einem Schutz versehen?
288 BOOL HasReadOnlyBoxSel() const;
290 // wurde der TabelleCursor veraendert ? Wenn ja speicher gleich
291 // die neuen Werte.
292 BOOL IsCrsrMovedUpdt();
293 // wurde der TabelleCursor veraendert ?
294 BOOL IsCrsrMoved() const
296 return nTblMkNd != GetMark()->nNode.GetIndex() ||
297 nTblPtNd != GetPoint()->nNode.GetIndex() ||
298 nTblMkCnt != GetMark()->nContent.GetIndex() ||
299 nTblPtCnt != GetPoint()->nContent.GetIndex();
302 BOOL IsChgd() const { return bChg; }
304 // Parke den Tabellen-Cursor auf dem StartNode der Boxen.
305 void ParkCrsr();
307 bool NewTableSelection();
308 void ActualizeSelection( const SwSelBoxes &rBoxes );
311 #endif