xref: /aoo41x/main/svx/inc/galobj.hxx (revision cdf0e10c)
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 _SVX_GALOBJ_HXX_
29 #define _SVX_GALOBJ_HXX_
30 
31 #include <tools/urlobj.hxx>
32 #include <vcl/graph.hxx>
33 #include "svx/galmisc.hxx"
34 
35 // -----------
36 // - Defines -
37 // -----------
38 
39 #define S_THUMB 80
40 
41 // -----------------------------------------------------------------------------
42 
43 #define SGA_FORMAT_NONE					0x00000000L
44 #define	SGA_FORMAT_STRING				0x00000001L
45 #define	SGA_FORMAT_GRAPHIC				0x00000010L
46 #define	SGA_FORMAT_SOUND				0x00000100L
47 #define	SGA_FORMAT_OLE					0x00001000L
48 #define	SGA_FORMAT_SVDRAW				0x00010000L
49 #define SGA_FORMAT_ALL					0xFFFFFFFFL
50 
51 // ----------------
52 // - GalSoundType -
53 // ----------------
54 
55 enum GalSoundType
56 {
57 	SOUND_STANDARD = 0,
58 	SOUND_COMPUTER = 1,
59 	SOUND_MISC = 2,
60 	SOUND_MUSIC = 3,
61 	SOUND_NATURE = 4,
62 	SOUND_SPEECH = 5,
63 	SOUND_TECHNIC = 6,
64 	SOUND_ANIMAL = 7
65 };
66 
67 // -------------
68 // - SgaObject -
69 // -------------
70 
71 class SVX_DLLPUBLIC SgaObject
72 {
73 	friend class GalleryTheme;
74 
75 private:
76 
77 	void					ImplUpdateURL( const INetURLObject& rNewURL ) { aURL = rNewURL; }
78 
79 protected:
80 
81 	Bitmap					aThumbBmp;
82 	GDIMetaFile				aThumbMtf;
83 	INetURLObject			aURL;
84 	String					aUserName;
85 	String					aTitle;
86 	sal_Bool					bIsValid;
87 	sal_Bool					bIsThumbBmp;
88 
89 	virtual void 			WriteData( SvStream& rOut, const String& rDestDir ) const;
90 	virtual void 			ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
91 
92 	sal_Bool					CreateThumb( const Graphic& rGraphic );
93 
94 public:
95 
96 							SgaObject();
97 	virtual					~SgaObject() {};
98 
99 	virtual SgaObjKind		GetObjKind() const = 0;
100 	virtual sal_uInt16			GetVersion() const = 0;
101 
102 	virtual Bitmap 			GetThumbBmp() const { return aThumbBmp; }
103 	const GDIMetaFile&		GetThumbMtf() const { return aThumbMtf; }
104 	const INetURLObject&	GetURL() const { return aURL; }
105 	sal_Bool					IsValid() const { return bIsValid; }
106 	sal_Bool					IsThumbBitmap() const { return bIsThumbBmp; }
107 
108     const String            GetTitle() const;
109     void                    SetTitle( const String& rTitle );
110 
111 	friend SvStream& 		operator<<( SvStream& rOut, const SgaObject& rObj );
112 	friend SvStream& 		operator>>( SvStream& rIn, SgaObject& rObj );
113 };
114 
115 // ------------------
116 // - SgaObjectSound -
117 // ------------------
118 
119 class SgaObjectSound : public SgaObject
120 {
121 private:
122 
123 	GalSoundType		eSoundType;
124 
125 	virtual void 		WriteData( SvStream& rOut, const String& rDestDir ) const;
126 	virtual void 		ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
127 
128 	virtual sal_uInt16		GetVersion() const { return 6; }
129 
130 public:
131 
132 						SgaObjectSound();
133 						SgaObjectSound( const INetURLObject& rURL );
134 	virtual 	   	   ~SgaObjectSound();
135 
136 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_SOUND; }
137 	virtual Bitmap 		GetThumbBmp() const;
138 	GalSoundType		GetSoundType() const { return eSoundType; }
139 };
140 
141 // -------------------
142 // - SgaObjectSvDraw -
143 // -------------------
144 
145 class FmFormModel;
146 
147 class SgaObjectSvDraw : public SgaObject
148 {
149 	using SgaObject::CreateThumb;
150 
151 private:
152 
153 	sal_Bool				CreateThumb( const FmFormModel& rModel );
154 
155 	virtual void 		WriteData( SvStream& rOut, const String& rDestDir ) const;
156 	virtual void 		ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
157 
158 	virtual sal_uInt16		GetVersion() const { return 5; }
159 
160 public:
161 
162 						SgaObjectSvDraw();
163 						SgaObjectSvDraw( const FmFormModel& rModel, const INetURLObject& rURL );
164 						SgaObjectSvDraw( SvStream& rIStm, const INetURLObject& rURL );
165 	virtual 	   	   ~SgaObjectSvDraw() {};
166 
167 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_SVDRAW; }
168 
169 public:
170 
171     static sal_Bool         DrawCentered( OutputDevice* pOut, const FmFormModel& rModel );
172 };
173 
174 // ----------------
175 // - SgaObjectBmp -
176 // ----------------
177 
178 class SgaObjectBmp: public SgaObject
179 {
180 private:
181 
182 	void				Init( const Graphic& rGraphic, const INetURLObject& rURL );
183 
184 	virtual void   		WriteData( SvStream& rOut, const String& rDestDir ) const;
185 	virtual void   		ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
186 
187 	virtual sal_uInt16		GetVersion() const { return 5; }
188 
189 public:
190 
191 						SgaObjectBmp();
192 						SgaObjectBmp( const INetURLObject& rURL );
193 						SgaObjectBmp( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormat );
194 	virtual				~SgaObjectBmp() {};
195 
196 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_BMP; }
197 };
198 
199 // -----------------
200 // - SgaObjectAnim -
201 // -----------------
202 
203 class SgaObjectAnim : public SgaObjectBmp
204 {
205 private:
206 
207 						SgaObjectAnim( const INetURLObject& ) {};
208 
209 public:
210 
211 						SgaObjectAnim();
212 						SgaObjectAnim( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormatName );
213 
214 	virtual 	   	   ~SgaObjectAnim() {};
215 
216 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_ANIM; }
217 };
218 
219 // -----------------
220 // - SgaObjectINet -
221 // -----------------
222 
223 class SgaObjectINet : public SgaObjectAnim
224 {
225 private:
226 
227 						SgaObjectINet( const INetURLObject& ) {};
228 
229 public:
230 
231 						SgaObjectINet();
232 						SgaObjectINet( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormatName );
233 
234 	virtual 	   	   ~SgaObjectINet() {};
235 
236 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_INET; }
237 };
238 #endif
239