xref: /aoo42x/main/vcl/inc/impgraph.hxx (revision ddde725d)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SV_IMPGRAPH_HXX
29 #define _SV_IMPGRAPH_HXX
30 
31 #include <tools/urlobj.hxx>
32 #include <vcl/bitmap.hxx>
33 #include <vcl/bitmapex.hxx>
34 #include <vcl/animate.hxx>
35 #include <vcl/gdimtf.hxx>
36 #include <vcl/graph.h>
37 #include <vcl/svgdata.hxx>
38 
39 // ---------------
40 // - ImpSwapInfo -
41 // ---------------
42 
43 struct ImpSwapInfo
44 {
45 	MapMode		maPrefMapMode;
46 	Size		maPrefSize;
47 };
48 
49 // --------------
50 // - ImpGraphic -
51 // --------------
52 
53 class	OutputDevice;
54 class	GfxLink;
55 struct	ImpSwapFile;
56 class GraphicConversionParameters;
57 
58 class ImpGraphic
59 {
60 	friend class Graphic;
61 
62 private:
63 
64 	GDIMetaFile			maMetaFile;
65 	BitmapEx			maEx;
66 	ImpSwapInfo			maSwapInfo;
67 	Animation*			mpAnimation;
68 	GraphicReader*		mpContext;
69 	ImpSwapFile*		mpSwapFile;
70 	GfxLink*			mpGfxLink;
71 	GraphicType			meType;
72 	String				maDocFileURLStr;
73 	sal_uLong			mnDocFilePos;
74     mutable sal_uLong   mnSizeBytes;
75 	sal_uLong			mnRefCount;
76 	sal_Bool			mbSwapOut;
77 	sal_Bool			mbSwapUnderway;
78 
79     // SvgData support
80     SvgDataPtr          maSvgData;
81 
82 private:
83 
84 						ImpGraphic();
85 						ImpGraphic( const ImpGraphic& rImpGraphic );
86 						ImpGraphic( const Bitmap& rBmp );
87 						ImpGraphic( const BitmapEx& rBmpEx );
88 						ImpGraphic(const SvgDataPtr& rSvgDataPtr);
89 						ImpGraphic( const Animation& rAnimation );
90 						ImpGraphic( const GDIMetaFile& rMtf );
91 	virtual				~ImpGraphic();
92 
93     ImpGraphic&			operator=( const ImpGraphic& rImpGraphic );
94 	sal_Bool				operator==( const ImpGraphic& rImpGraphic ) const;
95 	sal_Bool				operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); }
96 
97 	void				ImplClearGraphics( sal_Bool bCreateSwapInfo );
98 	void				ImplClear();
99 
100 	GraphicType			ImplGetType() const;
101 	void				ImplSetDefaultType();
102 	sal_Bool				ImplIsSupportedGraphic() const;
103 
104 	sal_Bool			ImplIsTransparent() const;
105 	sal_Bool			ImplIsAlpha() const;
106 	sal_Bool			ImplIsAnimated() const;
107 	sal_Bool			ImplIsEPS() const;
108 
109 	Bitmap				    ImplGetBitmap(const GraphicConversionParameters& rParameters) const;
110 	BitmapEx			    ImplGetBitmapEx(const GraphicConversionParameters& rParameters) const;
111 	Animation			    ImplGetAnimation() const;
112 	const GDIMetaFile&	    ImplGetGDIMetaFile() const;
113 
114 
115 	Size				ImplGetPrefSize() const;
116 	void				ImplSetPrefSize( const Size& rPrefSize );
117 
118 	MapMode				ImplGetPrefMapMode() const;
119 	void				ImplSetPrefMapMode( const MapMode& rPrefMapMode );
120 
121 	sal_uLong				ImplGetSizeBytes() const;
122 
123 	void				ImplDraw( OutputDevice* pOutDev,
124 								  const Point& rDestPt ) const;
125 	void				ImplDraw( OutputDevice* pOutDev,
126 								  const Point& rDestPt,
127 								  const Size& rDestSize ) const;
128 
129 	void				ImplStartAnimation( OutputDevice* pOutDev,
130 											const Point& rDestPt,
131 											long nExtraData = 0,
132 											OutputDevice* pFirstFrameOutDev = NULL );
133 	void				ImplStartAnimation( OutputDevice* pOutDev,
134 											const Point& rDestPt,
135 											const Size& rDestSize,
136 											long nExtraData = 0,
137 											OutputDevice* pFirstFrameOutDev = NULL );
138 	void				ImplStopAnimation( OutputDevice* pOutputDevice = NULL,
139 										   long nExtraData = 0 );
140 
141 	void				ImplSetAnimationNotifyHdl( const Link& rLink );
142 	Link				ImplGetAnimationNotifyHdl() const;
143 
144 	sal_uLong				ImplGetAnimationLoopCount() const;
145 	void				ImplResetAnimationLoopCount();
146 
147 	List*				ImplGetAnimationInfoList() const;
148 
149 private:
150 
151 	GraphicReader*		ImplGetContext();
152 	void				ImplSetContext( GraphicReader* pReader );
153 
154 private:
155 
156 	void				ImplSetDocFileName( const String& rName, sal_uLong nFilePos );
157 	const String&		ImplGetDocFileName() const;
158 	sal_uLong				ImplGetDocFilePos() const;
159 
160 	sal_Bool				ImplReadEmbedded( SvStream& rIStream, sal_Bool bSwap = sal_False );
161 	sal_Bool				ImplWriteEmbedded( SvStream& rOStream );
162 
163 	sal_Bool				ImplSwapIn();
164 	sal_Bool				ImplSwapIn( SvStream* pIStm );
165 
166 	sal_Bool				ImplSwapOut();
167 	sal_Bool				ImplSwapOut( SvStream* pOStm );
168 
169 	sal_Bool				ImplIsSwapOut() const;
170 
171 	void				ImplSetLink( const GfxLink& );
172 	GfxLink				ImplGetLink();
173 	sal_Bool				ImplIsLink() const;
174 
175 	sal_uLong				ImplGetChecksum() const;
176 
177 	sal_Bool				ImplExportNative( SvStream& rOStm ) const;
178 
179 	friend SvStream&	operator<<( SvStream& rOStm, const ImpGraphic& rImpGraphic );
180 	friend SvStream&	operator>>( SvStream& rIStm, ImpGraphic& rImpGraphic );
181 
182     // SvgData support
183     const SvgDataPtr& getSvgData() const;
184 };
185 
186 #endif // _SV_IMPGRAPH_HXX
187