Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SVX_GALMISC_HXX
21 : #define INCLUDED_SVX_GALMISC_HXX
22 :
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>
34 :
35 : class GalleryTheme;
36 :
37 0 : struct ExchangeData
38 : {
39 : GalleryTheme* pTheme;
40 : OUString aEditedTitle;
41 : Date aThemeChangeDate;
42 : tools::Time aThemeChangeTime;
43 :
44 0 : ExchangeData()
45 : : pTheme(NULL)
46 : , aThemeChangeDate( Date::EMPTY )
47 0 : , aThemeChangeTime( tools::Time::EMPTY )
48 : {
49 0 : }
50 : };
51 :
52 : enum SgaObjKind
53 : {
54 : SGA_OBJ_NONE = 0, // abstract object
55 : SGA_OBJ_BMP = 1, // bitmap object
56 : SGA_OBJ_SOUND = 2, // sound object
57 : SGA_OBJ_VIDEO = 3, // video object
58 : SGA_OBJ_ANIM = 4, // animation object
59 : SGA_OBJ_SVDRAW = 5, // Svdraw object
60 : SGA_OBJ_INET = 6 // graphics from the internet
61 : };
62 :
63 : #define IV_IMAPINFO (sal_uInt32('S')*0x00000001+sal_uInt32('D')*0x00000100+sal_uInt32('U')*0x00010000+sal_uInt32('D')*0x01000000)
64 : #define ID_IMAPINFO 2
65 :
66 : #define USERDATA_HDL() (LINK(this,SgaUserDataFactory,MakeUserData))
67 :
68 : #define GAL_RES(nId) ResId(nId, *GetGalleryResMgr())
69 : #define GAL_RESSTR(nId) GAL_RES(nId).toString()
70 : #define STREAMBUF_SIZE 16384L
71 :
72 : #define SGA_IMPORT_NONE 0x0000
73 : #define SGA_IMPORT_FILE 0x0001
74 : #define SGA_IMPORT_INET 0x0002
75 :
76 : #define GALLERY_PROGRESS_RANGE 10000
77 :
78 : #define GALLERY_FG_COLOR Application::GetSettings().GetStyleSettings().GetWindowTextColor()
79 : #define GALLERY_BG_COLOR Application::GetSettings().GetStyleSettings().GetWindowColor()
80 : #define GALLERY_DLG_COLOR Application::GetSettings().GetStyleSettings().GetDialogColor()
81 :
82 : class ResMgr;
83 : class SvStream;
84 : class Graphic;
85 : class FmFormModel;
86 : class ImageMap;
87 : class Gallery;
88 :
89 : SVX_DLLPUBLIC ResMgr*
90 : GetGalleryResMgr();
91 : sal_uInt16 GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, OUString& rFilterName, bool bShowProgress = false );
92 : bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel );
93 : bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap );
94 : SVX_DLLPUBLIC OUString
95 : GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen );
96 : OUString GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL );
97 :
98 : bool FileExists( const INetURLObject& rURL );
99 : bool CreateDir( const INetURLObject& rURL );
100 : bool CopyFile( const INetURLObject& rSrcURL, const INetURLObject& rDstURL );
101 : bool KillFile( const INetURLObject& rURL );
102 : BitmapEx GalleryResGetBitmapEx( sal_uInt32 nId );
103 :
104 : class SgaIMapInfo : public SdrObjUserData, public SfxListener
105 : {
106 : ImageMap aImageMap;
107 :
108 : public:
109 0 : SgaIMapInfo() : SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ) {};
110 :
111 0 : SgaIMapInfo( const ImageMap& rImageMap) :
112 : SdrObjUserData( IV_IMAPINFO, ID_IMAPINFO, 0 ),
113 0 : aImageMap( rImageMap ) {};
114 :
115 0 : virtual ~SgaIMapInfo() {};
116 :
117 0 : virtual SdrObjUserData* Clone( SdrObject* ) const SAL_OVERRIDE
118 : {
119 0 : SgaIMapInfo* pInfo = new SgaIMapInfo;
120 0 : pInfo->aImageMap = aImageMap;
121 0 : return pInfo;
122 : }
123 :
124 0 : const ImageMap& GetImageMap() const { return aImageMap; }
125 : };
126 :
127 : class SgaUserDataFactory
128 : {
129 : public:
130 0 : SgaUserDataFactory() { SdrObjFactory::InsertMakeUserDataHdl( USERDATA_HDL() ); }
131 0 : ~SgaUserDataFactory() { SdrObjFactory::RemoveMakeUserDataHdl( USERDATA_HDL() ); }
132 :
133 : DECL_LINK( MakeUserData, SdrObjFactory* );
134 : };
135 :
136 : class GraphicFilter;
137 :
138 : class SVX_DLLPUBLIC GalleryProgress
139 : {
140 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar > mxProgressBar;
141 : GraphicFilter* mpFilter;
142 :
143 : public:
144 :
145 : GalleryProgress( GraphicFilter* pFilter = NULL );
146 : ~GalleryProgress();
147 :
148 : void Update( sal_uIntPtr nVal, sal_uIntPtr nMaxVal );
149 : };
150 :
151 : class Gallery;
152 : class GalleryTheme;
153 : class GraphicObject;
154 :
155 : class GalleryTransferable : public TransferableHelper
156 : {
157 : friend class GalleryTheme;
158 : using TransferableHelper::CopyToClipboard;
159 :
160 : private:
161 :
162 : GalleryTheme* mpTheme;
163 : SgaObjKind meObjectKind;
164 : sal_uInt32 mnObjectPos;
165 : SotStorageStreamRef mxModelStream;
166 : GraphicObject* mpGraphicObject;
167 : ImageMap* mpImageMap;
168 : INetURLObject* mpURL;
169 :
170 : protected:
171 :
172 : GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObjectPos, bool bLazy );
173 : virtual ~GalleryTransferable();
174 :
175 : void InitData( bool bLazy );
176 :
177 : // TransferableHelper
178 : virtual void AddSupportedFormats() SAL_OVERRIDE;
179 : virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE;
180 : virtual bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE;
181 : virtual void DragFinished( sal_Int8 nDropAction ) SAL_OVERRIDE;
182 : virtual void ObjectReleased() SAL_OVERRIDE;
183 :
184 : void CopyToClipboard( vcl::Window* pWindow );
185 : void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions,
186 : sal_Int32 nDragPointer = DND_POINTER_NONE,
187 : sal_Int32 nDragImage = DND_IMAGE_NONE );
188 : };
189 :
190 : #define GALLERY_HINT_NONE 0x00000000
191 : #define GALLERY_HINT_CLOSE_THEME 0x00000001
192 : #define GALLERY_HINT_THEME_REMOVED 0x00000002
193 : #define GALLERY_HINT_THEME_RENAMED 0x00000004
194 : #define GALLERY_HINT_THEME_CREATED 0x00000008
195 : #define GALLERY_HINT_THEME_UPDATEVIEW 0x00000010
196 : #define GALLERY_HINT_CLOSE_OBJECT 0x00000020
197 : #define GALLERY_HINT_OBJECT_REMOVED 0x00000040
198 :
199 1520 : class GalleryHint : public SfxHint
200 : {
201 : private:
202 :
203 : sal_uIntPtr mnType;
204 : OUString maThemeName;
205 : OUString maStringData;
206 : sal_uIntPtr mnData1;
207 :
208 : public:
209 :
210 1520 : GalleryHint( sal_uIntPtr nType, const OUString& rThemeName, sal_uIntPtr nData1 = 0UL ) :
211 1520 : mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ) {}
212 :
213 0 : GalleryHint( sal_uIntPtr nType, const OUString& rThemeName, const OUString& rStringData, sal_uIntPtr nData1 = 0UL ) :
214 0 : mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nData1 ) {}
215 :
216 0 : sal_uIntPtr GetType() const { return mnType; }
217 0 : const OUString& GetThemeName() const { return maThemeName; }
218 0 : const OUString& GetStringData() const { return maStringData; }
219 0 : sal_uIntPtr GetData1() const { return mnData1; }
220 : };
221 :
222 : #endif
223 :
224 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|