Branch data 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 : 1421 : ObjectContactPainter::ObjectContactPainter()
39 : : {
40 : 1421 : }
41 : :
42 : : // The destructor.
43 : 1421 : ObjectContactPainter::~ObjectContactPainter()
44 : : {
45 [ - + ]: 1421 : }
46 : : } // end of namespace contact
47 : : } // end of namespace sdr
48 : :
49 : : //////////////////////////////////////////////////////////////////////////////
50 : :
51 : : namespace sdr
52 : : {
53 : : namespace contact
54 : : {
55 : 1410 : sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const
56 : : {
57 : 1410 : return maStartObjects.size();
58 : : }
59 : :
60 : 2796 : ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const
61 : : {
62 : 2796 : const SdrObject* pObj = maStartObjects[nIndex];
63 : : DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
64 : 2796 : return pObj->GetViewContact();
65 : : }
66 : :
67 : 1410 : ObjectContactOfObjListPainter::ObjectContactOfObjListPainter(
68 : : OutputDevice& rTargetDevice,
69 : : const SdrObjectVector& rObjects,
70 : : const SdrPage* pProcessedPage)
71 : : : ObjectContactPainter(),
72 : : mrTargetOutputDevice(rTargetDevice),
73 : : maStartObjects(rObjects),
74 [ + - ]: 1410 : mpProcessedPage(pProcessedPage)
75 : : {
76 : 1410 : }
77 : :
78 : 1410 : ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter()
79 : : {
80 [ - + ]: 1410 : }
81 : :
82 : : // Process the whole displaying
83 : 1410 : void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo)
84 : : {
85 : 1410 : const sal_uInt32 nCount(GetPaintObjectCount());
86 : :
87 [ + - ]: 1410 : if(nCount)
88 : : {
89 : 1410 : OutputDevice* pTargetDevice = TryToGetOutputDevice();
90 : :
91 [ + - ]: 1410 : if(pTargetDevice)
92 : : {
93 : : // update current ViewInformation2D at the ObjectContact
94 : 1410 : const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile();
95 [ + - ][ + - ]: 1410 : const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
[ + + ]
96 [ + - ]: 1410 : basegfx::B2DRange aViewRange;
97 : :
98 : : // create ViewRange
99 [ + + ]: 1410 : if(!bOutputToRecordingMetaFile)
100 : : {
101 : : // use visible pixels, but transform to world coordinates
102 : 1386 : const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel());
103 [ + - ]: 1386 : aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
104 [ + - ][ + - ]: 1386 : 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 [ + - ][ + - ]: 1410 : com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
115 [ + - ]: 1410 : updateViewInformation2D(aNewViewInformation2D);
116 : :
117 : : // collect primitive data in a sequence; this will already use the updated ViewInformation2D
118 [ + - ]: 1410 : drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence;
119 : :
120 [ + + ]: 4206 : for(sal_uInt32 a(0L); a < nCount; a++)
121 : : {
122 [ + - ][ + - ]: 2796 : const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
123 : :
124 : : drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence,
125 [ + - ][ + - ]: 2796 : rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
[ + - ]
126 : : }
127 : :
128 : : // if there is something to show, use a vclProcessor to render it
129 [ + - ]: 1410 : if(xPrimitiveSequence.hasElements())
130 : : {
131 : : drawinglayer::processor2d::BaseProcessor2D* pProcessor2D =
132 : : drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
133 [ + - ]: 1410 : *pTargetDevice, getViewInformation2D());
134 : :
135 [ + - ]: 1410 : if(pProcessor2D)
136 : : {
137 [ + - ]: 1410 : pProcessor2D->process(xPrimitiveSequence);
138 [ + - ][ + - ]: 1410 : delete pProcessor2D;
139 : : }
140 [ + - ][ + - ]: 1410 : }
141 : : }
142 : : }
143 : 1410 : }
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 : 1419 : OutputDevice* ObjectContactOfObjListPainter::TryToGetOutputDevice() const
165 : : {
166 : 1419 : 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 : 11 : ObjectContactOfPagePainter::ObjectContactOfPagePainter(
189 : : const SdrPage* pPage,
190 : : ObjectContact& rOriginalObjectContact)
191 : : : ObjectContactPainter(),
192 : : mrOriginalObjectContact(rOriginalObjectContact),
193 [ + - ]: 11 : mxStartPage(const_cast< SdrPage* >(pPage)) // no SdrPageWeakRef available to hold a const SdrPage*
194 : : {
195 : 11 : }
196 : :
197 [ + - ]: 11 : ObjectContactOfPagePainter::~ObjectContactOfPagePainter()
198 : : {
199 [ - + ]: 11 : }
200 : :
201 : 11 : void ObjectContactOfPagePainter::SetStartPage(const SdrPage* pPage)
202 : : {
203 [ - + ]: 11 : if(pPage != GetStartPage())
204 : : {
205 : 0 : mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no SdrPageWeakRef available to hold a const SdrPage*
206 : : }
207 : 11 : }
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: */
|