1*1d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1d2dbeb0SAndrew Rist * distributed with this work for additional information 6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 10*1d2dbeb0SAndrew Rist * 11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1d2dbeb0SAndrew Rist * 13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations 18*1d2dbeb0SAndrew Rist * under the License. 19*1d2dbeb0SAndrew Rist * 20*1d2dbeb0SAndrew Rist *************************************************************/ 21*1d2dbeb0SAndrew Rist 22*1d2dbeb0SAndrew Rist 23cdf0e10cSrcweir #ifndef _SWCRSR_HXX 24cdf0e10cSrcweir #define _SWCRSR_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/i18n/WordType.hpp> 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <pam.hxx> 29cdf0e10cSrcweir #include <tblsel.hxx> 30cdf0e10cSrcweir #include <cshtyp.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir struct _SwCursor_SavePos; 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace util { 36cdf0e10cSrcweir struct SearchOptions; 37cdf0e10cSrcweir } } } } 38cdf0e10cSrcweir 39cdf0e10cSrcweir 40cdf0e10cSrcweir // ein Basis-Struktur fuer die Parameter der Find-Methoden 41cdf0e10cSrcweir // return - Werte vom Found-Aufruf. 42cdf0e10cSrcweir const int FIND_NOT_FOUND = 0; 43cdf0e10cSrcweir const int FIND_FOUND = 1; 44cdf0e10cSrcweir const int FIND_NO_RING = 2; 45cdf0e10cSrcweir 46cdf0e10cSrcweir struct SwFindParas 47cdf0e10cSrcweir { 48cdf0e10cSrcweir virtual int Find( SwPaM*, SwMoveFn, const SwPaM*, sal_Bool ) = 0; 49cdf0e10cSrcweir virtual int IsReplaceMode() const = 0; 50cdf0e10cSrcweir }; 51cdf0e10cSrcweir 52cdf0e10cSrcweir typedef sal_uInt16 SwCursorSelOverFlags; 53cdf0e10cSrcweir namespace nsSwCursorSelOverFlags 54cdf0e10cSrcweir { 55cdf0e10cSrcweir const SwCursorSelOverFlags SELOVER_NONE = 0x00; 56cdf0e10cSrcweir const SwCursorSelOverFlags SELOVER_CHECKNODESSECTION = 0x01; 57cdf0e10cSrcweir const SwCursorSelOverFlags SELOVER_TOGGLE = 0x02; 58cdf0e10cSrcweir const SwCursorSelOverFlags SELOVER_ENABLEREVDIREKTION = 0x04; 59cdf0e10cSrcweir const SwCursorSelOverFlags SELOVER_CHANGEPOS = 0x08; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir class SwCursor : public SwPaM 63cdf0e10cSrcweir { 64cdf0e10cSrcweir friend class SwCrsrSaveState; 65cdf0e10cSrcweir 66cdf0e10cSrcweir _SwCursor_SavePos* pSavePos; 67cdf0e10cSrcweir long mnRowSpanOffset; // required for travelling in tabs with rowspans 68cdf0e10cSrcweir sal_uInt8 nCursorBidiLevel; // bidi level of the cursor 69cdf0e10cSrcweir bool mbColumnSelection; // true: cursor is aprt of a column selection 70cdf0e10cSrcweir 71cdf0e10cSrcweir sal_uLong FindAll( SwFindParas& , SwDocPositions, SwDocPositions, FindRanges, sal_Bool& bCancel ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir using SwPaM::Find; 74cdf0e10cSrcweir 75cdf0e10cSrcweir protected: 76cdf0e10cSrcweir virtual _SwCursor_SavePos* CreateNewSavePos() const; 77cdf0e10cSrcweir void SaveState(); 78cdf0e10cSrcweir void RestoreState(); 79cdf0e10cSrcweir GetSavePos() const80cdf0e10cSrcweir const _SwCursor_SavePos* GetSavePos() const { return pSavePos; } 81cdf0e10cSrcweir 82cdf0e10cSrcweir virtual const SwCntntFrm* DoSetBidiLevelLeftRight( 83cdf0e10cSrcweir sal_Bool & io_rbLeft, sal_Bool bVisualAllowed, sal_Bool bInsertCrsr); 84cdf0e10cSrcweir virtual void DoSetBidiLevelUpDown(); 85cdf0e10cSrcweir virtual bool IsSelOvrCheck(int eFlags); 86cdf0e10cSrcweir 87cdf0e10cSrcweir public: 88cdf0e10cSrcweir // single argument ctors shall be explicit. 89cdf0e10cSrcweir SwCursor( const SwPosition &rPos, SwPaM* pRing, bool bColumnSel ); 90cdf0e10cSrcweir virtual ~SwCursor(); 91cdf0e10cSrcweir 92cdf0e10cSrcweir // @@@ semantic: no copy ctor. 93cdf0e10cSrcweir SwCursor( SwCursor& rCpy); 94cdf0e10cSrcweir 95cdf0e10cSrcweir public: 96cdf0e10cSrcweir 97cdf0e10cSrcweir virtual SwCursor* Create( SwPaM* pRing = 0 ) const; 98cdf0e10cSrcweir 99cdf0e10cSrcweir virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO 100cdf0e10cSrcweir virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 ); 101cdf0e10cSrcweir 102cdf0e10cSrcweir void FillFindPos( SwDocPositions ePos, SwPosition& rPos ) const; 103cdf0e10cSrcweir SwMoveFnCollection* MakeFindRange( SwDocPositions, SwDocPositions, 104cdf0e10cSrcweir SwPaM* ) const; 105cdf0e10cSrcweir 106cdf0e10cSrcweir 107cdf0e10cSrcweir sal_uLong Find( const com::sun::star::util::SearchOptions& rSearchOpt, 108cdf0e10cSrcweir sal_Bool bSearchInNotes, 109cdf0e10cSrcweir SwDocPositions nStart, SwDocPositions nEnde, 110cdf0e10cSrcweir sal_Bool& bCancel, 111cdf0e10cSrcweir FindRanges = FND_IN_BODY, 112cdf0e10cSrcweir int bReplace = sal_False ); 113cdf0e10cSrcweir sal_uLong Find( const SwTxtFmtColl& rFmtColl, 114cdf0e10cSrcweir SwDocPositions nStart, SwDocPositions nEnde, 115cdf0e10cSrcweir sal_Bool& bCancel, 116cdf0e10cSrcweir FindRanges = FND_IN_BODY, 117cdf0e10cSrcweir const SwTxtFmtColl* pReplFmt = 0 ); 118cdf0e10cSrcweir sal_uLong Find( const SfxItemSet& rSet, sal_Bool bNoCollections, 119cdf0e10cSrcweir SwDocPositions nStart, SwDocPositions nEnde, 120cdf0e10cSrcweir sal_Bool& bCancel, 121cdf0e10cSrcweir FindRanges = FND_IN_BODY, 122cdf0e10cSrcweir const com::sun::star::util::SearchOptions* pSearchOpt = 0, 123cdf0e10cSrcweir const SfxItemSet* rReplSet = 0 ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir // UI versions 126cdf0e10cSrcweir sal_Bool IsStartWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; 127cdf0e10cSrcweir sal_Bool IsEndWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; 128cdf0e10cSrcweir sal_Bool IsInWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; 129cdf0e10cSrcweir sal_Bool IsStartEndSentence( bool bEnd ) const; 130cdf0e10cSrcweir sal_Bool GoStartWord(); 131cdf0e10cSrcweir sal_Bool GoEndWord(); 132cdf0e10cSrcweir sal_Bool GoNextWord(); 133cdf0e10cSrcweir sal_Bool GoPrevWord(); 134cdf0e10cSrcweir sal_Bool SelectWord( ViewShell* pViewShell, const Point* pPt = 0 ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir // API versions of above functions (will be used with a different 137cdf0e10cSrcweir // WordType for the break iterator) 138cdf0e10cSrcweir sal_Bool IsStartWordWT( sal_Int16 nWordType ) const; 139cdf0e10cSrcweir sal_Bool IsEndWordWT( sal_Int16 nWordType ) const; 140cdf0e10cSrcweir sal_Bool IsInWordWT( sal_Int16 nWordType ) const; 141cdf0e10cSrcweir sal_Bool GoStartWordWT( sal_Int16 nWordType ); 142cdf0e10cSrcweir sal_Bool GoEndWordWT( sal_Int16 nWordType ); 143cdf0e10cSrcweir sal_Bool GoNextWordWT( sal_Int16 nWordType ); 144cdf0e10cSrcweir sal_Bool GoPrevWordWT( sal_Int16 nWordType ); 145cdf0e10cSrcweir sal_Bool SelectWordWT( ViewShell* pViewShell, sal_Int16 nWordType, const Point* pPt = 0 ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir enum SentenceMoveType 148cdf0e10cSrcweir { 149cdf0e10cSrcweir NEXT_SENT, 150cdf0e10cSrcweir PREV_SENT, 151cdf0e10cSrcweir START_SENT, 152cdf0e10cSrcweir END_SENT 153cdf0e10cSrcweir }; 154cdf0e10cSrcweir sal_Bool GoSentence(SentenceMoveType eMoveType); GoNextSentence()155cdf0e10cSrcweir sal_Bool GoNextSentence(){return GoSentence(NEXT_SENT);} GoEndSentence()156cdf0e10cSrcweir sal_Bool GoEndSentence(){return GoSentence(END_SENT);} GoPrevSentence()157cdf0e10cSrcweir sal_Bool GoPrevSentence(){return GoSentence(PREV_SENT);} GoStartSentence()158cdf0e10cSrcweir sal_Bool GoStartSentence(){return GoSentence(START_SENT);} 159cdf0e10cSrcweir sal_Bool ExpandToSentenceBorders(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir virtual sal_Bool LeftRight( sal_Bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode, 162cdf0e10cSrcweir sal_Bool bAllowVisual, sal_Bool bSkipHidden, sal_Bool bInsertCrsr ); 163cdf0e10cSrcweir sal_Bool UpDown( sal_Bool bUp, sal_uInt16 nCnt, Point* pPt, long nUpDownX ); 164cdf0e10cSrcweir sal_Bool LeftRightMargin( sal_Bool bLeftMargin, sal_Bool bAPI = sal_False ); 165cdf0e10cSrcweir sal_Bool IsAtLeftRightMargin( sal_Bool bLeftMargin, sal_Bool bAPI = sal_False ) const; 166cdf0e10cSrcweir sal_Bool SttEndDoc( sal_Bool bSttDoc ); 167cdf0e10cSrcweir sal_Bool GoPrevNextCell( sal_Bool bNext, sal_uInt16 nCnt ); 168cdf0e10cSrcweir Left(sal_uInt16 nCnt,sal_uInt16 nMode,sal_Bool bAllowVisual,sal_Bool bSkipHidden)169cdf0e10cSrcweir sal_Bool Left( sal_uInt16 nCnt, sal_uInt16 nMode, sal_Bool bAllowVisual, sal_Bool bSkipHidden ) 170cdf0e10cSrcweir { return LeftRight( sal_True, nCnt, nMode, bAllowVisual, bSkipHidden, sal_False ); } Right(sal_uInt16 nCnt,sal_uInt16 nMode,sal_Bool bAllowVisual,sal_Bool bSkipHidden)171cdf0e10cSrcweir sal_Bool Right( sal_uInt16 nCnt, sal_uInt16 nMode, sal_Bool bAllowVisual, sal_Bool bSkipHidden ) 172cdf0e10cSrcweir { return LeftRight( sal_False, nCnt, nMode, bAllowVisual, bSkipHidden, sal_False ); } GoNextCell(sal_uInt16 nCnt=1)173cdf0e10cSrcweir sal_Bool GoNextCell( sal_uInt16 nCnt = 1 ) { return GoPrevNextCell( sal_True, nCnt ); } GoPrevCell(sal_uInt16 nCnt=1)174cdf0e10cSrcweir sal_Bool GoPrevCell( sal_uInt16 nCnt = 1 ) { return GoPrevNextCell( sal_False, nCnt ); } 175cdf0e10cSrcweir virtual sal_Bool GotoTable( const String& rName ); 176cdf0e10cSrcweir sal_Bool GotoTblBox( const String& rName ); 177cdf0e10cSrcweir sal_Bool GotoRegion( const String& rName ); 178cdf0e10cSrcweir sal_Bool GotoFtnAnchor(); 179cdf0e10cSrcweir sal_Bool GotoFtnTxt(); 180cdf0e10cSrcweir sal_Bool GotoNextFtnAnchor(); 181cdf0e10cSrcweir sal_Bool GotoPrevFtnAnchor(); 182cdf0e10cSrcweir sal_Bool GotoNextFtnCntnt(); 183cdf0e10cSrcweir sal_Bool GotoPrevFtnCntnt(); 184cdf0e10cSrcweir 185cdf0e10cSrcweir sal_Bool MovePara( SwWhichPara, SwPosPara ); 186cdf0e10cSrcweir sal_Bool MoveSection( SwWhichSection, SwPosSection ); 187cdf0e10cSrcweir sal_Bool MoveTable( SwWhichTable, SwPosTable ); 188cdf0e10cSrcweir sal_Bool MoveRegion( SwWhichRegion, SwPosRegion ); 189cdf0e10cSrcweir 190cdf0e10cSrcweir 191cdf0e10cSrcweir // gibt es eine Selection vom Content in die Tabelle 192cdf0e10cSrcweir // Return Wert gibt an, ob der Crsr auf der alten Position verbleibt 193cdf0e10cSrcweir virtual sal_Bool IsSelOvr( int eFlags = 194cdf0e10cSrcweir ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | 195cdf0e10cSrcweir nsSwCursorSelOverFlags::SELOVER_TOGGLE | 196cdf0e10cSrcweir nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )); 197cdf0e10cSrcweir virtual sal_Bool IsInProtectTable( sal_Bool bMove = sal_False, 198cdf0e10cSrcweir sal_Bool bChgCrsr = sal_True ); 199cdf0e10cSrcweir sal_Bool IsNoCntnt() const; 200cdf0e10cSrcweir 201cdf0e10cSrcweir void RestoreSavePos(); // Point auf die SavePos setzen 202cdf0e10cSrcweir 203cdf0e10cSrcweir // sal_True: an die Position kann der Cursor gesetzt werden 204cdf0e10cSrcweir virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const; 205cdf0e10cSrcweir 206cdf0e10cSrcweir // darf der Cursor in ReadOnlyBereiche? 207cdf0e10cSrcweir virtual bool IsReadOnlyAvailable() const; 208cdf0e10cSrcweir 209cdf0e10cSrcweir virtual sal_Bool IsSkipOverProtectSections() const; 210cdf0e10cSrcweir virtual sal_Bool IsSkipOverHiddenSections() const; 211cdf0e10cSrcweir GetCrsrBidiLevel() const212cdf0e10cSrcweir sal_uInt8 GetCrsrBidiLevel() const { return nCursorBidiLevel; } SetCrsrBidiLevel(sal_uInt8 nNewLevel)213cdf0e10cSrcweir void SetCrsrBidiLevel( sal_uInt8 nNewLevel ) { nCursorBidiLevel = nNewLevel; } 214cdf0e10cSrcweir IsColumnSelection() const215cdf0e10cSrcweir bool IsColumnSelection() const { return mbColumnSelection; } SetColumnSelection(bool bNew)216cdf0e10cSrcweir void SetColumnSelection( bool bNew ) { mbColumnSelection = bNew; } 217cdf0e10cSrcweir GetCrsrRowSpanOffset() const218cdf0e10cSrcweir long GetCrsrRowSpanOffset() const { return mnRowSpanOffset; } SetCrsrRowSpanOffset(long nNew)219cdf0e10cSrcweir void SetCrsrRowSpanOffset( long nNew ) { mnRowSpanOffset = nNew; } 220cdf0e10cSrcweir 221cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL( SwCursor ) 222cdf0e10cSrcweir }; 223cdf0e10cSrcweir 224cdf0e10cSrcweir 225cdf0e10cSrcweir class SwCrsrSaveState 226cdf0e10cSrcweir { 227cdf0e10cSrcweir SwCursor& rCrsr; 228cdf0e10cSrcweir public: SwCrsrSaveState(SwCursor & rC)229cdf0e10cSrcweir SwCrsrSaveState( SwCursor& rC ) : rCrsr( rC ) { rC.SaveState(); } ~SwCrsrSaveState()230cdf0e10cSrcweir ~SwCrsrSaveState() { rCrsr.RestoreState(); } 231cdf0e10cSrcweir }; 232cdf0e10cSrcweir 233cdf0e10cSrcweir struct _SwCursor_SavePos 234cdf0e10cSrcweir { 235cdf0e10cSrcweir sal_uLong nNode; 236cdf0e10cSrcweir xub_StrLen nCntnt; 237cdf0e10cSrcweir _SwCursor_SavePos* pNext; 238cdf0e10cSrcweir _SwCursor_SavePos_SwCursor_SavePos239cdf0e10cSrcweir _SwCursor_SavePos( const SwCursor& rCrsr ) 240cdf0e10cSrcweir : nNode( rCrsr.GetPoint()->nNode.GetIndex() ), 241cdf0e10cSrcweir nCntnt( rCrsr.GetPoint()->nContent.GetIndex() ), 242cdf0e10cSrcweir pNext( 0 ) 243cdf0e10cSrcweir {} ~_SwCursor_SavePos_SwCursor_SavePos244cdf0e10cSrcweir virtual ~_SwCursor_SavePos() {} 245cdf0e10cSrcweir 246cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL( _SwCursor_SavePos ) 247cdf0e10cSrcweir }; 248cdf0e10cSrcweir 249cdf0e10cSrcweir 250cdf0e10cSrcweir 251cdf0e10cSrcweir class SwTableCursor : public virtual SwCursor 252cdf0e10cSrcweir { 253cdf0e10cSrcweir 254cdf0e10cSrcweir protected: 255cdf0e10cSrcweir sal_uLong nTblPtNd, nTblMkNd; 256cdf0e10cSrcweir xub_StrLen nTblPtCnt, nTblMkCnt; 257cdf0e10cSrcweir SwSelBoxes aSelBoxes; 258cdf0e10cSrcweir sal_Bool bChg : 1; 259cdf0e10cSrcweir sal_Bool bParked : 1; // Tabellen-Cursor wurde geparkt 260cdf0e10cSrcweir 261cdf0e10cSrcweir virtual bool IsSelOvrCheck(int eFlags); 262cdf0e10cSrcweir 263cdf0e10cSrcweir public: 264cdf0e10cSrcweir SwTableCursor( const SwPosition &rPos, SwPaM* pRing = 0 ); 265cdf0e10cSrcweir SwTableCursor( SwTableCursor& ); 266cdf0e10cSrcweir virtual ~SwTableCursor(); 267cdf0e10cSrcweir 268cdf0e10cSrcweir virtual sal_Bool LeftRight( sal_Bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode, 269cdf0e10cSrcweir sal_Bool bAllowVisual, sal_Bool bSkipHidden, sal_Bool bInsertCrsr ); 270cdf0e10cSrcweir virtual sal_Bool GotoTable( const String& rName ); 271cdf0e10cSrcweir 272cdf0e10cSrcweir void InsertBox( const SwTableBox& rTblBox ); DeleteBox(sal_uInt16 nPos)273cdf0e10cSrcweir void DeleteBox( sal_uInt16 nPos ) { aSelBoxes.Remove( nPos ); bChg = sal_True; } GetBoxesCount() const274cdf0e10cSrcweir sal_uInt16 GetBoxesCount() const { return aSelBoxes.Count(); } GetBoxes() const275cdf0e10cSrcweir const SwSelBoxes& GetBoxes() const { return aSelBoxes; } 276cdf0e10cSrcweir 277cdf0e10cSrcweir // Baut fuer alle Boxen die Cursor auf 278cdf0e10cSrcweir SwCursor* MakeBoxSels( SwCursor* pAktCrsr ); 279cdf0e10cSrcweir // sind irgendwelche Boxen mit einem Schutz versehen? 280cdf0e10cSrcweir sal_Bool HasReadOnlyBoxSel() const; 281cdf0e10cSrcweir 282cdf0e10cSrcweir // wurde der TabelleCursor veraendert ? Wenn ja speicher gleich 283cdf0e10cSrcweir // die neuen Werte. 284cdf0e10cSrcweir sal_Bool IsCrsrMovedUpdt(); 285cdf0e10cSrcweir // wurde der TabelleCursor veraendert ? IsCrsrMoved() const286cdf0e10cSrcweir sal_Bool IsCrsrMoved() const 287cdf0e10cSrcweir { 288cdf0e10cSrcweir return nTblMkNd != GetMark()->nNode.GetIndex() || 289cdf0e10cSrcweir nTblPtNd != GetPoint()->nNode.GetIndex() || 290cdf0e10cSrcweir nTblMkCnt != GetMark()->nContent.GetIndex() || 291cdf0e10cSrcweir nTblPtCnt != GetPoint()->nContent.GetIndex(); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir IsChgd() const294cdf0e10cSrcweir sal_Bool IsChgd() const { return bChg; } 295cdf0e10cSrcweir 296cdf0e10cSrcweir // Parke den Tabellen-Cursor auf dem StartNode der Boxen. 297cdf0e10cSrcweir void ParkCrsr(); 298cdf0e10cSrcweir 299cdf0e10cSrcweir bool NewTableSelection(); 300cdf0e10cSrcweir void ActualizeSelection( const SwSelBoxes &rBoxes ); 301cdf0e10cSrcweir }; 302cdf0e10cSrcweir 303cdf0e10cSrcweir #endif 304cdf0e10cSrcweir 305