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
23 #include <tools/stream.hxx>
24 #include <vcl/dllapi.h>
25 #include <tools/solar.h>
26 #include <vcl/bitmap.hxx>
27 #include <vcl/bitmapex.hxx>
28 #include <vcl/animate.hxx>
29 #include <vcl/gdimtf.hxx>
30 #include <vcl/graph.h>
31 #include <vcl/gfxlink.hxx>
32 #include <com/sun/star/uno/Reference.hxx>
33 #include <vcl/svgdata.hxx>
35 namespace com
{ namespace sun
{ namespace star
{ namespace graphic
{ class XGraphic
;} } } }
43 namespace vcl
{ class Font
; }
46 class VCL_DLLPUBLIC GraphicConversionParameters
49 Size maSizePixel
; // default is (0,0)
52 bool mbUnlimitedSize
: 1; // default is false
53 bool mbAntiAliase
: 1; // default is false
54 bool mbSnapHorVerLines
: 1; // default is false
55 bool mbScaleHighQuality
: 1; // default is false
58 GraphicConversionParameters(
59 const Size
& rSizePixel
= Size(),
60 bool bUnlimitedSize
= false,
61 bool bAntiAliase
= false,
62 bool bSnapHorVerLines
= false,
63 bool bScaleHighQuality
= false)
64 : maSizePixel(rSizePixel
),
65 mbUnlimitedSize(bUnlimitedSize
),
66 mbAntiAliase(bAntiAliase
),
67 mbSnapHorVerLines(bSnapHorVerLines
),
68 mbScaleHighQuality(bScaleHighQuality
)
73 const Size
getSizePixel() const { return maSizePixel
; }
74 bool getUnlimitedSize() const { return mbUnlimitedSize
; }
75 bool getAntiAliase() const { return mbAntiAliase
; }
76 bool getSnapHorVerLines() const { return mbSnapHorVerLines
; }
77 bool getScaleHighQuality() const { return mbScaleHighQuality
; }
80 class VCL_DLLPUBLIC Graphic
: public SvDataCopyStream
84 ImpGraphic
* mpImpGraphic
;
88 SAL_DLLPRIVATE
void ImplTestRefCount();
89 SAL_DLLPRIVATE ImpGraphic
* ImplGetImpGraphic() const { return mpImpGraphic
; }
96 Graphic( const Graphic
& rGraphic
);
97 Graphic( const Bitmap
& rBmp
);
98 Graphic( const BitmapEx
& rBmpEx
);
99 Graphic( const SvgDataPtr
& rSvgDataPtr
);
100 Graphic( const Animation
& rAnimation
);
101 Graphic( const GDIMetaFile
& rMtf
);
102 Graphic( const ::com::sun::star::uno::Reference
< ::com::sun::star::graphic::XGraphic
>& rxGraphic
);
105 Graphic
& operator=( const Graphic
& rGraphic
);
106 bool operator==( const Graphic
& rGraphic
) const;
107 bool operator!=( const Graphic
& rGraphic
) const;
108 bool operator!() const;
112 GraphicType
GetType() const;
113 void SetDefaultType();
114 bool IsSupportedGraphic() const;
116 bool IsTransparent() const;
117 bool IsAlpha() const;
118 bool IsAnimated() const;
121 // #i102089# Access of Bitmap potentially will have to rasterconvert the Graphic
122 // if it is a MetaFile. To be able to control this conversion it is necessary to
123 // allow giving parameters which control AntiAliasing and LineSnapping of the
124 // MetaFile when played. Defaults will use a no-AAed, not snapped conversion as
126 Bitmap
GetBitmap(const GraphicConversionParameters
& rParameters
= GraphicConversionParameters()) const;
127 BitmapEx
GetBitmapEx(const GraphicConversionParameters
& rParameters
= GraphicConversionParameters()) const;
129 Animation
GetAnimation() const;
130 const GDIMetaFile
& GetGDIMetaFile() const;
132 ::com::sun::star::uno::Reference
< ::com::sun::star::graphic::XGraphic
> GetXGraphic() const;
134 Size
GetPrefSize() const;
135 void SetPrefSize( const Size
& rPrefSize
);
137 MapMode
GetPrefMapMode() const;
138 void SetPrefMapMode( const MapMode
& rPrefMapMode
);
140 Size
GetSizePixel( const OutputDevice
* pRefDevice
= NULL
) const;
142 sal_uLong
GetSizeBytes() const;
144 void Draw( OutputDevice
* pOutDev
,
145 const Point
& rDestPt
) const;
146 void Draw( OutputDevice
* pOutDev
,
147 const Point
& rDestPt
,
148 const Size
& rDestSize
) const;
149 static void DrawEx( OutputDevice
* pOutDev
, const OUString
& rText
,
150 vcl::Font
& rFont
, const BitmapEx
& rBitmap
,
151 const Point
& rDestPt
, const Size
& rDestSize
);
153 void StartAnimation( OutputDevice
* pOutDev
,
154 const Point
& rDestPt
,
155 const Size
& rDestSize
,
156 long nExtraData
= 0L,
157 OutputDevice
* pFirstFrameOutDev
= NULL
);
158 void StopAnimation( OutputDevice
* pOutputDevice
= NULL
,
159 long nExtraData
= 0L );
161 void SetAnimationNotifyHdl( const Link
<>& rLink
);
162 Link
<> GetAnimationNotifyHdl() const;
164 sal_uLong
GetAnimationLoopCount() const;
166 BitmapChecksum
GetChecksum() const;
170 GraphicReader
* GetContext();
171 void SetContext( GraphicReader
* pReader
);
174 friend class GraphicObject
;
176 void SwapOutAsLink();
177 bool SwapOut( SvStream
* pOStm
);
179 bool SwapIn( SvStream
* pIStm
);
180 bool IsSwapOut() const;
183 void SetLink( const GfxLink
& );
184 GfxLink
GetLink() const;
187 bool ExportNative( SvStream
& rOStream
) const;
189 friend VCL_DLLPUBLIC SvStream
& WriteGraphic( SvStream
& rOStream
, const Graphic
& rGraphic
);
190 friend VCL_DLLPUBLIC SvStream
& ReadGraphic( SvStream
& rIStream
, Graphic
& rGraphic
);
194 virtual void Load( SvStream
& ) SAL_OVERRIDE
;
195 virtual void Save( SvStream
& ) SAL_OVERRIDE
;
196 virtual void Assign( const SvDataCopyStream
& ) SAL_OVERRIDE
;
198 const SvgDataPtr
& getSvgData() const;
200 static css::uno::Sequence
<sal_Int8
> getUnoTunnelId();
203 #endif // INCLUDED_VCL_GRAPH_HXX
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */