xref: /aoo41x/main/svx/source/svdraw/svdpntv.cxx (revision a56bd57b)
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 		if(IsTextEdit() && GetSdrPageView())
916 		{
917 			static_cast< SdrView* >(this)->TextEditDrawing(rPaintWindow);
918 		}
919 
920 		// draw Overlay, also to PreRender device if exists
921 		rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion());
922 
923 		// output PreRendering
924 		rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion());
925 	}
926 }
927 
928 ////////////////////////////////////////////////////////////////////////////////////////////////////
929 
930 SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect)
931 {
932 	// #i74769# use BeginCompleteRedraw() as common base
933 	SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut);
934 	OSL_ENSURE(pPaintWindow, "SdrPaintView::BeginDrawLayers: No SdrPaintWindow (!)");
935 
936 	if(mpPageView)
937 	{
938 		SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow);
939 
940 		if(pKnownTarget)
941 		{
942 			// #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region
943 			// rReg may be made more granular (fine) with using it. Normally, rReg
944 			// does come from Window::Paint() anyways and thus is based on a single
945 			// rectangle which was derived from exactly that repaint region
946 			Region aOptimizedRepaintRegion(rReg);
947 
948 			// #i76114# Intersecting the region with the Window's paint region is disabled
949 			// for print preview in Calc, because the intersection can be empty (if the paint
950 			// region is outside of the table area of the page), and then no clip region
951 			// would be set.
952 			if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect)
953 			{
954 				Window* pWindow = (Window*)pOut;
955 
956 				if(pWindow->IsInPaint())
957 				{
958 					if(!pWindow->GetPaintRegion().IsEmpty())
959 					{
960 						aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion());
961 
962 #ifdef DBG_UTIL
963 						// #i74769# test-paint repaint region
964 						static bool bDoPaintForVisualControl(false);
965 						if(bDoPaintForVisualControl)
966 						{
967 							RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
968 							Rectangle aRegionRectangle;
969 
970 							while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
971 							{
972 								pWindow->SetLineColor(COL_LIGHTGREEN);
973 								pWindow->SetFillColor();
974 								pWindow->DrawRect(aRegionRectangle);
975 							}
976 
977 							aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
978 						}
979 #endif
980 					}
981 				}
982 			}
983 
984 			// prepare redraw
985 			pKnownTarget->PrepareRedraw(aOptimizedRepaintRegion);
986 
987 			// remember prepared SdrPageWindow
988 			mpPageView->setPreparedPageWindow(pKnownTarget);
989 		}
990 	}
991 
992 	return pPaintWindow;
993 }
994 
995 void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer)
996 {
997 	// #i74769# use EndCompleteRedraw() as common base
998 	EndCompleteRedraw(rPaintWindow, bPaintFormLayer);
999 
1000 	if(mpPageView)
1001 	{
1002 		// forget prepared SdrPageWindow
1003 		mpPageView->setPreparedPageWindow(0);
1004 	}
1005 }
1006 
1007 ////////////////////////////////////////////////////////////////////////////////////////////////////
1008 
1009 void SdrPaintView::ImpFormLayerDrawing(SdrPaintWindow& rPaintWindow) const
1010 {
1011 	if(mpPageView)
1012 	{
1013 		SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(rPaintWindow);
1014 
1015 		if(pKnownTarget)
1016 		{
1017 			const SdrModel& rModel = *(GetModel());
1018 			const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin();
1019 			const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False);
1020 
1021 			// BUFFERED use GetTargetOutputDevice() now, it may be targeted to VDevs, too
1022 			// need to set PreparedPageWindow to make DrawLayer use the correct ObjectContact
1023 			mpPageView->setPreparedPageWindow(pKnownTarget);
1024 			mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice());
1025 			mpPageView->setPreparedPageWindow(0);
1026 		}
1027 	}
1028 }
1029 
1030 ////////////////////////////////////////////////////////////////////////////////////////////////////
1031 
1032 sal_Bool SdrPaintView::KeyInput(const KeyEvent& /*rKEvt*/, Window* /*pWin*/)
1033 {
1034 	return sal_False;
1035 }
1036 
1037 void SdrPaintView::GlueInvalidate() const
1038 {
1039 	const sal_uInt32 nWindowCount(PaintWindowCount());
1040 
1041 	for(sal_uInt32 nWinNum(0L); nWinNum < nWindowCount; nWinNum++)
1042 	{
1043 		SdrPaintWindow* pPaintWindow = GetPaintWindow(nWinNum);
1044 
1045 		if(pPaintWindow->OutputToWindow())
1046 		{
1047 			OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
1048 
1049 			if(mpPageView)
1050 			{
1051 				const SdrObjList* pOL=mpPageView->GetObjList();
1052 				sal_uIntPtr nObjAnz=pOL->GetObjCount();
1053 				for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
1054 					const SdrObject* pObj=pOL->GetObj(nObjNum);
1055 					const SdrGluePointList* pGPL=pObj->GetGluePointList();
1056 					if (pGPL!=NULL && pGPL->GetCount()!=0) {
1057 						pGPL->Invalidate((Window&)rOutDev, pObj);
1058 					}
1059 				}
1060 			}
1061 		}
1062 	}
1063 }
1064 
1065 void SdrPaintView::InvalidateAllWin()
1066 {
1067 	const sal_uInt32 nWindowCount(PaintWindowCount());
1068 
1069 	for(sal_uInt32 a(0L); a < nWindowCount; a++)
1070 	{
1071 		SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
1072 
1073 		if(pPaintWindow->OutputToWindow())
1074 		{
1075 			InvalidateOneWin((Window&)pPaintWindow->GetOutputDevice());
1076 		}
1077 	}
1078 }
1079 
1080 void SdrPaintView::InvalidateAllWin(const Rectangle& rRect, sal_Bool bPlus1Pix)
1081 {
1082 	const sal_uInt32 nWindowCount(PaintWindowCount());
1083 
1084 	for(sal_uInt32 a(0L); a < nWindowCount; a++)
1085 	{
1086 		SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
1087 
1088 		if(pPaintWindow->OutputToWindow())
1089 		{
1090 			OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
1091 			Rectangle aRect(rRect);
1092 
1093 			if(bPlus1Pix)
1094 			{
1095 				Size aPixSiz(1,1);
1096 				Size aSiz(rOutDev.PixelToLogic(aPixSiz));
1097 				aRect.Left	()-=aSiz.Width();
1098 				aRect.Top	()-=aSiz.Height();
1099 				aRect.Right ()+=aSiz.Width();
1100 				aRect.Bottom()+=aSiz.Height();
1101 			}
1102 
1103 			Point aOrg(rOutDev.GetMapMode().GetOrigin());
1104 			aOrg.X()=-aOrg.X(); aOrg.Y()=-aOrg.Y();
1105 			Rectangle aOutRect(aOrg, rOutDev.GetOutputSize());
1106 
1107 			if (aRect.IsOver(aOutRect))
1108 			{
1109 				InvalidateOneWin((Window&)rOutDev, aRect);
1110 			}
1111 		}
1112 	}
1113 }
1114 
1115 void SdrPaintView::InvalidateOneWin(Window& rWin)
1116 {
1117 	// #111096#
1118 	// do not erase background, that causes flicker (!)
1119 	rWin.Invalidate(INVALIDATE_NOERASE);
1120 }
1121 
1122 void SdrPaintView::InvalidateOneWin(Window& rWin, const Rectangle& rRect)
1123 {
1124 	// #111096#
1125 	// do not erase background, that causes flicker (!)
1126 	rWin.Invalidate(rRect, INVALIDATE_NOERASE);
1127 }
1128 
1129 void SdrPaintView::LeaveOneGroup()
1130 {
1131 	if(mpPageView)
1132 	{
1133 		mpPageView->LeaveOneGroup();
1134 	}
1135 }
1136 
1137 void SdrPaintView::LeaveAllGroup()
1138 {
1139 	if(mpPageView)
1140 	{
1141 		mpPageView->LeaveAllGroup();
1142 	}
1143 }
1144 
1145 bool SdrPaintView::IsGroupEntered() const
1146 {
1147 	if(mpPageView)
1148 	{
1149 		return (mpPageView->GetEnteredLevel() != 0);
1150 	}
1151 
1152 	return false;
1153 }
1154 
1155 void SdrPaintView::SetNotPersistDefaultAttr(const SfxItemSet& rAttr, sal_Bool /*bReplaceAll*/)
1156 {
1157 	// bReplaceAll hat hier keinerlei Wirkung
1158 	sal_Bool bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool();
1159 	const SfxPoolItem *pPoolItem=NULL;
1160 	if (rAttr.GetItemState(SDRATTR_LAYERID,sal_True,&pPoolItem)==SFX_ITEM_SET) {
1161 		SdrLayerID nLayerId=((const SdrLayerIdItem*)pPoolItem)->GetValue();
1162 		const SdrLayer* pLayer=pMod->GetLayerAdmin().GetLayerPerID(nLayerId);
1163 		if (pLayer!=NULL) {
1164 			if (bMeasure) aMeasureLayer=pLayer->GetName();
1165 			else aAktLayer=pLayer->GetName();
1166 		}
1167 	}
1168 	if (rAttr.GetItemState(SDRATTR_LAYERNAME,sal_True,&pPoolItem)==SFX_ITEM_SET) {
1169 		if (bMeasure) aMeasureLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue();
1170 		else aAktLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue();
1171 	}
1172 }
1173 
1174 void SdrPaintView::MergeNotPersistDefaultAttr(SfxItemSet& rAttr, sal_Bool /*bOnlyHardAttr*/) const
1175 {
1176 	// bOnlyHardAttr hat hier keinerlei Wirkung
1177 	sal_Bool bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool();
1178 	const XubString& aNam=bMeasure?aMeasureLayer:aAktLayer;
1179 	rAttr.Put(SdrLayerNameItem(aNam));
1180 	SdrLayerID nLayer=pMod->GetLayerAdmin().GetLayerID(aNam,sal_True);
1181 	if (nLayer!=SDRLAYER_NOTFOUND) {
1182 		rAttr.Put(SdrLayerIdItem(nLayer));
1183 	}
1184 }
1185 
1186 void SdrPaintView::SetDefaultAttr(const SfxItemSet& rAttr, sal_Bool bReplaceAll)
1187 {
1188 #ifdef DBG_UTIL
1189 	{
1190 		sal_Bool bHasEEFeatureItems=sal_False;
1191 		SfxItemIter aIter(rAttr);
1192 		const SfxPoolItem* pItem=aIter.FirstItem();
1193 		while (!bHasEEFeatureItems && pItem!=NULL) {
1194 			if (!IsInvalidItem(pItem)) {
1195 				sal_uInt16 nW=pItem->Which();
1196 				if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=sal_True;
1197 			}
1198 			pItem=aIter.NextItem();
1199 		}
1200 
1201 		if(bHasEEFeatureItems)
1202 		{
1203 			String aMessage;
1204 			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.");
1205 			InfoBox(NULL, aMessage).Execute();
1206 		}
1207 	}
1208 #endif
1209 	if (bReplaceAll) aDefaultAttr.Set(rAttr);
1210 	else aDefaultAttr.Put(rAttr,sal_False); // FALSE= InvalidItems nicht als Default, sondern als "Loecher" betrachten
1211 	SetNotPersistDefaultAttr(rAttr,bReplaceAll);
1212 #ifdef DBG_UTIL
1213 	if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1214 #endif
1215 }
1216 
1217 void SdrPaintView::SetDefaultStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
1218 {
1219 	if (pDefaultStyleSheet)
1220         EndListening(*pDefaultStyleSheet);
1221     pDefaultStyleSheet=pStyleSheet;
1222     if (pDefaultStyleSheet)
1223         StartListening(*pDefaultStyleSheet);
1224 
1225 	if (pStyleSheet!=NULL && !bDontRemoveHardAttr) {
1226 		SfxWhichIter aIter(pStyleSheet->GetItemSet());
1227 		sal_uInt16 nWhich=aIter.FirstWhich();
1228 		while (nWhich!=0) {
1229 			if (pStyleSheet->GetItemSet().GetItemState(nWhich,sal_True)==SFX_ITEM_SET) {
1230 				aDefaultAttr.ClearItem(nWhich);
1231 			}
1232 			nWhich=aIter.NextWhich();
1233 		}
1234 	}
1235 #ifdef DBG_UTIL
1236 	if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1237 #endif
1238 }
1239 
1240 /* new interface src537 */
1241 sal_Bool SdrPaintView::GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr) const
1242 {
1243 	if(bOnlyHardAttr || !pDefaultStyleSheet)
1244 	{
1245 		rTargetSet.Put(aDefaultAttr, sal_False);
1246 	}
1247 	else
1248 	{
1249 		// sonst DefStyleSheet dazumergen
1250 		rTargetSet.Put(pDefaultStyleSheet->GetItemSet(), sal_False);
1251 		rTargetSet.Put(aDefaultAttr, sal_False);
1252 	}
1253 	MergeNotPersistDefaultAttr(rTargetSet, bOnlyHardAttr);
1254 	return sal_True;
1255 }
1256 
1257 sal_Bool SdrPaintView::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
1258 {
1259 	SetDefaultAttr(rSet,bReplaceAll);
1260 	return sal_True;
1261 }
1262 
1263 SfxStyleSheet* SdrPaintView::GetStyleSheet() const // SfxStyleSheet* SdrPaintView::GetStyleSheet(sal_Bool& rOk) const
1264 {
1265 	//rOk=sal_True;
1266 	return GetDefaultStyleSheet();
1267 }
1268 
1269 sal_Bool SdrPaintView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
1270 {
1271 	SetDefaultStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1272 	return sal_True;
1273 }
1274 
1275 ////////////////////////////////////////////////////////////////////////////////////////////////////
1276 
1277 #ifdef DBG_UTIL
1278 void SdrPaintView::ShowItemBrowser(sal_Bool bShow)
1279 {
1280 	if (bShow) {
1281 		if (pItemBrowser==NULL) {
1282 			pItemBrowser=new SdrItemBrowser(*(SdrView*)this);
1283 			pItemBrowser->SetFloatingMode(sal_True);
1284 		}
1285 		pItemBrowser->Show();
1286 		pItemBrowser->GrabFocus();
1287 	} else {
1288 		if (pItemBrowser!=NULL) {
1289 			pItemBrowser->Hide();
1290 			delete pItemBrowser;
1291 			pItemBrowser=NULL;
1292 		}
1293 	}
1294 }
1295 #endif
1296 
1297 void SdrPaintView::MakeVisible(const Rectangle& rRect, Window& rWin)
1298 {
1299 	MapMode aMap(rWin.GetMapMode());
1300 	Size aActualSize(rWin.GetOutputSize());
1301 
1302 	if( aActualSize.Height() > 0 && aActualSize.Width() > 0 )
1303 	{
1304 		Size aNewSize(rRect.GetSize());
1305 		sal_Bool bNewScale=sal_False;
1306 		sal_Bool bNeedMoreX=aNewSize.Width()>aActualSize.Width();
1307 		sal_Bool bNeedMoreY=aNewSize.Height()>aActualSize.Height();
1308 		if (bNeedMoreX || bNeedMoreY)
1309 		{
1310 			bNewScale=sal_True;
1311 			// Neuen MapMode (Size+Org) setzen und dabei alles invalidieren
1312 			Fraction aXFact(aNewSize.Width(),aActualSize.Width());
1313 			Fraction aYFact(aNewSize.Height(),aActualSize.Height());
1314 			if (aYFact>aXFact) aXFact=aYFact;
1315 			aXFact*=aMap.GetScaleX();
1316 			aXFact.ReduceInaccurate(10); // Um Ueberlaeufe und BigInt-Mapping zu vermeiden
1317 			aMap.SetScaleX(aXFact);
1318 			aMap.SetScaleY(aYFact);
1319 			rWin.SetMapMode(aMap);
1320 			aActualSize=rWin.GetOutputSize();
1321 		}
1322 		Point aOrg(aMap.GetOrigin());
1323 		long dx=0,dy=0;
1324 		long l=-aOrg.X();
1325 		long r=-aOrg.X()+aActualSize.Width()-1;
1326 		long o=-aOrg.Y();
1327 		long u=-aOrg.Y()+aActualSize.Height()-1;
1328 		if (l>rRect.Left()) dx=rRect.Left()-l;
1329 		else if (r<rRect.Right()) dx=rRect.Right()-r;
1330 		if (o>rRect.Top()) dy=rRect.Top()-o;
1331 		else if (u<rRect.Bottom()) dy=rRect.Bottom()-u;
1332 		aMap.SetOrigin(Point(aOrg.X()-dx,aOrg.Y()-dy));
1333 		if (!bNewScale) {
1334 			if (dx!=0 || dy!=0) {
1335 				rWin.Scroll(-dx,-dy);
1336 				rWin.SetMapMode(aMap);
1337 				rWin.Update();
1338 			}
1339 		} else {
1340 			rWin.SetMapMode(aMap);
1341 			InvalidateOneWin(rWin);
1342 		}
1343 	}
1344 }
1345 
1346 void SdrPaintView::DoConnect(SdrOle2Obj* /*pOleObj*/)
1347 {
1348 }
1349 
1350 void SdrPaintView::SetAnimationEnabled( sal_Bool bEnable )
1351 {
1352 	SetAnimationMode( bEnable ? SDR_ANIMATION_ANIMATE : SDR_ANIMATION_DISABLE );
1353 }
1354 
1355 void SdrPaintView::SetAnimationPause( bool bSet )
1356 {
1357 	if((bool)bAnimationPause != bSet)
1358 	{
1359 		bAnimationPause = bSet;
1360 
1361 		if(mpPageView)
1362 		{
1363 			for(sal_uInt32 b(0L); b < mpPageView->PageWindowCount(); b++)
1364 			{
1365 				const SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b));
1366 				sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact();
1367 				sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator();
1368 
1369 				if(rAnimator.IsPaused() != bSet)
1370 				{
1371 					rAnimator.SetPaused(bSet);
1372 				}
1373 			}
1374 		}
1375 	}
1376 }
1377 
1378 void SdrPaintView::SetAnimationMode( const SdrAnimationMode eMode )
1379 {
1380 	eAnimationMode = eMode;
1381 }
1382 
1383 void SdrPaintView::VisAreaChanged(const OutputDevice* pOut)
1384 {
1385 	if(mpPageView)
1386 	{
1387 		if (pOut)
1388 		{
1389 			SdrPageWindow* pWindow = mpPageView->FindPageWindow(*((OutputDevice*)pOut));
1390 
1391 			if(pWindow)
1392 			{
1393 				VisAreaChanged(*pWindow);
1394 			}
1395 		}
1396 		else
1397 		{
1398 			for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++)
1399 			{
1400 				VisAreaChanged(*mpPageView->GetPageWindow(a));
1401 			}
1402 		}
1403 	}
1404 }
1405 
1406 void SdrPaintView::VisAreaChanged(const SdrPageWindow& /*rWindow*/)
1407 {
1408     // notify SfxListener
1409     Broadcast(SvxViewHint(SvxViewHint::SVX_HINT_VIEWCHANGED));
1410 }
1411 
1412 const svtools::ColorConfig& SdrPaintView::getColorConfig() const
1413 {
1414 	return maColorConfig;
1415 }
1416 
1417 void SdrPaintView::onChangeColorConfig()
1418 {
1419     SetGridColor( Color( maColorConfig.GetColorValue( svtools::DRAWGRID ).nColor ) );
1420 }
1421 
1422 void SdrPaintView::SetGridColor( Color aColor )
1423 {
1424 	maGridColor = aColor;
1425 }
1426 
1427 Color SdrPaintView::GetGridColor() const
1428 {
1429 	return maGridColor;
1430 }
1431 
1432 // #103834# Set background color for svx at SdrPageViews
1433 void SdrPaintView::SetApplicationBackgroundColor(Color aBackgroundColor)
1434 {
1435 	if(mpPageView)
1436 	{
1437 		mpPageView->SetApplicationBackgroundColor(aBackgroundColor);
1438 	}
1439 }
1440 
1441 // #103911# Set document color for svx at SdrPageViews
1442 void SdrPaintView::SetApplicationDocumentColor(Color aDocumentColor)
1443 {
1444 	if(mpPageView)
1445 	{
1446 		mpPageView->SetApplicationDocumentColor(aDocumentColor);
1447 	}
1448 }
1449 
1450 // #114898#
1451 bool SdrPaintView::IsBufferedOutputAllowed() const
1452 {
1453 	return (mbBufferedOutputAllowed && maDrawinglayerOpt.IsPaintBuffer());
1454 }
1455 
1456 // #114898#
1457 void SdrPaintView::SetBufferedOutputAllowed(bool bNew)
1458 {
1459 	if(bNew != (bool)mbBufferedOutputAllowed)
1460 	{
1461 		mbBufferedOutputAllowed = bNew;
1462 	}
1463 }
1464 
1465 bool SdrPaintView::IsBufferedOverlayAllowed() const
1466 {
1467 	return (mbBufferedOverlayAllowed && maDrawinglayerOpt.IsOverlayBuffer());
1468 }
1469 
1470 void SdrPaintView::SetBufferedOverlayAllowed(bool bNew)
1471 {
1472 	if(bNew != (bool)mbBufferedOverlayAllowed)
1473 	{
1474 		mbBufferedOverlayAllowed = bNew;
1475 	}
1476 }
1477 
1478 sal_Bool SdrPaintView::IsPagePaintingAllowed() const
1479 {
1480 	return mbPagePaintingAllowed;
1481 }
1482 
1483 void SdrPaintView::SetPagePaintingAllowed(bool bNew)
1484 {
1485 	if(bNew != (bool)mbPagePaintingAllowed)
1486 	{
1487 		mbPagePaintingAllowed = bNew;
1488 	}
1489 }
1490 
1491 // #i38135# Sets the timer for Object animations and restarts.
1492 void SdrPaintView::SetAnimationTimer(sal_uInt32 nTime)
1493 {
1494 	if(mpPageView)
1495 	{
1496 		// first, reset all timers at all windows to 0L
1497 		for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++)
1498 		{
1499 			const SdrPageWindow& rPageWindow = *mpPageView->GetPageWindow(a);
1500 			sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact();
1501 			sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator();
1502 			rAnimator.SetTime(nTime);
1503 		}
1504 	}
1505 }
1506 
1507 // eof
1508