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
34namespace sdr::contact {
35
36ObjectContactPainter::ObjectContactPainter()
37{
38}
39
40// The destructor.
41ObjectContactPainter::~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 SdrObjectVector&& rObjects,
60 const SdrPage* pProcessedPage)
61: mrTargetOutputDevice(rTargetDevice),
62 maStartObjects(std::move(rObjects)),
63 mpProcessedPage(pProcessedPage)
64{
65}
66
68{
69}
70
71// Process the whole displaying
73{
74 const sal_uInt32 nCount(GetPaintObjectCount());
75
76 if(!nCount)
77 return;
78
79 OutputDevice* pTargetDevice = TryToGetOutputDevice();
80
81 if(!pTargetDevice)
82 return;
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,
104 0.0);
105 updateViewInformation2D(aNewViewInformation2D);
106
107 // collect primitive data in a sequence; this will already use the updated ViewInformation2D
109
110 for(sal_uInt32 a(0); a < nCount; a++)
111 {
112 const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
113
114 rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo, xPrimitiveSequence);
115 }
116
117 // if there is something to show, use a vclProcessor to render it
118 if(!xPrimitiveSequence.empty())
119 {
120 std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
121 *pTargetDevice,
122 getViewInformation2D()));
123
124 pProcessor2D->process(xPrimitiveSequence);
125 }
126}
127
128// recording MetaFile?
130{
132 return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
133}
134
135// pdf export?
137{
139}
140
142{
143 return &mrTargetOutputDevice;
144}
145
147{
148 return (GetStartPage() ? 1 : 0);
149}
150
152{
153 DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
154 return GetStartPage()->GetViewContact();
155}
156
158 ObjectContact& rOriginalObjectContact)
159: mrOriginalObjectContact(rOriginalObjectContact)
160{
161}
162
164{
165}
166
168{
169 if(pPage != GetStartPage())
170 {
171 mxStartPage = const_cast< SdrPage* >(pPage); // no tools::WeakReference<SdrPage> available to hold a const SdrPage*
172 }
173}
174
176{
178}
179
180}
181
182/* 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
OutDevType GetOutDevType() const
Abstract DrawObject.
Definition: svdobj.hxx:257
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:256
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:1165
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
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
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:875