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