Update ooo320-m1
[ooovba.git] / svx / source / sdr / contact / objectcontactofobjlistpainter.cxx
blob4b0ffda2d67fce569089842b8042e654b5fbf046
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: objectcontactofobjlistpainter.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
34 #include <svx/sdr/contact/displayinfo.hxx>
35 #include <svx/sdr/contact/viewobjectcontact.hxx>
36 #include <svx/svdpage.hxx>
37 #include <svx/svdobj.hxx>
38 #include <svx/sdr/contact/viewcontact.hxx>
39 #include <svx/svdmodel.hxx>
40 #include <drawinglayer/processor2d/vclprocessor2d.hxx>
41 #include <basegfx/matrix/b2dhommatrix.hxx>
42 #include <svx/sdr/contact/objectcontacttools.hxx>
43 #include <unoapi.hxx>
45 //////////////////////////////////////////////////////////////////////////////
47 namespace sdr
49 namespace contact
51 ObjectContactPainter::ObjectContactPainter()
55 // The destructor.
56 ObjectContactPainter::~ObjectContactPainter()
59 } // end of namespace contact
60 } // end of namespace sdr
62 //////////////////////////////////////////////////////////////////////////////
64 namespace sdr
66 namespace contact
68 sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const
70 return maStartObjects.size();
73 ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const
75 const SdrObject* pObj = maStartObjects[nIndex];
76 DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
77 return pObj->GetViewContact();
80 ObjectContactOfObjListPainter::ObjectContactOfObjListPainter(
81 OutputDevice& rTargetDevice,
82 const SdrObjectVector& rObjects,
83 const SdrPage* pProcessedPage)
84 : ObjectContactPainter(),
85 mrTargetOutputDevice(rTargetDevice),
86 maStartObjects(rObjects),
87 mpProcessedPage(pProcessedPage)
91 ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter()
95 // Process the whole displaying
96 void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo)
98 const sal_uInt32 nCount(GetPaintObjectCount());
100 if(nCount)
102 OutputDevice* pTargetDevice = TryToGetOutputDevice();
104 if(pTargetDevice)
106 // update current ViewInformation2D at the ObjectContact
107 const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile();
108 const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
109 basegfx::B2DRange aViewRange;
111 // create ViewRange
112 if(!bOutputToRecordingMetaFile)
114 // use visible pixels, but transform to world coordinates
115 const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel());
116 aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
117 aViewRange.transform(pTargetDevice->GetInverseViewTransformation());
120 // upate local ViewInformation2D
121 const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
122 basegfx::B2DHomMatrix(),
123 pTargetDevice->GetViewTransformation(),
124 aViewRange,
125 GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)),
126 0.0,
128 updateViewInformation2D(aNewViewInformation2D);
130 // collect primitive data in a sequence; this will already use the updated ViewInformation2D
131 drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence;
133 for(sal_uInt32 a(0L); a < nCount; a++)
135 const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
137 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence,
138 rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
141 // if there is something to show, use a vclProcessor to render it
142 if(xPrimitiveSequence.hasElements())
144 drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = createBaseProcessor2DFromOutputDevice(
145 *pTargetDevice, getViewInformation2D());
147 if(pProcessor2D)
149 pProcessor2D->process(xPrimitiveSequence);
150 delete pProcessor2D;
157 OutputDevice* ObjectContactOfObjListPainter::TryToGetOutputDevice() const
159 return &mrTargetOutputDevice;
161 } // end of namespace contact
162 } // end of namespace sdr
164 //////////////////////////////////////////////////////////////////////////////
166 namespace sdr
168 namespace contact
170 sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const
172 return (GetStartPage() ? 1L : 0L);
175 ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/) const
177 DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
178 return GetStartPage()->GetViewContact();
181 ObjectContactOfPagePainter::ObjectContactOfPagePainter(
182 const SdrPage* pPage,
183 ObjectContact& rOriginalObjectContact)
184 : ObjectContactPainter(),
185 mrOriginalObjectContact(rOriginalObjectContact),
186 mxStartPage(const_cast< SdrPage* >(pPage)) // no SdrPageWeakRef available to hold a const SdrPage*
190 ObjectContactOfPagePainter::~ObjectContactOfPagePainter()
194 void ObjectContactOfPagePainter::SetStartPage(const SdrPage* pPage)
196 if(pPage != GetStartPage())
198 mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no SdrPageWeakRef available to hold a const SdrPage*
202 OutputDevice* ObjectContactOfPagePainter::TryToGetOutputDevice() const
204 return mrOriginalObjectContact.TryToGetOutputDevice();
206 } // end of namespace contact
207 } // end of namespace sdr
209 //////////////////////////////////////////////////////////////////////////////
210 // eof