xref: /AOO41X/main/svx/inc/galobj.hxx (revision 5980243063f6840bf3a2e60b2243db5da5e78fa6)
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     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 
92                             SgaObject();
93     virtual                 ~SgaObject() {};
94 
95     virtual SgaObjKind      GetObjKind() const = 0;
96     virtual sal_uInt16          GetVersion() const = 0;
97 
98     virtual BitmapEx        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 BitmapEx    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 
166 // ----------------
167 // - SgaObjectBmp -
168 // ----------------
169 
170 class SgaObjectBmp: public SgaObject
171 {
172 private:
173 
174     void                Init( const Graphic& rGraphic, const INetURLObject& rURL );
175 
176     virtual void        WriteData( SvStream& rOut, const String& rDestDir ) const;
177     virtual void        ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
178 
179     virtual sal_uInt16      GetVersion() const { return 5; }
180 
181 public:
182 
183                         SgaObjectBmp();
184                         SgaObjectBmp( const INetURLObject& rURL );
185                         SgaObjectBmp( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormat );
186     virtual             ~SgaObjectBmp() {};
187 
188     virtual SgaObjKind  GetObjKind() const { return SGA_OBJ_BMP; }
189 };
190 
191 // -----------------
192 // - SgaObjectAnim -
193 // -----------------
194 
195 class SgaObjectAnim : public SgaObjectBmp
196 {
197 private:
198 
199                         SgaObjectAnim( const INetURLObject& ) {};
200 
201 public:
202 
203                         SgaObjectAnim();
204                         SgaObjectAnim( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormatName );
205 
206     virtual            ~SgaObjectAnim() {};
207 
208     virtual SgaObjKind  GetObjKind() const { return SGA_OBJ_ANIM; }
209 };
210 
211 // -----------------
212 // - SgaObjectINet -
213 // -----------------
214 
215 class SgaObjectINet : public SgaObjectAnim
216 {
217 private:
218 
219                         SgaObjectINet( const INetURLObject& ) {};
220 
221 public:
222 
223                         SgaObjectINet();
224                         SgaObjectINet( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormatName );
225 
226     virtual            ~SgaObjectINet() {};
227 
228     virtual SgaObjKind  GetObjKind() const { return SGA_OBJ_INET; }
229 };
230 #endif
231