Update ooo320-m1
[ooovba.git] / svx / inc / galmisc.hxx
blobd19fac542e76f91374cc52f1c85ec584ade0f73f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: galmisc.hxx,v $
10 * $Revision: 1.19 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_GALMISC_HXX_
32 #define _SVX_GALMISC_HXX_
34 #include <sot/storage.hxx>
35 #include <tools/urlobj.hxx>
36 #include <svtools/imap.hxx>
37 #include <svtools/hint.hxx>
38 #include <svtools/transfer.hxx>
39 #include <svx/svdobj.hxx>
40 #include "galobj.hxx"
41 #include <com/sun/star/uno/Reference.h>
42 #ifndef _COM_SUN_STAR_AWT_XPROGRESSMONITOR_HPP
43 #include <com/sun/star/awt/XProgressMonitor.hpp>
44 #endif
45 #include "svx/svxdllapi.h"
47 // -----------
48 // - Defines -
49 // -----------
51 #define IV_IMAPINFO (UINT32('S')*0x00000001+UINT32('D')*0x00000100+UINT32('U')*0x00010000+UINT32('D')*0x01000000)
52 #define ID_IMAPINFO 2
54 #define USERDATA_HDL() (LINK(this,SgaUserDataFactory,MakeUserData))
56 #define GAL_RESID( nId ) ResId( nId, *GetGalleryResMgr() )
57 #define STREAMBUF_SIZE 16384L
59 #define SGA_IMPORT_NONE 0x0000
60 #define SGA_IMPORT_FILE 0x0001
61 #define SGA_IMPORT_INET 0x0002
63 #define GALLERY_PROGRESS_RANGE 10000
65 #define GALLERY_FG_COLOR Application::GetSettings().GetStyleSettings().GetWindowTextColor()
66 #define GALLERY_BG_COLOR Application::GetSettings().GetStyleSettings().GetWindowColor()
67 #define GALLERY_DLG_COLOR Application::GetSettings().GetStyleSettings().GetDialogColor()
69 // -------------
70 // - Functions -
71 // -------------
73 class ResMgr;
74 class String;
75 class SvStream;
76 class Graphic;
77 class FmFormModel;
78 class ImageMap;
79 class Gallery;
81 SVX_DLLPUBLIC ResMgr* GetGalleryResMgr();
82 USHORT GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, String& rFilterName, BOOL bShowProgress = FALSE );
83 BOOL GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel );
84 BOOL CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap );
85 SVX_DLLPUBLIC String GetReducedString( const INetURLObject& rURL, ULONG nMaxLen );
86 String GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL );
88 BOOL FileExists( const INetURLObject& rURL );
89 BOOL CreateDir( const INetURLObject& rURL );
90 BOOL CopyFile( const INetURLObject& rSrcURL, const INetURLObject& rDstURL );
91 BOOL KillFile( const INetURLObject& rURL );
92 BitmapEx GalleryResGetBitmapEx( sal_uInt32 nId );
95 // ---------------
96 // - SgaIMapInfo -
97 // ---------------
99 class SgaIMapInfo : public SdrObjUserData, public SfxListener
101 ImageMap aImageMap;
103 public:
104 SgaIMapInfo() : SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ) {};
106 SgaIMapInfo( const ImageMap& rImageMap) :
107 SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ),
108 aImageMap( rImageMap ) {};
110 virtual ~SgaIMapInfo() {};
112 virtual SdrObjUserData* Clone( SdrObject* ) const
114 SgaIMapInfo* pInfo = new SgaIMapInfo;
115 pInfo->aImageMap = aImageMap;
116 return pInfo;
119 const ImageMap& GetImageMap() const { return aImageMap; }
122 // ----------------------
123 // - SgaUserDataFactory -
124 // ----------------------
126 class SgaUserDataFactory
128 public:
129 SgaUserDataFactory() { SdrObjFactory::InsertMakeUserDataHdl( USERDATA_HDL() ); }
130 ~SgaUserDataFactory() { SdrObjFactory::RemoveMakeUserDataHdl( USERDATA_HDL() ); }
132 DECL_LINK( MakeUserData, SdrObjFactory* );
135 // -------------------
136 // - GalleryProgress -
137 // -------------------
139 class GraphicFilter;
141 class SVX_DLLPUBLIC GalleryProgress
143 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar > mxProgressBar;
144 GraphicFilter* mpFilter;
146 public:
148 GalleryProgress( GraphicFilter* pFilter = NULL );
149 ~GalleryProgress();
151 void Update( ULONG nVal, ULONG nMaxVal );
154 // -----------------------
155 // - GalleryTransferable -
156 // -----------------------
158 class Gallery;
159 class GalleryTheme;
160 class GraphicObject;
162 class GalleryTransferable : public TransferableHelper
164 friend class GalleryTheme;
165 using TransferableHelper::CopyToClipboard;
167 private:
169 GalleryTheme* mpTheme;
170 SgaObjKind meObjectKind;
171 sal_uInt32 mnObjectPos;
172 SotStorageStreamRef mxModelStream;
173 GraphicObject* mpGraphicObject;
174 ImageMap* mpImageMap;
175 INetURLObject* mpURL;
177 protected:
179 GalleryTransferable( GalleryTheme* pTheme, ULONG nObjectPos, bool bLazy );
180 ~GalleryTransferable();
182 void InitData( bool bLazy );
184 // TransferableHelper
185 virtual void AddSupportedFormats();
186 virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
187 virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
188 virtual void DragFinished( sal_Int8 nDropAction );
189 virtual void ObjectReleased();
191 void CopyToClipboard( Window* pWindow );
192 void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions,
193 sal_Int32 nDragPointer = DND_POINTER_NONE,
194 sal_Int32 nDragImage = DND_IMAGE_NONE );
197 // ---------------
198 // - GalleryHint -
199 // ---------------
201 #define GALLERY_HINT_NONE 0x00000000
202 #define GALLERY_HINT_CLOSE_THEME 0x00000001
203 #define GALLERY_HINT_THEME_REMOVED 0x00000002
204 #define GALLERY_HINT_THEME_RENAMED 0x00000004
205 #define GALLERY_HINT_THEME_CREATED 0x00000008
206 #define GALLERY_HINT_THEME_UPDATEVIEW 0x00000010
207 #define GALLERY_HINT_CLOSE_OBJECT 0x00000020
208 #define GALLERY_HINT_OBJECT_REMOVED 0x00000040
210 // -----------------------------------------------------------------------------
212 class GalleryHint : public SfxHint
214 private:
216 ULONG mnType;
217 String maThemeName;
218 String maStringData;
219 ULONG mnData1;
220 ULONG mnData2;
222 public:
224 GalleryHint( ULONG nType, const String& rThemeName, ULONG nData1 = 0UL, ULONG nData2 = 0UL ) :
225 mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ), mnData2( nData2 ) {}
227 GalleryHint( ULONG nType, const String& rThemeName, const String& rStringData, ULONG nData1 = 0UL, ULONG nData2 = 0UL ) :
228 mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nData1 ), mnData2( nData2 ) {}
230 ULONG GetType() const { return mnType; }
231 const String& GetThemeName() const { return maThemeName; }
232 const String& GetStringData() const { return maStringData; }
233 ULONG GetData1() const { return mnData1; }
234 ULONG GetData2() const { return mnData2; }
237 #endif