LibreOffice Module svx (master)  1
objectcontactofobjlistpainter.cxx
Go to the documentation of this file.
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 
23 #include <svx/svdpage.hxx>
24 #include <svx/svdobj.hxx>
26 #include <svx/svdmodel.hxx>
30 #include <svx/unoapi.hxx>
31 #include <tools/debug.hxx>
32 #include <vcl/gdimtf.hxx>
33 #include <memory>
34 
35 namespace sdr { namespace contact {
36 
38 {
39 }
40 
41 // The destructor.
43 {
44 }
45 
47 {
48  return maStartObjects.size();
49 }
50 
52 {
53  const SdrObject* pObj = maStartObjects[nIndex];
54  DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
55  return pObj->GetViewContact();
56 }
57 
59  OutputDevice& rTargetDevice,
60  const SdrObjectVector& rObjects,
61  const SdrPage* pProcessedPage)
63  mrTargetOutputDevice(rTargetDevice),
64  maStartObjects(rObjects),
65  mpProcessedPage(pProcessedPage)
66 {
67 }
68 
70 {
71 }
72 
73 // Process the whole displaying
75 {
76  const sal_uInt32 nCount(GetPaintObjectCount());
77 
78  if(nCount)
79  {
80  OutputDevice* pTargetDevice = TryToGetOutputDevice();
81 
82  if(pTargetDevice)
83  {
84  // update current ViewInformation2D at the ObjectContact
85  const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile();
86  const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
87  basegfx::B2DRange aViewRange;
88 
89  // create ViewRange
90  if(!bOutputToRecordingMetaFile)
91  {
92  // use visible pixels, but transform to world coordinates
93  const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel());
94  aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
95  aViewRange.transform(pTargetDevice->GetInverseViewTransformation());
96  }
97 
98  // update local ViewInformation2D
99  const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
101  pTargetDevice->GetViewTransformation(),
102  aViewRange,
103  GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)),
104  0.0,
105  css::uno::Sequence<css::beans::PropertyValue>());
106  updateViewInformation2D(aNewViewInformation2D);
107 
108  // collect primitive data in a sequence; this will already use the updated ViewInformation2D
110 
111  for(sal_uInt32 a(0); a < nCount; a++)
112  {
113  const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
114 
115  xPrimitiveSequence.append(rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
116  }
117 
118  // if there is something to show, use a vclProcessor to render it
119  if(!xPrimitiveSequence.empty())
120  {
121  std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
122  *pTargetDevice,
124 
125  if(pProcessor2D)
126  {
127  pProcessor2D->process(xPrimitiveSequence);
128  }
129  }
130  }
131  }
132 }
133 
134 // recording MetaFile?
136 {
138  return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
139 }
140 
141 // pdf export?
143 {
145 }
146 
148 {
149  return &mrTargetOutputDevice;
150 }
151 
153 {
154  return (GetStartPage() ? 1 : 0);
155 }
156 
158 {
159  DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
160  return GetStartPage()->GetViewContact();
161 }
162 
164  ObjectContact& rOriginalObjectContact)
166  mrOriginalObjectContact(rOriginalObjectContact),
167  mxStartPage()
168 {
169 }
170 
172 {
173 }
174 
176 {
177  if(pPage != GetStartPage())
178  {
179  mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no tools::WeakReference<SdrPage> available to hold a const SdrPage*
180  }
181 }
182 
184 {
186 }
187 
188 }}
189 
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::B2DHomMatrix GetInverseViewTransformation() const
OutDevType GetOutDevType() const
virtual ViewContact & GetPaintObjectViewContact(sal_uInt32 nIndex) override
virtual drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequenceHierarchy(DisplayInfo &rDisplayInfo) const
ObjectContactOfPagePainter(ObjectContact &rOriginalObjectContact)
ViewObjectContact & GetViewObjectContact(ObjectContact &rObjectContact)
Definition: viewcontact.cxx:73
GDIMetaFile * GetConnectMetaFile() const
bool IsRecord() const
std::unique_ptr< BaseProcessor2D > createProcessor2DFromOutputDevice(OutputDevice &rTargetOutDev, const drawinglayer::geometry::ViewInformation2D &rViewInformation2D)
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:271
::std::vector< SdrObject * > SdrObjectVector
void updateViewInformation2D(const drawinglayer::geometry::ViewInformation2D &rViewInformation2D)
ObjectContactOfObjListPainter(OutputDevice &rTargetDevice, const SdrObjectVector &rObjects, const SdrPage *pProcessedPage)
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
int nCount
virtual ViewContact & GetPaintObjectViewContact(sal_uInt32 nIndex) override
virtual void ProcessDisplay(DisplayInfo &rDisplayInfo) override
#define DBG_ASSERT(sCon, aError)
uno_Any a
const drawinglayer::geometry::ViewInformation2D & getViewInformation2D() const
OUTDEV_PDF
virtual void append(const Primitive2DReference &) override
void reset(reference_type *pReference)
Size GetOutputSizePixel() const
Abstract DrawObject.
Definition: svdobj.hxx:312
bool IsPause() const
const sdr::contact::ViewContact & GetViewContact() const
Definition: svdpage.cxx:1124
virtual OutputDevice * TryToGetOutputDevice() const override
access to OutputDevice. May return 0L like the default implementations do. Override as needed...
uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage(SdrPage *pPage)
returns a StarOffice API wrapper for the given SdrPage
Definition: unopage.cxx:885
virtual OutputDevice * TryToGetOutputDevice() const
access to OutputDevice. May return 0L like the default implementations do. Override as needed...
virtual sal_uInt32 GetPaintObjectCount() const override
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
basegfx::B2DHomMatrix GetViewTransformation() const
virtual OutputDevice * TryToGetOutputDevice() const override
access to OutputDevice. May return 0L like the default implementations do. Override as needed...
virtual sal_uInt32 GetPaintObjectCount() const override