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