Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / galmisc.hxx
blobce89ab0ec5de2939de77e4cf1b360a7340e95099
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/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>
36 class GalleryTheme;
37 class SotStorageStream;
39 struct ExchangeData
41 GalleryTheme* pTheme;
42 OUString aEditedTitle;
43 Date aThemeChangeDate;
44 tools::Time aThemeChangeTime;
46 ExchangeData()
47 : pTheme(nullptr)
48 , aThemeChangeDate( Date::EMPTY )
49 , aThemeChangeTime( tools::Time::EMPTY )
54 enum class SgaObjKind
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
64 #define ID_IMAPINFO 2
66 class ResMgr;
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()
88 class SvStream;
89 class Graphic;
90 class FmFormModel;
91 class ImageMap;
92 class Gallery;
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
109 ImageMap aImageMap;
111 public:
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;
122 return pInfo;
125 const ImageMap& GetImageMap() const { return aImageMap; }
128 class SgaUserDataFactory
130 public:
131 SgaUserDataFactory() { SdrObjFactory::InsertMakeUserDataHdl( LINK(this,SgaUserDataFactory,MakeUserData) ); }
132 ~SgaUserDataFactory() { SdrObjFactory::RemoveMakeUserDataHdl( LINK(this,SgaUserDataFactory,MakeUserData) ); }
134 DECL_STATIC_LINK( SgaUserDataFactory, MakeUserData, SdrObjUserDataCreatorParams, SdrObjUserData* );
137 class GraphicFilter;
139 class SVX_DLLPUBLIC GalleryProgress
141 css::uno::Reference< css::awt::XProgressBar > mxProgressBar;
142 GraphicFilter* mpFilter;
144 public:
146 GalleryProgress( GraphicFilter* pFilter = nullptr );
147 ~GalleryProgress();
149 void Update( sal_uIntPtr nVal, sal_uIntPtr nMaxVal );
152 class Gallery;
153 class GalleryTheme;
154 class GraphicObject;
156 class GalleryTransferable : public TransferableHelper
158 friend class GalleryTheme;
159 using TransferableHelper::CopyToClipboard;
161 private:
163 GalleryTheme* mpTheme;
164 SgaObjKind meObjectKind;
165 sal_uInt32 mnObjectPos;
166 tools::SvRef<SotStorageStream> mxModelStream;
167 GraphicObject* mpGraphicObject;
168 ImageMap* mpImageMap;
169 INetURLObject* mpURL;
171 protected:
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
190 CLOSE_THEME,
191 THEME_REMOVED,
192 THEME_RENAMED,
193 THEME_CREATED,
194 THEME_UPDATEVIEW,
195 CLOSE_OBJECT,
196 OBJECT_REMOVED,
199 class GalleryHint : public SfxHint
201 private:
203 GalleryHintType mnType;
204 OUString maThemeName;
205 OUString maStringData;
206 sal_uIntPtr mnData1;
208 public:
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; }
222 #endif
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */