xref: /trunk/main/vcl/inc/impgraph.hxx (revision ebfcd9af)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_IMPGRAPH_HXX
25 #define _SV_IMPGRAPH_HXX
26 
27 #include <tools/urlobj.hxx>
28 #include <vcl/bitmap.hxx>
29 #include <vcl/bitmapex.hxx>
30 #include <vcl/animate.hxx>
31 #include <vcl/gdimtf.hxx>
32 #include <vcl/graph.h>
33 #include <vcl/svgdata.hxx>
34 
35 // ---------------
36 // - ImpSwapInfo -
37 // ---------------
38 
39 struct ImpSwapInfo
40 {
41 	MapMode		maPrefMapMode;
42 	Size		maPrefSize;
43 };
44 
45 // --------------
46 // - ImpGraphic -
47 // --------------
48 
49 class	OutputDevice;
50 class	GfxLink;
51 struct	ImpSwapFile;
52 class GraphicConversionParameters;
53 
54 class ImpGraphic
55 {
56 	friend class Graphic;
57 
58 private:
59 
60 	GDIMetaFile			maMetaFile;
61 	BitmapEx			maEx;
62 	ImpSwapInfo			maSwapInfo;
63 	Animation*			mpAnimation;
64 	GraphicReader*		mpContext;
65 	ImpSwapFile*		mpSwapFile;
66 	GfxLink*			mpGfxLink;
67 	GraphicType			meType;
68 	String				maDocFileURLStr;
69 	sal_uLong			mnDocFilePos;
70     mutable sal_uLong   mnSizeBytes;
71 	sal_uLong			mnRefCount;
72 	sal_Bool			mbSwapOut;
73 	sal_Bool			mbSwapUnderway;
74 
75     // SvgData support
76     SvgDataPtr          maSvgData;
77 
78 private:
79 
80 						ImpGraphic();
81 						ImpGraphic( const ImpGraphic& rImpGraphic );
82 						ImpGraphic( const Bitmap& rBmp );
83 						ImpGraphic( const BitmapEx& rBmpEx );
84 						ImpGraphic(const SvgDataPtr& rSvgDataPtr);
85 						ImpGraphic( const Animation& rAnimation );
86 						ImpGraphic( const GDIMetaFile& rMtf );
87 	virtual				~ImpGraphic();
88 
89     ImpGraphic&			operator=( const ImpGraphic& rImpGraphic );
90 	sal_Bool				operator==( const ImpGraphic& rImpGraphic ) const;
operator !=(const ImpGraphic & rImpGraphic) const91 	sal_Bool				operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); }
92 
93 	void				ImplClearGraphics( sal_Bool bCreateSwapInfo );
94 	void				ImplClear();
95 
96 	GraphicType			ImplGetType() const;
97 	void				ImplSetDefaultType();
98 	sal_Bool				ImplIsSupportedGraphic() const;
99 
100 	sal_Bool			ImplIsTransparent() const;
101 	sal_Bool			ImplIsAlpha() const;
102 	sal_Bool			ImplIsAnimated() const;
103 	sal_Bool			ImplIsEPS() const;
104 
105 	Bitmap				    ImplGetBitmap(const GraphicConversionParameters& rParameters) const;
106 	BitmapEx			    ImplGetBitmapEx(const GraphicConversionParameters& rParameters) const;
107 	Animation			    ImplGetAnimation() const;
108 	const GDIMetaFile&	    ImplGetGDIMetaFile() const;
109 
110 
111 	Size				ImplGetPrefSize() const;
112 	void				ImplSetPrefSize( const Size& rPrefSize );
113 
114 	MapMode				ImplGetPrefMapMode() const;
115 	void				ImplSetPrefMapMode( const MapMode& rPrefMapMode );
116 
117 	sal_uLong				ImplGetSizeBytes() const;
118 
119 	void				ImplDraw( OutputDevice* pOutDev,
120 								  const Point& rDestPt ) const;
121 	void				ImplDraw( OutputDevice* pOutDev,
122 								  const Point& rDestPt,
123 								  const Size& rDestSize ) const;
124 
125 	void				ImplStartAnimation( OutputDevice* pOutDev,
126 											const Point& rDestPt,
127 											long nExtraData = 0,
128 											OutputDevice* pFirstFrameOutDev = NULL );
129 	void				ImplStartAnimation( OutputDevice* pOutDev,
130 											const Point& rDestPt,
131 											const Size& rDestSize,
132 											long nExtraData = 0,
133 											OutputDevice* pFirstFrameOutDev = NULL );
134 	void				ImplStopAnimation( OutputDevice* pOutputDevice = NULL,
135 										   long nExtraData = 0 );
136 
137 	void				ImplSetAnimationNotifyHdl( const Link& rLink );
138 	Link				ImplGetAnimationNotifyHdl() const;
139 
140 	sal_uLong				ImplGetAnimationLoopCount() const;
141 	void				ImplResetAnimationLoopCount();
142 
143 	List*				ImplGetAnimationInfoList() const;
144 
145 private:
146 
147 	GraphicReader*		ImplGetContext();
148 	void				ImplSetContext( GraphicReader* pReader );
149 
150 private:
151 
152 	void				ImplSetDocFileName( const String& rName, sal_uLong nFilePos );
153 	const String&		ImplGetDocFileName() const;
154 	sal_uLong				ImplGetDocFilePos() const;
155 
156 	sal_Bool				ImplReadEmbedded( SvStream& rIStream, sal_Bool bSwap = sal_False );
157 	sal_Bool				ImplWriteEmbedded( SvStream& rOStream );
158 
159 	sal_Bool				ImplSwapIn();
160 	sal_Bool				ImplSwapIn( SvStream* pIStm );
161 
162 	sal_Bool				ImplSwapOut();
163 	sal_Bool				ImplSwapOut( SvStream* pOStm );
164 
165 	sal_Bool				ImplIsSwapOut() const;
166 
167 	void				ImplSetLink( const GfxLink& );
168 	GfxLink				ImplGetLink();
169 	sal_Bool				ImplIsLink() const;
170 
171 	sal_uLong				ImplGetChecksum() const;
172 
173 	sal_Bool				ImplExportNative( SvStream& rOStm ) const;
174 
175 	friend SvStream&	operator<<( SvStream& rOStm, const ImpGraphic& rImpGraphic );
176 	friend SvStream&	operator>>( SvStream& rIStm, ImpGraphic& rImpGraphic );
177 
178     // SvgData support
179     const SvgDataPtr& getSvgData() const;
180 };
181 
182 #endif // _SV_IMPGRAPH_HXX
183