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>
29 #include <svx/unoapi.hxx>
30 #include <tools/debug.hxx>
31 #include <vcl/gdimtf.hxx>
32 #include <memory>
33 
34 namespace sdr::contact {
35 
36 ObjectContactPainter::ObjectContactPainter()
37 {
38 }
39 
40 // The destructor.
41 ObjectContactPainter::~ObjectContactPainter()
42 {
43 }
44 
46 {
47  return maStartObjects.size();
48 }
49 
51 {
52  const SdrObject* pObj = maStartObjects[nIndex];
53  DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
54  return pObj->GetViewContact();
55 }
56 
58  OutputDevice& rTargetDevice,
59  const SdrObjectVector& rObjects,
60  const SdrPage* pProcessedPage)
61 : ObjectContactPainter(),
62  mrTargetOutputDevice(rTargetDevice),
63  maStartObjects(rObjects),
64  mpProcessedPage(pProcessedPage)
65 {
66 }
67 
69 {
70 }
71 
72 // Process the whole displaying
74 {
75  const sal_uInt32 nCount(GetPaintObjectCount());
76 
77  if(!nCount)
78  return;
79 
80  OutputDevice* pTargetDevice = TryToGetOutputDevice();
81 
82  if(!pTargetDevice)
83  return;
84 
85  // update current ViewInformation2D at the ObjectContact
86  const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile();
87  const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
88  basegfx::B2DRange aViewRange;
89 
90  // create ViewRange
91  if(!bOutputToRecordingMetaFile)
92  {
93  // use visible pixels, but transform to world coordinates
94  const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel());
95  aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
96  aViewRange.transform(pTargetDevice->GetInverseViewTransformation());
97  }
98 
99  // update local ViewInformation2D
100  const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
102  pTargetDevice->GetViewTransformation(),
103  aViewRange,
104  GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)),
105  0.0,
106  css::uno::Sequence<css::beans::PropertyValue>());
107  updateViewInformation2D(aNewViewInformation2D);
108 
109  // collect primitive data in a sequence; this will already use the updated ViewInformation2D
111 
112  for(sal_uInt32 a(0); a < nCount; a++)
113  {
114  const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
115 
116  xPrimitiveSequence.append(rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
117  }
118 
119  // if there is something to show, use a vclProcessor to render it
120  if(!xPrimitiveSequence.empty())
121  {
122  std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
123  *pTargetDevice,
124  getViewInformation2D()));
125 
126  if(pProcessor2D)
127  {
128  pProcessor2D->process(xPrimitiveSequence);
129  }
130  }
131 }
132 
133 // recording MetaFile?
135 {
137  return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
138 }
139 
140 // pdf export?
142 {
144 }
145 
147 {
148  return &mrTargetOutputDevice;
149 }
150 
152 {
153  return (GetStartPage() ? 1 : 0);
154 }
155 
157 {
158  DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
159  return GetStartPage()->GetViewContact();
160 }
161 
163  ObjectContact& rOriginalObjectContact)
164 : ObjectContactPainter(),
165  mrOriginalObjectContact(rOriginalObjectContact),
166  mxStartPage()
167 {
168 }
169 
171 {
172 }
173 
175 {
176  if(pPage != GetStartPage())
177  {
178  mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no tools::WeakReference<SdrPage> available to hold a const SdrPage*
179  }
180 }
181 
183 {
185 }
186 
187 }
188 
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::B2DHomMatrix GetInverseViewTransformation() const
OutDevType GetOutDevType() const
virtual ViewContact & GetPaintObjectViewContact(sal_uInt32 nIndex) override
class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) ObjectContactPainter typedef::std::vector< SdrObject * > SdrObjectVector
virtual drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequenceHierarchy(DisplayInfo &rDisplayInfo) const
ObjectContactOfPagePainter(ObjectContact &rOriginalObjectContact)
ViewObjectContact & GetViewObjectContact(ObjectContact &rObjectContact)
Definition: viewcontact.cxx:71
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:245
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
OUTDEV_PDF
virtual void append(const Primitive2DReference &) override
void reset(reference_type *pReference)
Size GetOutputSizePixel() const
Abstract DrawObject.
Definition: svdobj.hxx:313
bool IsPause() const
const sdr::contact::ViewContact & GetViewContact() const
Definition: svdpage.cxx:1100
virtual OutputDevice * TryToGetOutputDevice() const override
uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage(SdrPage *pPage)
returns a StarOffice API wrapper for the given SdrPage
Definition: unopage.cxx:873
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:365
basegfx::B2DHomMatrix GetViewTransformation() const
virtual OutputDevice * TryToGetOutputDevice() const override
virtual sal_uInt32 GetPaintObjectCount() const override