1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_IMPGRAPH_HXX
21 #define INCLUDED_VCL_INC_IMPGRAPH_HXX
23 #include <vcl/GraphicExternalLink.hxx>
24 #include "graphic/Manager.hxx"
28 MapMode maPrefMapMode
;
37 sal_uInt32 mnAnimationLoopCount
;
43 class GraphicConversionParameters
;
55 GraphicID(ImpGraphic
const & rGraphic
);
57 bool operator==(const GraphicID
& rID
) const
59 return rID
.mnID1
== mnID1
&& rID
.mnID2
== mnID2
&&
60 rID
.mnID3
== mnID3
&& rID
.mnID4
== mnID4
;
68 OString
getIDString() const;
71 class ImpGraphic final
74 friend class GraphicID
;
75 friend class vcl::graphic::Manager
;
79 GDIMetaFile maMetaFile
;
81 ImpSwapInfo maSwapInfo
;
82 std::unique_ptr
<Animation
> mpAnimation
;
83 std::shared_ptr
<GraphicReader
> mpContext
;
84 std::shared_ptr
<ImpSwapFile
> mpSwapFile
;
85 std::unique_ptr
<GfxLink
> mpGfxLink
;
87 mutable sal_uLong mnSizeBytes
;
90 VectorGraphicDataPtr maVectorGraphicData
;
91 css::uno::Sequence
<sal_Int8
> maPdfData
;
92 std::unique_ptr
<GraphicID
> mpGraphicID
;
93 GraphicExternalLink maGraphicExternalLink
;
95 std::chrono::high_resolution_clock::time_point maLastUsed
;
100 ImpGraphic( const ImpGraphic
& rImpGraphic
);
101 ImpGraphic( ImpGraphic
&& rImpGraphic
);
102 ImpGraphic( const GraphicExternalLink
& rExternalLink
);
103 ImpGraphic( const Bitmap
& rBmp
);
104 ImpGraphic( const BitmapEx
& rBmpEx
);
105 ImpGraphic(const VectorGraphicDataPtr
& rVectorGraphicDataPtr
);
106 ImpGraphic( const Animation
& rAnimation
);
107 ImpGraphic( const GDIMetaFile
& rMtf
);
110 void ImplSetPrepared(bool bAnimated
);
114 ImpGraphic
& operator=( const ImpGraphic
& rImpGraphic
);
115 ImpGraphic
& operator=( ImpGraphic
&& rImpGraphic
);
116 bool operator==( const ImpGraphic
& rImpGraphic
) const;
117 bool operator!=( const ImpGraphic
& rImpGraphic
) const { return !( *this == rImpGraphic
); }
119 OUString
const & getOriginURL() const
121 return maGraphicExternalLink
.msURL
;
124 void setOriginURL(OUString
const & rOriginURL
)
126 maGraphicExternalLink
.msURL
= rOriginURL
;
129 OString
getUniqueID()
132 mpGraphicID
.reset(new GraphicID(*this));
133 return mpGraphicID
->getIDString();
136 void ImplCreateSwapInfo();
137 void ImplClearGraphics();
140 GraphicType
ImplGetType() const { return meType
;}
141 void ImplSetDefaultType();
142 bool ImplIsSupportedGraphic() const;
144 bool ImplIsTransparent() const;
145 bool ImplIsAlpha() const;
146 bool ImplIsAnimated() const;
147 bool ImplIsEPS() const;
149 bool isAvailable() const;
150 bool makeAvailable();
152 Bitmap
ImplGetBitmap(const GraphicConversionParameters
& rParameters
) const;
153 BitmapEx
ImplGetBitmapEx(const GraphicConversionParameters
& rParameters
) const;
154 /// Gives direct access to the contained BitmapEx.
155 const BitmapEx
& ImplGetBitmapExRef() const;
156 Animation
ImplGetAnimation() const;
157 const GDIMetaFile
& ImplGetGDIMetaFile() const;
159 Size
ImplGetSizePixel() const;
161 Size
ImplGetPrefSize() const;
162 void ImplSetPrefSize( const Size
& rPrefSize
);
164 MapMode
ImplGetPrefMapMode() const;
165 void ImplSetPrefMapMode( const MapMode
& rPrefMapMode
);
167 sal_uLong
ImplGetSizeBytes() const;
169 void ImplDraw( OutputDevice
* pOutDev
,
170 const Point
& rDestPt
) const;
171 void ImplDraw( OutputDevice
* pOutDev
,
172 const Point
& rDestPt
,
173 const Size
& rDestSize
) const;
175 void ImplStartAnimation( OutputDevice
* pOutDev
,
176 const Point
& rDestPt
,
177 const Size
& rDestSize
,
179 OutputDevice
* pFirstFrameOutDev
);
180 void ImplStopAnimation( OutputDevice
* pOutputDevice
,
183 void ImplSetAnimationNotifyHdl( const Link
<Animation
*,void>& rLink
);
184 Link
<Animation
*,void> ImplGetAnimationNotifyHdl() const;
186 sal_uInt32
ImplGetAnimationLoopCount() const;
190 std::shared_ptr
<GraphicReader
>& ImplGetContext() { return mpContext
;}
191 void ImplSetContext( const std::shared_ptr
<GraphicReader
>& pReader
);
192 void ImplSetDummyContext( bool value
) { mbDummyContext
= value
; }
193 bool ImplReadEmbedded( SvStream
& rIStream
);
194 bool ImplWriteEmbedded( SvStream
& rOStream
);
197 bool ImplSwapIn( SvStream
* pIStm
);
200 bool ImplSwapOut( SvStream
* pOStm
);
202 bool ImplIsSwapOut() const { return mbSwapOut
;}
203 bool ImplIsDummyContext() const { return mbDummyContext
; }
204 void ImplSetLink( const GfxLink
& );
205 GfxLink
ImplGetLink();
206 bool ImplIsLink() const;
208 BitmapChecksum
ImplGetChecksum() const;
210 bool ImplExportNative( SvStream
& rOStm
) const;
212 friend void WriteImpGraphic(SvStream
& rOStm
, const ImpGraphic
& rImpGraphic
);
213 friend void ReadImpGraphic(SvStream
& rIStm
, ImpGraphic
& rImpGraphic
);
215 const VectorGraphicDataPtr
& getVectorGraphicData() const;
217 const css::uno::Sequence
<sal_Int8
>& getPdfData() const;
219 void setPdfData(const css::uno::Sequence
<sal_Int8
>& rPdfData
);
221 bool ensureAvailable () const;
226 #endif // INCLUDED_VCL_INC_IMPGRAPH_HXX
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */