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 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 28 #ifndef _SVSTDARR_HXX 29 #define _SVSTDARR_USHORTS 30 #include <svl/svstdarr.hxx> 31 #endif 32 33 #include <vcl/dialog.hxx> 34 #include <vcl/msgbox.hxx> 35 #include <vcl/wrkwin.hxx> 36 #include <viewopt.hxx> 37 #include <frmtool.hxx> 38 #include <viscrs.hxx> 39 #include <crsrsh.hxx> 40 #include <doc.hxx> 41 #include <swtable.hxx> 42 #include <viewimp.hxx> 43 #include <dview.hxx> 44 #include <rootfrm.hxx> 45 #include <txtfrm.hxx> 46 #include <docary.hxx> 47 #include <extinput.hxx> 48 #include <ndtxt.hxx> 49 #include <txtfld.hxx> 50 #include <scriptinfo.hxx> 51 #include <mdiexp.hxx> 52 #ifndef _COMCORE_HRC 53 #include <comcore.hrc> // ResId fuer Abfrage wenn zu Search & Replaces 54 #endif 55 56 #include <svx/sdr/overlay/overlaymanager.hxx> 57 #include <svx/sdrpaintwindow.hxx> 58 #include <vcl/svapp.hxx> 59 #include <svx/sdr/overlay/overlayselection.hxx> 60 #include <overlayrangesoutline.hxx> 61 62 #include <boost/scoped_ptr.hpp> 63 64 extern void SwCalcPixStatics( OutputDevice *pOut ); 65 66 //Damit beim ShowCrsr nicht immer wieder die gleiche Size teuer ermittelt 67 //werden muss, hier statische Member, die beim Wechsel des MapModes 68 // angepasst werden 69 70 long SwSelPaintRects::nPixPtX = 0; 71 long SwSelPaintRects::nPixPtY = 0; 72 MapMode* SwSelPaintRects::pMapMode = 0; 73 74 75 #ifdef SHOW_BOOKMARKS 76 // #include <IMark.hxx> 77 // 78 // class SwBookmarkRects : public SwSelPaintRects 79 // { 80 // virtual void Paint( const Rectangle& rRect ); 81 // virtual void FillRects(); 82 // 83 // public: 84 // SwBookmarkRects( const SwCrsrShell& rSh ) : SwSelPaintRects( rSh ) {} 85 // }; 86 // 87 // void SwBookmarkRects::Paint( const Rectangle& rRect ) 88 // { 89 // Window* pWin = GetShell()->GetWin(); 90 // 91 // RasterOp eOld( pWin->GetRasterOp() ); 92 // sal_Bool bLCol = pWin->IsLineColor(); 93 // Color aLCol( pWin->GetLineColor() ); 94 // sal_Bool bFCol = pWin->IsFillColor(); 95 // Color aFCol( pWin->GetFillColor() ); 96 // 97 // pWin->SetRasterOp( ROP_XOR ); 98 // Color aCol( RGB_COLORDATA( 0xF0, 0xC8, 0xF0 ) ^ COL_WHITE ); 99 // pWin->SetFillColor( aCol ); 100 // pWin->SetLineColor( aCol ); 101 // 102 // pWin->DrawRect( rRect ); 103 // 104 // if( bLCol ) pWin->SetLineColor( aLCol ); else pWin->SetLineColor(); 105 // if( bFCol ) pWin->SetFillColor( aFCol ); else pWin->SetFillColor(); 106 // pWin->SetRasterOp( eOld ); 107 // } 108 // 109 // void SwBookmarkRects::FillRects() 110 // { 111 // SwRegionRects aReg( GetShell()->VisArea() ); 112 // 113 // const SwBookmarks& rBkmkTbl = GetShell()->getIDocumentMarkAccess()->getBookmarks(); 114 // SwShellCrsr* pCrsr = 0; 115 // for( sal_uInt16 n = 0; n < rBkmkTbl.Count(); ++n ) 116 // { 117 // const SwBookmark& rBkmk = *rBkmkTbl[ n ]; 118 // if( rBkmk.IsBookMark() && rBkmk.GetOtherPos() ) 119 // { 120 // if( !pCrsr ) 121 // { 122 // pCrsr = new SwShellCrsr( *GetShell(), rBkmk.GetPos() ); 123 // pCrsr->SetMark(); 124 // } 125 // else 126 // *pCrsr->GetPoint() = rBkmk.GetPos(); 127 // *pCrsr->GetMark() = *rBkmk.GetOtherPos(); 128 // pCrsr->FillRects(); 129 // for( sal_uInt16 i = 0; i < pCrsr->Count(); ++i ) 130 // aReg -= (*pCrsr)[ i ]; 131 // 132 // pCrsr->Remove( 0, i ); 133 // } 134 // } 135 // if( pCrsr ) delete pCrsr; 136 // 137 // aReg.Invert(); 138 // SwRects::Insert( &aReg, 0 ); 139 // } 140 // 141 // SwBookmarkRects* pBookMarkRects = 0; 142 // 143 // void ShowBookmarks( const SwCrsrShell* pSh, int nAction, const SwRect* pRect = 0 ) 144 // { 145 // if( !pBookMarkRects && pSh->getIDocumentMarkAccess()->getBookmarks().Count() ) 146 // pBookMarkRects = new SwBookmarkRects( *pSh ); 147 // 148 // if( pBookMarkRects ) 149 // { 150 // switch( nAction ) 151 // { 152 // case 1: pBookMarkRects->Show(); break; 153 // case 2: pBookMarkRects->Hide(); break; 154 // case 3: pBookMarkRects->Invalidate( *pRect ); break; 155 // } 156 // 157 // if( !pBookMarkRects->Count() ) 158 // delete pBookMarkRects, pBookMarkRects = 0; 159 // } 160 // } 161 // 162 // #define SHOWBOOKMARKS1( nAct ) ShowBookmarks( GetShell(),nAct ); 163 // #define SHOWBOOKMARKS2( nAct, pRect ) ShowBookmarks( GetShell(),nAct, pRect ); 164 165 #else 166 167 #define SHOWBOOKMARKS1( nAct ) 168 #define SHOWBOOKMARKS2( nAct, pRect ) 169 170 #endif 171 172 #ifdef SHOW_REDLINES 173 #include <redline.hxx> 174 175 class SwRedlineRects : public SwSelPaintRects 176 { 177 sal_uInt16 nMode; 178 sal_uInt16 nNm; 179 180 virtual void Paint( const Rectangle& rRect ); 181 virtual void FillRects(); 182 183 public: 184 SwRedlineRects( const SwCrsrShell& rSh, sal_uInt16 nName, sal_uInt16 n ) 185 : SwSelPaintRects( rSh ), nMode( n ), nNm( nName ) 186 {} 187 }; 188 189 void SwRedlineRects::Paint( const Rectangle& rRect ) 190 { 191 Window* pWin = GetShell()->GetWin(); 192 193 RasterOp eOld( pWin->GetRasterOp() ); 194 sal_Bool bLCol = pWin->IsLineColor(); 195 Color aLCol( pWin->GetLineColor() ); 196 sal_Bool bFCol = pWin->IsFillColor(); 197 Color aFCol( pWin->GetFillColor() ); 198 199 pWin->SetRasterOp( ROP_XOR ); 200 Color aCol; 201 202 sal_uInt8 nVal = 0xc8 - ( (nMode / 4) * 16 ); 203 switch( nMode % 4 ) 204 { 205 case 0: aCol = RGB_COLORDATA( nVal, nVal, 0xFF ); break; 206 case 1: aCol = RGB_COLORDATA( 0xFF, 0xc8, nVal ); break; 207 case 2: aCol = RGB_COLORDATA( nVal, 0xFF, nVal ); break; 208 case 3: aCol = RGB_COLORDATA( 0xFF, nVal, nVal ); break; 209 } 210 aCol = aCol.GetColor() ^ COL_WHITE; 211 212 pWin->SetFillColor( aCol ); 213 pWin->SetLineColor( aCol ); 214 215 pWin->DrawRect( rRect ); 216 217 if( bLCol ) pWin->SetLineColor( aLCol ); else pWin->SetLineColor(); 218 if( bFCol ) pWin->SetFillColor( aFCol ); else pWin->SetFillColor(); 219 pWin->SetRasterOp( eOld ); 220 } 221 222 void SwRedlineRects::FillRects() 223 { 224 SwRegionRects aReg( GetShell()->VisArea() ); 225 226 const SwRedlineTbl& rTbl = GetShell()->GetDoc()->GetRedlineTbl(); 227 SwShellCrsr* pCrsr = 0; 228 for( sal_uInt16 n = 0; n < rTbl.Count(); ++n ) 229 { 230 const SwRedline& rRed = *rTbl[ n ]; 231 if( rRed.HasMark() && (nMode % 4 ) == rRed.GetType() && 232 nNm == rRed.GetAuthor() ) 233 { 234 if( !pCrsr ) 235 { 236 pCrsr = new SwShellCrsr( *GetShell(), *rRed.GetPoint() ); 237 pCrsr->SetMark(); 238 } 239 else 240 *pCrsr->GetPoint() = *rRed.GetPoint(); 241 *pCrsr->GetMark() = *rRed.GetMark(); 242 pCrsr->FillRects(); 243 for( sal_uInt16 i = 0; i < pCrsr->Count(); ++i ) 244 aReg -= (*pCrsr)[ i ]; 245 246 pCrsr->Remove( 0, i ); 247 } 248 } 249 if( pCrsr ) delete pCrsr; 250 251 aReg.Invert(); 252 SwRects::Insert( &aReg, 0 ); 253 } 254 255 SwRedlineRects* aRedlines[ 10 * 4 ]; 256 static int bFirstCall = sal_True; 257 258 void ShowRedlines( const SwCrsrShell* pSh, int nAction, const SwRect* pRect = 0 ) 259 { 260 if( bFirstCall ) 261 { 262 memset( aRedlines, 0, sizeof(aRedlines)); 263 bFirstCall = sal_False; 264 } 265 266 const SwRedlineTbl& rTbl = pSh->GetDoc()->GetRedlineTbl(); 267 const SwRedlineAuthorTbl& rAuthorTbl = pSh->GetDoc()->GetRedlineAuthorTbl(); 268 269 for( sal_uInt16 n = 0; n < rAuthorTbl.Count(); ++n ) 270 { 271 for( int i = 0; i < 4; ++i ) 272 { 273 SwRedlineRects** ppRedRect = &aRedlines[ n * 4 + i ]; 274 if( rTbl.Count() && !*ppRedRect ) 275 *ppRedRect = new SwRedlineRects( *pSh, n, n * 4 + i ); 276 277 if( *ppRedRect ) 278 { 279 switch( nAction ) 280 { 281 case 1: (*ppRedRect)->Show(); break; 282 case 2: (*ppRedRect)->Hide(); break; 283 case 3: (*ppRedRect)->Invalidate( *pRect ); break; 284 } 285 286 if( !(*ppRedRect)->Count() ) 287 delete *ppRedRect, *ppRedRect = 0; 288 } 289 } 290 } 291 } 292 293 #define SHOWREDLINES1( nAct ) ShowRedlines( GetShell(),nAct ); 294 #define SHOWREDLINES2( nAct, pRect ) ShowRedlines( GetShell(),nAct, pRect ); 295 296 #else 297 298 #define SHOWREDLINES1( nAct ) 299 #define SHOWREDLINES2( nAct, pRect ) 300 301 #endif 302 303 #ifdef JP_REDLINE 304 if( GetDoc()->GetRedlineTbl().Count() ) 305 { 306 SwRedlineTbl& rRedlineTbl = (SwRedlineTbl&)GetDoc()->GetRedlineTbl(); 307 for( sal_uInt16 i = 0; i < rRedlineTbl.Count(); ++i ) 308 rRedlineTbl[ i ]->HideRects( *GetShell() ); 309 } 310 #endif 311 312 // -------- Ab hier Klassen / Methoden fuer den nicht Text-Cursor ------ 313 314 SwVisCrsr::SwVisCrsr( const SwCrsrShell * pCShell ) 315 : pCrsrShell( pCShell ) 316 { 317 pCShell->GetWin()->SetCursor( &aTxtCrsr ); 318 bIsVisible = aTxtCrsr.IsVisible(); 319 bIsDragCrsr = sal_False; 320 aTxtCrsr.SetWidth( 0 ); 321 322 #ifdef SW_CRSR_TIMER 323 bTimerOn = sal_True; 324 SetTimeout( 50 ); // 50msec Verzoegerung 325 #endif 326 } 327 328 329 330 SwVisCrsr::~SwVisCrsr() 331 { 332 #ifdef SW_CRSR_TIMER 333 if( bTimerOn ) 334 Stop(); // Timer stoppen 335 #endif 336 337 if( bIsVisible && aTxtCrsr.IsVisible() ) 338 aTxtCrsr.Hide(); 339 340 pCrsrShell->GetWin()->SetCursor( 0 ); 341 } 342 343 344 345 346 void SwVisCrsr::Show() 347 { 348 if( !bIsVisible ) 349 { 350 bIsVisible = sal_True; 351 352 // muss ueberhaupt angezeigt werden ? 353 if( pCrsrShell->VisArea().IsOver( pCrsrShell->aCharRect ) ) 354 #ifdef SW_CRSR_TIMER 355 { 356 if( bTimerOn ) 357 Start(); // Timer aufsetzen 358 else 359 { 360 if( IsActive() ) 361 Stop(); // Timer Stoppen 362 363 _SetPosAndShow(); 364 } 365 } 366 #else 367 _SetPosAndShow(); 368 #endif 369 } 370 } 371 372 373 374 void SwVisCrsr::Hide() 375 { 376 if( bIsVisible ) 377 { 378 bIsVisible = sal_False; 379 380 #ifdef SW_CRSR_TIMER 381 if( IsActive() ) 382 Stop(); // Timer Stoppen 383 #endif 384 385 if( aTxtCrsr.IsVisible() ) // sollten die Flags nicht gueltig sein? 386 aTxtCrsr.Hide(); 387 } 388 } 389 390 #ifdef SW_CRSR_TIMER 391 392 void __EXPORT SwVisCrsr::Timeout() 393 { 394 ASSERT( !bIsDragCrsr, "Timer vorher abschalten" ); 395 if( bIsVisible ) 396 { 397 if ( !pCrsrShell->GetWin() ) //SwFrmFmt::GetGraphic setzt das Win temp aus! 398 Start(); 399 else 400 _SetPosAndShow(); 401 } 402 } 403 404 sal_Bool SwCrsrShell::ChgCrsrTimerFlag( sal_Bool bTimerOn ) 405 { 406 return pVisCrsr->ChgTimerFlag( bTimerOn ); 407 } 408 409 410 sal_Bool SwVisCrsr::ChgTimerFlag( sal_Bool bFlag ) 411 { 412 bOld = bTimerOn; 413 if( !bFlag && bIsVisible && IsActive() ) 414 { 415 Stop(); // Timer Stoppen 416 _SetPosAndShow(); 417 } 418 bTimerOn = bFlag; 419 return bOld; 420 } 421 422 #endif 423 424 425 void SwVisCrsr::_SetPosAndShow() 426 { 427 SwRect aRect; 428 long nTmpY = pCrsrShell->aCrsrHeight.Y(); 429 if( 0 > nTmpY ) 430 { 431 nTmpY = -nTmpY; 432 aTxtCrsr.SetOrientation( 900 ); 433 aRect = SwRect( pCrsrShell->aCharRect.Pos(), 434 Size( pCrsrShell->aCharRect.Height(), nTmpY ) ); 435 aRect.Pos().X() += pCrsrShell->aCrsrHeight.X(); 436 if( pCrsrShell->IsOverwriteCrsr() ) 437 aRect.Pos().Y() += aRect.Width(); 438 } 439 else 440 { 441 aTxtCrsr.SetOrientation( 0 ); 442 aRect = SwRect( pCrsrShell->aCharRect.Pos(), 443 Size( pCrsrShell->aCharRect.Width(), nTmpY ) ); 444 aRect.Pos().Y() += pCrsrShell->aCrsrHeight.X(); 445 } 446 447 // check if cursor should show the current cursor bidi level 448 aTxtCrsr.SetDirection( CURSOR_DIRECTION_NONE ); 449 const SwCursor* pTmpCrsr = pCrsrShell->_GetCrsr(); 450 451 if ( pTmpCrsr && !pCrsrShell->IsOverwriteCrsr() ) 452 { 453 SwNode& rNode = pTmpCrsr->GetPoint()->nNode.GetNode(); 454 if( rNode.IsTxtNode() ) 455 { 456 const SwTxtNode& rTNd = *rNode.GetTxtNode(); 457 const SwFrm* pFrm = rTNd.getLayoutFrm( pCrsrShell->GetLayout(), 0, 0, sal_False ); 458 if ( pFrm ) 459 { 460 const SwScriptInfo* pSI = ((SwTxtFrm*)pFrm)->GetScriptInfo(); 461 // cursor level has to be shown 462 if ( pSI && pSI->CountDirChg() > 1 ) 463 { 464 aTxtCrsr.SetDirection( 465 ( pTmpCrsr->GetCrsrBidiLevel() % 2 ) ? 466 CURSOR_DIRECTION_RTL : 467 CURSOR_DIRECTION_LTR ); 468 } 469 470 if ( pFrm->IsRightToLeft() ) 471 { 472 const OutputDevice *pOut = pCrsrShell->GetOut(); 473 if ( pOut ) 474 { 475 long nSize = pOut->GetSettings().GetStyleSettings().GetCursorSize(); 476 Size aSize( nSize, nSize ); 477 aSize = pOut->PixelToLogic( aSize ); 478 aRect.Left( aRect.Left() - aSize.Width() ); 479 } 480 } 481 } 482 } 483 } 484 485 if( aRect.Height() ) 486 { 487 ::SwCalcPixStatics( pCrsrShell->GetOut() ); 488 ::SwAlignRect( aRect, (ViewShell*)pCrsrShell ); 489 } 490 if( !pCrsrShell->IsOverwriteCrsr() || bIsDragCrsr || 491 pCrsrShell->IsSelection() ) 492 aRect.Width( 0 ); 493 494 aTxtCrsr.SetSize( aRect.SSize() ); 495 496 aTxtCrsr.SetPos( aRect.Pos() ); 497 if ( !pCrsrShell->IsCrsrReadonly() || pCrsrShell->GetViewOptions()->IsSelectionInReadonly() ) 498 { 499 if ( pCrsrShell->GetDrawView() ) 500 ((SwDrawView*)pCrsrShell->GetDrawView())->SetAnimationEnabled( 501 !pCrsrShell->IsSelection() ); 502 503 sal_uInt16 nStyle = bIsDragCrsr ? CURSOR_SHADOW : 0; 504 if( nStyle != aTxtCrsr.GetStyle() ) 505 { 506 aTxtCrsr.SetStyle( nStyle ); 507 aTxtCrsr.SetWindow( bIsDragCrsr ? pCrsrShell->GetWin() : 0 ); 508 } 509 510 aTxtCrsr.Show(); 511 } 512 } 513 514 ////////////////////////////////////////////////////////////////////////////// 515 516 SwSelPaintRects::SwSelPaintRects( const SwCrsrShell& rCSh ) 517 : SwRects( 0 ) 518 , pCShell( &rCSh ) 519 , mpCursorOverlay( 0 ) 520 , mbShowTxtInputFldOverlay( true ) 521 , mpTxtInputFldOverlay( NULL ) 522 { 523 } 524 525 SwSelPaintRects::~SwSelPaintRects() 526 { 527 Hide(); 528 } 529 530 void SwSelPaintRects::swapContent(SwSelPaintRects& rSwap) 531 { 532 SwRects aTempRects; 533 aTempRects.Insert(this, 0); 534 535 Remove(0, Count()); 536 Insert(&rSwap, 0); 537 538 rSwap.Remove(0, rSwap.Count()); 539 rSwap.Insert(&aTempRects, 0); 540 541 // #i75172# also swap mpCursorOverlay 542 sdr::overlay::OverlayObject* pTempOverlay = getCursorOverlay(); 543 setCursorOverlay(rSwap.getCursorOverlay()); 544 rSwap.setCursorOverlay(pTempOverlay); 545 546 const bool bTempShowTxtInputFldOverlay = mbShowTxtInputFldOverlay; 547 mbShowTxtInputFldOverlay = rSwap.mbShowTxtInputFldOverlay; 548 rSwap.mbShowTxtInputFldOverlay = bTempShowTxtInputFldOverlay; 549 550 sw::overlay::OverlayRangesOutline* pTempTxtInputFldOverlay = mpTxtInputFldOverlay; 551 mpTxtInputFldOverlay = rSwap.mpTxtInputFldOverlay; 552 rSwap.mpTxtInputFldOverlay = pTempTxtInputFldOverlay; 553 } 554 555 void SwSelPaintRects::Hide() 556 { 557 if(mpCursorOverlay) 558 { 559 delete mpCursorOverlay; 560 mpCursorOverlay = 0; 561 } 562 563 if ( mpTxtInputFldOverlay != NULL ) 564 { 565 delete mpTxtInputFldOverlay; 566 mpTxtInputFldOverlay = NULL; 567 } 568 569 SwRects::Remove( 0, Count() ); 570 } 571 572 void SwSelPaintRects::Show() 573 { 574 SdrView* pView = (SdrView*)pCShell->GetDrawView(); 575 576 if(pView && pView->PaintWindowCount()) 577 { 578 // reset rects 579 SwRects::Remove( 0, SwRects::Count() ); 580 FillRects(); 581 582 // get new rects 583 std::vector< basegfx::B2DRange > aNewRanges; 584 585 for(sal_uInt16 a(0); a < Count(); a++) 586 { 587 const SwRect aNextRect((*this)[a]); 588 const Rectangle aPntRect(aNextRect.SVRect()); 589 590 aNewRanges.push_back(basegfx::B2DRange( 591 aPntRect.Left(), aPntRect.Top(), 592 aPntRect.Right() + 1, aPntRect.Bottom() + 1)); 593 } 594 595 if(mpCursorOverlay) 596 { 597 if(aNewRanges.size()) 598 { 599 static_cast< sdr::overlay::OverlaySelection* >(mpCursorOverlay)->setRanges(aNewRanges); 600 } 601 else 602 { 603 delete mpCursorOverlay; 604 mpCursorOverlay = 0; 605 } 606 } 607 else if(Count()) 608 { 609 SdrPaintWindow* pCandidate = pView->GetPaintWindow(0); 610 sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager(); 611 612 if(pTargetOverlay) 613 { 614 // get the system's hilight color 615 const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; 616 const Color aHighlight(aSvtOptionsDrawinglayer.getHilightColor()); 617 618 // create correct selection 619 mpCursorOverlay = new sdr::overlay::OverlaySelection( 620 sdr::overlay::OVERLAY_TRANSPARENT, 621 aHighlight, 622 aNewRanges, 623 true); 624 625 pTargetOverlay->add(*mpCursorOverlay); 626 } 627 } 628 629 HighlightInputFld(); 630 } 631 } 632 633 634 void SwSelPaintRects::HighlightInputFld() 635 { 636 std::vector< basegfx::B2DRange > aInputFldRanges; 637 638 if ( mbShowTxtInputFldOverlay ) 639 { 640 SwTxtInputFld* pCurTxtInputFldAtCrsr = 641 dynamic_cast<SwTxtInputFld*>(GetShell()->GetTxtFldAtPos( GetShell()->GetCrsr()->Start(), false )); 642 if ( pCurTxtInputFldAtCrsr != NULL ) 643 { 644 SwTxtNode* pTxtNode = pCurTxtInputFldAtCrsr->GetpTxtNode(); 645 ::boost::scoped_ptr<SwShellCrsr> pCrsrForInputTxtFld( 646 new SwShellCrsr( *GetShell(), SwPosition( *pTxtNode, *(pCurTxtInputFldAtCrsr->GetStart()) ) ) ); 647 pCrsrForInputTxtFld->SetMark(); 648 pCrsrForInputTxtFld->GetMark()->nNode = *pTxtNode; 649 pCrsrForInputTxtFld->GetMark()->nContent.Assign( pTxtNode, *(pCurTxtInputFldAtCrsr->End()) ); 650 651 pCrsrForInputTxtFld->FillRects(); 652 653 for( sal_uInt16 a(0); a < pCrsrForInputTxtFld->Count(); ++a ) 654 { 655 const SwRect aNextRect((*pCrsrForInputTxtFld)[a]); 656 const Rectangle aPntRect(aNextRect.SVRect()); 657 658 aInputFldRanges.push_back(basegfx::B2DRange( 659 aPntRect.Left(), aPntRect.Top(), 660 aPntRect.Right() + 1, aPntRect.Bottom() + 1)); 661 } 662 } 663 } 664 665 if ( aInputFldRanges.size() > 0 ) 666 { 667 if ( mpTxtInputFldOverlay != NULL ) 668 { 669 mpTxtInputFldOverlay->setRanges( aInputFldRanges ); 670 } 671 else 672 { 673 SdrView* pView = (SdrView*)GetShell()->GetDrawView(); 674 SdrPaintWindow* pCandidate = pView->GetPaintWindow(0); 675 sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager(); 676 677 if(pTargetOverlay) 678 { 679 // use system's hilight color with decreased luminance as highlight color 680 const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; 681 Color aHighlight(aSvtOptionsDrawinglayer.getHilightColor()); 682 aHighlight.DecreaseLuminance( 128 ); 683 684 mpTxtInputFldOverlay = new sw::overlay::OverlayRangesOutline( aHighlight, aInputFldRanges ); 685 pTargetOverlay->add( *mpTxtInputFldOverlay ); 686 } 687 } 688 } 689 else 690 { 691 if ( mpTxtInputFldOverlay != NULL ) 692 { 693 delete mpTxtInputFldOverlay; 694 mpTxtInputFldOverlay = NULL; 695 } 696 } 697 } 698 699 700 void SwSelPaintRects::Invalidate( const SwRect& rRect ) 701 { 702 sal_uInt16 nSz = Count(); 703 if( !nSz ) 704 return; 705 706 SwRegionRects aReg( GetShell()->VisArea() ); 707 aReg.Remove( 0, aReg.Count() ); 708 aReg.Insert( this, 0 ); 709 aReg -= rRect; 710 SwRects::Remove( 0, nSz ); 711 SwRects::Insert( &aReg, 0 ); 712 713 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 714 // Liegt die Selection rechts oder unten ausserhalb des sichtbaren 715 // Bereiches, so ist diese nie auf eine Pixel rechts/unten aligned. 716 // Das muss hier erkannt und ggf. das Rechteckt erweitert werden. 717 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 718 if( GetShell()->bVisPortChgd && 0 != ( nSz = Count()) ) 719 { 720 SwSelPaintRects::Get1PixelInLogic( *GetShell() ); 721 SwRect* pRect = (SwRect*)GetData(); 722 for( ; nSz--; ++pRect ) 723 { 724 if( pRect->Right() == GetShell()->aOldRBPos.X() ) 725 pRect->Right( pRect->Right() + nPixPtX ); 726 if( pRect->Bottom() == GetShell()->aOldRBPos.Y() ) 727 pRect->Bottom( pRect->Bottom() + nPixPtY ); 728 } 729 } 730 } 731 732 void SwSelPaintRects::Paint( const Rectangle& /*rRect*/ ) 733 { 734 // nothing to do with overlays 735 } 736 737 738 // check current MapMode of the shell and set possibly the static members. 739 // Optional set the parameters pX, pY 740 void SwSelPaintRects::Get1PixelInLogic( const ViewShell& rSh, 741 long* pX, long* pY ) 742 { 743 const OutputDevice* pOut = rSh.GetWin(); 744 if ( ! pOut ) 745 pOut = rSh.GetOut(); 746 747 const MapMode& rMM = pOut->GetMapMode(); 748 if( pMapMode->GetMapUnit() != rMM.GetMapUnit() || 749 pMapMode->GetScaleX() != rMM.GetScaleX() || 750 pMapMode->GetScaleY() != rMM.GetScaleY() ) 751 { 752 *pMapMode = rMM; 753 Size aTmp( 1, 1 ); 754 aTmp = pOut->PixelToLogic( aTmp ); 755 nPixPtX = aTmp.Width(); 756 nPixPtY = aTmp.Height(); 757 } 758 if( pX ) 759 *pX = nPixPtX; 760 if( pY ) 761 *pY = nPixPtY; 762 } 763 764 765 /* */ 766 767 SwShellCrsr::SwShellCrsr( 768 const SwCrsrShell& rCShell, 769 const SwPosition &rPos ) 770 : SwCursor(rPos,0,false) 771 , SwSelPaintRects(rCShell) 772 , pPt(SwPaM::GetPoint()) 773 {} 774 775 776 SwShellCrsr::SwShellCrsr( 777 const SwCrsrShell& rCShell, 778 const SwPosition &rPos, 779 const Point& rPtPos, 780 SwPaM* pRing ) 781 : SwCursor(rPos, pRing, false) 782 , SwSelPaintRects(rCShell) 783 , aMkPt(rPtPos) 784 , aPtPt(rPtPos) 785 , pPt(SwPaM::GetPoint()) 786 {} 787 788 789 SwShellCrsr::SwShellCrsr( SwShellCrsr& rICrsr ) 790 : SwCursor(rICrsr) 791 , SwSelPaintRects(*rICrsr.GetShell()) 792 , aMkPt(rICrsr.GetMkPos()) 793 , aPtPt(rICrsr.GetPtPos()) 794 , pPt(SwPaM::GetPoint()) 795 {} 796 797 SwShellCrsr::~SwShellCrsr() 798 {} 799 800 801 bool SwShellCrsr::IsReadOnlyAvailable() const 802 { 803 return GetShell()->IsReadOnlyAvailable(); 804 } 805 806 void SwShellCrsr::SetMark() 807 { 808 if( SwPaM::GetPoint() == pPt ) 809 aMkPt = aPtPt; 810 else 811 aPtPt = aMkPt; 812 SwPaM::SetMark(); 813 } 814 815 void SwShellCrsr::FillRects() 816 { 817 // die neuen Rechtecke berechnen 818 if( HasMark() && 819 GetPoint()->nNode.GetNode().IsCntntNode() && 820 GetPoint()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) && 821 (GetMark()->nNode == GetPoint()->nNode || 822 (GetMark()->nNode.GetNode().IsCntntNode() && 823 GetMark()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) ) )) 824 GetShell()->GetLayout()->CalcFrmRects( *this, GetShell()->IsTableMode() ); //swmod 071107//swmod 071225 825 } 826 827 828 void SwShellCrsr::Show() 829 { 830 SwShellCrsr * pTmp = this; 831 do { 832 pTmp->SwSelPaintRects::Show(); 833 } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) ); 834 835 SHOWBOOKMARKS1( 1 ) 836 SHOWREDLINES1( 1 ) 837 } 838 839 840 // Dieses Rechteck wird neu gepaintet, also ist die SSelection in 841 // dem Bereich ungueltig 842 void SwShellCrsr::Invalidate( const SwRect& rRect ) 843 { 844 SwShellCrsr * pTmp = this; 845 846 do 847 { 848 pTmp->SwSelPaintRects::Invalidate( rRect ); 849 850 // --> FME 2005-08-18 #125102# 851 // skip any non SwShellCrsr objects in the ring 852 // (see:SwAutoFormat::DeleteSel() 853 // <-- 854 Ring* pTmpRing = pTmp; 855 pTmp = 0; 856 do 857 { 858 pTmpRing = pTmpRing->GetNext(); 859 pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing); 860 } 861 while ( !pTmp ); 862 } 863 while( this != pTmp ); 864 865 SHOWBOOKMARKS2( 3, &rRect ) 866 SHOWREDLINES2( 3, &rRect ) 867 } 868 869 870 void SwShellCrsr::Hide() 871 { 872 SwShellCrsr * pTmp = this; 873 do { 874 pTmp->SwSelPaintRects::Hide(); 875 } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) ); 876 877 SHOWBOOKMARKS1( 2 ) 878 SHOWREDLINES1( 2 ) 879 } 880 881 SwCursor* SwShellCrsr::Create( SwPaM* pRing ) const 882 { 883 return new SwShellCrsr( *GetShell(), *GetPoint(), GetPtPos(), pRing ); 884 } 885 886 887 short SwShellCrsr::MaxReplaceArived() 888 { 889 short nRet = RET_YES; 890 Window* pDlg = LAYOUT_THIS_WINDOW (::GetSearchDialog()); 891 if( pDlg ) 892 { 893 // alte Actions beenden; die Tabellen-Frames werden angelegt und 894 // eine SSelection kann erzeugt werden 895 SvUShorts aArr; 896 sal_uInt16 nActCnt; 897 ViewShell *pShell = const_cast< SwCrsrShell* >( GetShell() ), 898 *pSh = pShell; 899 do { 900 for( nActCnt = 0; pSh->ActionPend(); ++nActCnt ) 901 pSh->EndAction(); 902 aArr.Insert( nActCnt, aArr.Count() ); 903 } while( pShell != ( pSh = (ViewShell*)pSh->GetNext() ) ); 904 905 { 906 nRet = QueryBox( pDlg, SW_RES( MSG_COMCORE_ASKSEARCH )).Execute(); 907 } 908 909 for( sal_uInt16 n = 0; n < aArr.Count(); ++n ) 910 { 911 for( nActCnt = aArr[n]; nActCnt--; ) 912 pSh->StartAction(); 913 pSh = (ViewShell*)pSh->GetNext(); 914 } //swmod 071107//swmod 071225 915 } 916 else 917 // ansonsten aus dem Basic, und dann auf RET_YES schalten 918 nRet = RET_YES; 919 920 return nRet; 921 } 922 923 void SwShellCrsr::SaveTblBoxCntnt( const SwPosition* pPos ) 924 { 925 ((SwCrsrShell*)GetShell())->SaveTblBoxCntnt( pPos ); 926 } 927 928 sal_Bool SwShellCrsr::UpDown( sal_Bool bUp, sal_uInt16 nCnt ) 929 { 930 return SwCursor::UpDown( bUp, nCnt, 931 &GetPtPos(), GetShell()->GetUpDownX() ); 932 } 933 934 #ifdef DBG_UTIL 935 936 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung 937 // am sichtbaren Cursor 938 939 sal_Bool SwShellCrsr::IsSelOvr( int eFlags ) 940 { 941 return SwCursor::IsSelOvr( eFlags ); 942 } 943 944 #endif 945 946 // sal_True: an die Position kann der Cursor gesetzt werden 947 sal_Bool SwShellCrsr::IsAtValidPos( sal_Bool bPoint ) const 948 { 949 if( GetShell() && ( GetShell()->IsAllProtect() || 950 GetShell()->GetViewOptions()->IsReadonly() || 951 ( GetShell()->Imp()->GetDrawView() && 952 GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))) 953 return sal_True; 954 955 return SwCursor::IsAtValidPos( bPoint ); 956 } 957 958 /* */ 959 960 SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh, 961 const SwPosition& rPos ) 962 : SwCursor(rPos,0,false), SwShellCrsr(rCrsrSh, rPos), SwTableCursor(rPos) 963 { 964 } 965 966 SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh, 967 const SwPosition& rMkPos, const Point& rMkPt, 968 const SwPosition& rPtPos, const Point& rPtPt ) 969 : SwCursor(rPtPos,0,false), SwShellCrsr(rCrsrSh, rPtPos), SwTableCursor(rPtPos) 970 { 971 SetMark(); 972 *GetMark() = rMkPos; 973 GetMkPos() = rMkPt; 974 GetPtPos() = rPtPt; 975 } 976 977 SwShellTableCrsr::~SwShellTableCrsr() {} 978 979 void SwShellTableCrsr::SetMark() { SwShellCrsr::SetMark(); } 980 981 SwCursor* SwShellTableCrsr::Create( SwPaM* pRing ) const 982 { 983 return SwShellCrsr::Create( pRing ); 984 } 985 short SwShellTableCrsr::MaxReplaceArived() 986 { 987 return SwShellCrsr::MaxReplaceArived(); 988 } 989 void SwShellTableCrsr::SaveTblBoxCntnt( const SwPosition* pPos ) 990 { 991 SwShellCrsr::SaveTblBoxCntnt( pPos ); 992 } 993 994 995 void SwShellTableCrsr::FillRects() 996 { 997 // die neuen Rechtecke berechnen 998 // JP 16.01.98: wenn der Cursor noch "geparkt" ist nichts machen!! 999 if( !aSelBoxes.Count() || bParked || 1000 !GetPoint()->nNode.GetIndex() ) 1001 return; 1002 1003 SwRegionRects aReg( GetShell()->VisArea() ); 1004 SwNodes& rNds = GetDoc()->GetNodes(); 1005 for( sal_uInt16 n = 0; n < aSelBoxes.Count(); ++n ) 1006 { 1007 const SwStartNode* pSttNd = (*(aSelBoxes.GetData() + n ))->GetSttNd(); 1008 const SwTableNode* pSelTblNd = pSttNd->FindTableNode(); 1009 1010 SwNodeIndex aIdx( *pSttNd ); 1011 SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False ); 1012 1013 // TABLE IN TABLE 1014 // (see also lcl_FindTopLevelTable in unoobj2.cxx for a different 1015 // version to do this) 1016 const SwTableNode* pCurTblNd = pCNd->FindTableNode(); 1017 while ( pSelTblNd != pCurTblNd && pCurTblNd ) 1018 { 1019 aIdx = pCurTblNd->EndOfSectionIndex(); 1020 pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False ); 1021 pCurTblNd = pCNd->FindTableNode(); 1022 } 1023 1024 if( !pCNd ) 1025 continue; 1026 1027 SwFrm* pFrm = pCNd->getLayoutFrm( GetShell()->GetLayout(), &GetSttPos() ); 1028 while( pFrm && !pFrm->IsCellFrm() ) 1029 pFrm = pFrm->GetUpper(); 1030 1031 ASSERT( pFrm, "Node nicht in einer Tabelle" ); 1032 1033 while ( pFrm ) 1034 { 1035 if( pFrm && aReg.GetOrigin().IsOver( pFrm->Frm() ) ) 1036 aReg -= pFrm->Frm(); 1037 1038 pFrm = pFrm->GetNextCellLeaf( MAKEPAGE_NONE ); 1039 } 1040 } 1041 aReg.Invert(); 1042 Insert( &aReg, 0 ); 1043 } 1044 1045 1046 // Pruefe, ob sich der SPoint innerhalb der Tabellen-SSelection befindet 1047 sal_Bool SwShellTableCrsr::IsInside( const Point& rPt ) const 1048 { 1049 // die neuen Rechtecke berechnen 1050 // JP 16.01.98: wenn der Cursor noch "geparkt" ist nichts machen!! 1051 if( !aSelBoxes.Count() || bParked || 1052 !GetPoint()->nNode.GetIndex() ) 1053 return sal_False; 1054 1055 SwNodes& rNds = GetDoc()->GetNodes(); 1056 for( sal_uInt16 n = 0; n < aSelBoxes.Count(); ++n ) 1057 { 1058 SwNodeIndex aIdx( *(*(aSelBoxes.GetData() + n ))->GetSttNd() ); 1059 SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False ); 1060 if( !pCNd ) 1061 continue; 1062 1063 SwFrm* pFrm = pCNd->getLayoutFrm( GetShell()->GetLayout(), &GetPtPos() ); 1064 while( pFrm && !pFrm->IsCellFrm() ) 1065 pFrm = pFrm->GetUpper(); 1066 ASSERT( pFrm, "Node nicht in einer Tabelle" ); 1067 if( pFrm && pFrm->Frm().IsInside( rPt ) ) 1068 return sal_True; 1069 } 1070 return sal_False; 1071 } 1072 1073 #ifdef DBG_UTIL 1074 1075 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung 1076 // am sichtbaren Cursor 1077 sal_Bool SwShellTableCrsr::IsSelOvr( int eFlags ) 1078 { 1079 return SwShellCrsr::IsSelOvr( eFlags ); 1080 } 1081 1082 #endif 1083 1084 sal_Bool SwShellTableCrsr::IsAtValidPos( sal_Bool bPoint ) const 1085 { 1086 return SwShellCrsr::IsAtValidPos( bPoint ); 1087 } 1088 1089