merge the formfield patch from ooo-build
[ooovba.git] / binfilter / inc / bf_sw / swcrsr.hxx
blob94d26d4696075a4c11dc50f65b3d16676205c07e
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.8 $
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
33 #ifndef _PAM_HXX //autogen
34 #include <pam.hxx>
35 #endif
36 #ifndef _TBLSEL_HXX //autogen
37 #include <tblsel.hxx>
38 #endif
39 #ifndef _CSHTYP_HXX //autogen
40 #include <cshtyp.hxx>
41 #endif
42 namespace com { namespace sun { namespace star { namespace util {
43 struct SearchOptions;
44 } } } }
46 namespace binfilter {
49 class SwShellCrsr;
50 class SwShellTableCrsr;
51 class SwTableCursor;
52 class SwUnoCrsr;
53 class SwUnoTableCrsr;
54 struct _SwCursor_SavePos;
56 //STRIP008 namespace com { namespace sun { namespace star { namespace util {
57 //STRIP008 struct SearchOptions;
58 //STRIP008 } } } }
61 // ein Basis-Struktur fuer die Parameter der Find-Methoden
62 // return - Werte vom Found-Aufruf.
63 const int FIND_NOT_FOUND = 0;
64 const int FIND_FOUND = 1;
65 const int FIND_NO_RING = 2;
67 struct SwFindParas
69 virtual int Find( SwPaM*, SwMoveFn, const SwPaM*, FASTBOOL ) = 0;
70 virtual int IsReplaceMode() const = 0;
73 enum SwCursorSelOverFlags
75 SELOVER_NONE = 0x00,
76 SELOVER_CHECKNODESSECTION = 0x01,
77 SELOVER_TOGGLE = 0x02,
78 SELOVER_ENABLEREVDIREKTION = 0x04,
79 SELOVER_CHANGEPOS = 0x08
82 class SwCursor : public SwPaM
84 friend class SwCrsrSaveState;
86 _SwCursor_SavePos* pSavePos;
87 BYTE nCursorBidiLevel; // bidi level of the cursor
89 ULONG FindAll( SwFindParas& , SwDocPositions, SwDocPositions, FindRanges, BOOL& bCancel );
91 protected:
92 virtual _SwCursor_SavePos* CreateNewSavePos() const;
93 void SaveState();
94 void RestoreState();
96 const _SwCursor_SavePos* GetSavePos() const { return pSavePos; }
98 public:
99 SwCursor( const SwPosition &rPos, SwPaM* pRing = 0 );
100 virtual ~SwCursor();
103 virtual operator SwShellCrsr* ();
104 virtual operator SwShellTableCrsr* ();
105 virtual operator SwTableCursor* ();
106 virtual operator SwUnoCrsr* ();
107 virtual operator SwUnoTableCrsr* ();
109 inline operator const SwShellCrsr* () const;
110 inline operator const SwShellTableCrsr* () const;
111 inline operator const SwTableCursor* () const;
112 inline operator const SwUnoCrsr* () const;
113 inline operator const SwUnoTableCrsr* () const;
115 virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
118 ULONG Find( const ::com::sun::star::util::SearchOptions& rSearchOpt,
119 SwDocPositions nStart, SwDocPositions nEnde,
120 BOOL& bCancel,
121 FindRanges = FND_IN_BODY,
122 int bReplace = FALSE );
124 ULONG Find( const SwTxtFmtColl& rFmtColl,
125 SwDocPositions nStart, SwDocPositions nEnde,
126 BOOL& bCancel,
127 FindRanges = FND_IN_BODY,
128 const SwTxtFmtColl* pReplFmt = 0 );
130 ULONG Find( const SfxItemSet& rSet, FASTBOOL bNoCollections,
131 SwDocPositions nStart, SwDocPositions nEnde,
132 BOOL& bCancel,
133 FindRanges = FND_IN_BODY,
134 const ::com::sun::star::util::SearchOptions* pSearchOpt = 0,
135 const SfxItemSet* rReplSet = 0 );
137 FASTBOOL IsStartWord()const;
138 FASTBOOL IsEndWord() const;
139 FASTBOOL GoStartWord();
140 FASTBOOL GoEndWord();
141 FASTBOOL GoNextWord();
142 FASTBOOL GoPrevWord();
144 enum SentenceMoveType
146 NEXT_SENT,
147 PREV_SENT,
148 START_SENT,
149 END_SENT
151 FASTBOOL GoSentence(SentenceMoveType eMoveType);
152 FASTBOOL GoNextSentence(){DBG_BF_ASSERT(0, "STRIP"); return FALSE;}//STRIP001 return GoSentence(NEXT_SENT);}
153 FASTBOOL GoPrevSentence(){DBG_BF_ASSERT(0, "STRIP"); return FALSE;}//STRIP001 return GoSentence(PREV_SENT);}
155 FASTBOOL LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, BOOL bAllowVisual,
156 BOOL bInsertCrsr );
157 FASTBOOL UpDown( BOOL bUp, USHORT nCnt = 1,
158 Point* pPt = 0, long nUpDownX = 0 );
160 FASTBOOL Left( USHORT nCnt, USHORT nMode, BOOL bAllowVisual = FALSE )
161 { return LeftRight( TRUE, nCnt, nMode, bAllowVisual, FALSE ); }
162 FASTBOOL Right( USHORT nCnt, USHORT nMode, BOOL bAllowVisual = FALSE )
163 { return LeftRight( FALSE, nCnt, nMode, bAllowVisual, FALSE ); }
164 FASTBOOL Up( USHORT nCnt = 1 ) { return UpDown( TRUE, nCnt ); }
165 FASTBOOL Down( USHORT nCnt = 1 ) { return UpDown( FALSE, nCnt ); }
166 FASTBOOL LeftMargin() { DBG_BF_ASSERT(0, "STRIP"); return FALSE;} //STRIP001 { return LeftRightMargin( TRUE ); }
167 FASTBOOL RightMargin() { DBG_BF_ASSERT(0, "STRIP"); return FALSE;} //STRIP001 { return LeftRightMargin( FALSE ); }
168 FASTBOOL SttDoc() { DBG_BF_ASSERT(0, "STRIP"); return FALSE;} //STRIP001 { return SttEndDoc( TRUE ); }
169 FASTBOOL EndDoc() { DBG_BF_ASSERT(0, "STRIP"); return FALSE;} //STRIP001 { return SttEndDoc( FALSE ); }
170 FASTBOOL GoNextCell( USHORT nCnt = 1 ) { DBG_BF_ASSERT(0, "STRIP"); return FALSE;} //STRIP001 { return GoPrevNextCell( TRUE, nCnt ); }
171 FASTBOOL GoPrevCell( USHORT nCnt = 1 ) { DBG_BF_ASSERT(0, "STRIP"); return FALSE;} //STRIP001 { return GoPrevNextCell( FALSE, nCnt ); }
172 FASTBOOL GotoTblBox( const String& rName );
174 FASTBOOL MovePara( SwWhichPara, SwPosPara );
175 FASTBOOL MoveSection( SwWhichSection, SwPosSection );
176 FASTBOOL MoveTable( SwWhichTable, SwPosTable );
179 // gibt es eine Selection vom Content in die Tabelle
180 // Return Wert gibt an, ob der Crsr auf der alten Position verbleibt
181 virtual FASTBOOL IsSelOvr( int eFlags =
182 ( SELOVER_CHECKNODESSECTION |
183 SELOVER_TOGGLE | SELOVER_CHANGEPOS ));
184 virtual FASTBOOL IsInProtectTable( FASTBOOL bMove = FALSE,
185 FASTBOOL bChgCrsr = TRUE );
188 // TRUE: an die Position kann der Cursor gesetzt werden
189 virtual FASTBOOL IsAtValidPos( BOOL bPoint = TRUE ) const;
191 // darf der Cursor in ReadOnlyBereiche?
192 FASTBOOL IsReadOnlyAvailable() const;
194 BYTE GetCrsrBidiLevel() const { return nCursorBidiLevel; }
195 void SetCrsrBidiLevel( BYTE nNewLevel ) { nCursorBidiLevel = nNewLevel; }
197 DECL_FIXEDMEMPOOL_NEWDEL( SwCursor )
201 class SwCrsrSaveState
203 SwCursor& rCrsr;
204 public:
205 SwCrsrSaveState( SwCursor& rC ) : rCrsr( rC ) { rC.SaveState(); }
206 ~SwCrsrSaveState() { rCrsr.RestoreState(); }
209 struct _SwCursor_SavePos
211 ULONG nNode;
212 xub_StrLen nCntnt;
213 _SwCursor_SavePos* pNext;
215 _SwCursor_SavePos( const SwCursor& rCrsr )
216 : nNode( rCrsr.GetPoint()->nNode.GetIndex() ),
217 nCntnt( rCrsr.GetPoint()->nContent.GetIndex() ),
218 pNext( 0 )
220 virtual ~_SwCursor_SavePos() {}
222 DECL_FIXEDMEMPOOL_NEWDEL( _SwCursor_SavePos )
227 class SwTableCursor : public virtual SwCursor
230 protected:
231 ULONG nTblPtNd, nTblMkNd;
232 xub_StrLen nTblPtCnt, nTblMkCnt;
233 SwSelBoxes aSelBoxes;
234 BOOL bChg : 1;
235 BOOL bParked : 1; // Tabellen-Cursor wurde geparkt
237 public:
238 SwTableCursor( SwTableCursor& );
239 virtual ~SwTableCursor();
241 virtual operator SwTableCursor* ();
243 void DeleteBox( USHORT nPos ) { aSelBoxes.Remove( nPos ); bChg = TRUE; }
244 USHORT GetBoxesCount() const { return aSelBoxes.Count(); }
245 const SwSelBoxes& GetBoxes() const { return aSelBoxes; }
249 // --------------------------- inline Methoden ----------------------
251 inline SwCursor::operator const SwShellCrsr* () const
253 return (SwShellCrsr*)*((SwCursor*)this);
256 inline SwCursor::operator const SwShellTableCrsr* () const
258 return (SwShellTableCrsr*)*((SwCursor*)this);
261 inline SwCursor::operator const SwTableCursor* () const
263 return (SwTableCursor*)*((SwCursor*)this);
266 inline SwCursor::operator const SwUnoCrsr* () const
268 return (SwUnoCrsr*)*((SwCursor*)this);
271 inline SwCursor::operator const SwUnoTableCrsr* () const
273 return (SwUnoTableCrsr*)*((SwCursor*)this);
277 } //namespace binfilter
278 #endif