xref: /trunk/main/svx/inc/svx/galmisc.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_GALMISC_HXX_
25 #define _SVX_GALMISC_HXX_
26 
27 #include <sot/storage.hxx>
28 #include <tools/urlobj.hxx>
29 #include <svtools/imap.hxx>
30 #include <svl/hint.hxx>
31 #include <svtools/transfer.hxx>
32 #include <svx/svdobj.hxx>
33 #include <com/sun/star/uno/Reference.h>
34 #include <com/sun/star/awt/XProgressMonitor.hpp>
35 #include "svx/svxdllapi.h"
36 #include <tools/date.hxx>
37 #include <tools/time.hxx>
38 
39 // ------------
40 // - Forwards -
41 // ------------
42 
43 class GalleryTheme;
44 
45 // ----------------
46 // - ExchangeData -
47 // ----------------
48 
49 struct ExchangeData
50 {
51 	GalleryTheme*	pTheme;
52 	String			aEditedTitle;
53 	Date			aThemeChangeDate;
54 	Time			aThemeChangeTime;
55 };
56 
57 enum SgaObjKind
58 {
59 	SGA_OBJ_NONE = 0,	// Abstraktes Objekt
60 	SGA_OBJ_BMP	= 1,	// Bitmap-Objekt
61 	SGA_OBJ_SOUND =	2,	// Sound-Objekt
62 	SGA_OBJ_VIDEO =	3, 	// Video-Objekt
63 	SGA_OBJ_ANIM = 4,	// Animations-Objekt
64 	SGA_OBJ_SVDRAW = 5,	// Svdraw-Objekt
65 	SGA_OBJ_INET = 6	// Grafik aus dem Internet
66 };
67 
68 // -----------
69 // - Defines -
70 // -----------
71 
72 #define IV_IMAPINFO			    (sal_uInt32('S')*0x00000001+sal_uInt32('D')*0x00000100+sal_uInt32('U')*0x00010000+sal_uInt32('D')*0x01000000)
73 #define	ID_IMAPINFO			    2
74 
75 #define USERDATA_HDL()		    (LINK(this,SgaUserDataFactory,MakeUserData))
76 
77 #define GAL_RESID( nId )	    ResId( nId, *GetGalleryResMgr() )
78 #define STREAMBUF_SIZE		    16384L
79 
80 #define	SGA_IMPORT_NONE		    0x0000
81 #define	SGA_IMPORT_FILE		    0x0001
82 #define	SGA_IMPORT_INET		    0x0002
83 
84 #define GALLERY_PROGRESS_RANGE  10000
85 
86 #define GALLERY_FG_COLOR        Application::GetSettings().GetStyleSettings().GetWindowTextColor()
87 #define GALLERY_BG_COLOR        Application::GetSettings().GetStyleSettings().GetWindowColor()
88 #define GALLERY_DLG_COLOR       Application::GetSettings().GetStyleSettings().GetDialogColor()
89 
90 // -------------
91 // - Functions -
92 // -------------
93 
94 class ResMgr;
95 class String;
96 class SvStream;
97 class Graphic;
98 class FmFormModel;
99 class ImageMap;
100 class Gallery;
101 
102 SVX_DLLPUBLIC ResMgr*			GetGalleryResMgr();
103 sal_uInt16			GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, String& rFilterName, sal_Bool bShowProgress = sal_False );
104 sal_Bool			GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel );
105 sal_Bool			CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap );
106 SVX_DLLPUBLIC String			GetReducedString( const INetURLObject& rURL, sal_uIntPtr nMaxLen );
107 String			GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL );
108 
109 sal_Bool			FileExists( const INetURLObject& rURL );
110 sal_Bool			CreateDir(  const INetURLObject& rURL );
111 sal_Bool			CopyFile(  const INetURLObject& rSrcURL, const INetURLObject& rDstURL );
112 sal_Bool			KillFile( const INetURLObject& rURL );
113 BitmapEx		GalleryResGetBitmapEx( sal_uInt32 nId );
114 
115 
116 // ---------------
117 // - SgaIMapInfo -
118 // ---------------
119 
120 class SgaIMapInfo : public SdrObjUserData, public SfxListener
121 {
122 	ImageMap				aImageMap;
123 
124 public:
SgaIMapInfo()125 							SgaIMapInfo() : SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ) {};
126 
SgaIMapInfo(const ImageMap & rImageMap)127 							SgaIMapInfo( const ImageMap& rImageMap) :
128 								SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ),
129 								aImageMap( rImageMap ) {};
130 
~SgaIMapInfo()131 	virtual 				~SgaIMapInfo() {};
132 
Clone(SdrObject *) const133 	virtual SdrObjUserData* Clone( SdrObject* ) const
134 							{
135 								SgaIMapInfo* pInfo = new SgaIMapInfo;
136 								pInfo->aImageMap = aImageMap;
137 								return pInfo;
138 							}
139 
GetImageMap() const140 	const ImageMap&			GetImageMap() const { return aImageMap; }
141 };
142 
143 // ----------------------
144 // - SgaUserDataFactory -
145 // ----------------------
146 
147 class SgaUserDataFactory
148 {
149 public:
SgaUserDataFactory()150 		SgaUserDataFactory() { SdrObjFactory::InsertMakeUserDataHdl( USERDATA_HDL() ); }
~SgaUserDataFactory()151 		~SgaUserDataFactory() { SdrObjFactory::RemoveMakeUserDataHdl( USERDATA_HDL() ); }
152 
153 		DECL_LINK( MakeUserData, SdrObjFactory* );
154 };
155 
156 // -------------------
157 // - GalleryProgress -
158 // -------------------
159 
160 class GraphicFilter;
161 
162 class SVX_DLLPUBLIC GalleryProgress
163 {
164 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar >	mxProgressBar;
165 	GraphicFilter*															mpFilter;
166 
167 	public:
168 
169 									GalleryProgress( GraphicFilter* pFilter = NULL );
170 									~GalleryProgress();
171 
172 	void							Update( sal_uIntPtr nVal, sal_uIntPtr nMaxVal );
173 };
174 
175 // -----------------------
176 // - GalleryTransferable -
177 // -----------------------
178 
179 class Gallery;
180 class GalleryTheme;
181 class GraphicObject;
182 
183 class GalleryTransferable : public TransferableHelper
184 {
185 friend class GalleryTheme;
186 using TransferableHelper::CopyToClipboard;
187 
188 private:
189 
190 	GalleryTheme*					mpTheme;
191 	SgaObjKind						meObjectKind;
192 	sal_uInt32						mnObjectPos;
193     SotStorageStreamRef             mxModelStream;
194 	GraphicObject*					mpGraphicObject;
195 	ImageMap*						mpImageMap;
196 	INetURLObject*					mpURL;
197 
198 protected:
199 
200 									GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObjectPos, bool bLazy );
201 									~GalleryTransferable();
202 
203 	void							InitData( bool bLazy );
204 
205 	// TransferableHelper
206 	virtual void					AddSupportedFormats();
207 	virtual sal_Bool				GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
208 	virtual sal_Bool				WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
209 	virtual void					DragFinished( sal_Int8 nDropAction );
210 	virtual void					ObjectReleased();
211 
212 	void							CopyToClipboard( Window* pWindow );
213 	void							StartDrag( Window* pWindow, sal_Int8 nDragSourceActions,
214 											   sal_Int32 nDragPointer = DND_POINTER_NONE,
215 											   sal_Int32 nDragImage = DND_IMAGE_NONE );
216 };
217 
218 // ---------------
219 // - GalleryHint -
220 // ---------------
221 
222 #define GALLERY_HINT_NONE				0x00000000
223 #define GALLERY_HINT_CLOSE_THEME		0x00000001
224 #define GALLERY_HINT_THEME_REMOVED		0x00000002
225 #define GALLERY_HINT_THEME_RENAMED		0x00000004
226 #define GALLERY_HINT_THEME_CREATED		0x00000008
227 #define GALLERY_HINT_THEME_UPDATEVIEW	0x00000010
228 #define GALLERY_HINT_CLOSE_OBJECT		0x00000020
229 #define GALLERY_HINT_OBJECT_REMOVED		0x00000040
230 
231 // -----------------------------------------------------------------------------
232 
233 class GalleryHint : public SfxHint
234 {
235 private:
236 
237 	sal_uIntPtr			mnType;
238 	String			maThemeName;
239 	String			maStringData;
240 	sal_uIntPtr			mnData1;
241 	sal_uIntPtr			mnData2;
242 
243 public:
244 
GalleryHint(sal_uIntPtr nType,const String & rThemeName,sal_uIntPtr nData1=0UL,sal_uIntPtr nData2=0UL)245 					GalleryHint( sal_uIntPtr nType, const String& rThemeName, sal_uIntPtr nData1 = 0UL, sal_uIntPtr nData2 = 0UL ) :
246 						mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ), mnData2( nData2 ) {}
247 
GalleryHint(sal_uIntPtr nType,const String & rThemeName,const String & rStringData,sal_uIntPtr nData1=0UL,sal_uIntPtr nData2=0UL)248 					GalleryHint( sal_uIntPtr nType, const String& rThemeName, const String& rStringData, sal_uIntPtr nData1 = 0UL, sal_uIntPtr nData2 = 0UL ) :
249 						mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nData1 ), mnData2( nData2 ) {}
250 
GetType() const251 	sal_uIntPtr			GetType() const { return mnType; }
GetThemeName() const252 	const String&	GetThemeName() const { return maThemeName; }
GetStringData() const253 	const String&	GetStringData() const { return maStringData; }
GetData1() const254 	sal_uIntPtr			GetData1() const { return mnData1; }
GetData2() const255 	sal_uIntPtr			GetData2() const { return mnData2; }
256 };
257 
258 	#endif
259