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