Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVX_GALMISC_HXX_
30 : : #define _SVX_GALMISC_HXX_
31 : :
32 : : #include <sot/storage.hxx>
33 : : #include <tools/urlobj.hxx>
34 : : #include <svtools/imap.hxx>
35 : : #include <svl/hint.hxx>
36 : : #include <svtools/transfer.hxx>
37 : : #include <svx/svdobj.hxx>
38 : : #include <com/sun/star/uno/Reference.h>
39 : : #include <com/sun/star/awt/XProgressMonitor.hpp>
40 : : #include "svx/svxdllapi.h"
41 : : #include <tools/date.hxx>
42 : : #include <tools/time.hxx>
43 : :
44 : : // ------------
45 : : // - Forwards -
46 : : // ------------
47 : :
48 : : class GalleryTheme;
49 : :
50 : : // ----------------
51 : : // - ExchangeData -
52 : : // ----------------
53 : :
54 : : struct ExchangeData
55 : : {
56 : : GalleryTheme* pTheme;
57 : : String aEditedTitle;
58 : : Date aThemeChangeDate;
59 : : Time aThemeChangeTime;
60 : :
61 : : ExchangeData() :
62 : : aThemeChangeDate( Date::EMPTY ),
63 : : aThemeChangeTime( Time::EMPTY )
64 : : {}
65 : : };
66 : :
67 : : enum SgaObjKind
68 : : {
69 : : SGA_OBJ_NONE = 0, // abstract object
70 : : SGA_OBJ_BMP = 1, // bitmap object
71 : : SGA_OBJ_SOUND = 2, // sound object
72 : : SGA_OBJ_VIDEO = 3, // video object
73 : : SGA_OBJ_ANIM = 4, // animation object
74 : : SGA_OBJ_SVDRAW = 5, // Svdraw object
75 : : SGA_OBJ_INET = 6 // graphics from the internet
76 : : };
77 : :
78 : : // -----------
79 : : // - Defines -
80 : : // -----------
81 : :
82 : : #define IV_IMAPINFO (sal_uInt32('S')*0x00000001+sal_uInt32('D')*0x00000100+sal_uInt32('U')*0x00010000+sal_uInt32('D')*0x01000000)
83 : : #define ID_IMAPINFO 2
84 : :
85 : : #define USERDATA_HDL() (LINK(this,SgaUserDataFactory,MakeUserData))
86 : :
87 : : #define GAL_RES(nId) ResId(nId, *GetGalleryResMgr())
88 : : #define GAL_RESSTR(nId) GAL_RES(nId).toString()
89 : : #define STREAMBUF_SIZE 16384L
90 : :
91 : : #define SGA_IMPORT_NONE 0x0000
92 : : #define SGA_IMPORT_FILE 0x0001
93 : : #define SGA_IMPORT_INET 0x0002
94 : :
95 : : #define GALLERY_PROGRESS_RANGE 10000
96 : :
97 : : #define GALLERY_FG_COLOR Application::GetSettings().GetStyleSettings().GetWindowTextColor()
98 : : #define GALLERY_BG_COLOR Application::GetSettings().GetStyleSettings().GetWindowColor()
99 : : #define GALLERY_DLG_COLOR Application::GetSettings().GetStyleSettings().GetDialogColor()
100 : :
101 : : // -------------
102 : : // - Functions -
103 : : // -------------
104 : :
105 : : class ResMgr;
106 : : class String;
107 : : class SvStream;
108 : : class Graphic;
109 : : class FmFormModel;
110 : : class ImageMap;
111 : : class Gallery;
112 : :
113 : : SVX_DLLPUBLIC ResMgr* GetGalleryResMgr();
114 : : sal_uInt16 GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, String& rFilterName, sal_Bool bShowProgress = sal_False );
115 : : sal_Bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel );
116 : : sal_Bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap );
117 : : SVX_DLLPUBLIC String GetReducedString( const INetURLObject& rURL, sal_uIntPtr nMaxLen );
118 : : String GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL );
119 : :
120 : : sal_Bool FileExists( const INetURLObject& rURL );
121 : : sal_Bool CreateDir( const INetURLObject& rURL );
122 : : sal_Bool CopyFile( const INetURLObject& rSrcURL, const INetURLObject& rDstURL );
123 : : sal_Bool KillFile( const INetURLObject& rURL );
124 : : BitmapEx GalleryResGetBitmapEx( sal_uInt32 nId );
125 : :
126 : :
127 : : // ---------------
128 : : // - SgaIMapInfo -
129 : : // ---------------
130 : :
131 : : class SgaIMapInfo : public SdrObjUserData, public SfxListener
132 : : {
133 : : ImageMap aImageMap;
134 : :
135 : : public:
136 [ # # ][ # # ]: 0 : SgaIMapInfo() : SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ) {};
137 : :
138 : : SgaIMapInfo( const ImageMap& rImageMap) :
139 : : SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ),
140 : : aImageMap( rImageMap ) {};
141 : :
142 [ # # ][ # # ]: 0 : virtual ~SgaIMapInfo() {};
[ # # ]
143 : :
144 : 0 : virtual SdrObjUserData* Clone( SdrObject* ) const
145 : : {
146 [ # # ]: 0 : SgaIMapInfo* pInfo = new SgaIMapInfo;
147 : 0 : pInfo->aImageMap = aImageMap;
148 : 0 : return pInfo;
149 : : }
150 : :
151 : : const ImageMap& GetImageMap() const { return aImageMap; }
152 : : };
153 : :
154 : : // ----------------------
155 : : // - SgaUserDataFactory -
156 : : // ----------------------
157 : :
158 : : class SgaUserDataFactory
159 : : {
160 : : public:
161 : : SgaUserDataFactory() { SdrObjFactory::InsertMakeUserDataHdl( USERDATA_HDL() ); }
162 : : ~SgaUserDataFactory() { SdrObjFactory::RemoveMakeUserDataHdl( USERDATA_HDL() ); }
163 : :
164 : : DECL_LINK( MakeUserData, SdrObjFactory* );
165 : : };
166 : :
167 : : // -------------------
168 : : // - GalleryProgress -
169 : : // -------------------
170 : :
171 : : class GraphicFilter;
172 : :
173 : : class SVX_DLLPUBLIC GalleryProgress
174 : : {
175 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar > mxProgressBar;
176 : : GraphicFilter* mpFilter;
177 : :
178 : : public:
179 : :
180 : : GalleryProgress( GraphicFilter* pFilter = NULL );
181 : : ~GalleryProgress();
182 : :
183 : : void Update( sal_uIntPtr nVal, sal_uIntPtr nMaxVal );
184 : : };
185 : :
186 : : // -----------------------
187 : : // - GalleryTransferable -
188 : : // -----------------------
189 : :
190 : : class Gallery;
191 : : class GalleryTheme;
192 : : class GraphicObject;
193 : :
194 : : class GalleryTransferable : public TransferableHelper
195 : : {
196 : : friend class GalleryTheme;
197 : : using TransferableHelper::CopyToClipboard;
198 : :
199 : : private:
200 : :
201 : : GalleryTheme* mpTheme;
202 : : SgaObjKind meObjectKind;
203 : : sal_uInt32 mnObjectPos;
204 : : SotStorageStreamRef mxModelStream;
205 : : GraphicObject* mpGraphicObject;
206 : : ImageMap* mpImageMap;
207 : : INetURLObject* mpURL;
208 : :
209 : : protected:
210 : :
211 : : GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObjectPos, bool bLazy );
212 : : ~GalleryTransferable();
213 : :
214 : : void InitData( bool bLazy );
215 : :
216 : : // TransferableHelper
217 : : virtual void AddSupportedFormats();
218 : : virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
219 : : virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
220 : : virtual void DragFinished( sal_Int8 nDropAction );
221 : : virtual void ObjectReleased();
222 : :
223 : : void CopyToClipboard( Window* pWindow );
224 : : void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions,
225 : : sal_Int32 nDragPointer = DND_POINTER_NONE,
226 : : sal_Int32 nDragImage = DND_IMAGE_NONE );
227 : : };
228 : :
229 : : // ---------------
230 : : // - GalleryHint -
231 : : // ---------------
232 : :
233 : : #define GALLERY_HINT_NONE 0x00000000
234 : : #define GALLERY_HINT_CLOSE_THEME 0x00000001
235 : : #define GALLERY_HINT_THEME_REMOVED 0x00000002
236 : : #define GALLERY_HINT_THEME_RENAMED 0x00000004
237 : : #define GALLERY_HINT_THEME_CREATED 0x00000008
238 : : #define GALLERY_HINT_THEME_UPDATEVIEW 0x00000010
239 : : #define GALLERY_HINT_CLOSE_OBJECT 0x00000020
240 : : #define GALLERY_HINT_OBJECT_REMOVED 0x00000040
241 : :
242 : : // -----------------------------------------------------------------------------
243 : :
244 [ # # ]: 0 : class GalleryHint : public SfxHint
245 : : {
246 : : private:
247 : :
248 : : sal_uIntPtr mnType;
249 : : rtl::OUString maThemeName;
250 : : rtl::OUString maStringData;
251 : : sal_uIntPtr mnData1;
252 : : sal_uIntPtr mnData2;
253 : :
254 : : public:
255 : :
256 : : GalleryHint( sal_uIntPtr nType, const String& rThemeName, sal_uIntPtr nData1 = 0UL, sal_uIntPtr nData2 = 0UL ) :
257 : : mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ), mnData2( nData2 ) {}
258 : :
259 : : GalleryHint( sal_uIntPtr nType, const String& rThemeName, const String& rStringData, sal_uIntPtr nData1 = 0UL, sal_uIntPtr nData2 = 0UL ) :
260 : : mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nData1 ), mnData2( nData2 ) {}
261 : :
262 : : sal_uIntPtr GetType() const { return mnType; }
263 : : const rtl::OUString& GetThemeName() const { return maThemeName; }
264 : : const rtl::OUString& GetStringData() const { return maStringData; }
265 : : sal_uIntPtr GetData1() const { return mnData1; }
266 : : sal_uIntPtr GetData2() const { return mnData2; }
267 : : };
268 : :
269 : : #endif
270 : :
271 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|