Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_GRAPH_HXX
21 : #define INCLUDED_VCL_GRAPH_HXX
22 :
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>
34 :
35 : namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } }
36 :
37 :
38 : // - Graphic -
39 :
40 :
41 : class ImpGraphic;
42 : class OutputDevice;
43 : class Font;
44 : class GfxLink;
45 :
46 : class VCL_DLLPUBLIC GraphicConversionParameters
47 : {
48 : private:
49 : Size maSizePixel; // default is (0,0)
50 :
51 : // bitfield
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
56 :
57 : public:
58 0 : 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 0 : mbScaleHighQuality(bScaleHighQuality)
69 : {
70 0 : }
71 :
72 : // data read access
73 0 : const Size getSizePixel() const { return maSizePixel; }
74 0 : bool getUnlimitedSize() const { return mbUnlimitedSize; }
75 0 : bool getAntiAliase() const { return mbAntiAliase; }
76 0 : bool getSnapHorVerLines() const { return mbSnapHorVerLines; }
77 0 : bool getScaleHighQuality() const { return mbScaleHighQuality; }
78 : };
79 :
80 : class VCL_DLLPUBLIC Graphic : public SvDataCopyStream
81 : {
82 : private:
83 :
84 : ImpGraphic* mpImpGraphic;
85 :
86 : public:
87 :
88 : SAL_DLLPRIVATE void ImplTestRefCount();
89 0 : SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mpImpGraphic; }
90 :
91 : public:
92 :
93 : TYPEINFO_OVERRIDE();
94 :
95 : Graphic();
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 );
103 : virtual ~Graphic();
104 :
105 : Graphic& operator=( const Graphic& rGraphic );
106 : bool operator==( const Graphic& rGraphic ) const;
107 : bool operator!=( const Graphic& rGraphic ) const;
108 : bool operator!() const;
109 :
110 : void Clear();
111 :
112 : GraphicType GetType() const;
113 : void SetDefaultType();
114 : bool IsSupportedGraphic() const;
115 :
116 : bool IsTransparent() const;
117 : bool IsAlpha() const;
118 : bool IsAnimated() const;
119 : bool IsEPS() const;
120 :
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
125 : // before.
126 : Bitmap GetBitmap(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const;
127 : BitmapEx GetBitmapEx(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const;
128 :
129 : Animation GetAnimation() const;
130 : const GDIMetaFile& GetGDIMetaFile() const;
131 :
132 : ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > GetXGraphic() const;
133 :
134 : Size GetPrefSize() const;
135 : void SetPrefSize( const Size& rPrefSize );
136 :
137 : MapMode GetPrefMapMode() const;
138 : void SetPrefMapMode( const MapMode& rPrefMapMode );
139 :
140 : Size GetSizePixel( const OutputDevice* pRefDevice = NULL ) const;
141 :
142 : sal_uLong GetSizeBytes() const;
143 :
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 : Font& rFont, const BitmapEx& rBitmap,
151 : const Point& rDestPt, const Size& rDestSize );
152 :
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 );
160 :
161 : void SetAnimationNotifyHdl( const Link& rLink );
162 : Link GetAnimationNotifyHdl() const;
163 :
164 : sal_uLong GetAnimationLoopCount() const;
165 :
166 : sal_uLong GetChecksum() const;
167 :
168 : public:
169 :
170 : GraphicReader* GetContext();
171 : void SetContext( GraphicReader* pReader );
172 :
173 : public:
174 :
175 : void SetDocFileName( const OUString& rName, sal_uLong nFilePos );
176 : const OUString& GetDocFileName() const;
177 : sal_uLong GetDocFilePos() const;
178 :
179 : bool SwapOut();
180 : bool SwapOut( SvStream* pOStm );
181 : bool SwapIn();
182 : bool SwapIn( SvStream* pIStm );
183 : bool IsSwapOut() const;
184 :
185 : void SetLink( const GfxLink& );
186 : GfxLink GetLink() const;
187 : bool IsLink() const;
188 :
189 : bool ExportNative( SvStream& rOStream ) const;
190 :
191 : friend VCL_DLLPUBLIC SvStream& WriteGraphic( SvStream& rOStream, const Graphic& rGraphic );
192 : friend VCL_DLLPUBLIC SvStream& ReadGraphic( SvStream& rIStream, Graphic& rGraphic );
193 :
194 : public:
195 :
196 : virtual void Load( SvStream& ) SAL_OVERRIDE;
197 : virtual void Save( SvStream& ) SAL_OVERRIDE;
198 : virtual void Assign( const SvDataCopyStream& ) SAL_OVERRIDE;
199 :
200 : const SvgDataPtr& getSvgData() const;
201 :
202 : static css::uno::Sequence<sal_Int8> getUnoTunnelId();
203 : };
204 :
205 : #endif // INCLUDED_VCL_GRAPH_HXX
206 :
207 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|