LibreOffice Module vcl (master) 1
impgraph.hxx
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
20#pragma once
21
22#include <vcl/dllapi.h>
24#include <vcl/gdimtf.hxx>
25#include <vcl/graph.hxx>
26#include "graphic/Manager.hxx"
27#include "graphic/GraphicID.hxx"
28#include <optional>
29
31{
35
37 bool mbIsEPS;
40
42 sal_Int32 mnPageIndex;
43};
44
45class OutputDevice;
46class GfxLink;
47class ImpSwapFile;
49class ImpGraphic;
50namespace rtl { class OStringBuffer; }
51
52enum class GraphicContentType : sal_Int32
53{
54 Bitmap,
56 Vector
57};
58
60{
61 friend class Graphic;
62 friend class GraphicID;
64
65private:
66
72 std::unique_ptr<Animation> mpAnimation;
73 std::shared_ptr<GraphicReader> mpContext;
74 std::shared_ptr<ImpSwapFile> mpSwapFile;
75 std::shared_ptr<GfxLink> mpGfxLink;
80 std::shared_ptr<VectorGraphicData> maVectorGraphicData;
81 // cache checksum computation
82 mutable BitmapChecksum mnChecksum = 0;
83
84 std::optional<GraphicID> mxGraphicID;
86
87 std::chrono::high_resolution_clock::time_point maLastUsed;
89
90public:
91 ImpGraphic();
92 ImpGraphic( const ImpGraphic& rImpGraphic );
93 ImpGraphic( ImpGraphic&& rImpGraphic ) noexcept;
94 ImpGraphic( GraphicExternalLink aExternalLink);
95 ImpGraphic(std::shared_ptr<GfxLink> xGfxLink, sal_Int32 nPageIndex = 0);
96 ImpGraphic( const BitmapEx& rBmpEx );
97 ImpGraphic(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr);
98 ImpGraphic( const Animation& rAnimation );
99 ImpGraphic( const GDIMetaFile& rMtf );
100 ~ImpGraphic();
101
102 void setPrepared(bool bAnimated, const Size* pSizeHint);
103
104private:
105
106 ImpGraphic& operator=( const ImpGraphic& rImpGraphic );
107 ImpGraphic& operator=( ImpGraphic&& rImpGraphic );
108 bool operator==( const ImpGraphic& rImpGraphic ) const;
109 bool operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); }
110
111 OUString const & getOriginURL() const
112 {
113 return maGraphicExternalLink.msURL;
114 }
115
116 void setOriginURL(OUString const & rOriginURL)
117 {
118 maGraphicExternalLink.msURL = rOriginURL;
119 }
120
121 OString getUniqueID()
122 {
123 if (!mxGraphicID)
124 mxGraphicID.emplace(*this);
125 return mxGraphicID->getIDString();
126 }
127
128 void createSwapInfo();
129 void restoreFromSwapInfo();
130
131 void clearGraphics();
132 void clear();
133
134 GraphicType getType() const { return meType;}
135 void setDefaultType();
136 bool isSupportedGraphic() const;
137
138 bool isTransparent() const;
139 bool isAlpha() const;
140 bool isAnimated() const;
141 bool isEPS() const;
142
143 bool isAvailable() const;
144 bool makeAvailable();
145
146 Bitmap getBitmap(const GraphicConversionParameters& rParameters) const;
147 BitmapEx getBitmapEx(const GraphicConversionParameters& rParameters) const;
149 const BitmapEx& getBitmapExRef() const;
150 Animation getAnimation() const;
151 const GDIMetaFile& getGDIMetaFile() const;
152
153 Size getSizePixel() const;
154
155 Size getPrefSize() const;
156 void setPrefSize( const Size& rPrefSize );
157
158 MapMode getPrefMapMode() const;
159 void setPrefMapMode( const MapMode& rPrefMapMode );
160
161 sal_uLong getSizeBytes() const;
162
163 void draw(OutputDevice& rOutDev, const Point& rDestPt) const;
164 void draw(OutputDevice& rOutDev, const Point& rDestPt,
165 const Size& rDestSize) const;
166
167 void startAnimation(OutputDevice& rOutDev,
168 const Point& rDestPt,
169 const Size& rDestSize,
170 tools::Long nRendererId,
171 OutputDevice* pFirstFrameOutDev);
172 void stopAnimation( const OutputDevice* pOutputDevice,
173 tools::Long nRendererId );
174
175 void setAnimationNotifyHdl( const Link<Animation*,void>& rLink );
176 Link<Animation*,void> getAnimationNotifyHdl() const;
177
178 sal_uInt32 getAnimationLoopCount() const;
179
180private:
181 // swapping methods
182 bool swapInFromStream(SvStream& rStream);
183 bool swapInGraphic(SvStream& rStream);
184
185 bool swapInContent(SvStream& rStream);
186 bool swapOutContent(SvStream& rStream);
187 bool swapOutGraphic(SvStream& rStream);
188 // end swapping
189
190 std::shared_ptr<GraphicReader>& getContext() { return mpContext;}
191 void setContext( const std::shared_ptr<GraphicReader>& pReader );
192 void setDummyContext( bool value ) { mbDummyContext = value; }
193 bool isDummyContext() const { return mbDummyContext; }
194 void setGfxLink( const std::shared_ptr<GfxLink>& );
195 const std::shared_ptr<GfxLink> & getSharedGfxLink() const;
196 GfxLink getGfxLink() const;
197 bool isGfxLink() const;
198
199 BitmapChecksum getChecksum() const;
200
201 const std::shared_ptr<VectorGraphicData>& getVectorGraphicData() const;
202
204 BitmapEx getVectorGraphicReplacement() const;
205
206 bool ensureAvailable () const;
207
208 sal_Int32 getPageNumber() const;
209
210 // Set the pref size, but don't force swap-in
211 void setValuesForPrefSize(const Size& rPrefSize);
212 // Set the pref map mode, but don't force swap-in
213 void setValuesForPrefMapMod(const MapMode& rPrefMapMode);
214
215public:
216 void resetChecksum() { mnChecksum = 0; }
217 bool swapIn();
218 bool swapOut();
219 bool isSwappedOut() const { return mbSwapOut; }
220 SvStream* getSwapFileStream() const;
221 // public only because of use in GraphicFilter
222 void updateFromLoadedGraphic(const ImpGraphic* graphic);
223 void dumpState(rtl::OStringBuffer &rState);
224};
225
226/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
OString getUniqueID()
Definition: impgraph.hxx:121
std::shared_ptr< ImpSwapFile > mpSwapFile
Definition: impgraph.hxx:74
bool isSwappedOut() const
Definition: impgraph.hxx:219
GraphicType meType
Definition: impgraph.hxx:76
sal_uLong mnSizeBytes
Definition: impgraph.hxx:77
void resetChecksum()
Definition: impgraph.hxx:216
std::chrono::high_resolution_clock::time_point maLastUsed
Definition: impgraph.hxx:87
GraphicExternalLink maGraphicExternalLink
Definition: impgraph.hxx:85
GDIMetaFile maMetaFile
Definition: impgraph.hxx:67
std::optional< GraphicID > mxGraphicID
Definition: impgraph.hxx:84
bool mbPrepared
Definition: impgraph.hxx:88
OUString const & getOriginURL() const
Definition: impgraph.hxx:111
bool mbDummyContext
Definition: impgraph.hxx:79
std::shared_ptr< GfxLink > mpGfxLink
Definition: impgraph.hxx:75
Size maExPrefSize
If maBitmapEx is empty, this preferred size will be set on it when it gets initialized.
Definition: impgraph.hxx:70
bool mbSwapOut
Definition: impgraph.hxx:78
std::shared_ptr< GraphicReader > & getContext()
Definition: impgraph.hxx:190
std::unique_ptr< Animation > mpAnimation
Definition: impgraph.hxx:72
std::shared_ptr< VectorGraphicData > maVectorGraphicData
Definition: impgraph.hxx:80
ImpSwapInfo maSwapInfo
Definition: impgraph.hxx:71
bool isDummyContext() const
Definition: impgraph.hxx:193
GraphicType getType() const
Definition: impgraph.hxx:134
void setOriginURL(OUString const &rOriginURL)
Definition: impgraph.hxx:116
std::shared_ptr< GraphicReader > mpContext
Definition: impgraph.hxx:73
void setDummyContext(bool value)
Definition: impgraph.hxx:192
BitmapEx maBitmapEx
Definition: impgraph.hxx:68
bool operator!=(const ImpGraphic &rImpGraphic) const
Definition: impgraph.hxx:109
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
Any value
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
GraphicType
Definition: graph.hxx:35
GraphicContentType
Definition: impgraph.hxx:53
bool isAlpha(sal_Unicode c, bool bCompatible)
long Long
void dumpState(rtl::OStringBuffer &rState)
Definition: svapp.cxx:1705
ParserContextSharedPtr mpContext
sal_uIntPtr sal_uLong
MapMode maPrefMapMode
Definition: impgraph.hxx:32
Size maPrefSize
Definition: impgraph.hxx:33
bool mbIsTransparent
Definition: impgraph.hxx:38
bool mbIsAlpha
Definition: impgraph.hxx:39
Size maSizePixel
Definition: impgraph.hxx:34
sal_uInt32 mnAnimationLoopCount
Definition: impgraph.hxx:41
bool mbIsEPS
Definition: impgraph.hxx:37
bool mbIsAnimated
Definition: impgraph.hxx:36
sal_Int32 mnPageIndex
Definition: impgraph.hxx:42
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:175
RedlineType meType