1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef SW_CRSRSH_HXX 24 #define SW_CRSRSH_HXX 25 26 #include <com/sun/star/i18n/WordType.hpp> 27 28 #include <tools/string.hxx> 29 #include <tools/link.hxx> 30 #include <tools/rtti.hxx> 31 32 #include <IShellCursorSupplier.hxx> 33 #include "swdllapi.h" 34 #include <swtypes.hxx> // fuer SWPOSDOC 35 #include <viewsh.hxx> // fuer ViewShell 36 #include <calbck.hxx> // fuer SwClient 37 #include <cshtyp.hxx> // fuer die CursorShell Typen 38 #include <crstate.hxx> // fuer die CursorMove-Staties 39 #include <toxe.hxx> // SwTOXSearchDir 40 #include <tblsel.hxx> //SwTblSearchType 41 #include <viscrs.hxx> 42 #include <node.hxx> 43 #include <tblsel.hxx> 44 #include <IDocumentMarkAccess.hxx> 45 46 47 // einige Forward Deklarationen 48 49 class KeyCode; 50 class SfxItemSet; 51 class SfxPoolItem; 52 class SwCntntFrm; 53 class SwCrsrShell; 54 class SwCursor; 55 class SwField; 56 class SwFieldType; 57 class SwFmt; 58 class SwFmtFld; 59 class SwNodeIndex; 60 class SwPaM; 61 class SwShellCrsr; 62 class SwShellTableCrsr; 63 class SwTableNode; 64 class SwTxtFmtColl; 65 class SwVisCrsr; 66 class SwTxtINetFmt; 67 class SwFmtINetFmt; 68 class SwTxtAttr; 69 class SwTableBox; 70 class SwCellFrms; 71 class SwTOXMark; 72 class SwRedline; 73 class IBlockCursor; 74 class SwCntntNode; 75 class SwPostItField; 76 class SwTxtFld; 77 struct SwPosition; 78 79 namespace com { namespace sun { namespace star { namespace util { 80 struct SearchOptions; 81 } } } } 82 83 namespace com { namespace sun { namespace star { namespace text { 84 class XTextRange; 85 }}}} 86 87 namespace com { namespace sun { namespace star { namespace container { 88 class XStringKeyMap; 89 }}}} 90 91 // enum und struktur, um ueber die Doc-Position Informationen zu erfragen 92 93 struct SwContentAtPos 94 { 95 enum IsAttrAtPos 96 { 97 SW_NOTHING = 0x0000, 98 SW_FIELD = 0x0001, 99 SW_CLICKFIELD = 0x0002, 100 SW_FTN = 0x0004, 101 SW_INETATTR = 0x0008, 102 SW_TABLEBOXFML = 0x0010, 103 SW_REDLINE = 0x0020, 104 SW_OUTLINE = 0x0040, 105 SW_TOXMARK = 0x0080, 106 SW_REFMARK = 0x0100, 107 SW_NUMLABEL = 0x0200, // #i23726# 108 SW_CONTENT_CHECK = 0x0400, // --> FME 2005-05-13 #i43742# <-- 109 SW_SMARTTAG = 0x0800, 110 SW_FORMCTRL = 0x1000 111 #ifndef PRODUCT 112 ,SW_CURR_ATTRS = 0x4000 // nur zum Debuggen 113 ,SW_TABLEBOXVALUE = 0x8000 // nur zum Debuggen 114 #endif 115 } eCntntAtPos; 116 117 union { 118 const SwField* pFld; 119 const SfxPoolItem* pAttr; 120 const SwRedline* pRedl; 121 SwCntntNode * pNode; // #i23726# 122 const sw::mark::IFieldmark* pFldmark; 123 } aFnd; 124 125 int nDist; // #i23726# 126 127 String sStr; 128 const SwTxtAttr* pFndTxtAttr; 129 130 SwContentAtPos( int eGetAtPos = 0xffff ) 131 : eCntntAtPos( (IsAttrAtPos)eGetAtPos ) 132 { 133 aFnd.pFld = 0; 134 pFndTxtAttr = 0; 135 nDist = 0; // #i23726# 136 } 137 138 // befindet sich der Node in einem geschuetzten Bereich? 139 sal_Bool IsInProtectSect() const; 140 bool IsInRTLText()const; 141 }; 142 143 // ReturnWerte von SetCrsr (werden verodert) 144 const int CRSR_POSOLD = 0x01, // Cursor bleibt an alter Doc-Position 145 CRSR_POSCHG = 0x02; // Position vom Layout veraendert 146 147 // Helperfunction to resolve backward references in regular expressions 148 149 String *ReplaceBackReferences( const com::sun::star::util::SearchOptions& rSearchOpt, SwPaM* pPam ); 150 151 // die Cursor - Shell 152 class SW_DLLPUBLIC SwCrsrShell 153 : public ViewShell 154 , public SwModify 155 , public ::sw::IShellCursorSupplier 156 { 157 friend class SwCallLink; 158 friend class SwVisCrsr; 159 friend class SwSelPaintRects; 160 friend class SwChgLinkFlag; 161 162 //Braucht den Crsr als IntrnlCrsr. 163 friend sal_Bool GetAutoSumSel( const SwCrsrShell&, SwCellFrms& ); 164 165 public: // public, damit defaultet werden kann !! 166 167 /* ein enum fuer den Aufruf von UpdateCrsr */ 168 enum CrsrFlag { 169 UPDOWN = (1 << 0), // Up/Down auf Spalte halten 170 SCROLLWIN = (1 << 1), // Window Scrollen 171 CHKRANGE = (1 << 2), // ueberpruefen von ueberlappenden PaM's 172 NOCALRECT = (1 << 3), // CharRect nicht neu berechnen 173 READONLY = (1 << 4) // Sichtbar machen trotz Readonly 174 }; 175 176 private: 177 178 SwRect aCharRect; // Char-SRectangle auf dem der Cursor steht 179 Point aCrsrHeight; // Hohe&Offset von sichtbaren Cursor 180 Point aOldRBPos; // Right/Bottom von letzter VisArea 181 // (wird im Invalidate vom Cursor benutzt) 182 183 184 // um event. Macro was anhaengt auszufuehren. 185 Link aFlyMacroLnk; // Link will be called, if the Crsr is set 186 // into a fly. A macro can be then becalled 187 Link aChgLnk; // link will be called by every attribut/ 188 // format changes at cursor position. 189 Link aGrfArrivedLnk; // Link calls to UI if a grafik is arrived 190 191 192 SwShellCrsr* pCurCrsr; // der aktuelle Cursor 193 SwShellCrsr* pCrsrStk; // Stack fuer den Cursor 194 SwVisCrsr *pVisCrsr; // der Sichtbare-Cursor 195 196 IBlockCursor *pBlockCrsr; // interface of cursor for block (=rectangular) selection 197 198 SwShellTableCrsr* pTblCrsr; // Tabellen-Crsr; nur in Tabellen, wenn 199 // die Selection ueber 2 Spalten liegt 200 201 SwNodeIndex* pBoxIdx; // fuers erkennen der veraenderten 202 SwTableBox* pBoxPtr; // Tabellen-Zelle 203 204 long nUpDownX; // versuche den Cursor bei Up/Down immer in 205 // der gleichen Spalte zu bewegen 206 long nLeftFrmPos; 207 sal_uLong nAktNode; // save CursorPos at Start-Action 208 xub_StrLen nAktCntnt; 209 sal_uInt16 nAktNdTyp; 210 bool bAktSelection; 211 212 /* 213 * Mit den Methoden SttCrsrMove und EndCrsrMove wird dieser Zaehler 214 * Inc-/Decrementiert. Solange der Zaehler ungleich 0 ist, erfolgt 215 * auf den akt. Cursor kein Update. Dadurch koennen "komplizierte" 216 * Cursorbewegungen (ueber Find()) realisiert werden. 217 */ 218 sal_uInt16 nCrsrMove; 219 sal_uInt16 nBasicActionCnt; // Actions, die vom Basic geklammert wurden 220 CrsrMoveState eMvState; // Status fuers Crsr-Travelling - GetCrsrOfst 221 222 String sMarkedListId; 223 int nMarkedListLevel; 224 225 sal_Bool bHasFocus : 1; // Shell ist in einem Window "aktiv" 226 sal_Bool bSVCrsrVis : 1; // SV-Cursor Un-/Sichtbar 227 sal_Bool bChgCallFlag : 1; // Attributaenderung innerhalb von 228 // Start- und EndAction 229 sal_Bool bVisPortChgd : 1; // befindet sich im VisPortChg-Aufruf 230 // (wird im Invalidate vom Cursor benutzt) 231 232 sal_Bool bCallChgLnk : 1; // Flag fuer abgeleitete Klassen: 233 // sal_True -> ChgLnk callen 234 // Zugriff nur ueber SwChgLinkFlag 235 sal_Bool bAllProtect : 1; // Flag fuer Bereiche 236 // sal_True -> alles geschuetzt / versteckt 237 sal_Bool bInCMvVisportChgd : 1; // Flag fuer CrsrMoves 238 // sal_True -> die Sicht wurde verschoben 239 sal_Bool bGCAttr : 1; // sal_True -> es existieren nichtaufgespannte Attr. 240 sal_Bool bIgnoreReadonly : 1; // sal_True -> Beim naechsten EndAction trotz 241 // Readonly den Crsr sichtbar machen. 242 sal_Bool bSelTblCells : 1; // sal_True -> Zellen uebers InputWin selektieren 243 sal_Bool bAutoUpdateCells : 1; // sal_True -> Zellen werden autoformatiert 244 sal_Bool bBasicHideCrsr : 1; // sal_True -> HideCrsr vom Basic 245 sal_Bool bSetCrsrInReadOnly : 1;// sal_True -> Cursor darf in ReadOnly-Bereiche 246 sal_Bool bOverwriteCrsr : 1; // sal_True -> show Overwrite Crsr 247 248 // OD 11.02.2003 #100556# - flag to allow/avoid execution of marcos (default: true) 249 bool mbMacroExecAllowed : 1; 250 251 SW_DLLPRIVATE void UpdateCrsr( 252 sal_uInt16 eFlags = SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE, 253 sal_Bool bIdleEnd = sal_False ); 254 255 SW_DLLPRIVATE void _ParkPams( SwPaM* pDelRg, SwShellCrsr** ppDelRing ); 256 257 // -> #i27615# 258 259 /** Mark a certain list level of a certain list 260 261 OD 2008-04-02 #refactorlists# 262 levels of a certain lists are marked now 263 264 @param sListId list Id of the list whose level is marked 265 @param nLevel to be marked list level 266 267 An empty sListId denotes that no level of a list is marked. 268 */ 269 SW_DLLPRIVATE void MarkListLevel( const String& sListId, 270 const int nLevel ); 271 // <- #i27615# 272 273 // private method(s) accessed from public inline method(s) must be exported. 274 sal_Bool LeftRight( sal_Bool, sal_uInt16, sal_uInt16, sal_Bool ); 275 SW_DLLPRIVATE sal_Bool UpDown( sal_Bool, sal_uInt16 ); 276 SW_DLLPRIVATE sal_Bool LRMargin( sal_Bool, sal_Bool bAPI = sal_False ); 277 SW_DLLPRIVATE sal_Bool IsAtLRMargin( sal_Bool, sal_Bool bAPI = sal_False ) const; 278 279 SW_DLLPRIVATE short GetTextDirection( const Point* pPt = 0 ) const; 280 281 typedef sal_Bool (SwCursor:: *FNCrsr)(); 282 SW_DLLPRIVATE sal_Bool CallCrsrFN( FNCrsr ); 283 284 SW_DLLPRIVATE const SwRedline* _GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect ); 285 286 protected: 287 288 inline SwMoveFnCollection* MakeFindRange( sal_uInt16, sal_uInt16, SwPaM* ) const; 289 290 /* 291 * Compare-Methode for the StackCursor and the current Cursor. 292 * The Methods return -1, 0, 1 for lower, equal, greater. The enum 293 * CrsrCompareType says which position is compared. 294 */ 295 enum CrsrCompareType { 296 StackPtStackMk, 297 StackPtCurrPt, 298 StackPtCurrMk, 299 StackMkCurrPt, 300 StackMkCurrMk, 301 CurrPtCurrMk 302 }; 303 int CompareCursor( CrsrCompareType eType ) const; 304 305 // Setzt alle PaMs in OldNode auf NewPos + Offset 306 void PaMCorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, 307 const xub_StrLen nOffset = 0 ); 308 309 // --> FME 2004-07-30 #i32329# Enhanced table selection 310 sal_Bool _SelTblRowOrCol( bool bRow, bool bRowSimple = false ); 311 // <-- 312 313 // --> FME 2005-01-31 #i41424# Only update the marked number levels if necessary 314 bool SetInFrontOfLabel( sal_Bool bNew ); 315 // <-- 316 317 void RefreshBlockCursor(); 318 319 /** Updates the marked list level according to the cursor. 320 */ 321 SW_DLLPRIVATE void UpdateMarkedListLevel(); 322 323 protected: 324 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew); 325 326 public: 327 TYPEINFO(); 328 SwCrsrShell( SwDoc& rDoc, Window *pWin, const SwViewOption *pOpt = 0 ); 329 // verkleideter Copy-Constructor 330 SwCrsrShell( SwCrsrShell& rShell, Window *pWin ); 331 virtual ~SwCrsrShell(); 332 333 // IShellCursorSupplier 334 virtual SwPaM & CreateNewShellCursor(); 335 virtual SwPaM & GetCurrentShellCursor(); 336 337 // neuen Cusror erzeugen und den alten anhaengen 338 SwPaM * CreateCrsr(); 339 // loesche den aktuellen Cursor und der folgende wird zum Aktuellen 340 sal_Bool DestroyCrsr(); 341 // TableCursor in normale Cursor verwandeln, Tablemode aufheben 342 void TblCrsrToCursor(); 343 // enter block mode, change normal cursor into block cursor 344 void CrsrToBlockCrsr(); 345 // leave block mode, change block cursor into normal cursor 346 void BlockCrsrToCrsr(); 347 348 // SelAll() selects the document body content 349 // if ExtendedSelect() is called afterwards, the whole nodes array is selected 350 // only for usage in special cases allowed! 351 void ExtendedSelectAll(); 352 353 SwPaM* GetCrsr( sal_Bool bMakeTblCrsr = sal_True ) const; 354 inline SwCursor* GetSwCrsr( sal_Bool bMakeTblCrsr = sal_True ) const; 355 // nur den akt. Cursor returnen 356 SwShellCrsr* _GetCrsr() { return pCurCrsr; } 357 const SwShellCrsr* _GetCrsr() const { return pCurCrsr; } 358 359 // uebergebenen Cursor anzeigen - fuer UNO 360 void SetSelection(const SwPaM& rCrsr); 361 362 // alle Cursor aus den ContentNodes entfernen und auf 0 setzen. 363 // Wurde aus der FEShell hierher verschoben. 364 void ParkCrsr( const SwNodeIndex &rIdx ); 365 366 // gebe den akt. Cursor-Stack zurueck. 367 // ( Wird in der EditShell beim Loeschen von Inhalten benoetigt! ) 368 inline SwPaM* GetStkCrsr() const; 369 370 // Start der Klammerung, SV-Cursor und selektierte Bereiche hiden 371 void StartAction(); 372 // Ende der Klammerung, SV-Cursor und selektierte Bereiche anzeigen 373 void EndAction( const sal_Bool bIdleEnd = sal_False ); 374 375 // Basiscursortravelling 376 long GetUpDownX() const { return nUpDownX; } 377 378 sal_Bool Left( sal_uInt16 nCnt, sal_uInt16 nMode, sal_Bool bAllowVisual = sal_False ) 379 { return LeftRight( sal_True, nCnt, nMode, bAllowVisual ); } 380 sal_Bool Right( sal_uInt16 nCnt, sal_uInt16 nMode, sal_Bool bAllowVisual = sal_False ) 381 { return LeftRight( sal_False, nCnt, nMode, bAllowVisual ); } 382 sal_Bool Up( sal_uInt16 nCnt = 1 ) { return UpDown( sal_True, nCnt ); } 383 sal_Bool Down( sal_uInt16 nCnt = 1 ) { return UpDown( sal_False, nCnt ); } 384 sal_Bool LeftMargin() { return LRMargin( sal_True ); } 385 sal_Bool RightMargin(sal_Bool bAPI = sal_False) { return LRMargin( sal_False, bAPI ); } 386 sal_Bool SttEndDoc( sal_Bool bStt ); 387 388 sal_Bool MovePage( SwWhichPage, SwPosPage ); 389 sal_Bool MovePara( SwWhichPara, SwPosPara ); 390 sal_Bool MoveSection( SwWhichSection, SwPosSection ); 391 sal_Bool MoveTable( SwWhichTable, SwPosTable ); 392 sal_Bool MoveColumn( SwWhichColumn, SwPosColumn ); 393 sal_Bool MoveRegion( SwWhichRegion, SwPosRegion ); 394 395 // die Suchfunktionen 396 sal_uLong Find( const com::sun::star::util::SearchOptions& rSearchOpt, 397 sal_Bool bSearchInNotes, 398 SwDocPositions eStart, SwDocPositions eEnde, 399 sal_Bool& bCancel, 400 FindRanges eRng, int bReplace = sal_False ); 401 402 sal_uLong Find( const SwTxtFmtColl& rFmtColl, 403 SwDocPositions eStart, SwDocPositions eEnde, 404 sal_Bool& bCancel, 405 FindRanges eRng, const SwTxtFmtColl* pReplFmt = 0 ); 406 407 sal_uLong Find( const SfxItemSet& rSet, sal_Bool bNoCollections, 408 SwDocPositions eStart, SwDocPositions eEnde, 409 sal_Bool& bCancel, 410 FindRanges eRng, 411 const com::sun::star::util::SearchOptions* pSearchOpt = 0, 412 const SfxItemSet* rReplSet = 0 ); 413 414 // Positionieren des Cursors 415 // returnt 416 // CRSR_POSCHG: wenn der ob der SPoint vom Layout korrigiert wurde. 417 // CRSR_POSOLD: wenn der Crsr nicht veraendert wurde 418 int SetCrsr( const Point &rPt, sal_Bool bOnlyText = sal_False, bool bBlock = true ); 419 420 421 /* 422 * Benachrichtung, dass der sichtbare Bereich sich geaendert 423 * hat. aVisArea wird neu gesetzt, anschliessend wird 424 * gescrollt. Das uebergebene Rectangle liegt auf 425 * Pixelgrenzen, um Pixelfehler beim Scrollen zu vermeiden. 426 */ 427 virtual void VisPortChgd( const SwRect & ); 428 429 /* 430 * Virtuelle PaintMethode, damit die Selection nach dem Paint wieder 431 * sichtbar wird. 432 */ 433 void Paint( const Rectangle & rRect ); 434 435 // Bereiche 436 inline void SetMark(); 437 inline sal_Bool HasMark(); 438 439 void ClearMark(); 440 441 /** 442 Ensure point and mark of the current PaM are in a specific order. 443 444 @param bPointFirst TRUE: If the point is behind the mark then 445 swap the PaM. FALSE: If the mark is behind the point then swap 446 the PaM. 447 */ 448 void NormalizePam(sal_Bool bPointFirst = sal_True); 449 450 void SwapPam(); 451 sal_Bool ChgCurrPam( const Point & rPt, 452 sal_Bool bTstOnly = sal_True, //Nur testen, nicht setzen 453 sal_Bool bTstHit = sal_False ); //Nur genaue Treffer 454 void KillPams(); 455 456 // erzeuge eine Kopie vom Cursor und speicher diese im Stack 457 void Push(); 458 /* 459 * Loescht einen Cursor (gesteuert durch bOldCrsr) 460 * - vom Stack oder ( bOldCrsr = sal_True ) 461 * - den aktuellen und der auf dem Stack stehende wird zum aktuellen 462 * 463 * Return: es war auf dem Stack noch einer vorhanden 464 */ 465 sal_Bool Pop( sal_Bool bOldCrsr = sal_True ); 466 /* 467 * Verbinde zwei Cursor miteinander. 468 * Loesche vom Stack den obersten und setzen dessen Mark im Aktuellen. 469 */ 470 void Combine(); 471 472 #if !defined(DBG_UTIL) 473 void SttCrsrMove() { ++nCrsrMove; StartAction(); } 474 void EndCrsrMove( const sal_Bool bIdleEnd = sal_False ) 475 { EndAction( bIdleEnd ); --nCrsrMove; } 476 #else 477 void SttCrsrMove(); 478 void EndCrsrMove( const sal_Bool bIdleEnd = sal_False ); 479 #endif 480 481 /* 482 * Beim Abgeben des Focuses werden die selektierten Bereiche nicht mehr 483 * angezeigt; andererseits beim Erhalten des Focuses, werden alle selek- 484 * tierten Bereiche wieder angezeigt. (Bereiche muessen neu berechnet 485 * werden!) 486 */ 487 sal_Bool HasShFcs() const { return bHasFocus; } 488 void ShLooseFcs(); 489 void ShGetFcs( sal_Bool bUpdate = sal_True ); 490 491 // Methoden zum Anzeigen bzw. Verstecken des sichtbaren Text-Cursors 492 void ShowCrsr(); 493 void HideCrsr(); 494 // Methoden zum Anzeigen bzw. Verstecken der selektierten Bereiche mit 495 // dem sichtbaren Cursor 496 void ShowCrsrs( sal_Bool bCrsrVis ); 497 void HideCrsrs(); 498 499 sal_Bool IsOverwriteCrsr() const { return bOverwriteCrsr; } 500 void SetOverwriteCrsr( sal_Bool bFlag ) { bOverwriteCrsr = bFlag; } 501 502 // gebe den aktuellen Frame, in dem der Cursor steht, zurueck 503 SwCntntFrm *GetCurrFrm( const sal_Bool bCalcFrm = sal_True ) const; 504 505 //sal_True wenn der Crsr wenn der Crsr wegen Readonly gehidet ist, 506 //sal_False wenn der arbeitet (trotz Readonly). 507 sal_Bool IsCrsrReadonly() const; 508 // Cursor steht in etwas geschuetztem oder in die Selektion umspannt 509 // etwas geschuetztes. 510 sal_Bool HasReadonlySel() const; 511 // darf der Cursor in ReadOnlyBereiche? 512 sal_Bool IsReadOnlyAvailable() const { return bSetCrsrInReadOnly; } 513 void SetReadOnlyAvailable( sal_Bool bFlag ); 514 sal_Bool IsOverReadOnlyPos( const Point& rPt ) const; 515 516 // Methoden fuer aFlyMacroLnk 517 void SetFlyMacroLnk( const Link& rLnk ) { aFlyMacroLnk = rLnk; } 518 const Link& GetFlyMacroLnk() const { return aFlyMacroLnk; } 519 520 // Methoden geben/aendern den Link fuer die Attribut/Format-Aenderungen 521 void SetChgLnk( const Link &rLnk ) { aChgLnk = rLnk; } 522 const Link& GetChgLnk() const { return aChgLnk; } 523 524 // Methoden geben/aendern den Link fuers "Grafik vollstaendig geladen" 525 void SetGrfArrivedLnk( const Link &rLnk ) { aGrfArrivedLnk = rLnk; } 526 const Link& GetGrfArrivedLnk() const { return aGrfArrivedLnk; } 527 528 //ChgLink callen, innerhalb einer Action wird der Ruf verzoegert. 529 void CallChgLnk(); 530 531 // Abfrage, ob der aktuelle Cursor eine Selektion aufspannt, 532 // also, ob Mark gesetzt und SPoint und Mark unterschiedlich sind. 533 sal_Bool HasSelection() const; 534 535 // Abfrage, ob ueberhaupt eine Selektion existiert, sprich der akt. Cursor 536 // aufgespannt oder nicht der einzigste ist. 537 inline sal_Bool IsSelection() const; 538 // returns if multiple cursors are available 539 inline sal_Bool IsMultiSelection() const; 540 541 // Abfrage, ob ein kompletter Absatz selektiert wurde 542 sal_Bool IsSelFullPara() const; 543 // Abfrage, ob die Selektion in einem Absatz ist 544 inline sal_Bool IsSelOnePara() const; 545 546 //Sollte fuer das Clipboard der WaitPtr geschaltet werden. 547 sal_Bool ShouldWait() const; 548 549 /* 550 * liefert das SRectangle, auf dem der Cursor steht. 551 */ 552 const SwRect &GetCharRect() const { return aCharRect; } 553 554 // Obtains character rectangle at the position. 555 sal_Bool GetCharRectAt( SwRect& rOrig, const SwPosition& rPos, 556 SwCrsrMoveState *pCMS = 0 ) const; 557 558 /* 559 * liefert zurueck, ob der Cursor sich ganz oder teilweise im 560 * sichtbaren Bereich befindet. 561 */ 562 sal_Bool IsCrsrVisible() const { return VisArea().IsOver( GetCharRect() ); } 563 564 // gebe die aktuelle Seitennummer zurueck: 565 // sal_True: in der der Cursor steht 566 // sal_False: die am oberen Rand sichtbar ist 567 void GetPageNum( sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum, 568 sal_Bool bAtCrsrPos = sal_True, const sal_Bool bCalcFrm = sal_True ); 569 // bestimme in welche Richtung "leere Seiten" behandelt werden! 570 // (wird benutzt im PhyPage.. ) 571 sal_uInt16 GetNextPrevPageNum( sal_Bool bNext = sal_True ); 572 573 // setze den Cursor auf die Seite "nPage" an den Anfang 574 sal_Bool GotoPage( sal_uInt16 nPage ); 575 576 // gebe alle Dokumentseiten zurueck 577 sal_uInt16 GetPageCnt(); 578 579 // Gehe zur naechsten Selection 580 sal_Bool GoNextCrsr(); 581 // gehe zur vorherigen Selection 582 sal_Bool GoPrevCrsr(); 583 584 // at CurCrsr.SPoint 585 ::sw::mark::IMark* SetBookmark( 586 const KeyCode&, 587 const ::rtl::OUString& rName, 588 const ::rtl::OUString& rShortName, 589 IDocumentMarkAccess::MarkType eMark = IDocumentMarkAccess::BOOKMARK); 590 bool GotoMark( const ::sw::mark::IMark* const pMark ); // sets CurCrsr.SPoint 591 bool GotoMark( const ::sw::mark::IMark* const pMark, bool bAtStart ); 592 bool GoNextBookmark(); // true, if there was one 593 bool GoPrevBookmark(); 594 595 bool IsFormProtected(); 596 ::sw::mark::IFieldmark* GetCurrentFieldmark(); 597 ::sw::mark::IFieldmark* GetFieldmarkAfter(); 598 ::sw::mark::IFieldmark* GetFieldmarkBefore(); 599 bool GotoFieldmark( const ::sw::mark::IFieldmark* const pMark ); 600 601 // aktualisiere den Crsrs, d.H. setze ihn wieder in den Content. 602 // Das sollte nur aufgerufen werden, wenn der Cursor z.B. beim 603 // Loeschen von Rahmen irgendwohin gesetzt wurde. Die Position 604 // ergibt sich aus seiner aktuellen Position im Layout !! 605 void UpdateCrsrPos(); 606 607 // returne den am akt. Cursor selektierten Text. Dieser wird mit 608 // Felder etc. aufgefuellt!! 609 String GetSelTxt() const; 610 // gebe nur den Text ab der akt. Cursor Position zurueck (bis zum NodeEnde) 611 String GetText() const; 612 613 // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen 614 inline const SwTableNode* IsCrsrInTbl( sal_Bool bIsPtInTbl = sal_True ) const; 615 // erfrage die Document - Layout - Position vom akt. Crsr 616 inline Point& GetCrsrDocPos( sal_Bool bPoint = sal_True ) const; 617 inline sal_Bool IsCrsrPtAtEnd() const; 618 619 inline const SwPaM* GetTblCrs() const; 620 inline SwPaM* GetTblCrs(); 621 622 sal_Bool IsTblComplex() const; 623 sal_Bool IsTblComplexForChart(); 624 // erfrage die akt. TabellenSelektion als Text 625 String GetBoxNms() const; 626 627 // setze Crsr in die naechsten/vorherigen Celle 628 sal_Bool GoNextCell( sal_Bool bAppendLine = sal_True ); 629 sal_Bool GoPrevCell(); 630 // gehe zu dieser Box (wenn vorhanden und in Tabelle!) 631 sal_Bool GotoTable( const String& rName ); 632 633 // select a table row, column or box (based on the current cursor) 634 sal_Bool SelTblRow() { return _SelTblRowOrCol( true ); } 635 sal_Bool SelTblCol() { return _SelTblRowOrCol( false ); } 636 sal_Bool SelTblBox(); 637 // --> FME 2004-07-30 #i32329# Enhanced table selection 638 sal_Bool SelTbl(); 639 // <-- 640 641 // zum naechsten/vorhergehenden Punkt auf gleicher Ebene 642 sal_Bool GotoNextNum(); 643 sal_Bool GotoPrevNum(); 644 645 // zu diesem Gliederungspunkt 646 sal_Bool GotoOutline( const String& rName ); 647 // zum naechsten/vorhergehenden oder angegebenen OultineNode 648 void GotoOutline( sal_uInt16 nIdx ); 649 // suche die "Outline-Position" im Nodes-Array vom akt. Kaiptel 650 sal_uInt16 GetOutlinePos( sal_uInt8 nLevel = UCHAR_MAX ); 651 // selektiere den angeben Bereich von OutlineNodes. Optional 652 // inclusive der Childs. Die sal_uInt16 sind die Positionen im 653 // OutlineNds-Array!! (EditShell) 654 sal_Bool MakeOutlineSel( sal_uInt16 nSttPos, sal_uInt16 nEndPos, 655 sal_Bool bWithChilds = sal_False ); 656 657 sal_Bool GotoNextOutline(); // naechster Node mit Outline-Num. 658 sal_Bool GotoPrevOutline(); // vorheriger Node mit Outline-Num. 659 660 /** Delivers the current shell cursor 661 662 Some operations have to run on the current cursor ring, 663 some on the pTblCrsr (if exist) or the current cursor ring and 664 some on the pTblCrsr or pBlockCrsr or the current cursor ring. 665 This small function checks the existence and delivers the wished cursor. 666 667 @param bBlock [bool] 668 if the block cursor is of interest or not 669 670 @return pTblCrsr if exist, 671 pBlockCrsr if exist and of interest (param bBlock) 672 otherwise pCurCrsr 673 */ 674 SwShellCrsr* getShellCrsr( bool bBlock ); 675 const SwShellCrsr* getShellCrsr( bool bBlock ) const 676 { return (const_cast<SwCrsrShell*>(this))->getShellCrsr( bBlock ); } 677 678 FASTBOOL IsBlockMode() const { return 0 != pBlockCrsr; } 679 const IBlockCursor* GetBlockCrsr() const { return pBlockCrsr; } 680 IBlockCursor* GetBlockCrsr() { return pBlockCrsr; } 681 682 // ist der Crsr in einer Tabelle und ist die Selection ueber 683 // zwei Spalten 684 sal_Bool IsTableMode() const { return 0 != pTblCrsr; } 685 686 // erfrage den Tabellen Crsr; ausserhalb von Tabellen immer 0 687 const SwShellTableCrsr* GetTableCrsr() const { return pTblCrsr; } 688 SwShellTableCrsr* GetTableCrsr() { return pTblCrsr; } 689 sal_uInt16 UpdateTblSelBoxes(); 690 691 sal_Bool GotoFtnTxt(); // springe aus dem Content zur Fussnote 692 sal_Bool GotoFtnAnchor(); // springe aus der Fussnote zum Anker 693 sal_Bool GotoPrevFtnAnchor(); 694 sal_Bool GotoNextFtnAnchor(); 695 696 sal_Bool GotoFlyAnchor(); // springe aus dem Rahmen zum Anker 697 sal_Bool GotoHeaderTxt(); // springe aus dem Content zum Header 698 sal_Bool GotoFooterTxt(); // springe aus dem Content zum Footer 699 // springe in den Header/Footer des angegebenen oder akt. PageDesc 700 sal_Bool SetCrsrInHdFt( sal_uInt16 nDescNo = USHRT_MAX, 701 sal_Bool bInHeader = sal_True ); 702 // is point of cursor in header/footer. pbInHeader return sal_True if it is 703 // in a headerframe otherwise in a footerframe 704 sal_Bool IsInHeaderFooter( sal_Bool* pbInHeader = 0 ) const; 705 706 // springe zum naechsten Verzeichnis [mit dem Namen] 707 sal_Bool GotoNextTOXBase( const String* = 0 ); 708 // springe zum vorherigen Verzeichnis [mit dem Namen] 709 sal_Bool GotoPrevTOXBase( const String* = 0 ); 710 sal_Bool GotoTOXMarkBase(); // springe zum Verzeichnis vom TOXMark 711 // springe zum naechsten (vorherigen) Verzeichniseintrag 712 sal_Bool GotoNxtPrvTOXMark( sal_Bool bNext = sal_True ); 713 // Zur naechsten/ vorherigen Verzeichnismarke dieses Typs traveln 714 const SwTOXMark& GotoTOXMark( const SwTOXMark& rStart, SwTOXSearch eDir ); 715 716 // springe zum naechsten (vorherigen) Tabellenformel 717 // optional auch nur zu kaputten Formeln springen 718 sal_Bool GotoNxtPrvTblFormula( sal_Bool bNext = sal_True, 719 sal_Bool bOnlyErrors = sal_False ); 720 // jump to the next / previous hyperlink - inside text and also 721 // on graphics 722 sal_Bool SelectNxtPrvHyperlink( sal_Bool bNext = sal_True ); 723 724 // springe zu dieser Refmark 725 sal_Bool GotoRefMark( const String& rRefMark, sal_uInt16 nSubType = 0, 726 sal_uInt16 nSeqNo = 0 ); 727 728 // hole vom Start/Ende der akt. Selection das nte Zeichen 729 sal_Unicode GetChar( sal_Bool bEnd = sal_True, long nOffset = 0 ); 730 // erweiter die akt. Selection am Anfang/Ende um n Zeichen 731 sal_Bool ExtendSelection( sal_Bool bEnd = sal_True, xub_StrLen nCount = 1 ); 732 // setze nur den sichtbaren Cursor an die angegebene Dokument-Pos. 733 // returnt sal_False: wenn der ob der SPoint vom Layout korrigiert wurde. 734 // (wird zum Anzeigen von Drag&Drop/Copy-Cursor benoetigt) 735 sal_Bool SetVisCrsr( const Point &rPt ); 736 inline void UnSetVisCrsr(); 737 738 // springe zum nachsten/vorherigen Feld des entsprechenden Types 739 sal_Bool MoveFldType( 740 const SwFieldType* pFldType, 741 const bool bNext, 742 const sal_uInt16 nResType = USHRT_MAX, 743 const bool bAddSetExpressionFldsToInputFlds = true ); 744 // springe genau zu diesem Feld 745 sal_Bool GotoFld( const SwFmtFld& rFld ); 746 747 SwTxtFld* GetTxtFldAtPos( 748 const SwPosition* pPos, 749 const bool bIncludeInputFldAtStart ) const; 750 SwField* GetFieldAtCrsr( 751 const SwPaM* pCrsr, 752 const bool bIncludeInputFldAtStart ) const; 753 SwField* GetCurFld( const bool bIncludeInputFldAtStart = false ) const; 754 bool CrsrInsideInputFld() const; 755 bool PosInsideInputFld( const SwPosition& rPos ) const; 756 bool DocPtInsideInputFld( const Point& rDocPt ) const; 757 xub_StrLen StartOfInputFldAtPos( const SwPosition& rPos ) const; 758 xub_StrLen EndOfInputFldAtPos( const SwPosition& rPos ) const; 759 760 // returne die Anzahl der Cursor im Ring (Flag besagt ob man nur 761 // aufgepspannte haben will - sprich etwas selektiert ist (Basic)) 762 sal_uInt16 GetCrsrCnt( sal_Bool bAll = sal_True ) const; 763 764 // Char Travelling - Methoden (in crstrvl1.cxx) 765 sal_Bool GoStartWord(); 766 sal_Bool GoEndWord(); 767 sal_Bool GoNextWord(); 768 sal_Bool GoPrevWord(); 769 sal_Bool GoNextSentence(); 770 sal_Bool GoPrevSentence(); 771 sal_Bool GoStartSentence(); 772 sal_Bool GoEndSentence(); 773 sal_Bool SelectWord( const Point* pPt = 0 ); 774 sal_Bool ExpandToSentenceBorders(); 775 776 // Position vom akt. Cursor erfragen 777 sal_Bool IsStartWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES )const; 778 sal_Bool IsEndWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; 779 sal_Bool IsInWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; 780 sal_Bool IsStartSentence() const; 781 sal_Bool IsEndSentence() const; 782 sal_Bool IsSttPara() const; 783 sal_Bool IsEndPara() const; 784 sal_Bool IsStartOfDoc() const; 785 sal_Bool IsEndOfDoc() const; 786 sal_Bool IsInFrontOfLabel() const; 787 sal_Bool IsAtLeftMargin() const { return IsAtLRMargin( sal_True ); } 788 sal_Bool IsAtRightMargin(sal_Bool bAPI = sal_False) const { return IsAtLRMargin( sal_False, bAPI ); } 789 790 // loesche alle erzeugten Crsr, setze den Tabellen-Crsr und den letzten 791 // Cursor auf seinen TextNode (oder StartNode?). 792 // Beim naechsten ::GetCrsr werden sie wieder alle erzeugt. 793 // Wird fuers Drag&Drop/ClipBorad-Paste in Tabellen benoetigt. 794 sal_Bool ParkTblCrsr(); 795 796 // gibt es nicht aufgespannte Attribute? 797 sal_Bool IsGCAttr() const { return bGCAttr; } 798 void ClearGCAttr() { bGCAttr = sal_False; } 799 void UpdateAttr() { bGCAttr = sal_True; } 800 801 // ist das gesamte Dokument geschuetzt/versteckt?? (fuer UI,..) 802 sal_Bool IsAllProtect() const { return bAllProtect; } 803 804 #ifdef SW_CRSR_TIMER 805 // setze das Flag am VisCrsr, ob dieser ueber Timer getriggert (sal_True) 806 // oder direkt (sal_False) angezeigt wird. (default ist Timer getriggert) 807 sal_Bool ChgCrsrTimerFlag( sal_Bool bTimerOn = sal_True ); 808 #endif 809 810 sal_Bool BasicActionPend() const { return nBasicActionCnt != nStartAction; } 811 812 // springe zum benannten Bereich 813 sal_Bool GotoRegion( const String& rName ); 814 815 // zeige die aktuelle Selektion an 816 virtual void MakeSelVisible(); 817 818 // setzte den Cursor auf einen NICHT geschuetzten/versteckten Node 819 sal_Bool FindValidCntntNode( sal_Bool bOnlyText = sal_False ); 820 821 sal_Bool GetContentAtPos( const Point& rPt, 822 SwContentAtPos& rCntntAtPos, 823 sal_Bool bSetCrsr = sal_False, 824 SwRect* pFldRect = 0 ); 825 826 // --> OD 2008-06-19 #i90516# 827 const SwPostItField* GetPostItFieldAtCursor() const; 828 // <-- 829 830 // get smart tags at point position 831 void GetSmartTagTerm( const Point& rPt, 832 SwRect& rSelectRect, 833 ::com::sun::star::uno::Sequence< rtl::OUString >& rSmartTagTypes, 834 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > >& rStringKeyMaps, 835 ::com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rRange ); 836 837 // get smart tags at current cursor position 838 void GetSmartTagTerm( ::com::sun::star::uno::Sequence< rtl::OUString >& rSmartTagTypes, 839 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > >& rStringKeyMaps, 840 ::com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rRange ) const; 841 842 sal_Bool IsPageAtPos( const Point &rPt ) const; 843 844 // Attribut selelktieren 845 sal_Bool SelectTxtAttr( sal_uInt16 nWhich, sal_Bool bExpand, const SwTxtAttr* pAttr = 0 ); 846 sal_Bool GotoINetAttr( const SwTxtINetFmt& rAttr ); 847 const SwFmtINetFmt* FindINetAttr( const String& rName ) const; 848 849 sal_Bool SelectTxt( const xub_StrLen nStart, 850 const xub_StrLen nEnd ); 851 852 sal_Bool CheckTblBoxCntnt( const SwPosition* pPos = 0 ); 853 void SaveTblBoxCntnt( const SwPosition* pPos = 0 ); 854 void ClearTblBoxCntnt(); 855 sal_Bool EndAllTblBoxEdit(); 856 857 void SetSelTblCells( sal_Bool bFlag ) { bSelTblCells = bFlag; } 858 sal_Bool IsSelTblCells() const { return bSelTblCells; } 859 860 sal_Bool IsAutoUpdateCells() const { return bAutoUpdateCells; } 861 void SetAutoUpdateCells( sal_Bool bFlag ) { bAutoUpdateCells = bFlag; } 862 863 sal_Bool GetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode, 864 SwRect& rRect, short& rOrient ); 865 sal_Bool SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ); 866 867 const SwRedline* SelNextRedline(); 868 const SwRedline* SelPrevRedline(); 869 const SwRedline* GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect = sal_False ); 870 871 // is cursor or the point in/over a vertical formatted text? 872 sal_Bool IsInVerticalText( const Point* pPt = 0 ) const; 873 // is cursor or the point in/over a right to left formatted text? 874 sal_Bool IsInRightToLeftText( const Point* pPt = 0 ) const; 875 876 void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage); 877 SwFrm* oldColFrm; 878 bool bColumnChange(); 879 void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection); 880 void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn); 881 // If the current cursor position is inside a hidden range, the hidden range 882 // is selected and true is returned: 883 bool SelectHiddenRange(); 884 885 // remove all invalid cursors 886 void ClearUpCrsrs(); 887 888 // OD 11.02.2003 #100556# - set/get flag to allow/avoid execution of macros 889 inline void SetMacroExecAllowed( const bool _bMacroExecAllowed ) 890 { 891 mbMacroExecAllowed = _bMacroExecAllowed; 892 } 893 inline bool IsMacroExecAllowed() 894 { 895 return mbMacroExecAllowed; 896 } 897 898 // #111827# 899 /** 900 Returns textual description of the current selection. 901 902 - If the current selection is a multi-selection the result is 903 STR_MULTISEL. 904 - Else the result is the text of the selection. 905 906 @return the textual description of the current selection 907 */ 908 String GetCrsrDescr() const; 909 }; 910 911 912 // Cursor Inlines: 913 inline SwMoveFnCollection* SwCrsrShell::MakeFindRange( 914 sal_uInt16 nStt, sal_uInt16 nEnd, SwPaM* pPam ) const 915 { 916 return pCurCrsr->MakeFindRange( (SwDocPositions)nStt, (SwDocPositions)nEnd, pPam ); 917 } 918 919 inline SwCursor* SwCrsrShell::GetSwCrsr( sal_Bool bMakeTblCrsr ) const 920 { 921 return (SwCursor*)GetCrsr( bMakeTblCrsr ); 922 } 923 924 inline SwPaM* SwCrsrShell::GetStkCrsr() const { return pCrsrStk; } 925 926 inline void SwCrsrShell::SetMark() { pCurCrsr->SetMark(); } 927 928 inline sal_Bool SwCrsrShell::HasMark() { return( pCurCrsr->HasMark() ); } 929 930 inline sal_Bool SwCrsrShell::IsSelection() const 931 { 932 return IsTableMode() || pCurCrsr->HasMark() || 933 pCurCrsr->GetNext() != pCurCrsr; 934 } 935 inline sal_Bool SwCrsrShell::IsMultiSelection() const 936 { 937 return pCurCrsr->GetNext() != pCurCrsr; 938 } 939 940 inline sal_Bool SwCrsrShell::IsSelOnePara() const 941 { 942 return pCurCrsr == pCurCrsr->GetNext() && 943 pCurCrsr->GetPoint()->nNode == pCurCrsr->GetMark()->nNode; 944 } 945 946 inline const SwTableNode* SwCrsrShell::IsCrsrInTbl( sal_Bool bIsPtInTbl ) const 947 { 948 return pCurCrsr->GetNode( bIsPtInTbl )->FindTableNode(); 949 } 950 951 inline sal_Bool SwCrsrShell::IsCrsrPtAtEnd() const 952 { 953 return pCurCrsr->End() == pCurCrsr->GetPoint(); 954 } 955 956 inline Point& SwCrsrShell::GetCrsrDocPos( sal_Bool bPoint ) const 957 { 958 return bPoint ? pCurCrsr->GetPtPos() : pCurCrsr->GetMkPos(); 959 } 960 961 inline const SwPaM* SwCrsrShell::GetTblCrs() const 962 { 963 return pTblCrsr; 964 } 965 966 inline SwPaM* SwCrsrShell::GetTblCrs() 967 { 968 return pTblCrsr; 969 } 970 971 inline void SwCrsrShell::UnSetVisCrsr() 972 { 973 pVisCrsr->Hide(); 974 pVisCrsr->SetDragCrsr( sal_False ); 975 } 976 977 #endif // _CRSRSH_HXX 978