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