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_svx.hxx" 26 #include <com/sun/star/awt/XWindow.hpp> 27 #include <svx/svdpntv.hxx> 28 #include <vcl/msgbox.hxx> 29 #include <svx/sdrpaintwindow.hxx> 30 #include <svtools/grfmgr.hxx> 31 #include <svx/svdmodel.hxx> 32 33 #ifdef DBG_UTIL 34 #include <svdibrow.hxx> 35 #endif 36 #include <svx/svdpage.hxx> 37 #include <svx/svdpagv.hxx> 38 #include <svl/smplhint.hxx> 39 40 #include <svx/svdpntv.hxx> 41 #include <editeng/editdata.hxx> 42 #include <svx/svdmrkv.hxx> 43 #include <svx/svdpagv.hxx> 44 #include <svx/svdpage.hxx> 45 #include <svx/svdmodel.hxx> 46 #include <svx/svdundo.hxx> 47 #include <svx/svdview.hxx> 48 #include <svx/svdglue.hxx> 49 #include <svx/svdobj.hxx> 50 #include <svx/svdograf.hxx> 51 #include <svx/svdattrx.hxx> 52 #include "svdibrow.hxx" 53 #include "svx/svditer.hxx" 54 #include <svx/svdouno.hxx> 55 #include <svx/sdr/overlay/overlayobjectlist.hxx> 56 #include <svx/sdr/overlay/overlayrollingrectangle.hxx> 57 #include <svx/sdr/overlay/overlaymanager.hxx> 58 #include <svx/svdglue.hxx> 59 #include <svx/svdobj.hxx> 60 #include <svx/svdview.hxx> 61 #include <svx/sxlayitm.hxx> 62 #include <svl/itemiter.hxx> 63 #include <editeng/eeitem.hxx> 64 #include <svl/whiter.hxx> 65 #include <svl/style.hxx> 66 #include <svx/sdrpagewindow.hxx> 67 #include <svx/svdouno.hxx> 68 #include <vcl/svapp.hxx> 69 #include <com/sun/star/awt/XWindow.hpp> 70 #include <com/sun/star/awt/PosSize.hpp> 71 #include <com/sun/star/awt/XControl.hpp> 72 73 // #i38135# 74 #include <svx/sdr/contact/objectcontact.hxx> 75 #include <svx/sdr/animation/objectanimator.hxx> 76 #include <svx/sdr/contact/viewcontact.hxx> 77 78 using namespace ::rtl; 79 using namespace ::com::sun::star; 80 81 //////////////////////////////////////////////////////////////////////////////////////////////////// 82 // #114409#-3 Migrate Encirclement 83 class ImplEncirclementOverlay 84 { 85 // The OverlayObjects 86 ::sdr::overlay::OverlayObjectList maObjects; 87 88 // The remembered second position in logical coodinates 89 basegfx::B2DPoint maSecondPosition; 90 91 public: 92 ImplEncirclementOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos); 93 ~ImplEncirclementOverlay(); 94 95 void SetSecondPosition(const basegfx::B2DPoint& rNewPosition); 96 }; 97 98 ImplEncirclementOverlay::ImplEncirclementOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos) 99 : maSecondPosition(rStartPos) 100 { 101 for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++) 102 { 103 SdrPaintWindow* pCandidate = rView.GetPaintWindow(a); 104 ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager(); 105 106 if(pTargetOverlay) 107 { 108 ::sdr::overlay::OverlayRollingRectangleStriped* aNew = new ::sdr::overlay::OverlayRollingRectangleStriped( 109 rStartPos, rStartPos, false); 110 pTargetOverlay->add(*aNew); 111 maObjects.append(*aNew); 112 } 113 } 114 } 115 116 ImplEncirclementOverlay::~ImplEncirclementOverlay() 117 { 118 // The OverlayObjects are cleared using the destructor of OverlayObjectList. 119 // That destructor calls clear() at the list which removes all objects from the 120 // OverlayManager and deletes them. 121 } 122 123 void ImplEncirclementOverlay::SetSecondPosition(const basegfx::B2DPoint& rNewPosition) 124 { 125 if(rNewPosition != maSecondPosition) 126 { 127 // apply to OverlayObjects 128 for(sal_uInt32 a(0L); a < maObjects.count(); a++) 129 { 130 ::sdr::overlay::OverlayRollingRectangleStriped& rCandidate = (::sdr::overlay::OverlayRollingRectangleStriped&)maObjects.getOverlayObject(a); 131 rCandidate.setSecondPosition(rNewPosition); 132 } 133 134 // remember new position 135 maSecondPosition = rNewPosition; 136 } 137 } 138 139 //////////////////////////////////////////////////////////////////////////////////////////////////// 140 // interface to SdrPaintWindow 141 142 SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const 143 { 144 for(SdrPaintWindowVector::const_iterator a = maPaintWindows.begin(); a != maPaintWindows.end(); a++) 145 { 146 if(&((*a)->GetOutputDevice()) == &rOut) 147 { 148 return *a; 149 } 150 } 151 152 return 0L; 153 } 154 155 SdrPaintWindow* SdrPaintView::GetPaintWindow(sal_uInt32 nIndex) const 156 { 157 if(nIndex < maPaintWindows.size()) 158 { 159 return maPaintWindows[nIndex]; 160 } 161 162 return 0L; 163 } 164 165 void SdrPaintView::AppendPaintWindow(SdrPaintWindow& rNew) 166 { 167 maPaintWindows.push_back(&rNew); 168 } 169 170 SdrPaintWindow* SdrPaintView::RemovePaintWindow(SdrPaintWindow& rOld) 171 { 172 SdrPaintWindow* pRetval = 0L; 173 const SdrPaintWindowVector::iterator aFindResult = ::std::find(maPaintWindows.begin(), maPaintWindows.end(), &rOld); 174 175 if(aFindResult != maPaintWindows.end()) 176 { 177 // remember return value, aFindResult is no longer valid after deletion 178 pRetval = *aFindResult; 179 maPaintWindows.erase(aFindResult); 180 } 181 182 return pRetval; 183 } 184 185 OutputDevice* SdrPaintView::GetFirstOutputDevice() const 186 { 187 if(PaintWindowCount()) 188 { 189 return &(GetPaintWindow(0)->GetOutputDevice()); 190 } 191 192 return 0L; 193 } 194 195 //////////////////////////////////////////////////////////////////////////////////////////////////// 196 197 TYPEINIT1( SvxViewHint, SfxHint ); 198 199 SvxViewHint::SvxViewHint (HintType eHintType) 200 : meHintType(eHintType) 201 { 202 } 203 204 SvxViewHint::HintType SvxViewHint::GetHintType (void) const 205 { 206 return meHintType; 207 } 208 209 210 //////////////////////////////////////////////////////////////////////////////////////////////////// 211 212 TYPEINIT2(SdrPaintView,SfxListener,SfxRepeatTarget); 213 214 DBG_NAME(SdrPaintView); 215 216 void SdrPaintView::ImpClearVars() 217 { 218 #ifdef DBG_UTIL 219 pItemBrowser=NULL; 220 #endif 221 bPageVisible=sal_True; 222 bPageBorderVisible=sal_True; 223 bBordVisible=sal_True; 224 bGridVisible=sal_True; 225 bGridFront =sal_False; 226 bHlplVisible=sal_True; 227 bHlplFront =sal_True; 228 bGlueVisible=sal_False; 229 bGlueVisible2=sal_False; 230 bGlueVisible3=sal_False; 231 bGlueVisible4=sal_False; 232 bSwapAsynchron=sal_False; 233 bPrintPreview=sal_False; 234 mbPreviewRenderer=sal_False; 235 236 eAnimationMode = SDR_ANIMATION_ANIMATE; 237 bAnimationPause = sal_False; 238 239 nHitTolPix=2; 240 nMinMovPix=3; 241 nHitTolLog=0; 242 nMinMovLog=0; 243 pActualOutDev=NULL; 244 pDragWin=NULL; 245 bRestoreColors=sal_True; 246 pDefaultStyleSheet=NULL; 247 bSomeObjChgdFlag=sal_False; 248 nGraphicManagerDrawMode = GRFMGR_DRAW_STANDARD; 249 aComeBackTimer.SetTimeout(1); 250 aComeBackTimer.SetTimeoutHdl(LINK(this,SdrPaintView,ImpComeBackHdl)); 251 String aNam; // System::GetUserName() just return an empty string 252 253 if (pMod) 254 SetDefaultStyleSheet(pMod->GetDefaultStyleSheet(), sal_True); 255 256 aNam.ToUpperAscii(); 257 258 maGridColor = Color( COL_BLACK ); 259 BrkEncirclement(); 260 } 261 262 SdrPaintView::SdrPaintView(SdrModel* pModel1, OutputDevice* pOut) 263 : mpEncirclementOverlay(0L), 264 mpPageView(0L), 265 aDefaultAttr(pModel1->GetItemPool()), 266 mbBufferedOutputAllowed(false), 267 mbBufferedOverlayAllowed(false), 268 mbPagePaintingAllowed(true), 269 mbHideOle(false), 270 mbHideChart(false), 271 mbHideDraw(false), 272 mbHideFormControl(false) 273 { 274 DBG_CTOR(SdrPaintView,NULL); 275 pMod=pModel1; 276 ImpClearVars(); 277 278 if(pOut) 279 { 280 AddWindowToPaintView(pOut); 281 } 282 283 // Flag zur Visualisierung von Gruppen 284 bVisualizeEnteredGroup = sal_True; 285 286 maColorConfig.AddListener(this); 287 onChangeColorConfig(); 288 } 289 290 SdrPaintView::~SdrPaintView() 291 { 292 DBG_DTOR(SdrPaintView,NULL); 293 if (pDefaultStyleSheet) 294 EndListening(*pDefaultStyleSheet); 295 296 maColorConfig.RemoveListener(this); 297 ClearPageView(); 298 299 #ifdef DBG_UTIL 300 if(pItemBrowser) 301 { 302 delete pItemBrowser; 303 } 304 #endif 305 306 // delete existing SdrPaintWindows 307 while(!maPaintWindows.empty()) 308 { 309 delete maPaintWindows.back(); 310 maPaintWindows.pop_back(); 311 } 312 313 // #114409#-3 Migrate HelpLine 314 BrkEncirclement(); 315 } 316 317 //////////////////////////////////////////////////////////////////////////////////////////////////// 318 319 void __EXPORT SdrPaintView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) 320 { 321 //If the stylesheet has been destroyed 322 if (&rBC == pDefaultStyleSheet) 323 { 324 if (rHint.ISA(SfxSimpleHint) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING) 325 pDefaultStyleSheet = NULL; 326 return; 327 } 328 329 sal_Bool bObjChg=!bSomeObjChgdFlag; // sal_True= auswerten fuer ComeBack-Timer 330 if (bObjChg) { 331 SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint); 332 if (pSdrHint!=NULL) { 333 SdrHintKind eKind=pSdrHint->GetKind(); 334 if (eKind==HINT_OBJCHG || eKind==HINT_OBJINSERTED || eKind==HINT_OBJREMOVED) { 335 if (bObjChg) { 336 bSomeObjChgdFlag=sal_True; 337 aComeBackTimer.Start(); 338 } 339 } 340 if (eKind==HINT_PAGEORDERCHG) { 341 const SdrPage* pPg=pSdrHint->GetPage(); 342 343 if(pPg && !pPg->IsInserted()) 344 { 345 if(mpPageView && mpPageView->GetPage() == pPg) 346 { 347 HideSdrPage(); 348 } 349 } 350 } 351 } 352 } 353 } 354 355 void SdrPaintView::ConfigurationChanged( ::utl::ConfigurationBroadcaster* , sal_uInt32 ) 356 { 357 onChangeColorConfig(); 358 InvalidateAllWin(); 359 } 360 361 //////////////////////////////////////////////////////////////////////////////////////////////////// 362 363 IMPL_LINK_INLINE_START(SdrPaintView,ImpComeBackHdl,Timer*,EMPTYARG) 364 { 365 if (bSomeObjChgdFlag) { 366 bSomeObjChgdFlag=sal_False; 367 ModelHasChanged(); 368 } 369 return 0; 370 } 371 IMPL_LINK_INLINE_END(SdrPaintView,ImpComeBackHdl,Timer*,pTimer) 372 373 void SdrPaintView::FlushComeBackTimer() const 374 { 375 if (bSomeObjChgdFlag) { 376 // casting auf nonconst 377 ((SdrPaintView*)this)->ImpComeBackHdl(&((SdrPaintView*)this)->aComeBackTimer); 378 ((SdrPaintView*)this)->aComeBackTimer.Stop(); 379 } 380 } 381 382 void SdrPaintView::ModelHasChanged() 383 { 384 // Auch alle PageViews benachrichtigen 385 if(mpPageView && !mpPageView->GetPage()->IsInserted()) 386 { 387 HideSdrPage(); 388 } 389 390 // test mpPageView here again, HideSdrPage() may have invalidated it. 391 if(mpPageView) 392 { 393 mpPageView->ModelHasChanged(); 394 } 395 396 #ifdef DBG_UTIL 397 if(pItemBrowser) 398 { 399 pItemBrowser->SetDirty(); 400 } 401 #endif 402 } 403 404 //////////////////////////////////////////////////////////////////////////////////////////////////// 405 406 sal_Bool SdrPaintView::IsAction() const 407 { 408 return IsEncirclement(); 409 } 410 411 void SdrPaintView::MovAction(const Point& rPnt) 412 { 413 if (IsEncirclement()) 414 { 415 MovEncirclement(rPnt); 416 } 417 } 418 419 void SdrPaintView::EndAction() 420 { 421 if(IsEncirclement()) 422 { 423 EndEncirclement(); 424 } 425 } 426 427 void SdrPaintView::BckAction() 428 { 429 BrkEncirclement(); 430 } 431 432 void SdrPaintView::BrkAction() 433 { 434 BrkEncirclement(); 435 } 436 437 void SdrPaintView::TakeActionRect(Rectangle& rRect) const 438 { 439 if(IsEncirclement()) 440 { 441 rRect = Rectangle(aDragStat.GetStart(),aDragStat.GetNow()); 442 } 443 } 444 445 //////////////////////////////////////////////////////////////////////////////////////////////////// 446 // info about TextEdit. Default is sal_False. 447 bool SdrPaintView::IsTextEdit() const 448 { 449 return false; 450 } 451 452 // info about TextEditPageView. Default is 0L. 453 SdrPageView* SdrPaintView::GetTextEditPageView() const 454 { 455 return 0L; 456 } 457 458 //////////////////////////////////////////////////////////////////////////////////////////////////// 459 460 sal_uInt16 SdrPaintView::ImpGetMinMovLogic(short nMinMov, const OutputDevice* pOut) const 461 { 462 if (nMinMov>=0) return sal_uInt16(nMinMov); 463 if (pOut==NULL) 464 { 465 pOut = GetFirstOutputDevice(); 466 } 467 if (pOut!=NULL) { 468 return short(-pOut->PixelToLogic(Size(nMinMov,0)).Width()); 469 } else { 470 return 0; 471 } 472 } 473 474 sal_uInt16 SdrPaintView::ImpGetHitTolLogic(short nHitTol, const OutputDevice* pOut) const 475 { 476 if (nHitTol>=0) return sal_uInt16(nHitTol); 477 if (pOut==NULL) 478 { 479 pOut = GetFirstOutputDevice(); 480 } 481 if (pOut!=NULL) { 482 return short(-pOut->PixelToLogic(Size(nHitTol,0)).Width()); 483 } else { 484 return 0; 485 } 486 } 487 488 void SdrPaintView::TheresNewMapMode() 489 { 490 if (pActualOutDev!=NULL) { 491 nHitTolLog=(sal_uInt16)((OutputDevice*)pActualOutDev)->PixelToLogic(Size(nHitTolPix,0)).Width(); 492 nMinMovLog=(sal_uInt16)((OutputDevice*)pActualOutDev)->PixelToLogic(Size(nMinMovPix,0)).Width(); 493 } 494 } 495 496 void SdrPaintView::SetActualWin(const OutputDevice* pWin) 497 { 498 pActualOutDev=pWin; 499 TheresNewMapMode(); 500 } 501 502 //////////////////////////////////////////////////////////////////////////////////////////////////// 503 504 void SdrPaintView::BegEncirclement(const Point& rPnt) 505 { 506 BrkAction(); 507 508 DBG_ASSERT(0L == mpEncirclementOverlay, "SdrSnapView::BegSetPageOrg: There exists a ImplPageOriginOverlay (!)"); 509 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y()); 510 mpEncirclementOverlay = new ImplEncirclementOverlay(*this, aStartPos); 511 512 aDragStat.Reset(rPnt); 513 aDragStat.SetMinMove(ImpGetMinMovLogic(-2,0L)); 514 aDragStat.NextPoint(); 515 } 516 517 void SdrPaintView::MovEncirclement(const Point& rPnt) 518 { 519 if(IsEncirclement() && aDragStat.CheckMinMoved(rPnt)) 520 { 521 aDragStat.NextMove(rPnt); 522 523 DBG_ASSERT(mpEncirclementOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)"); 524 basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y()); 525 mpEncirclementOverlay->SetSecondPosition(aNewPos); 526 } 527 } 528 529 Rectangle SdrPaintView::EndEncirclement(sal_Bool bNoJustify) 530 { 531 Rectangle aRetval; 532 533 if(IsEncirclement()) 534 { 535 if(aDragStat.IsMinMoved()) 536 { 537 aRetval = Rectangle(aDragStat.GetStart(), aDragStat.GetNow()); 538 539 if(!bNoJustify) 540 { 541 aRetval.Justify(); 542 } 543 } 544 545 // cleanup 546 BrkEncirclement(); 547 } 548 549 return aRetval; 550 } 551 552 void SdrPaintView::BrkEncirclement() 553 { 554 if(IsEncirclement()) 555 { 556 DBG_ASSERT(mpEncirclementOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)"); 557 delete mpEncirclementOverlay; 558 mpEncirclementOverlay = 0L; 559 } 560 } 561 562 //////////////////////////////////////////////////////////////////////////////////////////////////// 563 564 void SdrPaintView::ClearPageView() 565 { 566 BrkAction(); 567 568 if(mpPageView) 569 { 570 InvalidateAllWin(); 571 delete mpPageView; 572 mpPageView = 0L; 573 } 574 } 575 576 SdrPageView* SdrPaintView::ShowSdrPage(SdrPage* pPage) 577 { 578 if(pPage && (!mpPageView || mpPageView->GetPage() != pPage)) 579 { 580 if(mpPageView) 581 { 582 InvalidateAllWin(); 583 delete mpPageView; 584 } 585 586 mpPageView = new SdrPageView(pPage, *((SdrView*)this)); 587 mpPageView->Show(); 588 } 589 590 return mpPageView; 591 } 592 593 void SdrPaintView::HideSdrPage() 594 { 595 if(mpPageView) 596 { 597 mpPageView->Hide(); 598 delete mpPageView; 599 mpPageView = 0L; 600 } 601 } 602 603 void SdrPaintView::AddWindowToPaintView(OutputDevice* pNewWin) 604 { 605 DBG_ASSERT(pNewWin, "SdrPaintView::AddWindowToPaintView: No OutputDevice(!)"); 606 SdrPaintWindow* pNewPaintWindow = new SdrPaintWindow(*this, *pNewWin); 607 AppendPaintWindow(*pNewPaintWindow); 608 609 if(mpPageView) 610 { 611 mpPageView->AddPaintWindowToPageView(*pNewPaintWindow); 612 } 613 614 #ifdef DBG_UTIL 615 if (pItemBrowser!=NULL) 616 pItemBrowser->ForceParent(); 617 #endif 618 } 619 620 void SdrPaintView::DeleteWindowFromPaintView(OutputDevice* pOldWin) 621 { 622 DBG_ASSERT(pOldWin, "SdrPaintView::DeleteWindowFromPaintView: No OutputDevice(!)"); 623 SdrPaintWindow* pCandidate = FindPaintWindow(*pOldWin); 624 625 if(pCandidate) 626 { 627 if(mpPageView) 628 { 629 mpPageView->RemovePaintWindowFromPageView(*pCandidate); 630 } 631 632 RemovePaintWindow(*pCandidate); 633 delete pCandidate; 634 } 635 636 #ifdef DBG_UTIL 637 if (pItemBrowser!=NULL) 638 pItemBrowser->ForceParent(); 639 #endif 640 } 641 642 void SdrPaintView::SetLayerVisible(const XubString& rName, sal_Bool bShow) 643 { 644 if(mpPageView) 645 { 646 mpPageView->SetLayerVisible(rName,bShow); 647 } 648 649 InvalidateAllWin(); 650 } 651 652 bool SdrPaintView::IsLayerVisible(const XubString& rName) const 653 { 654 if(mpPageView) 655 { 656 return mpPageView->IsLayerVisible(rName); 657 } 658 659 return false; 660 } 661 662 void SdrPaintView::SetAllLayersVisible(sal_Bool bShow) 663 { 664 if(mpPageView) 665 { 666 mpPageView->SetAllLayersVisible(bShow); 667 } 668 669 InvalidateAllWin(); 670 } 671 672 void SdrPaintView::SetLayerLocked(const XubString& rName, sal_Bool bLock) 673 { 674 if(mpPageView) 675 { 676 mpPageView->SetLayerLocked(rName,bLock); 677 } 678 } 679 680 bool SdrPaintView::IsLayerLocked(const XubString& rName) const 681 { 682 if(mpPageView) 683 { 684 return mpPageView->IsLayerLocked(rName); 685 } 686 687 return false; 688 } 689 690 void SdrPaintView::SetAllLayersLocked(sal_Bool bLock) 691 { 692 if(mpPageView) 693 { 694 mpPageView->SetAllLayersLocked(bLock); 695 } 696 } 697 698 void SdrPaintView::SetLayerPrintable(const XubString& rName, sal_Bool bPrn) 699 { 700 if(mpPageView) 701 { 702 mpPageView->SetLayerPrintable(rName,bPrn); 703 } 704 } 705 706 bool SdrPaintView::IsLayerPrintable(const XubString& rName) const 707 { 708 if(mpPageView) 709 { 710 return mpPageView->IsLayerPrintable(rName); 711 } 712 713 return false; 714 } 715 716 void SdrPaintView::SetAllLayersPrintable(sal_Bool bPrn) 717 { 718 if(mpPageView) 719 { 720 mpPageView->SetAllLayersPrintable(bPrn); 721 } 722 } 723 724 void SdrPaintView::PrePaint() 725 { 726 if(mpPageView) 727 { 728 mpPageView->PrePaint(); 729 } 730 } 731 732 void SdrPaintView::PostPaint() 733 { 734 if(mpPageView) 735 { 736 mpPageView->PostPaint(); 737 } 738 } 739 740 //////////////////////////////////////////////////////////////////////////////////////////////////// 741 // #define SVX_REPAINT_TIMER_TEST 742 743 void SdrPaintView::CompleteRedraw(OutputDevice* pOut, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) 744 { 745 #ifdef SVX_REPAINT_TIMER_TEST 746 #define REMEMBERED_TIMES_COUNT (10) 747 static bool bDoTimerTest(false); 748 static bool bTimesInited(false); 749 static sal_uInt32 nRepeatCount(10L); 750 static double fLastTimes[REMEMBERED_TIMES_COUNT]; 751 const sal_uInt32 nStartTime(Time::GetSystemTicks()); 752 sal_uInt32 count(1L); 753 sal_uInt32 a; 754 755 if(bDoTimerTest) 756 { 757 count = nRepeatCount; 758 } 759 760 for(a = 0L; a < count; a++) 761 { 762 #endif // SVX_REPAINT_TIMER_TEST 763 764 // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region 765 // rReg may be made more granular (fine) with using it. Normally, rReg 766 // does come from Window::Paint() anyways and thus is based on a single 767 // rectangle which was derived from exactly that repaint region 768 Region aOptimizedRepaintRegion(rReg); 769 770 if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType()) 771 { 772 Window* pWindow = (Window*)pOut; 773 774 if(pWindow->IsInPaint()) 775 { 776 if(!pWindow->GetPaintRegion().IsEmpty()) 777 { 778 aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion()); 779 780 #ifdef DBG_UTIL 781 // #i74769# test-paint repaint region 782 static bool bDoPaintForVisualControl(false); 783 if(bDoPaintForVisualControl) 784 { 785 RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects()); 786 Rectangle aRegionRectangle; 787 788 while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle)) 789 { 790 pWindow->SetLineColor(COL_LIGHTGREEN); 791 pWindow->SetFillColor(); 792 pWindow->DrawRect(aRegionRectangle); 793 } 794 795 aOptimizedRepaintRegion.EndEnumRects(aRegionHandle); 796 } 797 #endif 798 } 799 } 800 } 801 802 SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut); 803 OSL_ENSURE(pPaintWindow, "SdrPaintView::CompleteRedraw: No OutDev (!)"); 804 805 DoCompleteRedraw(*pPaintWindow, aOptimizedRepaintRegion, pRedirector); 806 EndCompleteRedraw(*pPaintWindow, true); 807 808 #ifdef SVX_REPAINT_TIMER_TEST 809 } 810 811 if(bDoTimerTest) 812 { 813 const sal_uInt32 nStopTime(Time::GetSystemTicks()); 814 const sal_uInt32 nNeededTime(nStopTime - nStartTime); 815 const double fTimePerPaint((double)nNeededTime / (double)nRepeatCount); 816 817 if(!bTimesInited) 818 { 819 for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++) 820 { 821 fLastTimes[a] = fTimePerPaint; 822 } 823 824 bTimesInited = true; 825 } 826 else 827 { 828 for(a = 1L; a < REMEMBERED_TIMES_COUNT; a++) 829 { 830 fLastTimes[a - 1L] = fLastTimes[a]; 831 } 832 833 fLastTimes[REMEMBERED_TIMES_COUNT - 1L] = fTimePerPaint; 834 } 835 836 double fAddedTimes(0.0); 837 838 for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++) 839 { 840 fAddedTimes += fLastTimes[a]; 841 } 842 843 const double fAverageTimePerPaint(fAddedTimes / (double)REMEMBERED_TIMES_COUNT); 844 845 fprintf(stderr, "-----------(start result)----------\n"); 846 fprintf(stderr, "StartTime : %u, StopTime: %u, NeededTime: %u, TimePerPaint: %f\n", nStartTime, nStopTime, nNeededTime, fTimePerPaint); 847 fprintf(stderr, "Remembered times: "); 848 849 for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++) 850 { 851 fprintf(stderr, "%d: %f ", a, fLastTimes[a]); 852 } 853 854 fprintf(stderr, "\n"); 855 fprintf(stderr, "AverageTimePerPaint: %f\n", fAverageTimePerPaint); 856 fprintf(stderr, "-----------(stop result)----------\n"); 857 } 858 #endif // SVX_REPAINT_TIMER_TEST 859 } 860 861 //////////////////////////////////////////////////////////////////////////////////////////////////// 862 // #i72889# 863 864 SdrPaintWindow* SdrPaintView::BeginCompleteRedraw(OutputDevice* pOut) 865 { 866 OSL_ENSURE(pOut, "SdrPaintView::BeginCompleteRedraw: No OutDev (!)"); 867 SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut); 868 869 if(pPaintWindow) 870 { 871 // draw preprocessing, only for known devices 872 // prepare PreRendering 873 pPaintWindow->PreparePreRenderDevice(); 874 } 875 else 876 { 877 // None of the known OutputDevices is the target of this paint, use 878 // a temporary SdrPaintWindow for this Redraw. 879 pPaintWindow = new SdrPaintWindow(*this, *pOut); 880 pPaintWindow->setTemporaryTarget(true); 881 } 882 883 return pPaintWindow; 884 } 885 886 void SdrPaintView::DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) 887 { 888 // redraw all PageViews with the target. This may expand the RedrawRegion 889 // at the PaintWindow, plus taking care of FormLayer expansion 890 if(mpPageView) 891 { 892 mpPageView->CompleteRedraw(rPaintWindow, rReg, pRedirector); 893 } 894 } 895 896 void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer) 897 { 898 if(rPaintWindow.getTemporaryTarget()) 899 { 900 // get rid of temp target again 901 delete (&rPaintWindow); 902 } 903 else 904 { 905 // draw postprocessing, only for known devices 906 // it is necessary to always paint FormLayer 907 if(bPaintFormLayer) 908 { 909 ImpFormLayerDrawing(rPaintWindow); 910 } 911 912 // look for active TextEdit. As long as this cannot be painted to a VDev, 913 // it cannot get part of buffering. In that case, output evtl. prerender 914 // early and paint text edit to window. 915 const bool bTextEditActive(IsTextEdit() && GetTextEditPageView()); 916 917 if(bTextEditActive) 918 { 919 // output PreRendering and destroy it so that it is not used for FormLayer 920 // or overlay 921 rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion()); 922 923 // draw old text edit stuff before overlay to have it as part of the background 924 // ATM. This will be changed to have the text editing on the overlay, bit it 925 // is not an easy thing to do, see BegTextEdit and the OutlinerView stuff used... 926 if(bTextEditActive) 927 { 928 ImpTextEditDrawing(rPaintWindow); 929 } 930 931 // draw Overlay directly to window. This will save the contents of the window 932 // in the RedrawRegion to the overlay background buffer, too. 933 // This may lead to problems when reading from the screen is slow from the 934 // graphics driver/graphiccard combination. 935 rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion(), false); 936 } 937 else 938 { 939 // draw Overlay, also to PreRender device if exists 940 rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion(), true); 941 942 // output PreRendering 943 rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion()); 944 } 945 } 946 } 947 948 //////////////////////////////////////////////////////////////////////////////////////////////////// 949 950 SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect) 951 { 952 // #i74769# use BeginCompleteRedraw() as common base 953 SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut); 954 OSL_ENSURE(pPaintWindow, "SdrPaintView::BeginDrawLayers: No SdrPaintWindow (!)"); 955 956 if(mpPageView) 957 { 958 SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow); 959 960 if(pKnownTarget) 961 { 962 // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region 963 // rReg may be made more granular (fine) with using it. Normally, rReg 964 // does come from Window::Paint() anyways and thus is based on a single 965 // rectangle which was derived from exactly that repaint region 966 Region aOptimizedRepaintRegion(rReg); 967 968 // #i76114# Intersecting the region with the Window's paint region is disabled 969 // for print preview in Calc, because the intersection can be empty (if the paint 970 // region is outside of the table area of the page), and then no clip region 971 // would be set. 972 if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect) 973 { 974 Window* pWindow = (Window*)pOut; 975 976 if(pWindow->IsInPaint()) 977 { 978 if(!pWindow->GetPaintRegion().IsEmpty()) 979 { 980 aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion()); 981 982 #ifdef DBG_UTIL 983 // #i74769# test-paint repaint region 984 static bool bDoPaintForVisualControl(false); 985 if(bDoPaintForVisualControl) 986 { 987 RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects()); 988 Rectangle aRegionRectangle; 989 990 while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle)) 991 { 992 pWindow->SetLineColor(COL_LIGHTGREEN); 993 pWindow->SetFillColor(); 994 pWindow->DrawRect(aRegionRectangle); 995 } 996 997 aOptimizedRepaintRegion.EndEnumRects(aRegionHandle); 998 } 999 #endif 1000 } 1001 } 1002 } 1003 1004 // prepare redraw 1005 pKnownTarget->PrepareRedraw(aOptimizedRepaintRegion); 1006 1007 // remember prepared SdrPageWindow 1008 mpPageView->setPreparedPageWindow(pKnownTarget); 1009 } 1010 } 1011 1012 return pPaintWindow; 1013 } 1014 1015 void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer) 1016 { 1017 // #i74769# use EndCompleteRedraw() as common base 1018 EndCompleteRedraw(rPaintWindow, bPaintFormLayer); 1019 1020 if(mpPageView) 1021 { 1022 // forget prepared SdrPageWindow 1023 mpPageView->setPreparedPageWindow(0); 1024 } 1025 } 1026 1027 //////////////////////////////////////////////////////////////////////////////////////////////////// 1028 1029 void SdrPaintView::ImpTextEditDrawing(SdrPaintWindow& rPaintWindow) const 1030 { 1031 // draw old text edit stuff 1032 if(IsTextEdit()) 1033 { 1034 SdrPageView* pPageView = GetTextEditPageView(); 1035 1036 if(pPageView) 1037 { 1038 // paint TextEdit directly to the destination OutDev 1039 const Region& rRedrawRegion = rPaintWindow.GetRedrawRegion(); 1040 const Rectangle aCheckRect(rRedrawRegion.GetBoundRect()); 1041 pPageView->PaintOutlinerView(&rPaintWindow.GetOutputDevice(), aCheckRect); 1042 } 1043 } 1044 } 1045 1046 void SdrPaintView::ImpFormLayerDrawing(SdrPaintWindow& rPaintWindow) const 1047 { 1048 if(mpPageView) 1049 { 1050 SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(rPaintWindow); 1051 1052 if(pKnownTarget) 1053 { 1054 const SdrModel& rModel = *(GetModel()); 1055 const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin(); 1056 const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False); 1057 1058 // BUFFERED use GetTargetOutputDevice() now, it may be targeted to VDevs, too 1059 // need to set PreparedPageWindow to make DrawLayer use the correct ObjectContact 1060 mpPageView->setPreparedPageWindow(pKnownTarget); 1061 mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice()); 1062 mpPageView->setPreparedPageWindow(0); 1063 } 1064 } 1065 } 1066 1067 //////////////////////////////////////////////////////////////////////////////////////////////////// 1068 1069 sal_Bool SdrPaintView::KeyInput(const KeyEvent& /*rKEvt*/, Window* /*pWin*/) 1070 { 1071 return sal_False; 1072 } 1073 1074 void SdrPaintView::GlueInvalidate() const 1075 { 1076 const sal_uInt32 nWindowCount(PaintWindowCount()); 1077 1078 for(sal_uInt32 nWinNum(0L); nWinNum < nWindowCount; nWinNum++) 1079 { 1080 SdrPaintWindow* pPaintWindow = GetPaintWindow(nWinNum); 1081 1082 if(pPaintWindow->OutputToWindow()) 1083 { 1084 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 1085 1086 if(mpPageView) 1087 { 1088 const SdrObjList* pOL=mpPageView->GetObjList(); 1089 sal_uIntPtr nObjAnz=pOL->GetObjCount(); 1090 for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz; nObjNum++) { 1091 const SdrObject* pObj=pOL->GetObj(nObjNum); 1092 const SdrGluePointList* pGPL=pObj->GetGluePointList(); 1093 if (pGPL!=NULL && pGPL->GetCount()!=0) { 1094 pGPL->Invalidate((Window&)rOutDev, pObj); 1095 } 1096 } 1097 } 1098 } 1099 } 1100 } 1101 1102 void SdrPaintView::InvalidateAllWin() 1103 { 1104 const sal_uInt32 nWindowCount(PaintWindowCount()); 1105 1106 for(sal_uInt32 a(0L); a < nWindowCount; a++) 1107 { 1108 SdrPaintWindow* pPaintWindow = GetPaintWindow(a); 1109 1110 if(pPaintWindow->OutputToWindow()) 1111 { 1112 InvalidateOneWin((Window&)pPaintWindow->GetOutputDevice()); 1113 } 1114 } 1115 } 1116 1117 void SdrPaintView::InvalidateAllWin(const Rectangle& rRect, sal_Bool bPlus1Pix) 1118 { 1119 const sal_uInt32 nWindowCount(PaintWindowCount()); 1120 1121 for(sal_uInt32 a(0L); a < nWindowCount; a++) 1122 { 1123 SdrPaintWindow* pPaintWindow = GetPaintWindow(a); 1124 1125 if(pPaintWindow->OutputToWindow()) 1126 { 1127 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 1128 Rectangle aRect(rRect); 1129 1130 if(bPlus1Pix) 1131 { 1132 Size aPixSiz(1,1); 1133 Size aSiz(rOutDev.PixelToLogic(aPixSiz)); 1134 aRect.Left ()-=aSiz.Width(); 1135 aRect.Top ()-=aSiz.Height(); 1136 aRect.Right ()+=aSiz.Width(); 1137 aRect.Bottom()+=aSiz.Height(); 1138 } 1139 1140 Point aOrg(rOutDev.GetMapMode().GetOrigin()); 1141 aOrg.X()=-aOrg.X(); aOrg.Y()=-aOrg.Y(); 1142 Rectangle aOutRect(aOrg, rOutDev.GetOutputSize()); 1143 1144 if (aRect.IsOver(aOutRect)) 1145 { 1146 InvalidateOneWin((Window&)rOutDev, aRect); 1147 } 1148 } 1149 } 1150 } 1151 1152 void SdrPaintView::InvalidateOneWin(Window& rWin) 1153 { 1154 // #111096# 1155 // do not erase background, that causes flicker (!) 1156 rWin.Invalidate(INVALIDATE_NOERASE); 1157 } 1158 1159 void SdrPaintView::InvalidateOneWin(Window& rWin, const Rectangle& rRect) 1160 { 1161 // #111096# 1162 // do not erase background, that causes flicker (!) 1163 rWin.Invalidate(rRect, INVALIDATE_NOERASE); 1164 } 1165 1166 void SdrPaintView::LeaveOneGroup() 1167 { 1168 if(mpPageView) 1169 { 1170 mpPageView->LeaveOneGroup(); 1171 } 1172 } 1173 1174 void SdrPaintView::LeaveAllGroup() 1175 { 1176 if(mpPageView) 1177 { 1178 mpPageView->LeaveAllGroup(); 1179 } 1180 } 1181 1182 bool SdrPaintView::IsGroupEntered() const 1183 { 1184 if(mpPageView) 1185 { 1186 return (mpPageView->GetEnteredLevel() != 0); 1187 } 1188 1189 return false; 1190 } 1191 1192 void SdrPaintView::SetNotPersistDefaultAttr(const SfxItemSet& rAttr, sal_Bool /*bReplaceAll*/) 1193 { 1194 // bReplaceAll hat hier keinerlei Wirkung 1195 sal_Bool bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool(); 1196 const SfxPoolItem *pPoolItem=NULL; 1197 if (rAttr.GetItemState(SDRATTR_LAYERID,sal_True,&pPoolItem)==SFX_ITEM_SET) { 1198 SdrLayerID nLayerId=((const SdrLayerIdItem*)pPoolItem)->GetValue(); 1199 const SdrLayer* pLayer=pMod->GetLayerAdmin().GetLayerPerID(nLayerId); 1200 if (pLayer!=NULL) { 1201 if (bMeasure) aMeasureLayer=pLayer->GetName(); 1202 else aAktLayer=pLayer->GetName(); 1203 } 1204 } 1205 if (rAttr.GetItemState(SDRATTR_LAYERNAME,sal_True,&pPoolItem)==SFX_ITEM_SET) { 1206 if (bMeasure) aMeasureLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue(); 1207 else aAktLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue(); 1208 } 1209 } 1210 1211 void SdrPaintView::MergeNotPersistDefaultAttr(SfxItemSet& rAttr, sal_Bool /*bOnlyHardAttr*/) const 1212 { 1213 // bOnlyHardAttr hat hier keinerlei Wirkung 1214 sal_Bool bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool(); 1215 const XubString& aNam=bMeasure?aMeasureLayer:aAktLayer; 1216 rAttr.Put(SdrLayerNameItem(aNam)); 1217 SdrLayerID nLayer=pMod->GetLayerAdmin().GetLayerID(aNam,sal_True); 1218 if (nLayer!=SDRLAYER_NOTFOUND) { 1219 rAttr.Put(SdrLayerIdItem(nLayer)); 1220 } 1221 } 1222 1223 void SdrPaintView::SetDefaultAttr(const SfxItemSet& rAttr, sal_Bool bReplaceAll) 1224 { 1225 #ifdef DBG_UTIL 1226 { 1227 sal_Bool bHasEEFeatureItems=sal_False; 1228 SfxItemIter aIter(rAttr); 1229 const SfxPoolItem* pItem=aIter.FirstItem(); 1230 while (!bHasEEFeatureItems && pItem!=NULL) { 1231 if (!IsInvalidItem(pItem)) { 1232 sal_uInt16 nW=pItem->Which(); 1233 if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=sal_True; 1234 } 1235 pItem=aIter.NextItem(); 1236 } 1237 1238 if(bHasEEFeatureItems) 1239 { 1240 String aMessage; 1241 aMessage.AppendAscii("SdrPaintView::SetDefaultAttr(): Das setzen von EE_FEATURE-Items an der SdrView macht keinen Sinn! Es fuehrt nur zu Overhead und nicht mehr lesbaren Dokumenten."); 1242 InfoBox(NULL, aMessage).Execute(); 1243 } 1244 } 1245 #endif 1246 if (bReplaceAll) aDefaultAttr.Set(rAttr); 1247 else aDefaultAttr.Put(rAttr,sal_False); // FALSE= InvalidItems nicht als Default, sondern als "Loecher" betrachten 1248 SetNotPersistDefaultAttr(rAttr,bReplaceAll); 1249 #ifdef DBG_UTIL 1250 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1251 #endif 1252 } 1253 1254 void SdrPaintView::SetDefaultStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr) 1255 { 1256 if (pDefaultStyleSheet) 1257 EndListening(*pDefaultStyleSheet); 1258 pDefaultStyleSheet=pStyleSheet; 1259 if (pDefaultStyleSheet) 1260 StartListening(*pDefaultStyleSheet); 1261 1262 if (pStyleSheet!=NULL && !bDontRemoveHardAttr) { 1263 SfxWhichIter aIter(pStyleSheet->GetItemSet()); 1264 sal_uInt16 nWhich=aIter.FirstWhich(); 1265 while (nWhich!=0) { 1266 if (pStyleSheet->GetItemSet().GetItemState(nWhich,sal_True)==SFX_ITEM_SET) { 1267 aDefaultAttr.ClearItem(nWhich); 1268 } 1269 nWhich=aIter.NextWhich(); 1270 } 1271 } 1272 #ifdef DBG_UTIL 1273 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1274 #endif 1275 } 1276 1277 /* new interface src537 */ 1278 sal_Bool SdrPaintView::GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr) const 1279 { 1280 if(bOnlyHardAttr || !pDefaultStyleSheet) 1281 { 1282 rTargetSet.Put(aDefaultAttr, sal_False); 1283 } 1284 else 1285 { 1286 // sonst DefStyleSheet dazumergen 1287 rTargetSet.Put(pDefaultStyleSheet->GetItemSet(), sal_False); 1288 rTargetSet.Put(aDefaultAttr, sal_False); 1289 } 1290 MergeNotPersistDefaultAttr(rTargetSet, bOnlyHardAttr); 1291 return sal_True; 1292 } 1293 1294 sal_Bool SdrPaintView::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll) 1295 { 1296 SetDefaultAttr(rSet,bReplaceAll); 1297 return sal_True; 1298 } 1299 1300 SfxStyleSheet* SdrPaintView::GetStyleSheet() const // SfxStyleSheet* SdrPaintView::GetStyleSheet(sal_Bool& rOk) const 1301 { 1302 //rOk=sal_True; 1303 return GetDefaultStyleSheet(); 1304 } 1305 1306 sal_Bool SdrPaintView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr) 1307 { 1308 SetDefaultStyleSheet(pStyleSheet,bDontRemoveHardAttr); 1309 return sal_True; 1310 } 1311 1312 //////////////////////////////////////////////////////////////////////////////////////////////////// 1313 1314 #ifdef DBG_UTIL 1315 void SdrPaintView::ShowItemBrowser(sal_Bool bShow) 1316 { 1317 if (bShow) { 1318 if (pItemBrowser==NULL) { 1319 pItemBrowser=new SdrItemBrowser(*(SdrView*)this); 1320 pItemBrowser->SetFloatingMode(sal_True); 1321 } 1322 pItemBrowser->Show(); 1323 pItemBrowser->GrabFocus(); 1324 } else { 1325 if (pItemBrowser!=NULL) { 1326 pItemBrowser->Hide(); 1327 delete pItemBrowser; 1328 pItemBrowser=NULL; 1329 } 1330 } 1331 } 1332 #endif 1333 1334 void SdrPaintView::MakeVisible(const Rectangle& rRect, Window& rWin) 1335 { 1336 MapMode aMap(rWin.GetMapMode()); 1337 Size aActualSize(rWin.GetOutputSize()); 1338 1339 if( aActualSize.Height() > 0 && aActualSize.Width() > 0 ) 1340 { 1341 Size aNewSize(rRect.GetSize()); 1342 sal_Bool bNewScale=sal_False; 1343 sal_Bool bNeedMoreX=aNewSize.Width()>aActualSize.Width(); 1344 sal_Bool bNeedMoreY=aNewSize.Height()>aActualSize.Height(); 1345 if (bNeedMoreX || bNeedMoreY) 1346 { 1347 bNewScale=sal_True; 1348 // Neuen MapMode (Size+Org) setzen und dabei alles invalidieren 1349 Fraction aXFact(aNewSize.Width(),aActualSize.Width()); 1350 Fraction aYFact(aNewSize.Height(),aActualSize.Height()); 1351 if (aYFact>aXFact) aXFact=aYFact; 1352 aXFact*=aMap.GetScaleX(); 1353 aXFact.ReduceInaccurate(10); // Um Ueberlaeufe und BigInt-Mapping zu vermeiden 1354 aMap.SetScaleX(aXFact); 1355 aMap.SetScaleY(aYFact); 1356 rWin.SetMapMode(aMap); 1357 aActualSize=rWin.GetOutputSize(); 1358 } 1359 Point aOrg(aMap.GetOrigin()); 1360 long dx=0,dy=0; 1361 long l=-aOrg.X(); 1362 long r=-aOrg.X()+aActualSize.Width()-1; 1363 long o=-aOrg.Y(); 1364 long u=-aOrg.Y()+aActualSize.Height()-1; 1365 if (l>rRect.Left()) dx=rRect.Left()-l; 1366 else if (r<rRect.Right()) dx=rRect.Right()-r; 1367 if (o>rRect.Top()) dy=rRect.Top()-o; 1368 else if (u<rRect.Bottom()) dy=rRect.Bottom()-u; 1369 aMap.SetOrigin(Point(aOrg.X()-dx,aOrg.Y()-dy)); 1370 if (!bNewScale) { 1371 if (dx!=0 || dy!=0) { 1372 rWin.Scroll(-dx,-dy); 1373 rWin.SetMapMode(aMap); 1374 rWin.Update(); 1375 } 1376 } else { 1377 rWin.SetMapMode(aMap); 1378 InvalidateOneWin(rWin); 1379 } 1380 } 1381 } 1382 1383 void SdrPaintView::DoConnect(SdrOle2Obj* /*pOleObj*/) 1384 { 1385 } 1386 1387 void SdrPaintView::SetAnimationEnabled( sal_Bool bEnable ) 1388 { 1389 SetAnimationMode( bEnable ? SDR_ANIMATION_ANIMATE : SDR_ANIMATION_DISABLE ); 1390 } 1391 1392 void SdrPaintView::SetAnimationPause( bool bSet ) 1393 { 1394 if((bool)bAnimationPause != bSet) 1395 { 1396 bAnimationPause = bSet; 1397 1398 if(mpPageView) 1399 { 1400 for(sal_uInt32 b(0L); b < mpPageView->PageWindowCount(); b++) 1401 { 1402 const SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b)); 1403 sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact(); 1404 sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator(); 1405 1406 if(rAnimator.IsPaused() != bSet) 1407 { 1408 rAnimator.SetPaused(bSet); 1409 } 1410 } 1411 } 1412 } 1413 } 1414 1415 void SdrPaintView::SetAnimationMode( const SdrAnimationMode eMode ) 1416 { 1417 eAnimationMode = eMode; 1418 } 1419 1420 void SdrPaintView::VisAreaChanged(const OutputDevice* pOut) 1421 { 1422 if(mpPageView) 1423 { 1424 if (pOut) 1425 { 1426 SdrPageWindow* pWindow = mpPageView->FindPageWindow(*((OutputDevice*)pOut)); 1427 1428 if(pWindow) 1429 { 1430 VisAreaChanged(*pWindow); 1431 } 1432 } 1433 else 1434 { 1435 for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++) 1436 { 1437 VisAreaChanged(*mpPageView->GetPageWindow(a)); 1438 } 1439 } 1440 } 1441 } 1442 1443 void SdrPaintView::VisAreaChanged(const SdrPageWindow& /*rWindow*/) 1444 { 1445 // notify SfxListener 1446 Broadcast(SvxViewHint(SvxViewHint::SVX_HINT_VIEWCHANGED)); 1447 } 1448 1449 const svtools::ColorConfig& SdrPaintView::getColorConfig() const 1450 { 1451 return maColorConfig; 1452 } 1453 1454 void SdrPaintView::onChangeColorConfig() 1455 { 1456 SetGridColor( Color( maColorConfig.GetColorValue( svtools::DRAWGRID ).nColor ) ); 1457 } 1458 1459 void SdrPaintView::SetGridColor( Color aColor ) 1460 { 1461 maGridColor = aColor; 1462 } 1463 1464 Color SdrPaintView::GetGridColor() const 1465 { 1466 return maGridColor; 1467 } 1468 1469 // #103834# Set background color for svx at SdrPageViews 1470 void SdrPaintView::SetApplicationBackgroundColor(Color aBackgroundColor) 1471 { 1472 if(mpPageView) 1473 { 1474 mpPageView->SetApplicationBackgroundColor(aBackgroundColor); 1475 } 1476 } 1477 1478 // #103911# Set document color for svx at SdrPageViews 1479 void SdrPaintView::SetApplicationDocumentColor(Color aDocumentColor) 1480 { 1481 if(mpPageView) 1482 { 1483 mpPageView->SetApplicationDocumentColor(aDocumentColor); 1484 } 1485 } 1486 1487 // #114898# 1488 bool SdrPaintView::IsBufferedOutputAllowed() const 1489 { 1490 return (mbBufferedOutputAllowed && maDrawinglayerOpt.IsPaintBuffer()); 1491 } 1492 1493 // #114898# 1494 void SdrPaintView::SetBufferedOutputAllowed(bool bNew) 1495 { 1496 if(bNew != (bool)mbBufferedOutputAllowed) 1497 { 1498 mbBufferedOutputAllowed = bNew; 1499 } 1500 } 1501 1502 bool SdrPaintView::IsBufferedOverlayAllowed() const 1503 { 1504 return (mbBufferedOverlayAllowed && maDrawinglayerOpt.IsOverlayBuffer()); 1505 } 1506 1507 void SdrPaintView::SetBufferedOverlayAllowed(bool bNew) 1508 { 1509 if(bNew != (bool)mbBufferedOverlayAllowed) 1510 { 1511 mbBufferedOverlayAllowed = bNew; 1512 } 1513 } 1514 1515 sal_Bool SdrPaintView::IsPagePaintingAllowed() const 1516 { 1517 return mbPagePaintingAllowed; 1518 } 1519 1520 void SdrPaintView::SetPagePaintingAllowed(bool bNew) 1521 { 1522 if(bNew != (bool)mbPagePaintingAllowed) 1523 { 1524 mbPagePaintingAllowed = bNew; 1525 } 1526 } 1527 1528 // #i38135# Sets the timer for Object animations and restarts. 1529 void SdrPaintView::SetAnimationTimer(sal_uInt32 nTime) 1530 { 1531 if(mpPageView) 1532 { 1533 // first, reset all timers at all windows to 0L 1534 for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++) 1535 { 1536 const SdrPageWindow& rPageWindow = *mpPageView->GetPageWindow(a); 1537 sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact(); 1538 sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator(); 1539 rAnimator.SetTime(nTime); 1540 } 1541 } 1542 } 1543 1544 // eof 1545