bump product version to 4.2.0.1
[LibreOffice.git] / include / svx / galmisc.hxx
blob7045a51390ed1b8415fc3e191f242cedcd8207ee
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_GALMISC_HXX
21 #define INCLUDED_SVX_GALMISC_HXX
23 #include <sot/storage.hxx>
24 #include <tools/urlobj.hxx>
25 #include <svtools/imap.hxx>
26 #include <svl/hint.hxx>
27 #include <svtools/transfer.hxx>
28 #include <svx/svdobj.hxx>
29 #include <com/sun/star/uno/Reference.h>
30 #include <com/sun/star/awt/XProgressMonitor.hpp>
31 #include <svx/svxdllapi.h>
32 #include <tools/date.hxx>
33 #include <tools/time.hxx>
35 class GalleryTheme;
37 struct ExchangeData
39 GalleryTheme* pTheme;
40 OUString aEditedTitle;
41 Date aThemeChangeDate;
42 Time aThemeChangeTime;
44 ExchangeData() :
45 aThemeChangeDate( Date::EMPTY ),
46 aThemeChangeTime( Time::EMPTY )
50 enum SgaObjKind
52 SGA_OBJ_NONE = 0, // abstract object
53 SGA_OBJ_BMP = 1, // bitmap object
54 SGA_OBJ_SOUND = 2, // sound object
55 SGA_OBJ_VIDEO = 3, // video object
56 SGA_OBJ_ANIM = 4, // animation object
57 SGA_OBJ_SVDRAW = 5, // Svdraw object
58 SGA_OBJ_INET = 6 // graphics from the internet
61 #define IV_IMAPINFO (sal_uInt32('S')*0x00000001+sal_uInt32('D')*0x00000100+sal_uInt32('U')*0x00010000+sal_uInt32('D')*0x01000000)
62 #define ID_IMAPINFO 2
64 #define USERDATA_HDL() (LINK(this,SgaUserDataFactory,MakeUserData))
66 #define GAL_RES(nId) ResId(nId, *GetGalleryResMgr())
67 #define GAL_RESSTR(nId) GAL_RES(nId).toString()
68 #define STREAMBUF_SIZE 16384L
70 #define SGA_IMPORT_NONE 0x0000
71 #define SGA_IMPORT_FILE 0x0001
72 #define SGA_IMPORT_INET 0x0002
74 #define GALLERY_PROGRESS_RANGE 10000
76 #define GALLERY_FG_COLOR Application::GetSettings().GetStyleSettings().GetWindowTextColor()
77 #define GALLERY_BG_COLOR Application::GetSettings().GetStyleSettings().GetWindowColor()
78 #define GALLERY_DLG_COLOR Application::GetSettings().GetStyleSettings().GetDialogColor()
80 class ResMgr;
81 class SvStream;
82 class Graphic;
83 class FmFormModel;
84 class ImageMap;
85 class Gallery;
87 SVX_DLLPUBLIC ResMgr*
88 GetGalleryResMgr();
89 sal_uInt16 GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, OUString& rFilterName, sal_Bool bShowProgress = sal_False );
90 sal_Bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel );
91 sal_Bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap );
92 SVX_DLLPUBLIC OUString
93 GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen );
94 OUString GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL );
96 sal_Bool FileExists( const INetURLObject& rURL );
97 sal_Bool CreateDir( const INetURLObject& rURL );
98 sal_Bool CopyFile( const INetURLObject& rSrcURL, const INetURLObject& rDstURL );
99 sal_Bool KillFile( const INetURLObject& rURL );
100 BitmapEx GalleryResGetBitmapEx( sal_uInt32 nId );
102 class SgaIMapInfo : public SdrObjUserData, public SfxListener
104 ImageMap aImageMap;
106 public:
107 SgaIMapInfo() : SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ) {};
109 SgaIMapInfo( const ImageMap& rImageMap) :
110 SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ),
111 aImageMap( rImageMap ) {};
113 virtual ~SgaIMapInfo() {};
115 virtual SdrObjUserData* Clone( SdrObject* ) const
117 SgaIMapInfo* pInfo = new SgaIMapInfo;
118 pInfo->aImageMap = aImageMap;
119 return pInfo;
122 const ImageMap& GetImageMap() const { return aImageMap; }
125 class SgaUserDataFactory
127 public:
128 SgaUserDataFactory() { SdrObjFactory::InsertMakeUserDataHdl( USERDATA_HDL() ); }
129 ~SgaUserDataFactory() { SdrObjFactory::RemoveMakeUserDataHdl( USERDATA_HDL() ); }
131 DECL_LINK( MakeUserData, SdrObjFactory* );
134 class GraphicFilter;
136 class SVX_DLLPUBLIC GalleryProgress
138 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar > mxProgressBar;
139 GraphicFilter* mpFilter;
141 public:
143 GalleryProgress( GraphicFilter* pFilter = NULL );
144 ~GalleryProgress();
146 void Update( sal_uIntPtr nVal, sal_uIntPtr nMaxVal );
149 class Gallery;
150 class GalleryTheme;
151 class GraphicObject;
153 class GalleryTransferable : public TransferableHelper
155 friend class GalleryTheme;
156 using TransferableHelper::CopyToClipboard;
158 private:
160 GalleryTheme* mpTheme;
161 SgaObjKind meObjectKind;
162 sal_uInt32 mnObjectPos;
163 SotStorageStreamRef mxModelStream;
164 GraphicObject* mpGraphicObject;
165 ImageMap* mpImageMap;
166 INetURLObject* mpURL;
168 protected:
170 GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObjectPos, bool bLazy );
171 ~GalleryTransferable();
173 void InitData( bool bLazy );
175 // TransferableHelper
176 virtual void AddSupportedFormats();
177 virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
178 virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
179 virtual void DragFinished( sal_Int8 nDropAction );
180 virtual void ObjectReleased();
182 void CopyToClipboard( Window* pWindow );
183 void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions,
184 sal_Int32 nDragPointer = DND_POINTER_NONE,
185 sal_Int32 nDragImage = DND_IMAGE_NONE );
188 #define GALLERY_HINT_NONE 0x00000000
189 #define GALLERY_HINT_CLOSE_THEME 0x00000001
190 #define GALLERY_HINT_THEME_REMOVED 0x00000002
191 #define GALLERY_HINT_THEME_RENAMED 0x00000004
192 #define GALLERY_HINT_THEME_CREATED 0x00000008
193 #define GALLERY_HINT_THEME_UPDATEVIEW 0x00000010
194 #define GALLERY_HINT_CLOSE_OBJECT 0x00000020
195 #define GALLERY_HINT_OBJECT_REMOVED 0x00000040
197 class GalleryHint : public SfxHint
199 private:
201 sal_uIntPtr mnType;
202 OUString maThemeName;
203 OUString maStringData;
204 sal_uIntPtr mnData1;
205 sal_uIntPtr mnData2;
207 public:
209 GalleryHint( sal_uIntPtr nType, const OUString& rThemeName, sal_uIntPtr nData1 = 0UL, sal_uIntPtr nData2 = 0UL ) :
210 mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ), mnData2( nData2 ) {}
212 GalleryHint( sal_uIntPtr nType, const OUString& rThemeName, const OUString& rStringData, sal_uIntPtr nData1 = 0UL, sal_uIntPtr nData2 = 0UL ) :
213 mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nData1 ), mnData2( nData2 ) {}
215 sal_uIntPtr GetType() const { return mnType; }
216 const OUString& GetThemeName() const { return maThemeName; }
217 const OUString& GetStringData() const { return maStringData; }
218 sal_uIntPtr GetData1() const { return mnData1; }
219 sal_uIntPtr GetData2() const { return mnData2; }
222 #endif
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */