Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / graph.hxx
blob8dcf5925f87f53d6ad0b24d7ee7d7a4ee73d1e72
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <memory>
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
40 NONE,
41 Bitmap,
42 GdiMetafile,
43 Default
46 namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } }
47 namespace vcl { class Font; }
49 class GfxLink;
50 class ImpGraphic;
51 class OutputDevice;
52 class ReaderData;
54 class VCL_DLLPUBLIC GraphicReader
56 public:
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;
67 protected:
68 OUString maUpperName;
70 GraphicReader();
71 private:
72 std::unique_ptr<ReaderData> mpReaderData;
75 class VCL_DLLPUBLIC GraphicConversionParameters
77 private:
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
84 public:
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)
97 // data read access
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
106 private:
108 std::shared_ptr<ImpGraphic> mxImpGraphic;
110 public:
112 SAL_DLLPRIVATE void ImplTestRefCount();
113 SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mxImpGraphic.get(); }
115 public:
116 Graphic();
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;
132 void Clear();
134 GraphicType GetType() const;
135 void SetDefaultType();
136 bool IsSupportedGraphic() const;
138 bool IsTransparent() const;
139 bool IsAlpha() const;
140 bool IsAnimated() const;
141 bool IsEPS() 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
147 // before.
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,
185 long nExtraData );
187 void SetAnimationNotifyHdl( const Link<Animation*,void>& rLink );
188 Link<Animation*,void> GetAnimationNotifyHdl() const;
190 sal_uLong GetAnimationLoopCount() const;
192 BitmapChecksum GetChecksum() const;
194 public:
196 std::shared_ptr<GraphicReader>& GetContext();
197 void SetContext( const std::shared_ptr<GraphicReader> &pReader );
198 void SetDummyContext(bool value);
199 bool IsDummyContext();
200 private:
201 friend class GraphicObject;
203 bool SwapOut();
204 void SwapOutAsLink();
205 bool SwapOut( SvStream* pOStm );
206 bool SwapIn();
207 bool SwapIn( SvStream* pIStm );
208 bool IsSwapOut() const;
210 public:
211 void SetLink( const GfxLink& );
212 GfxLink GetLink() const;
213 bool IsLink() 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);
220 public:
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: */