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