Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
21 : #include <svx/sdr/contact/displayinfo.hxx>
22 : #include <svx/sdr/contact/viewobjectcontact.hxx>
23 : #include <svx/svdpage.hxx>
24 : #include <svx/svdobj.hxx>
25 : #include <svx/sdr/contact/viewcontact.hxx>
26 : #include <svx/svdmodel.hxx>
27 : #include <drawinglayer/processor2d/vclprocessor2d.hxx>
28 : #include <basegfx/matrix/b2dhommatrix.hxx>
29 : #include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
30 : #include <svx/unoapi.hxx>
31 :
32 : //////////////////////////////////////////////////////////////////////////////
33 :
34 : namespace sdr
35 : {
36 : namespace contact
37 : {
38 13 : ObjectContactPainter::ObjectContactPainter()
39 : {
40 13 : }
41 :
42 : // The destructor.
43 13 : ObjectContactPainter::~ObjectContactPainter()
44 : {
45 13 : }
46 : } // end of namespace contact
47 : } // end of namespace sdr
48 :
49 : //////////////////////////////////////////////////////////////////////////////
50 :
51 : namespace sdr
52 : {
53 : namespace contact
54 : {
55 13 : sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const
56 : {
57 13 : return maStartObjects.size();
58 : }
59 :
60 13 : ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const
61 : {
62 13 : const SdrObject* pObj = maStartObjects[nIndex];
63 : DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
64 13 : return pObj->GetViewContact();
65 : }
66 :
67 13 : ObjectContactOfObjListPainter::ObjectContactOfObjListPainter(
68 : OutputDevice& rTargetDevice,
69 : const SdrObjectVector& rObjects,
70 : const SdrPage* pProcessedPage)
71 : : ObjectContactPainter(),
72 : mrTargetOutputDevice(rTargetDevice),
73 : maStartObjects(rObjects),
74 13 : mpProcessedPage(pProcessedPage)
75 : {
76 13 : }
77 :
78 13 : ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter()
79 : {
80 13 : }
81 :
82 : // Process the whole displaying
83 13 : void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo)
84 : {
85 13 : const sal_uInt32 nCount(GetPaintObjectCount());
86 :
87 13 : if(nCount)
88 : {
89 13 : OutputDevice* pTargetDevice = TryToGetOutputDevice();
90 :
91 13 : if(pTargetDevice)
92 : {
93 : // update current ViewInformation2D at the ObjectContact
94 13 : const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile();
95 13 : const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
96 13 : basegfx::B2DRange aViewRange;
97 :
98 : // create ViewRange
99 13 : if(!bOutputToRecordingMetaFile)
100 : {
101 : // use visible pixels, but transform to world coordinates
102 0 : const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel());
103 0 : aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
104 0 : aViewRange.transform(pTargetDevice->GetInverseViewTransformation());
105 : }
106 :
107 : // upate local ViewInformation2D
108 : const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
109 : basegfx::B2DHomMatrix(),
110 : pTargetDevice->GetViewTransformation(),
111 : aViewRange,
112 : GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)),
113 : 0.0,
114 13 : com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>());
115 13 : updateViewInformation2D(aNewViewInformation2D);
116 :
117 : // collect primitive data in a sequence; this will already use the updated ViewInformation2D
118 13 : drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence;
119 :
120 26 : for(sal_uInt32 a(0L); a < nCount; a++)
121 : {
122 13 : const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
123 :
124 : drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence,
125 13 : rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
126 : }
127 :
128 : // if there is something to show, use a vclProcessor to render it
129 13 : if(xPrimitiveSequence.hasElements())
130 : {
131 : drawinglayer::processor2d::BaseProcessor2D* pProcessor2D =
132 : drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
133 12 : *pTargetDevice, getViewInformation2D());
134 :
135 12 : if(pProcessor2D)
136 : {
137 12 : pProcessor2D->process(xPrimitiveSequence);
138 12 : delete pProcessor2D;
139 : }
140 13 : }
141 : }
142 : }
143 13 : }
144 :
145 : // VirtualDevice?
146 0 : bool ObjectContactOfObjListPainter::isOutputToVirtualDevice() const
147 : {
148 0 : return (OUTDEV_VIRDEV == mrTargetOutputDevice.GetOutDevType());
149 : }
150 :
151 : // recording MetaFile?
152 0 : bool ObjectContactOfObjListPainter::isOutputToRecordingMetaFile() const
153 : {
154 0 : GDIMetaFile* pMetaFile = mrTargetOutputDevice.GetConnectMetaFile();
155 0 : return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
156 : }
157 :
158 : // pdf export?
159 0 : bool ObjectContactOfObjListPainter::isOutputToPDFFile() const
160 : {
161 0 : return (0 != mrTargetOutputDevice.GetPDFWriter());
162 : }
163 :
164 13 : OutputDevice* ObjectContactOfObjListPainter::TryToGetOutputDevice() const
165 : {
166 13 : return &mrTargetOutputDevice;
167 : }
168 : } // end of namespace contact
169 : } // end of namespace sdr
170 :
171 : //////////////////////////////////////////////////////////////////////////////
172 :
173 : namespace sdr
174 : {
175 : namespace contact
176 : {
177 0 : sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const
178 : {
179 0 : return (GetStartPage() ? 1L : 0L);
180 : }
181 :
182 0 : ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/) const
183 : {
184 : DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
185 0 : return GetStartPage()->GetViewContact();
186 : }
187 :
188 0 : ObjectContactOfPagePainter::ObjectContactOfPagePainter(
189 : const SdrPage* pPage,
190 : ObjectContact& rOriginalObjectContact)
191 : : ObjectContactPainter(),
192 : mrOriginalObjectContact(rOriginalObjectContact),
193 0 : mxStartPage(const_cast< SdrPage* >(pPage)) // no SdrPageWeakRef available to hold a const SdrPage*
194 : {
195 0 : }
196 :
197 0 : ObjectContactOfPagePainter::~ObjectContactOfPagePainter()
198 : {
199 0 : }
200 :
201 0 : void ObjectContactOfPagePainter::SetStartPage(const SdrPage* pPage)
202 : {
203 0 : if(pPage != GetStartPage())
204 : {
205 0 : mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no SdrPageWeakRef available to hold a const SdrPage*
206 : }
207 0 : }
208 :
209 0 : OutputDevice* ObjectContactOfPagePainter::TryToGetOutputDevice() const
210 : {
211 0 : return mrOriginalObjectContact.TryToGetOutputDevice();
212 : }
213 : } // end of namespace contact
214 : } // end of namespace sdr
215 :
216 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|