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_GRAPH_HXX
21 #define INCLUDED_VCL_GRAPH_HXX
24 #include <tools/stream.hxx>
25 #include <vcl/dllapi.h>
26 #include <tools/solar.h>
27 #include <rtl/ustring.hxx>
28 #include <vcl/bitmap.hxx>
29 #include <vcl/bitmapex.hxx>
30 #include <vcl/animate.hxx>
31 #include <vcl/gdimtf.hxx>
32 #include <vcl/gfxlink.hxx>
33 #include <com/sun/star/uno/Reference.hxx>
34 #include <vcl/svgdata.hxx>
35 #include <basegfx/vector/b2dsize.hxx>
38 enum class GraphicType
46 namespace com
{ namespace sun
{ namespace star
{ namespace graphic
{ class XGraphic
;} } } }
47 namespace vcl
{ class Font
; }
54 class VCL_DLLPUBLIC GraphicReader
57 virtual ~GraphicReader();
59 const OUString
& GetUpperFilterName() const { return maUpperName
; }
61 // TODO: when incompatible changes are possible again
62 // the preview size hint should be redone
63 void DisablePreviewMode();
64 void SetPreviewSize( const Size
& );
65 Size
GetPreviewSize() const;
72 std::unique_ptr
<ReaderData
> mpReaderData
;
75 class VCL_DLLPUBLIC GraphicConversionParameters
78 Size maSizePixel
; // default is (0,0)
80 bool mbUnlimitedSize
: 1; // default is false
81 bool mbAntiAliase
: 1; // default is false
82 bool mbSnapHorVerLines
: 1; // default is false
85 GraphicConversionParameters(
86 const Size
& rSizePixel
= Size(),
87 bool bUnlimitedSize
= false,
88 bool bAntiAliase
= false,
89 bool bSnapHorVerLines
= false)
90 : maSizePixel(rSizePixel
),
91 mbUnlimitedSize(bUnlimitedSize
),
92 mbAntiAliase(bAntiAliase
),
93 mbSnapHorVerLines(bSnapHorVerLines
)
98 const Size
& getSizePixel() const { return maSizePixel
; }
99 bool getUnlimitedSize() const { return mbUnlimitedSize
; }
100 bool getAntiAliase() const { return mbAntiAliase
; }
101 bool getSnapHorVerLines() const { return mbSnapHorVerLines
; }
104 class VCL_DLLPUBLIC Graphic
108 std::shared_ptr
<ImpGraphic
> mxImpGraphic
;
112 SAL_DLLPRIVATE
void ImplTestRefCount();
113 SAL_DLLPRIVATE ImpGraphic
* ImplGetImpGraphic() const { return mxImpGraphic
.get(); }
117 Graphic( const Graphic
& rGraphic
);
118 Graphic( Graphic
&& rGraphic
);
119 Graphic( const Bitmap
& rBmp
);
120 Graphic( const BitmapEx
& rBmpEx
);
121 Graphic( const SvgDataPtr
& rSvgDataPtr
);
122 Graphic( const Animation
& rAnimation
);
123 Graphic( const GDIMetaFile
& rMtf
);
124 Graphic( const css::uno::Reference
< css::graphic::XGraphic
>& rxGraphic
);
126 Graphic
& operator=( const Graphic
& rGraphic
);
127 Graphic
& operator=( Graphic
&& rGraphic
);
128 bool operator==( const Graphic
& rGraphic
) const;
129 bool operator!=( const Graphic
& rGraphic
) const;
130 bool operator!() const;
134 GraphicType
GetType() const;
135 void SetDefaultType();
136 bool IsSupportedGraphic() const;
138 bool IsTransparent() const;
139 bool IsAlpha() const;
140 bool IsAnimated() const;
143 // #i102089# Access of Bitmap potentially will have to rasterconvert the Graphic
144 // if it is a MetaFile. To be able to control this conversion it is necessary to
145 // allow giving parameters which control AntiAliasing and LineSnapping of the
146 // MetaFile when played. Defaults will use a no-AAed, not snapped conversion as
148 Bitmap
GetBitmap(const GraphicConversionParameters
& rParameters
= GraphicConversionParameters()) const;
149 BitmapEx
GetBitmapEx(const GraphicConversionParameters
& rParameters
= GraphicConversionParameters()) const;
150 /// Gives direct access to the contained BitmapEx.
151 const BitmapEx
& GetBitmapExRef() const;
153 Animation
GetAnimation() const;
154 const GDIMetaFile
& GetGDIMetaFile() const;
156 css::uno::Reference
< css::graphic::XGraphic
> GetXGraphic() const;
158 Size
GetPrefSize() const;
159 void SetPrefSize( const Size
& rPrefSize
);
161 MapMode
GetPrefMapMode() const;
162 void SetPrefMapMode( const MapMode
& rPrefMapMode
);
164 basegfx::B2DSize
GetPPI() const;
166 Size
GetSizePixel( const OutputDevice
* pRefDevice
= nullptr ) const;
168 sal_uLong
GetSizeBytes() const;
170 void Draw( OutputDevice
* pOutDev
,
171 const Point
& rDestPt
) const;
172 void Draw( OutputDevice
* pOutDev
,
173 const Point
& rDestPt
,
174 const Size
& rDestSize
) const;
175 static void DrawEx( OutputDevice
* pOutDev
, const OUString
& rText
,
176 vcl::Font
& rFont
, const BitmapEx
& rBitmap
,
177 const Point
& rDestPt
, const Size
& rDestSize
);
179 void StartAnimation( OutputDevice
* pOutDev
,
180 const Point
& rDestPt
,
181 const Size
& rDestSize
,
182 long nExtraData
= 0L,
183 OutputDevice
* pFirstFrameOutDev
= nullptr );
184 void StopAnimation( OutputDevice
* pOutputDevice
,
187 void SetAnimationNotifyHdl( const Link
<Animation
*,void>& rLink
);
188 Link
<Animation
*,void> GetAnimationNotifyHdl() const;
190 sal_uLong
GetAnimationLoopCount() const;
192 BitmapChecksum
GetChecksum() const;
196 std::shared_ptr
<GraphicReader
>& GetContext();
197 void SetContext( const std::shared_ptr
<GraphicReader
> &pReader
);
198 void SetDummyContext(bool value
);
199 bool IsDummyContext();
201 friend class GraphicObject
;
204 void SwapOutAsLink();
205 bool SwapOut( SvStream
* pOStm
);
207 bool SwapIn( SvStream
* pIStm
);
208 bool IsSwapOut() const;
211 void SetLink( const GfxLink
& );
212 GfxLink
GetLink() const;
215 bool ExportNative( SvStream
& rOStream
) const;
217 friend VCL_DLLPUBLIC
void WriteGraphic(SvStream
& rOStream
, const Graphic
& rGraphic
);
218 friend VCL_DLLPUBLIC
void ReadGraphic(SvStream
& rIStream
, Graphic
& rGraphic
);
222 const SvgDataPtr
& getSvgData() const;
224 void setPdfData(const css::uno::Sequence
<sal_Int8
>& rPdfData
);
225 const css::uno::Sequence
<sal_Int8
>& getPdfData() const;
227 static css::uno::Sequence
<sal_Int8
> getUnoTunnelId();
230 #endif // INCLUDED_VCL_GRAPH_HXX
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */