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 .
22 #include <vcl/dllapi.h>
23 #include <vcl/GraphicExternalLink.hxx>
24 #include <vcl/gdimtf.hxx>
25 #include <vcl/graph.hxx>
26 #include "graphic/Manager.hxx"
27 #include "graphic/GraphicID.hxx"
31 MapMode maPrefMapMode
;
40 sal_uInt32 mnAnimationLoopCount
;
41 sal_Int32 mnPageIndex
;
47 class GraphicConversionParameters
;
50 enum class GraphicContentType
: sal_Int32
57 class VCL_DLLPUBLIC ImpGraphic final
60 friend class GraphicID
;
61 friend class vcl::graphic::Manager
;
65 GDIMetaFile maMetaFile
;
67 /// If maBitmapEx is empty, this preferred size will be set on it when it gets initialized.
69 ImpSwapInfo maSwapInfo
;
70 std::unique_ptr
<Animation
> mpAnimation
;
71 std::shared_ptr
<GraphicReader
> mpContext
;
72 std::shared_ptr
<ImpSwapFile
> mpSwapFile
;
73 std::shared_ptr
<GfxLink
> mpGfxLink
;
75 mutable sal_uLong mnSizeBytes
;
78 std::shared_ptr
<VectorGraphicData
> maVectorGraphicData
;
79 // cache checksum computation
80 mutable BitmapChecksum mnChecksum
= 0;
82 std::unique_ptr
<GraphicID
> mpGraphicID
;
83 GraphicExternalLink maGraphicExternalLink
;
85 std::chrono::high_resolution_clock::time_point maLastUsed
;
90 ImpGraphic( const ImpGraphic
& rImpGraphic
);
91 ImpGraphic( ImpGraphic
&& rImpGraphic
) noexcept
;
92 ImpGraphic( const GraphicExternalLink
& rExternalLink
);
93 ImpGraphic(std::shared_ptr
<GfxLink
> const& rGfxLink
, sal_Int32 nPageIndex
= 0);
94 ImpGraphic( const BitmapEx
& rBmpEx
);
95 ImpGraphic(const std::shared_ptr
<VectorGraphicData
>& rVectorGraphicDataPtr
);
96 ImpGraphic( const Animation
& rAnimation
);
97 ImpGraphic( const GDIMetaFile
& rMtf
);
100 void setPrepared(bool bAnimated
, const Size
* pSizeHint
);
104 ImpGraphic
& operator=( const ImpGraphic
& rImpGraphic
);
105 ImpGraphic
& operator=( ImpGraphic
&& rImpGraphic
);
106 bool operator==( const ImpGraphic
& rImpGraphic
) const;
107 bool operator!=( const ImpGraphic
& rImpGraphic
) const { return !( *this == rImpGraphic
); }
109 OUString
const & getOriginURL() const
111 return maGraphicExternalLink
.msURL
;
114 void setOriginURL(OUString
const & rOriginURL
)
116 maGraphicExternalLink
.msURL
= rOriginURL
;
119 OString
getUniqueID()
122 mpGraphicID
.reset(new GraphicID(*this));
123 return mpGraphicID
->getIDString();
126 void createSwapInfo();
127 void restoreFromSwapInfo();
129 void clearGraphics();
132 GraphicType
getType() const { return meType
;}
133 void setDefaultType();
134 bool isSupportedGraphic() const;
136 bool isTransparent() const;
137 bool isAlpha() const;
138 bool isAnimated() const;
141 bool isAvailable() const;
142 bool makeAvailable();
144 Bitmap
getBitmap(const GraphicConversionParameters
& rParameters
) const;
145 BitmapEx
getBitmapEx(const GraphicConversionParameters
& rParameters
) const;
146 /// Gives direct access to the contained BitmapEx.
147 const BitmapEx
& getBitmapExRef() const;
148 Animation
getAnimation() const;
149 const GDIMetaFile
& getGDIMetaFile() const;
151 Size
getSizePixel() const;
153 Size
getPrefSize() const;
154 void setPrefSize( const Size
& rPrefSize
);
156 MapMode
getPrefMapMode() const;
157 void setPrefMapMode( const MapMode
& rPrefMapMode
);
159 sal_uLong
getSizeBytes() const;
161 void draw(OutputDevice
& rOutDev
, const Point
& rDestPt
) const;
162 void draw(OutputDevice
& rOutDev
, const Point
& rDestPt
,
163 const Size
& rDestSize
) const;
165 void startAnimation(OutputDevice
& rOutDev
,
166 const Point
& rDestPt
,
167 const Size
& rDestSize
,
168 tools::Long nExtraData
,
169 OutputDevice
* pFirstFrameOutDev
);
170 void stopAnimation( const OutputDevice
* pOutputDevice
,
171 tools::Long nExtraData
);
173 void setAnimationNotifyHdl( const Link
<Animation
*,void>& rLink
);
174 Link
<Animation
*,void> getAnimationNotifyHdl() const;
176 sal_uInt32
getAnimationLoopCount() const;
180 bool swapInFromStream(SvStream
& rStream
);
181 bool swapInGraphic(SvStream
& rStream
);
183 bool swapInContent(SvStream
& rStream
);
184 bool swapOutContent(SvStream
& rStream
);
185 bool swapOutGraphic(SvStream
& rStream
);
188 std::shared_ptr
<GraphicReader
>& getContext() { return mpContext
;}
189 void setContext( const std::shared_ptr
<GraphicReader
>& pReader
);
190 void setDummyContext( bool value
) { mbDummyContext
= value
; }
191 bool isDummyContext() const { return mbDummyContext
; }
192 void setGfxLink( const std::shared_ptr
<GfxLink
>& );
193 const std::shared_ptr
<GfxLink
> & getSharedGfxLink() const;
194 GfxLink
getGfxLink() const;
195 bool isGfxLink() const;
197 BitmapChecksum
getChecksum() const;
199 const std::shared_ptr
<VectorGraphicData
>& getVectorGraphicData() const;
201 /// Gets the bitmap replacement for a vector graphic.
202 BitmapEx
getVectorGraphicReplacement() const;
204 bool ensureAvailable () const;
206 sal_Int32
getPageNumber() const;
208 // Set the pref size, but don't force swap-in
209 void setValuesForPrefSize(const Size
& rPrefSize
);
210 // Set the pref map mode, but don't force swap-in
211 void setValuesForPrefMapMod(const MapMode
& rPrefMapMode
);
214 void resetChecksum() { mnChecksum
= 0; }
217 bool isSwappedOut() const { return mbSwapOut
; }
218 OUString
getSwapFileURL() const;
219 // public only because of use in GraphicFilter
220 void updateFromLoadedGraphic(ImpGraphic
* graphic
);
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */