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