1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/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>
36 class SotStorageStream
;
41 OUString aEditedTitle
;
42 Date aThemeChangeDate
;
43 tools::Time aThemeChangeTime
;
47 , aThemeChangeDate( Date::EMPTY
)
48 , aThemeChangeTime( tools::Time::EMPTY
)
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
64 #define IV_IMAPINFO (sal_uInt32('S')*0x00000001+sal_uInt32('D')*0x00000100+sal_uInt32('U')*0x00010000+sal_uInt32('D')*0x01000000)
67 #define USERDATA_HDL() (LINK(this,SgaUserDataFactory,MakeUserData))
69 #define GAL_RES(nId) ResId(nId, *GetGalleryResMgr())
70 #define GAL_RESSTR(nId) GAL_RES(nId).toString()
71 #define STREAMBUF_SIZE 16384L
73 enum class GalleryGraphicImportRet
75 IMPORT_NONE
, IMPORT_FILE
, IMPORT_INET
78 #define GALLERY_PROGRESS_RANGE 10000
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()
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
);
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
);
106 class SgaIMapInfo
: public SdrObjUserData
, public SfxListener
111 SgaIMapInfo() : SdrObjUserData( IV_IMAPINFO
, ID_IMAPINFO
, 0 ) {};
113 SgaIMapInfo( const ImageMap
& rImageMap
) :
114 SdrObjUserData( IV_IMAPINFO
, ID_IMAPINFO
, 0 ),
115 aImageMap( rImageMap
) {};
117 virtual ~SgaIMapInfo() {};
119 virtual SdrObjUserData
* Clone( SdrObject
* ) const SAL_OVERRIDE
121 SgaIMapInfo
* pInfo
= new SgaIMapInfo
;
122 pInfo
->aImageMap
= aImageMap
;
126 const ImageMap
& GetImageMap() const { return aImageMap
; }
129 class SgaUserDataFactory
132 SgaUserDataFactory() { SdrObjFactory::InsertMakeUserDataHdl( USERDATA_HDL() ); }
133 ~SgaUserDataFactory() { SdrObjFactory::RemoveMakeUserDataHdl( USERDATA_HDL() ); }
135 DECL_STATIC_LINK( SgaUserDataFactory
, MakeUserData
, SdrObjFactory
* );
140 class SVX_DLLPUBLIC GalleryProgress
142 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XProgressBar
> mxProgressBar
;
143 GraphicFilter
* mpFilter
;
147 GalleryProgress( GraphicFilter
* pFilter
= NULL
);
150 void Update( sal_uIntPtr nVal
, sal_uIntPtr nMaxVal
);
157 class GalleryTransferable
: public TransferableHelper
159 friend class GalleryTheme
;
160 using TransferableHelper::CopyToClipboard
;
164 GalleryTheme
* mpTheme
;
165 SgaObjKind meObjectKind
;
166 sal_uInt32 mnObjectPos
;
167 tools::SvRef
<SotStorageStream
> mxModelStream
;
168 GraphicObject
* mpGraphicObject
;
169 ImageMap
* mpImageMap
;
170 INetURLObject
* mpURL
;
174 GalleryTransferable( GalleryTheme
* pTheme
, sal_uIntPtr nObjectPos
, bool bLazy
);
175 virtual ~GalleryTransferable();
177 void InitData( bool bLazy
);
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
;
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
);
192 enum class GalleryHintType
203 class GalleryHint
: public SfxHint
207 GalleryHintType mnType
;
208 OUString maThemeName
;
209 OUString maStringData
;
214 GalleryHint( GalleryHintType nType
, const OUString
& rThemeName
, sal_uIntPtr nData1
= 0UL ) :
215 mnType( nType
), maThemeName( rThemeName
), mnData1( nData1
) {}
217 GalleryHint( GalleryHintType nType
, const OUString
& rThemeName
, const OUString
& rStringData
, sal_uIntPtr nData1
= 0UL ) :
218 mnType( nType
), maThemeName( rThemeName
), maStringData( rStringData
), mnData1( nData1
) {}
220 GalleryHintType
GetType() const { return mnType
; }
221 const OUString
& GetThemeName() const { return maThemeName
; }
222 const OUString
& GetStringData() const { return maStringData
; }
223 sal_uIntPtr
GetData1() const { return mnData1
; }
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */