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>
34 #include <tools/resid.hxx>
37 class SotStorageStream
;
42 OUString aEditedTitle
;
43 Date aThemeChangeDate
;
44 tools::Time aThemeChangeTime
;
48 , aThemeChangeDate( Date::EMPTY
)
49 , aThemeChangeTime( tools::Time::EMPTY
)
56 NONE
= 0, // abstract object
57 Bitmap
= 1, // bitmap object
58 Sound
= 2, // sound object
59 Animation
= 4, // animation object
60 SvDraw
= 5, // Svdraw object
61 Inet
= 6 // graphics from the internet
68 SVX_DLLPUBLIC ResMgr
* GetGalleryResMgr();
70 inline OUString
GalResId(sal_uInt16 nId
)
72 return ResId(nId
, *GetGalleryResMgr());
75 #define STREAMBUF_SIZE 16384L
77 enum class GalleryGraphicImportRet
79 IMPORT_NONE
, IMPORT_FILE
82 #define GALLERY_PROGRESS_RANGE 10000
84 #define GALLERY_FG_COLOR Application::GetSettings().GetStyleSettings().GetWindowTextColor()
85 #define GALLERY_BG_COLOR Application::GetSettings().GetStyleSettings().GetWindowColor()
86 #define GALLERY_DLG_COLOR Application::GetSettings().GetStyleSettings().GetDialogColor()
94 GalleryGraphicImportRet
GalleryGraphicImport( const INetURLObject
& rURL
, Graphic
& rGraphic
, OUString
& rFilterName
, bool bShowProgress
= false );
95 bool GallerySvDrawImport( SvStream
& rIStm
, SdrModel
& rModel
);
96 bool CreateIMapGraphic( const FmFormModel
& rModel
, Graphic
& rGraphic
, ImageMap
& rImageMap
);
97 SVX_DLLPUBLIC OUString
98 GetReducedString( const INetURLObject
& rURL
, sal_Int32 nMaxLen
);
99 OUString
GetSvDrawStreamNameFromURL( const INetURLObject
& rSvDrawObjURL
);
101 bool FileExists( const INetURLObject
& rURL
);
102 bool CreateDir( const INetURLObject
& rURL
);
103 bool CopyFile( const INetURLObject
& rSrcURL
, const INetURLObject
& rDstURL
);
104 bool KillFile( const INetURLObject
& rURL
);
105 BitmapEx
GalleryResGetBitmapEx(const OUString
& rId
);
107 class SgaIMapInfo
: public SdrObjUserData
, public SfxListener
112 SgaIMapInfo() : SdrObjUserData( SdrInventor::SgaImap
, ID_IMAPINFO
) {};
114 SgaIMapInfo( const ImageMap
& rImageMap
) :
115 SdrObjUserData( SdrInventor::SgaImap
, ID_IMAPINFO
),
116 aImageMap( rImageMap
) {};
118 virtual SdrObjUserData
* Clone( SdrObject
* ) const override
120 SgaIMapInfo
* pInfo
= new SgaIMapInfo
;
121 pInfo
->aImageMap
= aImageMap
;
125 const ImageMap
& GetImageMap() const { return aImageMap
; }
128 class SgaUserDataFactory
131 SgaUserDataFactory() { SdrObjFactory::InsertMakeUserDataHdl( LINK(this,SgaUserDataFactory
,MakeUserData
) ); }
132 ~SgaUserDataFactory() { SdrObjFactory::RemoveMakeUserDataHdl( LINK(this,SgaUserDataFactory
,MakeUserData
) ); }
134 DECL_STATIC_LINK( SgaUserDataFactory
, MakeUserData
, SdrObjUserDataCreatorParams
, SdrObjUserData
* );
139 class SVX_DLLPUBLIC GalleryProgress
141 css::uno::Reference
< css::awt::XProgressBar
> mxProgressBar
;
142 GraphicFilter
* mpFilter
;
146 GalleryProgress( GraphicFilter
* pFilter
= nullptr );
149 void Update( sal_uIntPtr nVal
, sal_uIntPtr nMaxVal
);
156 class GalleryTransferable
: public TransferableHelper
158 friend class GalleryTheme
;
159 using TransferableHelper::CopyToClipboard
;
163 GalleryTheme
* mpTheme
;
164 SgaObjKind meObjectKind
;
165 sal_uInt32 mnObjectPos
;
166 tools::SvRef
<SotStorageStream
> mxModelStream
;
167 GraphicObject
* mpGraphicObject
;
168 ImageMap
* mpImageMap
;
169 INetURLObject
* mpURL
;
173 GalleryTransferable( GalleryTheme
* pTheme
, sal_uIntPtr nObjectPos
, bool bLazy
);
174 virtual ~GalleryTransferable() override
;
176 void InitData( bool bLazy
);
178 // TransferableHelper
179 virtual void AddSupportedFormats() override
;
180 virtual bool GetData( const css::datatransfer::DataFlavor
& rFlavor
, const OUString
& rDestDoc
) override
;
181 virtual bool WriteObject( tools::SvRef
<SotStorageStream
>& rxOStm
, void* pUserObject
, SotClipboardFormatId nUserObjectId
, const css::datatransfer::DataFlavor
& rFlavor
) override
;
182 virtual void DragFinished( sal_Int8 nDropAction
) override
;
183 virtual void ObjectReleased() override
;
185 void StartDrag( vcl::Window
* pWindow
, sal_Int8 nDragSourceActions
);
188 enum class GalleryHintType
199 class GalleryHint
: public SfxHint
203 GalleryHintType mnType
;
204 OUString maThemeName
;
205 OUString maStringData
;
210 GalleryHint( GalleryHintType nType
, const OUString
& rThemeName
, sal_uIntPtr nData1
= 0UL ) :
211 mnType( nType
), maThemeName( rThemeName
), mnData1( nData1
) {}
213 GalleryHint( GalleryHintType nType
, const OUString
& rThemeName
, const OUString
& rStringData
, sal_uIntPtr nData1
= 0UL ) :
214 mnType( nType
), maThemeName( rThemeName
), maStringData( rStringData
), mnData1( nData1
) {}
216 GalleryHintType
GetType() const { return mnType
; }
217 const OUString
& GetThemeName() const { return maThemeName
; }
218 const OUString
& GetStringData() const { return maStringData
; }
219 sal_uIntPtr
GetData1() const { return mnData1
; }
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */