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