xref: /aoo42x/main/svx/inc/galobj.hxx (revision 21b36550)
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 
ImplUpdateURL(const INetURLObject & rNewURL)73 	void					ImplUpdateURL( const INetURLObject& rNewURL ) { aURL = rNewURL; }
74 
75 protected:
76 
77 	BitmapEx				aThumbBmp; // Allow transparence to survive
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 							SgaObject();
~SgaObject()92 	virtual					~SgaObject() {};
93 
94 	virtual SgaObjKind		GetObjKind() const = 0;
95 	virtual sal_uInt16			GetVersion() const = 0;
96 
GetThumbBmp() const97 	virtual BitmapEx		GetThumbBmp() const { return aThumbBmp; }
GetThumbMtf() const98 	const GDIMetaFile&		GetThumbMtf() const { return aThumbMtf; }
GetURL() const99 	const INetURLObject&	GetURL() const { return aURL; }
IsValid() const100 	sal_Bool					IsValid() const { return bIsValid; }
IsThumbBitmap() const101 	sal_Bool					IsThumbBitmap() const { return bIsThumbBmp; }
102 
103     const String            GetTitle() const;
104     void                    SetTitle( const String& rTitle );
105 
106 	friend SvStream& 		operator<<( SvStream& rOut, const SgaObject& rObj );
107 	friend SvStream& 		operator>>( SvStream& rIn, SgaObject& rObj );
108 
109     BitmapEx createPreviewBitmapEx(const Size& rSizePixel) const;
110 };
111 
112 // ------------------
113 // - SgaObjectSound -
114 // ------------------
115 
116 class SgaObjectSound : public SgaObject
117 {
118 private:
119 
120 	GalSoundType		eSoundType;
121 
122 	virtual void 		WriteData( SvStream& rOut, const String& rDestDir ) const;
123 	virtual void 		ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
124 
GetVersion() const125 	virtual sal_uInt16		GetVersion() const { return 6; }
126 
127 public:
128 
129 						SgaObjectSound();
130 						SgaObjectSound( const INetURLObject& rURL );
131 	virtual 	   	   ~SgaObjectSound();
132 
GetObjKind() const133 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_SOUND; }
134 	virtual BitmapEx	GetThumbBmp() const;
GetSoundType() const135 	GalSoundType		GetSoundType() const { return eSoundType; }
136 };
137 
138 // -------------------
139 // - SgaObjectSvDraw -
140 // -------------------
141 
142 class FmFormModel;
143 
144 class SgaObjectSvDraw : public SgaObject
145 {
146 	using SgaObject::CreateThumb;
147 
148 private:
149 
150 	sal_Bool				CreateThumb( const FmFormModel& rModel );
151 
152 	virtual void 		WriteData( SvStream& rOut, const String& rDestDir ) const;
153 	virtual void 		ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
154 
GetVersion() const155 	virtual sal_uInt16		GetVersion() const { return 5; }
156 
157 public:
158 
159 						SgaObjectSvDraw();
160 						SgaObjectSvDraw( const FmFormModel& rModel, const INetURLObject& rURL );
161 						SgaObjectSvDraw( SvStream& rIStm, const INetURLObject& rURL );
~SgaObjectSvDraw()162 	virtual 	   	   ~SgaObjectSvDraw() {};
163 
GetObjKind() const164 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_SVDRAW; }
165 };
166 
167 // ----------------
168 // - SgaObjectBmp -
169 // ----------------
170 
171 class SgaObjectBmp: public SgaObject
172 {
173 private:
174 
175 	void				Init( const Graphic& rGraphic, const INetURLObject& rURL );
176 
177 	virtual void   		WriteData( SvStream& rOut, const String& rDestDir ) const;
178 	virtual void   		ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
179 
GetVersion() const180 	virtual sal_uInt16		GetVersion() const { return 5; }
181 
182 public:
183 
184 						SgaObjectBmp();
185 						SgaObjectBmp( const INetURLObject& rURL );
186 						SgaObjectBmp( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormat );
~SgaObjectBmp()187 	virtual				~SgaObjectBmp() {};
188 
GetObjKind() const189 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_BMP; }
190 };
191 
192 // -----------------
193 // - SgaObjectAnim -
194 // -----------------
195 
196 class SgaObjectAnim : public SgaObjectBmp
197 {
198 private:
199 
SgaObjectAnim(const INetURLObject &)200 						SgaObjectAnim( const INetURLObject& ) {};
201 
202 public:
203 
204 						SgaObjectAnim();
205 						SgaObjectAnim( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormatName );
206 
~SgaObjectAnim()207 	virtual 	   	   ~SgaObjectAnim() {};
208 
GetObjKind() const209 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_ANIM; }
210 };
211 
212 // -----------------
213 // - SgaObjectINet -
214 // -----------------
215 
216 class SgaObjectINet : public SgaObjectAnim
217 {
218 private:
219 
SgaObjectINet(const INetURLObject &)220 						SgaObjectINet( const INetURLObject& ) {};
221 
222 public:
223 
224 						SgaObjectINet();
225 						SgaObjectINet( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormatName );
226 
~SgaObjectINet()227 	virtual 	   	   ~SgaObjectINet() {};
228 
GetObjKind() const229 	virtual SgaObjKind	GetObjKind() const { return SGA_OBJ_INET; }
230 };
231 #endif
232