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 <basegfx/matrix/b2dhommatrix.hxx>
28 : #include <drawinglayer/processor2d/processor2dtools.hxx>
29 : #include <svx/unoapi.hxx>
30 :
31 :
32 :
33 : namespace sdr
34 : {
35 : namespace contact
36 : {
37 0 : ObjectContactPainter::ObjectContactPainter()
38 : {
39 0 : }
40 :
41 : // The destructor.
42 0 : ObjectContactPainter::~ObjectContactPainter()
43 : {
44 0 : }
45 : } // end of namespace contact
46 : } // end of namespace sdr
47 :
48 :
49 :
50 : namespace sdr
51 : {
52 : namespace contact
53 : {
54 0 : sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const
55 : {
56 0 : return maStartObjects.size();
57 : }
58 :
59 0 : ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const
60 : {
61 0 : const SdrObject* pObj = maStartObjects[nIndex];
62 : DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
63 0 : return pObj->GetViewContact();
64 : }
65 :
66 0 : ObjectContactOfObjListPainter::ObjectContactOfObjListPainter(
67 : OutputDevice& rTargetDevice,
68 : const SdrObjectVector& rObjects,
69 : const SdrPage* pProcessedPage)
70 : : ObjectContactPainter(),
71 : mrTargetOutputDevice(rTargetDevice),
72 : maStartObjects(rObjects),
73 0 : mpProcessedPage(pProcessedPage)
74 : {
75 0 : }
76 :
77 0 : ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter()
78 : {
79 0 : }
80 :
81 : // Process the whole displaying
82 0 : void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo)
83 : {
84 0 : const sal_uInt32 nCount(GetPaintObjectCount());
85 :
86 0 : if(nCount)
87 : {
88 0 : OutputDevice* pTargetDevice = TryToGetOutputDevice();
89 :
90 0 : if(pTargetDevice)
91 : {
92 : // update current ViewInformation2D at the ObjectContact
93 0 : const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile();
94 0 : const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
95 0 : basegfx::B2DRange aViewRange;
96 :
97 : // create ViewRange
98 0 : if(!bOutputToRecordingMetaFile)
99 : {
100 : // use visible pixels, but transform to world coordinates
101 0 : const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel());
102 0 : aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
103 0 : aViewRange.transform(pTargetDevice->GetInverseViewTransformation());
104 : }
105 :
106 : // upate local ViewInformation2D
107 : const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
108 : basegfx::B2DHomMatrix(),
109 : pTargetDevice->GetViewTransformation(),
110 : aViewRange,
111 : GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)),
112 : 0.0,
113 0 : com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>());
114 0 : updateViewInformation2D(aNewViewInformation2D);
115 :
116 : // collect primitive data in a sequence; this will already use the updated ViewInformation2D
117 0 : drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence;
118 :
119 0 : for(sal_uInt32 a(0L); a < nCount; a++)
120 : {
121 0 : const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
122 :
123 : drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence,
124 0 : rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
125 : }
126 :
127 : // if there is something to show, use a vclProcessor to render it
128 0 : if(xPrimitiveSequence.hasElements())
129 : {
130 : drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createProcessor2DFromOutputDevice(
131 : *pTargetDevice,
132 0 : getViewInformation2D());
133 :
134 0 : if(pProcessor2D)
135 : {
136 0 : pProcessor2D->process(xPrimitiveSequence);
137 0 : delete pProcessor2D;
138 : }
139 0 : }
140 : }
141 : }
142 0 : }
143 :
144 : // VirtualDevice?
145 0 : bool ObjectContactOfObjListPainter::isOutputToVirtualDevice() const
146 : {
147 0 : return (OUTDEV_VIRDEV == mrTargetOutputDevice.GetOutDevType());
148 : }
149 :
150 : // recording MetaFile?
151 0 : bool ObjectContactOfObjListPainter::isOutputToRecordingMetaFile() const
152 : {
153 0 : GDIMetaFile* pMetaFile = mrTargetOutputDevice.GetConnectMetaFile();
154 0 : return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
155 : }
156 :
157 : // pdf export?
158 0 : bool ObjectContactOfObjListPainter::isOutputToPDFFile() const
159 : {
160 0 : return (0 != mrTargetOutputDevice.GetPDFWriter());
161 : }
162 :
163 0 : OutputDevice* ObjectContactOfObjListPainter::TryToGetOutputDevice() const
164 : {
165 0 : return &mrTargetOutputDevice;
166 : }
167 : } // end of namespace contact
168 : } // end of namespace sdr
169 :
170 :
171 :
172 : namespace sdr
173 : {
174 : namespace contact
175 : {
176 0 : sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const
177 : {
178 0 : return (GetStartPage() ? 1L : 0L);
179 : }
180 :
181 0 : ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/) const
182 : {
183 : DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
184 0 : return GetStartPage()->GetViewContact();
185 : }
186 :
187 0 : ObjectContactOfPagePainter::ObjectContactOfPagePainter(
188 : const SdrPage* pPage,
189 : ObjectContact& rOriginalObjectContact)
190 : : ObjectContactPainter(),
191 : mrOriginalObjectContact(rOriginalObjectContact),
192 0 : mxStartPage(const_cast< SdrPage* >(pPage)) // no SdrPageWeakRef available to hold a const SdrPage*
193 : {
194 0 : }
195 :
196 0 : ObjectContactOfPagePainter::~ObjectContactOfPagePainter()
197 : {
198 0 : }
199 :
200 0 : void ObjectContactOfPagePainter::SetStartPage(const SdrPage* pPage)
201 : {
202 0 : if(pPage != GetStartPage())
203 : {
204 0 : mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no SdrPageWeakRef available to hold a const SdrPage*
205 : }
206 0 : }
207 :
208 0 : OutputDevice* ObjectContactOfPagePainter::TryToGetOutputDevice() const
209 : {
210 0 : return mrOriginalObjectContact.TryToGetOutputDevice();
211 : }
212 : } // end of namespace contact
213 : } // end of namespace sdr
214 :
215 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|