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>
33#include <memory>
34
35namespace sdr::contact {
36
37ObjectContactPainter::ObjectContactPainter()
38{
39}
40
41// The destructor.
42ObjectContactPainter::~ObjectContactPainter()
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 SdrObjectVector&& rObjects,
61 const SdrPage* pProcessedPage)
62: mrTargetOutputDevice(rTargetDevice),
63 maStartObjects(std::move(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 drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
101 aNewViewInformation2D.setViewTransformation(pTargetDevice->GetViewTransformation());
102 aNewViewInformation2D.setViewport(aViewRange);
103 aNewViewInformation2D.setVisualizedPage(GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)));
104 updateViewInformation2D(aNewViewInformation2D);
105
106 // collect primitive data in a sequence; this will already use the updated ViewInformation2D
108
109 for(sal_uInt32 a(0); a < nCount; a++)
110 {
111 const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
112
113 rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo, xPrimitiveSequence);
114 }
115
116 // if there is something to show, use a vclProcessor to render it
117 if(!xPrimitiveSequence.empty())
118 {
119 std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
120 *pTargetDevice,
121 getViewInformation2D()));
122
123 pProcessor2D->process(xPrimitiveSequence);
124 }
125}
126
127// recording MetaFile?
129{
131 return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
132}
133
134// pdf export?
136{
138}
139
141{
142 if (isOutputToPDFFile())
143 {
144 vcl::PDFExtOutDevData* pPDFExtOutDevData(dynamic_cast<vcl::PDFExtOutDevData*>(
146
147 if (nullptr != pPDFExtOutDevData)
148 {
149 return pPDFExtOutDevData->GetIsExportTaggedPDF();
150 }
151 }
152 return false;
153}
154
156{
157 return &mrTargetOutputDevice;
158}
159
161{
162 return (GetStartPage() ? 1 : 0);
163}
164
166{
167 DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
168 return GetStartPage()->GetViewContact();
169}
170
172 ObjectContact& rOriginalObjectContact)
173: mrOriginalObjectContact(rOriginalObjectContact)
174{
175}
176
178{
179}
180
182{
183 if(pPage != GetStartPage())
184 {
185 mxStartPage = const_cast< SdrPage* >(pPage); // no tools::WeakReference<SdrPage> available to hold a const SdrPage*
186 }
187}
188
190{
192}
193
194}
195
196/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsPause() const
bool IsRecord() const
GDIMetaFile * GetConnectMetaFile() const
basegfx::B2DHomMatrix GetViewTransformation() const
basegfx::B2DHomMatrix GetInverseViewTransformation() const
Size GetOutputSizePixel() const
vcl::ExtOutDevData * GetExtOutDevData() const
OutDevType GetOutDevType() const
Abstract DrawObject.
Definition: svdobj.hxx:261
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:261
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:377
const sdr::contact::ViewContact & GetViewContact() const
Definition: svdpage.cxx:1166
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
void setViewport(const basegfx::B2DRange &rNew)
void setViewTransformation(const basegfx::B2DHomMatrix &rNew)
void setVisualizedPage(const css::uno::Reference< css::drawing::XDrawPage > &rNew)
virtual void ProcessDisplay(DisplayInfo &rDisplayInfo) override
ObjectContactOfObjListPainter(OutputDevice &rTargetDevice, SdrObjectVector &&rObjects, const SdrPage *pProcessedPage)
virtual ViewContact & GetPaintObjectViewContact(sal_uInt32 nIndex) override
virtual OutputDevice * TryToGetOutputDevice() const override
virtual sal_uInt32 GetPaintObjectCount() const override
virtual sal_uInt32 GetPaintObjectCount() const override
ObjectContactOfPagePainter(ObjectContact &rOriginalObjectContact)
virtual OutputDevice * TryToGetOutputDevice() const override
virtual ViewContact & GetPaintObjectViewContact(sal_uInt32 nIndex) override
virtual OutputDevice * TryToGetOutputDevice() const
access to OutputDevice. May return 0L like the default implementations do. Override as needed.
ViewObjectContact & GetViewObjectContact(ObjectContact &rObjectContact)
Definition: viewcontact.cxx:65
virtual void getPrimitive2DSequenceHierarchy(DisplayInfo &rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor &rVisitor) const
bool GetIsExportTaggedPDF() const
int nCount
#define DBG_ASSERT(sCon, aError)
sal_Int32 nIndex
uno_Any a
std::unique_ptr< BaseProcessor2D > createProcessor2DFromOutputDevice(OutputDevice &rTargetOutDev, const drawinglayer::geometry::ViewInformation2D &rViewInformation2D)
class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) ObjectContactPainter typedef ::std::vector< SdrObject * > SdrObjectVector
OUTDEV_PDF
uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage(SdrPage *pPage) noexcept
returns a StarOffice API wrapper for the given SdrPage
Definition: unopage.cxx:873