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/sdrpagewindow.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
35*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
36*cdf0e10cSrcweir #include <vcl/svapp.hxx>
37*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
38*cdf0e10cSrcweir #include <svx/svdouno.hxx>
39*cdf0e10cSrcweir #include <svx/svdpage.hxx>
40*cdf0e10cSrcweir #include <svx/svdview.hxx>
41*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
42*cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
43*cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofpageview.hxx>
44*cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
45*cdf0e10cSrcweir #include <vos/mutex.hxx>
46*cdf0e10cSrcweir #include <svx/fmview.hxx>
47*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir using namespace ::rtl;
52*cdf0e10cSrcweir using namespace ::com::sun::star;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageWindow::GetControlContainer( bool _bCreateIfNecessary ) const
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir     if ( !mxControlContainer.is() && _bCreateIfNecessary )
59*cdf0e10cSrcweir 	{
60*cdf0e10cSrcweir 		SdrView& rView = GetPageView().GetView();
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir         const SdrPaintWindow& rPaintWindow( GetOriginalPaintWindow() ? *GetOriginalPaintWindow() : GetPaintWindow() );
63*cdf0e10cSrcweir 		if ( rPaintWindow.OutputToWindow() && !rView.IsPrintPreview() )
64*cdf0e10cSrcweir 		{
65*cdf0e10cSrcweir 			Window& rWindow = dynamic_cast< Window& >( rPaintWindow.GetOutputDevice() );
66*cdf0e10cSrcweir             const_cast< SdrPageWindow* >( this )->mxControlContainer = VCLUnoHelper::CreateControlContainer( &rWindow );
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 			// #100394# xC->setVisible triggers window->Show() and this has
69*cdf0e10cSrcweir 			// problems when the view is not completely constructed which may
70*cdf0e10cSrcweir 			// happen when loading. This leads to accessibility broadcasts which
71*cdf0e10cSrcweir 			// throw asserts due to the not finished view. All this chan be avoided
72*cdf0e10cSrcweir 			// since xC->setVisible is here called only for the side effect in
73*cdf0e10cSrcweir 			// UnoControlContainer::setVisible(...) which calls createPeer(...).
74*cdf0e10cSrcweir 			// This will now be called directly from here.
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 			// UnoContainerModel erzeugen
77*cdf0e10cSrcweir 			// uno::Reference< awt::XWindow > xC(mxControlContainer, uno::UNO_QUERY);
78*cdf0e10cSrcweir 			// CreateControlContainer() is only used from
79*cdf0e10cSrcweir 			// , thus it seems not necessary to make
80*cdf0e10cSrcweir 			// it visible her at all.
81*cdf0e10cSrcweir 			// #58917# Das Show darf nicht am VCL-Fenster landen, weil dann Assertion vom SFX
82*cdf0e10cSrcweir 			// sal_Bool bVis = pWindow->IsVisible();
83*cdf0e10cSrcweir 			// xC->setVisible(sal_True);
84*cdf0e10cSrcweir 			// if ( !bVis )
85*cdf0e10cSrcweir 			// 	pWindow->Hide();
86*cdf0e10cSrcweir 			//	if( !mxContext.is() && bVisible )
87*cdf0e10cSrcweir 			//		// Es ist ein TopWindow, also automatisch anzeigen
88*cdf0e10cSrcweir 			//		createPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > (), ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > () );
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 			uno::Reference< awt::XControl > xControl(mxControlContainer, uno::UNO_QUERY);
91*cdf0e10cSrcweir 			if(xControl.is())
92*cdf0e10cSrcweir 			{
93*cdf0e10cSrcweir 				uno::Reference< uno::XInterface > xContext = xControl->getContext();
94*cdf0e10cSrcweir 				if(!xContext.is())
95*cdf0e10cSrcweir 				{
96*cdf0e10cSrcweir 					xControl->createPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > (),
97*cdf0e10cSrcweir 						::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > () );
98*cdf0e10cSrcweir 				}
99*cdf0e10cSrcweir 			}
100*cdf0e10cSrcweir 		}
101*cdf0e10cSrcweir 		else
102*cdf0e10cSrcweir 		{
103*cdf0e10cSrcweir 			// Printer und VirtualDevice, bzw. kein OutDev
104*cdf0e10cSrcweir 			uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
105*cdf0e10cSrcweir 			if( xFactory.is() )
106*cdf0e10cSrcweir 			{
107*cdf0e10cSrcweir                 const_cast< SdrPageWindow* >( this )->mxControlContainer = uno::Reference< awt::XControlContainer >(xFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlContainer")), uno::UNO_QUERY);
108*cdf0e10cSrcweir 				uno::Reference< awt::XControlModel > xModel(xFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlContainerModel")), uno::UNO_QUERY);
109*cdf0e10cSrcweir 				uno::Reference< awt::XControl > xControl(mxControlContainer, uno::UNO_QUERY);
110*cdf0e10cSrcweir 				if (xControl.is())
111*cdf0e10cSrcweir 					xControl->setModel(xModel);
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 				OutputDevice& rOutDev = rPaintWindow.GetOutputDevice();
114*cdf0e10cSrcweir 				Point aPosPix = rOutDev.GetMapMode().GetOrigin();
115*cdf0e10cSrcweir 				Size aSizePix = rOutDev.GetOutputSizePixel();
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 				uno::Reference< awt::XWindow > xContComp(mxControlContainer, uno::UNO_QUERY);
118*cdf0e10cSrcweir 				if( xContComp.is() )
119*cdf0e10cSrcweir 					xContComp->setPosSize(aPosPix.X(), aPosPix.Y(), aSizePix.Width(), aSizePix.Height(), awt::PosSize::POSSIZE);
120*cdf0e10cSrcweir 			}
121*cdf0e10cSrcweir 		}
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir         FmFormView* pViewAsFormView = dynamic_cast< FmFormView* >( &rView );
124*cdf0e10cSrcweir         if ( pViewAsFormView )
125*cdf0e10cSrcweir 		    pViewAsFormView->InsertControlContainer(mxControlContainer);
126*cdf0e10cSrcweir 	}
127*cdf0e10cSrcweir     return mxControlContainer;
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir SdrPageWindow::SdrPageWindow(SdrPageView& rPageView, SdrPaintWindow& rPaintWindow)
131*cdf0e10cSrcweir :	mpObjectContact(0L),
132*cdf0e10cSrcweir 	mrPageView(rPageView),
133*cdf0e10cSrcweir 	mpPaintWindow(&rPaintWindow),
134*cdf0e10cSrcweir     mpOriginalPaintWindow(NULL)
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir SdrPageWindow::~SdrPageWindow()
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir 	// #110094#, #i26631#
141*cdf0e10cSrcweir 	ResetObjectContact();
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	if (mxControlContainer.is())
144*cdf0e10cSrcweir 	{
145*cdf0e10cSrcweir 		SdrView& rView = GetPageView().GetView();
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		// notify derived views
148*cdf0e10cSrcweir         FmFormView* pViewAsFormView = dynamic_cast< FmFormView* >( &rView );
149*cdf0e10cSrcweir         if ( pViewAsFormView )
150*cdf0e10cSrcweir 		    pViewAsFormView->RemoveControlContainer(mxControlContainer);
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 		// dispose the control container
153*cdf0e10cSrcweir 		uno::Reference< lang::XComponent > xComponent(mxControlContainer, uno::UNO_QUERY);
154*cdf0e10cSrcweir 		xComponent->dispose();
155*cdf0e10cSrcweir 	}
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir // #110094# ObjectContact section
159*cdf0e10cSrcweir sdr::contact::ObjectContact* SdrPageWindow::CreateViewSpecificObjectContact()
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	return new sdr::contact::ObjectContactOfPageView(*this);
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir // OVERLAYMANAGER
165*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* SdrPageWindow::GetOverlayManager() const
166*cdf0e10cSrcweir {
167*cdf0e10cSrcweir 	return GetPaintWindow().GetOverlayManager();
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir void SdrPageWindow::patchPaintWindow(SdrPaintWindow& rPaintWindow)
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir     mpOriginalPaintWindow = mpPaintWindow;
173*cdf0e10cSrcweir     mpPaintWindow = &rPaintWindow;
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir void SdrPageWindow::unpatchPaintWindow()
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir     DBG_ASSERT(mpOriginalPaintWindow, "SdrPageWindow::unpatchPaintWindow: paint window not patched!" );
179*cdf0e10cSrcweir     if ( mpOriginalPaintWindow )
180*cdf0e10cSrcweir     {
181*cdf0e10cSrcweir         mpPaintWindow = mpOriginalPaintWindow;
182*cdf0e10cSrcweir         mpOriginalPaintWindow = NULL;
183*cdf0e10cSrcweir     }
184*cdf0e10cSrcweir }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir void SdrPageWindow::PrePaint()
187*cdf0e10cSrcweir {
188*cdf0e10cSrcweir 	// give OC the chance to do ProcessDisplay preparations
189*cdf0e10cSrcweir 	if(HasObjectContact())
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		GetObjectContact().PrepareProcessDisplay();
192*cdf0e10cSrcweir 	}
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir void SdrPageWindow::PostPaint()
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir }
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir void SdrPageWindow::PrepareRedraw(const Region& rReg)
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir 	// evtl. give OC the chance to do ProcessDisplay preparations
202*cdf0e10cSrcweir 	if(HasObjectContact())
203*cdf0e10cSrcweir 	{
204*cdf0e10cSrcweir 		GetObjectContact().PrepareProcessDisplay();
205*cdf0e10cSrcweir 	}
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	// remember eventually changed RedrawArea at PaintWindow for usage with
208*cdf0e10cSrcweir 	// overlay and PreRenderDevice stuff
209*cdf0e10cSrcweir 	GetPaintWindow().SetRedrawRegion(rReg);
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
213*cdf0e10cSrcweir // clip test
214*cdf0e10cSrcweir #ifdef CLIPPER_TEST
215*cdf0e10cSrcweir #include <svx/svdopath.hxx>
216*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
217*cdf0e10cSrcweir #include <vcl/salbtype.hxx>		// FRound
218*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygoncutandtouch.hxx>
219*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
220*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
221*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygonclipper.hxx>
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir // for ::std::sort
224*cdf0e10cSrcweir #include <algorithm>
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir namespace
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir 	void impPaintStrokePolygon(const basegfx::B2DPolygon& rCandidate, OutputDevice& rOutDev, Color aColor)
229*cdf0e10cSrcweir 	{
230*cdf0e10cSrcweir 		basegfx::B2DPolygon aCandidate(rCandidate);
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 		if(aCandidate.areControlPointsUsed())
233*cdf0e10cSrcweir 		{
234*cdf0e10cSrcweir 			aCandidate = basegfx::tools::adaptiveSubdivideByAngle(rCandidate);
235*cdf0e10cSrcweir 		}
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 		if(aCandidate.count())
238*cdf0e10cSrcweir 		{
239*cdf0e10cSrcweir 			const sal_uInt32 nLoopCount(aCandidate.isClosed() ? aCandidate.count() : aCandidate.count() - 1L);
240*cdf0e10cSrcweir 			rOutDev.SetFillColor();
241*cdf0e10cSrcweir 			rOutDev.SetLineColor(aColor);
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 			for(sal_uInt32 a(0L); a < nLoopCount; a++)
244*cdf0e10cSrcweir 			{
245*cdf0e10cSrcweir 				const basegfx::B2DPoint aBStart(aCandidate.getB2DPoint(a));
246*cdf0e10cSrcweir 				const basegfx::B2DPoint aBEnd(aCandidate.getB2DPoint((a + 1) % aCandidate.count()));
247*cdf0e10cSrcweir 				const Point aStart(FRound(aBStart.getX()), FRound(aBStart.getY()));
248*cdf0e10cSrcweir 				const Point aEnd(FRound(aBEnd.getX()), FRound(aBEnd.getY()));
249*cdf0e10cSrcweir 				rOutDev.DrawLine(aStart, aEnd);
250*cdf0e10cSrcweir 			}
251*cdf0e10cSrcweir 		}
252*cdf0e10cSrcweir 	}
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	void impTryTest(const SdrPageView& rPageView, OutputDevice& rOutDev)
255*cdf0e10cSrcweir 	{
256*cdf0e10cSrcweir 		if(rPageView.GetPage() && rPageView.GetPage()->GetObjCount() >= 2L)
257*cdf0e10cSrcweir 		{
258*cdf0e10cSrcweir 			SdrPage* pPage = rPageView.GetPage();
259*cdf0e10cSrcweir 			SdrObject* pObjA = pPage->GetObj(0L);
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 			if(pObjA && pObjA->ISA(SdrPathObj))
262*cdf0e10cSrcweir 			{
263*cdf0e10cSrcweir 				basegfx::B2DPolyPolygon aPolyA(((SdrPathObj*)pObjA)->GetPathPoly());
264*cdf0e10cSrcweir 				aPolyA = basegfx::tools::correctOrientations(aPolyA);
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 				basegfx::B2DPolyPolygon aPolyB;
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 				for(sal_uInt32 a(1L); a < rPageView.GetPage()->GetObjCount(); a++)
269*cdf0e10cSrcweir 				{
270*cdf0e10cSrcweir 					SdrObject* pObjB = pPage->GetObj(a);
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 					if(pObjB && pObjB->ISA(SdrPathObj))
273*cdf0e10cSrcweir 					{
274*cdf0e10cSrcweir 						basegfx::B2DPolyPolygon aCandidate(((SdrPathObj*)pObjB)->GetPathPoly());
275*cdf0e10cSrcweir 						aCandidate = basegfx::tools::correctOrientations(aCandidate);
276*cdf0e10cSrcweir 						aPolyB.append(aCandidate);
277*cdf0e10cSrcweir 					}
278*cdf0e10cSrcweir 				}
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 				if(aPolyA.count() && aPolyA.isClosed() && aPolyB.count())
281*cdf0e10cSrcweir 				{
282*cdf0e10cSrcweir 					// poly A is the clipregion, clip poly b against it. Algo depends on
283*cdf0e10cSrcweir 					// poly b being closed.
284*cdf0e10cSrcweir 					basegfx::B2DPolyPolygon aResult(basegfx::tools::clipPolyPolygonOnPolyPolygon(aPolyB, aPolyA));
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 					for(sal_uInt32 a(0L); a < aResult.count(); a++)
287*cdf0e10cSrcweir 					{
288*cdf0e10cSrcweir 						Color aColor(rand()%255, rand()%255, rand()%255);
289*cdf0e10cSrcweir 						impPaintStrokePolygon(aResult.getB2DPolygon(a), rOutDev, aColor);
290*cdf0e10cSrcweir 					}
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 					bool bBla = true;
293*cdf0e10cSrcweir 				}
294*cdf0e10cSrcweir 			}
295*cdf0e10cSrcweir 		}
296*cdf0e10cSrcweir 	}
297*cdf0e10cSrcweir } // end of anonymous namespace
298*cdf0e10cSrcweir #endif // CLIPPER_TEST
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir void SdrPageWindow::RedrawAll(sdr::contact::ViewObjectContactRedirector* pRedirector) const
303*cdf0e10cSrcweir {
304*cdf0e10cSrcweir 	// set Redirector
305*cdf0e10cSrcweir 	GetObjectContact().SetViewObjectContactRedirector(pRedirector);
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 	// set PaintingPageView
308*cdf0e10cSrcweir 	const SdrView& rView = mrPageView.GetView();
309*cdf0e10cSrcweir 	SdrModel& rModel = *((SdrModel*)rView.GetModel());
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir 	// get to be processed layers
312*cdf0e10cSrcweir 	const sal_Bool bPrinter(GetPaintWindow().OutputToPrinter());
313*cdf0e10cSrcweir 	SetOfByte aProcessLayers = bPrinter ? mrPageView.GetPrintableLayers() : mrPageView.GetVisibleLayers();
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 	// create PaintInfoRec, #114359# use Rectangle only temporarily
316*cdf0e10cSrcweir 	const Region& rRegion = GetPaintWindow().GetRedrawRegion();
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 	// create processing data
319*cdf0e10cSrcweir 	sdr::contact::DisplayInfo aDisplayInfo;
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir 	// Draw all layers. do NOT draw form layer from CompleteRedraw, this is done separate
322*cdf0e10cSrcweir 	// as a single layer paint
323*cdf0e10cSrcweir 	const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin();
324*cdf0e10cSrcweir 	const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False);
325*cdf0e10cSrcweir 	aProcessLayers.Clear(nControlLayerId);
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 	// still something to paint?
328*cdf0e10cSrcweir 	if(!aProcessLayers.IsEmpty())
329*cdf0e10cSrcweir 	{
330*cdf0e10cSrcweir 		aDisplayInfo.SetProcessLayers(aProcessLayers);
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir 		// Set region as redraw area
333*cdf0e10cSrcweir 		aDisplayInfo.SetRedrawArea(rRegion);
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 		// Draw/Impress
336*cdf0e10cSrcweir 		aDisplayInfo.SetPageProcessingActive(rView.IsPagePaintingAllowed()); // #i72889#
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 		// paint page
339*cdf0e10cSrcweir 		GetObjectContact().ProcessDisplay(aDisplayInfo);
340*cdf0e10cSrcweir 	}
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir 	// reset redirector
343*cdf0e10cSrcweir 	GetObjectContact().SetViewObjectContactRedirector(0L);
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 	// LineClip test
346*cdf0e10cSrcweir #ifdef CLIPPER_TEST
347*cdf0e10cSrcweir 	if(true)
348*cdf0e10cSrcweir 	{
349*cdf0e10cSrcweir 		impTryTest(GetPageView(), GetPaintWindow().GetOutputDevice());
350*cdf0e10cSrcweir 	}
351*cdf0e10cSrcweir #endif // CLIPPER_TEST
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir void SdrPageWindow::RedrawLayer(const SdrLayerID* pId, sdr::contact::ViewObjectContactRedirector* pRedirector) const
355*cdf0e10cSrcweir {
356*cdf0e10cSrcweir 	// set redirector
357*cdf0e10cSrcweir 	GetObjectContact().SetViewObjectContactRedirector(pRedirector);
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 	// set PaintingPageView
360*cdf0e10cSrcweir 	const SdrView& rView = mrPageView.GetView();
361*cdf0e10cSrcweir 	SdrModel& rModel = *((SdrModel*)rView.GetModel());
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 	// get the layers to process
364*cdf0e10cSrcweir 	const sal_Bool bPrinter(GetPaintWindow().OutputToPrinter());
365*cdf0e10cSrcweir 	SetOfByte aProcessLayers = bPrinter ? mrPageView.GetPrintableLayers() : mrPageView.GetVisibleLayers();
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 	// is the given layer visible at all?
368*cdf0e10cSrcweir 	if(aProcessLayers.IsSet(*pId))
369*cdf0e10cSrcweir 	{
370*cdf0e10cSrcweir 		// find out if we are painting the ControlLayer
371*cdf0e10cSrcweir 		const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin();
372*cdf0e10cSrcweir 		const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False);
373*cdf0e10cSrcweir 		const sal_Bool bControlLayerProcessingActive(pId && nControlLayerId == *pId);
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 		// create PaintInfoRec, use Rectangle only temporarily
376*cdf0e10cSrcweir 		const Region& rRegion = GetPaintWindow().GetRedrawRegion();
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 		// create processing data
379*cdf0e10cSrcweir 		sdr::contact::DisplayInfo aDisplayInfo;
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 		// is it the control layer? If Yes, set flag
382*cdf0e10cSrcweir 		aDisplayInfo.SetControlLayerProcessingActive(bControlLayerProcessingActive);
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 		// Draw just the one given layer
385*cdf0e10cSrcweir 		aProcessLayers.ClearAll();
386*cdf0e10cSrcweir 		aProcessLayers.Set(*pId);
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir 		aDisplayInfo.SetProcessLayers(aProcessLayers);
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir 		// Set region as redraw area
391*cdf0e10cSrcweir 		aDisplayInfo.SetRedrawArea(rRegion);
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir 		// Writer or calc, coming from original RedrawOneLayer.
394*cdf0e10cSrcweir         // #i72889# no page painting for layer painting
395*cdf0e10cSrcweir 		aDisplayInfo.SetPageProcessingActive(false);
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 		// paint page
398*cdf0e10cSrcweir 		GetObjectContact().ProcessDisplay(aDisplayInfo);
399*cdf0e10cSrcweir 	}
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 	// reset redirector
402*cdf0e10cSrcweir 	GetObjectContact().SetViewObjectContactRedirector(0L);
403*cdf0e10cSrcweir }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir // Invalidate call, used from ObjectContact(OfPageView) in InvalidatePartOfView(...)
406*cdf0e10cSrcweir void SdrPageWindow::InvalidatePageWindow(const basegfx::B2DRange& rRange)
407*cdf0e10cSrcweir {
408*cdf0e10cSrcweir 	if(GetPageView().IsVisible() && GetPaintWindow().OutputToWindow())
409*cdf0e10cSrcweir 	{
410*cdf0e10cSrcweir         const SvtOptionsDrawinglayer aDrawinglayerOpt;
411*cdf0e10cSrcweir         Window& rWindow(static_cast< Window& >(GetPaintWindow().GetOutputDevice()));
412*cdf0e10cSrcweir         basegfx::B2DRange aDiscreteRange(rRange);
413*cdf0e10cSrcweir         aDiscreteRange.transform(rWindow.GetViewTransformation());
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir         if(aDrawinglayerOpt.IsAntiAliasing())
416*cdf0e10cSrcweir         {
417*cdf0e10cSrcweir             // invalidate one discrete unit more under the assumption that AA
418*cdf0e10cSrcweir             // needs one pixel more
419*cdf0e10cSrcweir             aDiscreteRange.grow(1.0);
420*cdf0e10cSrcweir         }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir 		const Rectangle aVCLDiscreteRectangle(
423*cdf0e10cSrcweir 				(sal_Int32)floor(aDiscreteRange.getMinX()), (sal_Int32)floor(aDiscreteRange.getMinY()),
424*cdf0e10cSrcweir 				(sal_Int32)ceil(aDiscreteRange.getMaxX()), (sal_Int32)ceil(aDiscreteRange.getMaxY()));
425*cdf0e10cSrcweir         const bool bWasMapModeEnabled(rWindow.IsMapModeEnabled());
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir         rWindow.EnableMapMode(false);
428*cdf0e10cSrcweir 		rWindow.Invalidate(aVCLDiscreteRectangle, INVALIDATE_NOERASE);
429*cdf0e10cSrcweir         rWindow.EnableMapMode(bWasMapModeEnabled);
430*cdf0e10cSrcweir 	}
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir // #110094# ObjectContact section
434*cdf0e10cSrcweir sdr::contact::ObjectContact& SdrPageWindow::GetObjectContact() const
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir 	if(!mpObjectContact)
437*cdf0e10cSrcweir 	{
438*cdf0e10cSrcweir 		((SdrPageWindow*)this)->mpObjectContact = ((SdrPageWindow*)this)->CreateViewSpecificObjectContact();
439*cdf0e10cSrcweir 	}
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir 	return *mpObjectContact;
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir bool SdrPageWindow::HasObjectContact() const
445*cdf0e10cSrcweir {
446*cdf0e10cSrcweir     return ( mpObjectContact != NULL );
447*cdf0e10cSrcweir }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir // #i26631#
450*cdf0e10cSrcweir void SdrPageWindow::ResetObjectContact()
451*cdf0e10cSrcweir {
452*cdf0e10cSrcweir 	if(mpObjectContact)
453*cdf0e10cSrcweir 	{
454*cdf0e10cSrcweir 		delete mpObjectContact;
455*cdf0e10cSrcweir 		mpObjectContact = 0L;
456*cdf0e10cSrcweir 	}
457*cdf0e10cSrcweir }
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir void SdrPageWindow::SetDesignMode( bool _bDesignMode ) const
460*cdf0e10cSrcweir {
461*cdf0e10cSrcweir     const ::sdr::contact::ObjectContactOfPageView* pOC = dynamic_cast< const ::sdr::contact::ObjectContactOfPageView* >( &GetObjectContact() );
462*cdf0e10cSrcweir     DBG_ASSERT( pOC, "SdrPageWindow::SetDesignMode: invalid object contact!" );
463*cdf0e10cSrcweir     if ( pOC )
464*cdf0e10cSrcweir         pOC->SetUNOControlsDesignMode( _bDesignMode );
465*cdf0e10cSrcweir }
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
468*cdf0e10cSrcweir // eof
469