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