1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 #include <com/sun/star/i18n/WordType.hpp>
37 struct _SwCursor_SavePos
;
39 namespace com
{ namespace sun
{ namespace star
{ namespace util
{
44 // ein Basis-Struktur fuer die Parameter der Find-Methoden
45 // return - Werte vom Found-Aufruf.
46 const int FIND_NOT_FOUND
= 0;
47 const int FIND_FOUND
= 1;
48 const int FIND_NO_RING
= 2;
52 virtual int Find( SwPaM
*, SwMoveFn
, const SwPaM
*, BOOL
) = 0;
53 virtual int IsReplaceMode() const = 0;
56 typedef USHORT SwCursorSelOverFlags
;
57 namespace nsSwCursorSelOverFlags
59 const SwCursorSelOverFlags SELOVER_NONE
= 0x00;
60 const SwCursorSelOverFlags SELOVER_CHECKNODESSECTION
= 0x01;
61 const SwCursorSelOverFlags SELOVER_TOGGLE
= 0x02;
62 const SwCursorSelOverFlags SELOVER_ENABLEREVDIREKTION
= 0x04;
63 const SwCursorSelOverFlags SELOVER_CHANGEPOS
= 0x08;
66 class SwCursor
: public SwPaM
68 friend class SwCrsrSaveState
;
70 _SwCursor_SavePos
* pSavePos
;
71 long mnRowSpanOffset
; // required for travelling in tabs with rowspans
72 BYTE nCursorBidiLevel
; // bidi level of the cursor
73 bool mbColumnSelection
; // true: cursor is aprt of a column selection
75 ULONG
FindAll( SwFindParas
& , SwDocPositions
, SwDocPositions
, FindRanges
, BOOL
& bCancel
);
80 virtual _SwCursor_SavePos
* CreateNewSavePos() const;
84 const _SwCursor_SavePos
* GetSavePos() const { return pSavePos
; }
86 virtual const SwCntntFrm
* DoSetBidiLevelLeftRight(
87 BOOL
& io_rbLeft
, BOOL bVisualAllowed
, BOOL bInsertCrsr
);
88 virtual void DoSetBidiLevelUpDown();
89 virtual bool IsSelOvrCheck(int eFlags
);
92 // single argument ctors shall be explicit.
93 SwCursor( const SwPosition
&rPos
, SwPaM
* pRing
, bool bColumnSel
);
96 // @@@ semantic: no copy ctor.
97 SwCursor( SwCursor
& rCpy
);
99 // forbidden and not implemented.
100 //SwCursor( const SwCursor& );
101 // @@@ used e.g. in core/frmedt/fetab.cxx @@@
102 // SwCursor & operator= ( const SwCursor& );
105 virtual SwCursor
* Create( SwPaM
* pRing
= 0 ) const;
107 virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO
108 virtual void SaveTblBoxCntnt( const SwPosition
* pPos
= 0 );
110 void FillFindPos( SwDocPositions ePos
, SwPosition
& rPos
) const;
111 SwMoveFnCollection
* MakeFindRange( SwDocPositions
, SwDocPositions
,
115 ULONG
Find( const com::sun::star::util::SearchOptions
& rSearchOpt
,
117 SwDocPositions nStart
, SwDocPositions nEnde
,
119 FindRanges
= FND_IN_BODY
,
120 int bReplace
= FALSE
);
121 ULONG
Find( const SwTxtFmtColl
& rFmtColl
,
122 SwDocPositions nStart
, SwDocPositions nEnde
,
124 FindRanges
= FND_IN_BODY
,
125 const SwTxtFmtColl
* pReplFmt
= 0 );
126 ULONG
Find( const SfxItemSet
& rSet
, BOOL bNoCollections
,
127 SwDocPositions nStart
, SwDocPositions nEnde
,
129 FindRanges
= FND_IN_BODY
,
130 const com::sun::star::util::SearchOptions
* pSearchOpt
= 0,
131 const SfxItemSet
* rReplSet
= 0 );
134 BOOL
IsStartWord( sal_Int16 nWordType
= com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
135 BOOL
IsEndWord( sal_Int16 nWordType
= com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
136 BOOL
IsInWord( sal_Int16 nWordType
= com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES
) const;
137 BOOL
IsStartEndSentence( bool bEnd
) const;
142 BOOL
SelectWord( const Point
* pPt
= 0 );
144 // API versions of above functions (will be used with a different
145 // WordType for the break iterator)
146 BOOL
IsStartWordWT( sal_Int16 nWordType
) const;
147 BOOL
IsEndWordWT( sal_Int16 nWordType
) const;
148 BOOL
IsInWordWT( sal_Int16 nWordType
) const;
149 BOOL
GoStartWordWT( sal_Int16 nWordType
);
150 BOOL
GoEndWordWT( sal_Int16 nWordType
);
151 BOOL
GoNextWordWT( sal_Int16 nWordType
);
152 BOOL
GoPrevWordWT( sal_Int16 nWordType
);
153 BOOL
SelectWordWT( sal_Int16 nWordType
, const Point
* pPt
= 0 );
155 enum SentenceMoveType
162 BOOL
GoSentence(SentenceMoveType eMoveType
);
163 BOOL
GoNextSentence(){return GoSentence(NEXT_SENT
);}
164 BOOL
GoEndSentence(){return GoSentence(END_SENT
);}
165 BOOL
GoPrevSentence(){return GoSentence(PREV_SENT
);}
166 BOOL
GoStartSentence(){return GoSentence(START_SENT
);}
167 BOOL
ExpandToSentenceBorders();
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();
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
237 SwCrsrSaveState( SwCursor
& rC
) : rCrsr( rC
) { rC
.SaveState(); }
238 ~SwCrsrSaveState() { rCrsr
.RestoreState(); }
241 struct _SwCursor_SavePos
245 _SwCursor_SavePos
* pNext
;
247 _SwCursor_SavePos( const SwCursor
& rCrsr
)
248 : nNode( rCrsr
.GetPoint()->nNode
.GetIndex() ),
249 nCntnt( rCrsr
.GetPoint()->nContent
.GetIndex() ),
252 virtual ~_SwCursor_SavePos() {}
254 DECL_FIXEDMEMPOOL_NEWDEL( _SwCursor_SavePos
)
259 class SwTableCursor
: public virtual SwCursor
263 ULONG nTblPtNd
, nTblMkNd
;
264 xub_StrLen nTblPtCnt
, nTblMkCnt
;
265 SwSelBoxes aSelBoxes
;
267 BOOL bParked
: 1; // Tabellen-Cursor wurde geparkt
269 virtual bool IsSelOvrCheck(int eFlags
);
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
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.
307 bool NewTableSelection();
308 void ActualizeSelection( const SwSelBoxes
&rBoxes
);