1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofpageview.hxx>
31*cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx>
32*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
33*cdf0e10cSrcweir #include <svx/svdpage.hxx>
34*cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
35*cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx>
36*cdf0e10cSrcweir #include <svx/svdview.hxx>
37*cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx>
38*cdf0e10cSrcweir #include <svx/sdr/animation/objectanimator.hxx>
39*cdf0e10cSrcweir #include <svx/sdr/event/eventhandler.hxx>
40*cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx>
41*cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
42*cdf0e10cSrcweir #include <drawinglayer/processor2d/vclprocessor2d.hxx>
43*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
44*cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
45*cdf0e10cSrcweir #include <svx/sdr/contact/objectcontacttools.hxx>
46*cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp>
47*cdf0e10cSrcweir #include <svx/unoapi.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir using namespace com::sun::star;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir namespace sdr
56*cdf0e10cSrcweir {
57*cdf0e10cSrcweir 	namespace contact
58*cdf0e10cSrcweir 	{
59*cdf0e10cSrcweir 		// internal access to SdrPage of SdrPageView
60*cdf0e10cSrcweir 		SdrPage* ObjectContactOfPageView::GetSdrPage() const
61*cdf0e10cSrcweir 		{
62*cdf0e10cSrcweir 			return GetPageWindow().GetPageView().GetPage();
63*cdf0e10cSrcweir 		}
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 		ObjectContactOfPageView::ObjectContactOfPageView(SdrPageWindow& rPageWindow)
66*cdf0e10cSrcweir 		:	ObjectContact(),
67*cdf0e10cSrcweir 			mrPageWindow(rPageWindow)
68*cdf0e10cSrcweir 		{
69*cdf0e10cSrcweir 			// init PreviewRenderer flag
70*cdf0e10cSrcweir 			setPreviewRenderer(((SdrPaintView&)rPageWindow.GetPageView().GetView()).IsPreviewRenderer());
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 			// init timer
73*cdf0e10cSrcweir 			SetTimeout(1);
74*cdf0e10cSrcweir 			Stop();
75*cdf0e10cSrcweir 		}
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 		ObjectContactOfPageView::~ObjectContactOfPageView()
78*cdf0e10cSrcweir 		{
79*cdf0e10cSrcweir 			// execute missing LazyInvalidates and stop timer
80*cdf0e10cSrcweir 			Timeout();
81*cdf0e10cSrcweir 		}
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 		// LazyInvalidate request. Take action.
84*cdf0e10cSrcweir 		void ObjectContactOfPageView::setLazyInvalidate(ViewObjectContact& /*rVOC*/)
85*cdf0e10cSrcweir 		{
86*cdf0e10cSrcweir 			// do NOT call parent, but remember that something is to do by
87*cdf0e10cSrcweir 			// starting the LazyInvalidateTimer
88*cdf0e10cSrcweir 			Start();
89*cdf0e10cSrcweir 		}
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 		// call this to support evtl. preparations for repaint
92*cdf0e10cSrcweir 		void ObjectContactOfPageView::PrepareProcessDisplay()
93*cdf0e10cSrcweir 		{
94*cdf0e10cSrcweir 			if(IsActive())
95*cdf0e10cSrcweir 			{
96*cdf0e10cSrcweir 				static bool bInvalidateDuringPaint(true);
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 				if(bInvalidateDuringPaint)
99*cdf0e10cSrcweir 				{
100*cdf0e10cSrcweir 					// there are still non-triggered LazyInvalidate events, trigger these
101*cdf0e10cSrcweir 					Timeout();
102*cdf0e10cSrcweir 				}
103*cdf0e10cSrcweir 			}
104*cdf0e10cSrcweir 		}
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 		// From baseclass Timer, the timeout call triggered by te LazyInvalidate mechanism
107*cdf0e10cSrcweir 		void ObjectContactOfPageView::Timeout()
108*cdf0e10cSrcweir 		{
109*cdf0e10cSrcweir 			// stop the timer
110*cdf0e10cSrcweir 			Stop();
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 			// invalidate all LazyInvalidate VOCs new situations
113*cdf0e10cSrcweir 			const sal_uInt32 nVOCCount(getViewObjectContactCount());
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 			for(sal_uInt32 a(0); a < nVOCCount; a++)
116*cdf0e10cSrcweir 			{
117*cdf0e10cSrcweir 				ViewObjectContact* pCandidate = getViewObjectContact(a);
118*cdf0e10cSrcweir 				pCandidate->triggerLazyInvalidate();
119*cdf0e10cSrcweir 			}
120*cdf0e10cSrcweir 		}
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 		// Process the whole displaying
123*cdf0e10cSrcweir 		void ObjectContactOfPageView::ProcessDisplay(DisplayInfo& rDisplayInfo)
124*cdf0e10cSrcweir 		{
125*cdf0e10cSrcweir 			const SdrPage* pStartPage = GetSdrPage();
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 			if(pStartPage && !rDisplayInfo.GetProcessLayers().IsEmpty())
128*cdf0e10cSrcweir 			{
129*cdf0e10cSrcweir 				const ViewContact& rDrawPageVC = pStartPage->GetViewContact();
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 				if(rDrawPageVC.GetObjectCount())
132*cdf0e10cSrcweir 				{
133*cdf0e10cSrcweir 					DoProcessDisplay(rDisplayInfo);
134*cdf0e10cSrcweir 				}
135*cdf0e10cSrcweir 			}
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 			// after paint take care of the evtl. scheduled asynchronious commands.
138*cdf0e10cSrcweir 			// Do this by resetting the timer contained there. Thus, after the paint
139*cdf0e10cSrcweir 			// that timer will be triggered and the events will be executed.
140*cdf0e10cSrcweir 			if(HasEventHandler())
141*cdf0e10cSrcweir 			{
142*cdf0e10cSrcweir 				sdr::event::TimerEventHandler& rEventHandler = GetEventHandler();
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 				if(!rEventHandler.IsEmpty())
145*cdf0e10cSrcweir 				{
146*cdf0e10cSrcweir 					rEventHandler.Restart();
147*cdf0e10cSrcweir 				}
148*cdf0e10cSrcweir 			}
149*cdf0e10cSrcweir 		}
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 		// Process the whole displaying. Only use given DsiplayInfo, do not access other
152*cdf0e10cSrcweir 		// OutputDevices then the given ones.
153*cdf0e10cSrcweir 		void ObjectContactOfPageView::DoProcessDisplay(DisplayInfo& rDisplayInfo)
154*cdf0e10cSrcweir 		{
155*cdf0e10cSrcweir 			// visualize entered group when that feature is switched on and it's not
156*cdf0e10cSrcweir 			// a print output. #i29129# No ghosted display for printing.
157*cdf0e10cSrcweir 			sal_Bool bVisualizeEnteredGroup(DoVisualizeEnteredGroup() && !isOutputToPrinter());
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 			// Visualize entered groups: Set to ghosted as default
160*cdf0e10cSrcweir 			// start. Do this only for the DrawPage, not for MasterPages
161*cdf0e10cSrcweir 			if(bVisualizeEnteredGroup)
162*cdf0e10cSrcweir 			{
163*cdf0e10cSrcweir 				rDisplayInfo.SetGhostedDrawMode();
164*cdf0e10cSrcweir 			}
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 			// #114359# save old and set clip region
167*cdf0e10cSrcweir 			OutputDevice* pOutDev = TryToGetOutputDevice();
168*cdf0e10cSrcweir 			OSL_ENSURE(0 != pOutDev, "ObjectContactOfPageView without OutDev, someone has overloaded TryToGetOutputDevice wrong (!)");
169*cdf0e10cSrcweir 			sal_Bool bClipRegionPushed(sal_False);
170*cdf0e10cSrcweir 			const Region& rRedrawArea(rDisplayInfo.GetRedrawArea());
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 			if(!rRedrawArea.IsEmpty())
173*cdf0e10cSrcweir 			{
174*cdf0e10cSrcweir 				bClipRegionPushed = sal_True;
175*cdf0e10cSrcweir 				pOutDev->Push(PUSH_CLIPREGION);
176*cdf0e10cSrcweir 				pOutDev->IntersectClipRegion(rRedrawArea);
177*cdf0e10cSrcweir 			}
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 			// Get start node and process DrawPage contents
180*cdf0e10cSrcweir 			const ViewObjectContact& rDrawPageVOContact = GetSdrPage()->GetViewContact().GetViewObjectContact(*this);
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 			// update current ViewInformation2D at the ObjectContact
183*cdf0e10cSrcweir 			const double fCurrentTime(getPrimitiveAnimator().GetTime());
184*cdf0e10cSrcweir 			OutputDevice& rTargetOutDev = GetPageWindow().GetPaintWindow().GetTargetOutputDevice();
185*cdf0e10cSrcweir             basegfx::B2DRange aViewRange;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 			// create ViewRange
188*cdf0e10cSrcweir             if(isOutputToRecordingMetaFile())
189*cdf0e10cSrcweir             {
190*cdf0e10cSrcweir                 if(isOutputToPDFFile() || isOutputToPrinter())
191*cdf0e10cSrcweir                 {
192*cdf0e10cSrcweir                     // #i98402# if it's a PDF export, set the ClipRegion as ViewRange. This is
193*cdf0e10cSrcweir                     // mainly because SW does not use DrawingLayer Page-Oriented and if not doing this,
194*cdf0e10cSrcweir                     // all existing objects will be collected as primitives and processed.
195*cdf0e10cSrcweir                     // OD 2009-03-05 #i99876# perform the same also for SW on printing.
196*cdf0e10cSrcweir                     const Rectangle aLogicClipRectangle(rDisplayInfo.GetRedrawArea().GetBoundRect());
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir                     aViewRange = basegfx::B2DRange(
199*cdf0e10cSrcweir                         aLogicClipRectangle.Left(), aLogicClipRectangle.Top(),
200*cdf0e10cSrcweir 						aLogicClipRectangle.Right(), aLogicClipRectangle.Bottom());
201*cdf0e10cSrcweir                 }
202*cdf0e10cSrcweir             }
203*cdf0e10cSrcweir             else
204*cdf0e10cSrcweir 			{
205*cdf0e10cSrcweir 				// use visible pixels, but transform to world coordinates
206*cdf0e10cSrcweir 				const Size aOutputSizePixel(rTargetOutDev.GetOutputSizePixel());
207*cdf0e10cSrcweir 				aViewRange = basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 				// if a clip region is set, use it
210*cdf0e10cSrcweir 				if(!rDisplayInfo.GetRedrawArea().IsEmpty())
211*cdf0e10cSrcweir 				{
212*cdf0e10cSrcweir 					// get logic clip range and create discrete one
213*cdf0e10cSrcweir 					const Rectangle aLogicClipRectangle(rDisplayInfo.GetRedrawArea().GetBoundRect());
214*cdf0e10cSrcweir 					basegfx::B2DRange aLogicClipRange(
215*cdf0e10cSrcweir 						aLogicClipRectangle.Left(), aLogicClipRectangle.Top(),
216*cdf0e10cSrcweir 						aLogicClipRectangle.Right(), aLogicClipRectangle.Bottom());
217*cdf0e10cSrcweir 					basegfx::B2DRange aDiscreteClipRange(aLogicClipRange);
218*cdf0e10cSrcweir 					aDiscreteClipRange.transform(rTargetOutDev.GetViewTransformation());
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 					// align the discrete one to discrete boundaries (pixel bounds). Also
221*cdf0e10cSrcweir 					// expand X and Y max by one due to Rectangle definition source
222*cdf0e10cSrcweir 					aDiscreteClipRange.expand(basegfx::B2DTuple(
223*cdf0e10cSrcweir 						floor(aDiscreteClipRange.getMinX()),
224*cdf0e10cSrcweir 						floor(aDiscreteClipRange.getMinY())));
225*cdf0e10cSrcweir 					aDiscreteClipRange.expand(basegfx::B2DTuple(
226*cdf0e10cSrcweir 						1.0 + ceil(aDiscreteClipRange.getMaxX()),
227*cdf0e10cSrcweir 						1.0 + ceil(aDiscreteClipRange.getMaxY())));
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 					// intersect current ViewRange with ClipRange
230*cdf0e10cSrcweir 					aViewRange.intersect(aDiscreteClipRange);
231*cdf0e10cSrcweir 				}
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 				// transform to world coordinates
234*cdf0e10cSrcweir                 aViewRange.transform(rTargetOutDev.GetInverseViewTransformation());
235*cdf0e10cSrcweir 			}
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 			// update local ViewInformation2D
238*cdf0e10cSrcweir 			const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
239*cdf0e10cSrcweir 				basegfx::B2DHomMatrix(),
240*cdf0e10cSrcweir 				rTargetOutDev.GetViewTransformation(),
241*cdf0e10cSrcweir 				aViewRange,
242*cdf0e10cSrcweir 				GetXDrawPageForSdrPage(GetSdrPage()),
243*cdf0e10cSrcweir 				fCurrentTime,
244*cdf0e10cSrcweir 				uno::Sequence<beans::PropertyValue>());
245*cdf0e10cSrcweir 			updateViewInformation2D(aNewViewInformation2D);
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 			// get whole Primitive2DSequence; this will already make use of updated ViewInformation2D
248*cdf0e10cSrcweir 			// and may use the MapMode from the Target OutDev in the DisplayInfo
249*cdf0e10cSrcweir 			drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence(rDrawPageVOContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir 			// if there is something to show, use a primitive processor to render it. There
252*cdf0e10cSrcweir 			// is a choice between VCL and Canvas processors currently. The decision is made in
253*cdf0e10cSrcweir 			// createBaseProcessor2DFromOutputDevice and takes into accout things like the
254*cdf0e10cSrcweir 			// Target is a MetaFile, a VDev or something else. The Canvas renderer is triggered
255*cdf0e10cSrcweir 			// currently using the shown boolean. Canvas is not yet the default.
256*cdf0e10cSrcweir 			if(xPrimitiveSequence.hasElements())
257*cdf0e10cSrcweir 			{
258*cdf0e10cSrcweir 				// prepare OutputDevice (historical stuff, maybe soon removed)
259*cdf0e10cSrcweir 				rDisplayInfo.ClearGhostedDrawMode(); // reset, else the VCL-paint with the processor will not do the right thing
260*cdf0e10cSrcweir 				pOutDev->SetLayoutMode(0); // reset, default is no BiDi/RTL
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 				// create renderer
263*cdf0e10cSrcweir                 drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = createBaseProcessor2DFromOutputDevice(
264*cdf0e10cSrcweir                     rTargetOutDev, getViewInformation2D());
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 				if(pProcessor2D)
267*cdf0e10cSrcweir 				{
268*cdf0e10cSrcweir 					pProcessor2D->process(xPrimitiveSequence);
269*cdf0e10cSrcweir 					delete pProcessor2D;
270*cdf0e10cSrcweir 				}
271*cdf0e10cSrcweir 			}
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 			// #114359# restore old ClipReghion
274*cdf0e10cSrcweir 			if(bClipRegionPushed)
275*cdf0e10cSrcweir 			{
276*cdf0e10cSrcweir 				pOutDev->Pop();
277*cdf0e10cSrcweir 			}
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 			// Visualize entered groups: Reset to original DrawMode
280*cdf0e10cSrcweir 			if(bVisualizeEnteredGroup)
281*cdf0e10cSrcweir 			{
282*cdf0e10cSrcweir 				rDisplayInfo.ClearGhostedDrawMode();
283*cdf0e10cSrcweir 			}
284*cdf0e10cSrcweir 		}
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 		// test if visualizing of entered groups is switched on at all
287*cdf0e10cSrcweir 		bool ObjectContactOfPageView::DoVisualizeEnteredGroup() const
288*cdf0e10cSrcweir 		{
289*cdf0e10cSrcweir 			SdrView& rView = GetPageWindow().GetPageView().GetView();
290*cdf0e10cSrcweir 			return rView.DoVisualizeEnteredGroup();
291*cdf0e10cSrcweir 		}
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 		// get active group's (the entered group) ViewContact
294*cdf0e10cSrcweir 		const ViewContact* ObjectContactOfPageView::getActiveViewContact() const
295*cdf0e10cSrcweir 		{
296*cdf0e10cSrcweir 			SdrObjList* pActiveGroupList = GetPageWindow().GetPageView().GetObjList();
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 			if(pActiveGroupList)
299*cdf0e10cSrcweir 			{
300*cdf0e10cSrcweir 				if(pActiveGroupList->ISA(SdrPage))
301*cdf0e10cSrcweir 				{
302*cdf0e10cSrcweir 					// It's a Page itself
303*cdf0e10cSrcweir 					return &(((SdrPage*)pActiveGroupList)->GetViewContact());
304*cdf0e10cSrcweir 				}
305*cdf0e10cSrcweir 				else if(pActiveGroupList->GetOwnerObj())
306*cdf0e10cSrcweir 				{
307*cdf0e10cSrcweir 					// Group object
308*cdf0e10cSrcweir 					return &(pActiveGroupList->GetOwnerObj()->GetViewContact());
309*cdf0e10cSrcweir 				}
310*cdf0e10cSrcweir 			}
311*cdf0e10cSrcweir 			else if(GetSdrPage())
312*cdf0e10cSrcweir 			{
313*cdf0e10cSrcweir 				// use page of associated SdrPageView
314*cdf0e10cSrcweir 				return &(GetSdrPage()->GetViewContact());
315*cdf0e10cSrcweir 			}
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 			return 0;
318*cdf0e10cSrcweir 		}
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 		// Invalidate given rectangle at the window/output which is represented by
321*cdf0e10cSrcweir 		// this ObjectContact.
322*cdf0e10cSrcweir 		void ObjectContactOfPageView::InvalidatePartOfView(const basegfx::B2DRange& rRange) const
323*cdf0e10cSrcweir 		{
324*cdf0e10cSrcweir 			// invalidate at associated PageWindow
325*cdf0e10cSrcweir             GetPageWindow().InvalidatePageWindow(rRange);
326*cdf0e10cSrcweir 		}
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 		// Get info if given Rectangle is visible in this view
329*cdf0e10cSrcweir 		bool ObjectContactOfPageView::IsAreaVisible(const basegfx::B2DRange& rRange) const
330*cdf0e10cSrcweir 		{
331*cdf0e10cSrcweir 			// compare with the visible rectangle
332*cdf0e10cSrcweir 			if(rRange.isEmpty())
333*cdf0e10cSrcweir 			{
334*cdf0e10cSrcweir 				// no range -> not visible
335*cdf0e10cSrcweir 				return false;
336*cdf0e10cSrcweir 			}
337*cdf0e10cSrcweir 			else
338*cdf0e10cSrcweir 			{
339*cdf0e10cSrcweir 				const OutputDevice& rTargetOutDev = GetPageWindow().GetPaintWindow().GetTargetOutputDevice();
340*cdf0e10cSrcweir 				const Size aOutputSizePixel(rTargetOutDev.GetOutputSizePixel());
341*cdf0e10cSrcweir 				basegfx::B2DRange aLogicViewRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 				aLogicViewRange.transform(rTargetOutDev.GetInverseViewTransformation());
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 				if(!aLogicViewRange.isEmpty() && !aLogicViewRange.overlaps(rRange))
346*cdf0e10cSrcweir 				{
347*cdf0e10cSrcweir 					return false;
348*cdf0e10cSrcweir 				}
349*cdf0e10cSrcweir 			}
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir 			// call parent
352*cdf0e10cSrcweir 			return ObjectContact::IsAreaVisible(rRange);
353*cdf0e10cSrcweir 		}
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 		// Get info about the need to visualize GluePoints
356*cdf0e10cSrcweir 		bool ObjectContactOfPageView::AreGluePointsVisible() const
357*cdf0e10cSrcweir 		{
358*cdf0e10cSrcweir 			return GetPageWindow().GetPageView().GetView().ImpIsGlueVisible();
359*cdf0e10cSrcweir 		}
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 		// check if text animation is allowed.
362*cdf0e10cSrcweir 		bool ObjectContactOfPageView::IsTextAnimationAllowed() const
363*cdf0e10cSrcweir 		{
364*cdf0e10cSrcweir 			SdrView& rView = GetPageWindow().GetPageView().GetView();
365*cdf0e10cSrcweir 			const SvtAccessibilityOptions& rOpt = rView.getAccessibilityOptions();
366*cdf0e10cSrcweir 			return rOpt.GetIsAllowAnimatedText();
367*cdf0e10cSrcweir 		}
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir 		// check if graphic animation is allowed.
370*cdf0e10cSrcweir 		bool ObjectContactOfPageView::IsGraphicAnimationAllowed() const
371*cdf0e10cSrcweir 		{
372*cdf0e10cSrcweir 			SdrView& rView = GetPageWindow().GetPageView().GetView();
373*cdf0e10cSrcweir 			const SvtAccessibilityOptions& rOpt = rView.getAccessibilityOptions();
374*cdf0e10cSrcweir 			return rOpt.GetIsAllowAnimatedGraphics();
375*cdf0e10cSrcweir 		}
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 		// check if asynchronious graphis loading is allowed. Default is sal_False.
378*cdf0e10cSrcweir 		bool ObjectContactOfPageView::IsAsynchronGraphicsLoadingAllowed() const
379*cdf0e10cSrcweir 		{
380*cdf0e10cSrcweir 			SdrView& rView = GetPageWindow().GetPageView().GetView();
381*cdf0e10cSrcweir 			return rView.IsSwapAsynchron();
382*cdf0e10cSrcweir 		}
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 		// check if buffering of MasterPages is allowed. Default is sal_False.
385*cdf0e10cSrcweir 		bool ObjectContactOfPageView::IsMasterPageBufferingAllowed() const
386*cdf0e10cSrcweir 		{
387*cdf0e10cSrcweir 			SdrView& rView = GetPageWindow().GetPageView().GetView();
388*cdf0e10cSrcweir 			return rView.IsMasterPagePaintCaching();
389*cdf0e10cSrcweir 		}
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir 		// print?
392*cdf0e10cSrcweir 		bool ObjectContactOfPageView::isOutputToPrinter() const
393*cdf0e10cSrcweir 		{
394*cdf0e10cSrcweir 			return (OUTDEV_PRINTER == mrPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType());
395*cdf0e10cSrcweir 		}
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 		// window?
398*cdf0e10cSrcweir 		bool ObjectContactOfPageView::isOutputToWindow() const
399*cdf0e10cSrcweir 		{
400*cdf0e10cSrcweir 			return (OUTDEV_WINDOW == mrPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType());
401*cdf0e10cSrcweir 		}
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 		// VirtualDevice?
404*cdf0e10cSrcweir 		bool ObjectContactOfPageView::isOutputToVirtualDevice() const
405*cdf0e10cSrcweir 		{
406*cdf0e10cSrcweir 			return (OUTDEV_VIRDEV == mrPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType());
407*cdf0e10cSrcweir 		}
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 		// recording MetaFile?
410*cdf0e10cSrcweir 		bool ObjectContactOfPageView::isOutputToRecordingMetaFile() const
411*cdf0e10cSrcweir 		{
412*cdf0e10cSrcweir 			GDIMetaFile* pMetaFile = mrPageWindow.GetPaintWindow().GetOutputDevice().GetConnectMetaFile();
413*cdf0e10cSrcweir 			return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
414*cdf0e10cSrcweir 		}
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 		// pdf export?
417*cdf0e10cSrcweir 		bool ObjectContactOfPageView::isOutputToPDFFile() const
418*cdf0e10cSrcweir 		{
419*cdf0e10cSrcweir             return (0 != mrPageWindow.GetPaintWindow().GetOutputDevice().GetPDFWriter());
420*cdf0e10cSrcweir 		}
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir 		// gray display mode
423*cdf0e10cSrcweir 		bool ObjectContactOfPageView::isDrawModeGray() const
424*cdf0e10cSrcweir 		{
425*cdf0e10cSrcweir 			const sal_uInt32 nDrawMode(mrPageWindow.GetPaintWindow().GetOutputDevice().GetDrawMode());
426*cdf0e10cSrcweir 			return (nDrawMode == (DRAWMODE_GRAYLINE|DRAWMODE_GRAYFILL|DRAWMODE_BLACKTEXT|DRAWMODE_GRAYBITMAP|DRAWMODE_GRAYGRADIENT));
427*cdf0e10cSrcweir 		}
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 		// gray display mode
430*cdf0e10cSrcweir 		bool ObjectContactOfPageView::isDrawModeBlackWhite() const
431*cdf0e10cSrcweir 		{
432*cdf0e10cSrcweir 			const sal_uInt32 nDrawMode(mrPageWindow.GetPaintWindow().GetOutputDevice().GetDrawMode());
433*cdf0e10cSrcweir 			return (nDrawMode == (DRAWMODE_BLACKLINE|DRAWMODE_BLACKTEXT|DRAWMODE_WHITEFILL|DRAWMODE_GRAYBITMAP|DRAWMODE_WHITEGRADIENT));
434*cdf0e10cSrcweir 		}
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 		// high contrast display mode
437*cdf0e10cSrcweir 		bool ObjectContactOfPageView::isDrawModeHighContrast() const
438*cdf0e10cSrcweir 		{
439*cdf0e10cSrcweir 			const sal_uInt32 nDrawMode(mrPageWindow.GetPaintWindow().GetOutputDevice().GetDrawMode());
440*cdf0e10cSrcweir 			return (nDrawMode == (DRAWMODE_SETTINGSLINE|DRAWMODE_SETTINGSFILL|DRAWMODE_SETTINGSTEXT|DRAWMODE_SETTINGSGRADIENT));
441*cdf0e10cSrcweir 		}
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir         // access to SdrPageView
444*cdf0e10cSrcweir 		SdrPageView* ObjectContactOfPageView::TryToGetSdrPageView() const
445*cdf0e10cSrcweir         {
446*cdf0e10cSrcweir             return &(mrPageWindow.GetPageView());
447*cdf0e10cSrcweir         }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 		// access to OutputDevice
451*cdf0e10cSrcweir 		OutputDevice* ObjectContactOfPageView::TryToGetOutputDevice() const
452*cdf0e10cSrcweir 		{
453*cdf0e10cSrcweir 			SdrPreRenderDevice* pPreRenderDevice = mrPageWindow.GetPaintWindow().GetPreRenderDevice();
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir 			if(pPreRenderDevice)
456*cdf0e10cSrcweir 			{
457*cdf0e10cSrcweir 				return &(pPreRenderDevice->GetPreRenderDevice());
458*cdf0e10cSrcweir 			}
459*cdf0e10cSrcweir 			else
460*cdf0e10cSrcweir 			{
461*cdf0e10cSrcweir 				return &(mrPageWindow.GetPaintWindow().GetOutputDevice());
462*cdf0e10cSrcweir 			}
463*cdf0e10cSrcweir 		}
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 		// set all UNO controls displayed in the view to design/alive mode
466*cdf0e10cSrcweir         void ObjectContactOfPageView::SetUNOControlsDesignMode( bool _bDesignMode ) const
467*cdf0e10cSrcweir         {
468*cdf0e10cSrcweir             const sal_uInt32 nCount(getViewObjectContactCount());
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 			for(sal_uInt32 a(0); a < nCount; a++)
471*cdf0e10cSrcweir             {
472*cdf0e10cSrcweir                 const ViewObjectContact* pVOC = getViewObjectContact(a);
473*cdf0e10cSrcweir 				const ViewObjectContactOfUnoControl* pUnoObjectVOC = dynamic_cast< const ViewObjectContactOfUnoControl* >(pVOC);
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir 				if(pUnoObjectVOC)
476*cdf0e10cSrcweir 				{
477*cdf0e10cSrcweir 	                pUnoObjectVOC->setControlDesignMode(_bDesignMode);
478*cdf0e10cSrcweir 				}
479*cdf0e10cSrcweir             }
480*cdf0e10cSrcweir         }
481*cdf0e10cSrcweir 	} // end of namespace contact
482*cdf0e10cSrcweir } // end of namespace sdr
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
485*cdf0e10cSrcweir // eof
486