1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
32 //////////////////////////////////////////////////////////////////////////////
38 ObjectContactPainter::ObjectContactPainter()
43 ObjectContactPainter::~ObjectContactPainter()
46 } // end of namespace contact
47 } // end of namespace sdr
49 //////////////////////////////////////////////////////////////////////////////
55 sal_uInt32
ObjectContactOfObjListPainter::GetPaintObjectCount() const
57 return maStartObjects
.size();
60 ViewContact
& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex
) const
62 const SdrObject
* pObj
= maStartObjects
[nIndex
];
63 DBG_ASSERT(pObj
, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
64 return pObj
->GetViewContact();
67 ObjectContactOfObjListPainter::ObjectContactOfObjListPainter(
68 OutputDevice
& rTargetDevice
,
69 const SdrObjectVector
& rObjects
,
70 const SdrPage
* pProcessedPage
)
71 : ObjectContactPainter(),
72 mrTargetOutputDevice(rTargetDevice
),
73 maStartObjects(rObjects
),
74 mpProcessedPage(pProcessedPage
)
78 ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter()
82 // Process the whole displaying
83 void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo
& rDisplayInfo
)
85 const sal_uInt32
nCount(GetPaintObjectCount());
89 OutputDevice
* pTargetDevice
= TryToGetOutputDevice();
93 // update current ViewInformation2D at the ObjectContact
94 const GDIMetaFile
* pMetaFile
= pTargetDevice
->GetConnectMetaFile();
95 const bool bOutputToRecordingMetaFile(pMetaFile
&& pMetaFile
->IsRecord() && !pMetaFile
->IsPause());
96 basegfx::B2DRange aViewRange
;
99 if(!bOutputToRecordingMetaFile
)
101 // use visible pixels, but transform to world coordinates
102 const Size
aOutputSizePixel(pTargetDevice
->GetOutputSizePixel());
103 aViewRange
= ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel
.getWidth(), aOutputSizePixel
.getHeight());
104 aViewRange
.transform(pTargetDevice
->GetInverseViewTransformation());
107 // upate local ViewInformation2D
108 const drawinglayer::geometry::ViewInformation2D
aNewViewInformation2D(
109 basegfx::B2DHomMatrix(),
110 pTargetDevice
->GetViewTransformation(),
112 GetXDrawPageForSdrPage(const_cast< SdrPage
* >(mpProcessedPage
)),
114 com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>());
115 updateViewInformation2D(aNewViewInformation2D
);
117 // collect primitive data in a sequence; this will already use the updated ViewInformation2D
118 drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence
;
120 for(sal_uInt32
a(0L); a
< nCount
; a
++)
122 const ViewObjectContact
& rViewObjectContact
= GetPaintObjectViewContact(a
).GetViewObjectContact(*this);
124 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence
,
125 rViewObjectContact
.getPrimitive2DSequenceHierarchy(rDisplayInfo
));
128 // if there is something to show, use a vclProcessor to render it
129 if(xPrimitiveSequence
.hasElements())
131 drawinglayer::processor2d::BaseProcessor2D
* pProcessor2D
=
132 drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
133 *pTargetDevice
, getViewInformation2D());
137 pProcessor2D
->process(xPrimitiveSequence
);
146 bool ObjectContactOfObjListPainter::isOutputToVirtualDevice() const
148 return (OUTDEV_VIRDEV
== mrTargetOutputDevice
.GetOutDevType());
151 // recording MetaFile?
152 bool ObjectContactOfObjListPainter::isOutputToRecordingMetaFile() const
154 GDIMetaFile
* pMetaFile
= mrTargetOutputDevice
.GetConnectMetaFile();
155 return (pMetaFile
&& pMetaFile
->IsRecord() && !pMetaFile
->IsPause());
159 bool ObjectContactOfObjListPainter::isOutputToPDFFile() const
161 return (0 != mrTargetOutputDevice
.GetPDFWriter());
164 OutputDevice
* ObjectContactOfObjListPainter::TryToGetOutputDevice() const
166 return &mrTargetOutputDevice
;
168 } // end of namespace contact
169 } // end of namespace sdr
171 //////////////////////////////////////////////////////////////////////////////
177 sal_uInt32
ObjectContactOfPagePainter::GetPaintObjectCount() const
179 return (GetStartPage() ? 1L : 0L);
182 ViewContact
& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32
/*nIndex*/) const
184 DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
185 return GetStartPage()->GetViewContact();
188 ObjectContactOfPagePainter::ObjectContactOfPagePainter(
189 const SdrPage
* pPage
,
190 ObjectContact
& rOriginalObjectContact
)
191 : ObjectContactPainter(),
192 mrOriginalObjectContact(rOriginalObjectContact
),
193 mxStartPage(const_cast< SdrPage
* >(pPage
)) // no SdrPageWeakRef available to hold a const SdrPage*
197 ObjectContactOfPagePainter::~ObjectContactOfPagePainter()
201 void ObjectContactOfPagePainter::SetStartPage(const SdrPage
* pPage
)
203 if(pPage
!= GetStartPage())
205 mxStartPage
.reset(const_cast< SdrPage
* >(pPage
)); // no SdrPageWeakRef available to hold a const SdrPage*
209 OutputDevice
* ObjectContactOfPagePainter::TryToGetOutputDevice() const
211 return mrOriginalObjectContact
.TryToGetOutputDevice();
213 } // end of namespace contact
214 } // end of namespace sdr
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */