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 <vcl/imap.hxx> 24 #include <svl/hint.hxx> 25 #include <vcl/transfer.hxx> 26 #include <svx/svdobj.hxx> 27 #include <com/sun/star/uno/Reference.h> 28 #include <svx/svxdllapi.h> 29 #include <tools/date.hxx> 30 #include <tools/time.hxx> 31 #include <memory> 32 33 namespace com::sun::star::awt { class XProgressBar; } 34 35 class INetURLObject; 36 class GalleryTheme; 37 class SotStorageStream; 38 39 struct ExchangeData 40 { 41 GalleryTheme* pTheme; 42 OUString aEditedTitle; 43 Date aThemeChangeDate; 44 tools::Time aThemeChangeTime; 45 ExchangeDataExchangeData46 ExchangeData() 47 : pTheme(nullptr) 48 , aThemeChangeDate( Date::EMPTY ) 49 , aThemeChangeTime( tools::Time::EMPTY ) 50 { 51 } 52 }; 53 54 enum class SgaObjKind 55 { 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 62 }; 63 64 #define ID_IMAPINFO 2 65 66 #define STREAMBUF_SIZE 16384L 67 68 enum class GalleryGraphicImportRet 69 { 70 IMPORT_NONE, IMPORT_FILE 71 }; 72 73 #define GALLERY_PROGRESS_RANGE 10000 74 75 #define GALLERY_FG_COLOR Application::GetSettings().GetStyleSettings().GetWindowTextColor() 76 #define GALLERY_BG_COLOR Application::GetSettings().GetStyleSettings().GetWindowColor() 77 #define GALLERY_DLG_COLOR Application::GetSettings().GetStyleSettings().GetDialogColor() 78 79 class SvStream; 80 class Graphic; 81 class FmFormModel; 82 83 GalleryGraphicImportRet GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, OUString& rFilterName ); 84 bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel ); 85 bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap ); 86 SVX_DLLPUBLIC OUString 87 GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen ); 88 OUString GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL ); 89 90 bool FileExists( const INetURLObject& rURL ); 91 bool CreateDir( const INetURLObject& rURL ); 92 bool CopyFile( const INetURLObject& rSrcURL, const INetURLObject& rDstURL ); 93 bool KillFile( const INetURLObject& rURL ); 94 BitmapEx GalleryResGetBitmapEx(const OUString& rId); 95 96 class SgaIMapInfo final : public SdrObjUserData, public SfxListener 97 { 98 ImageMap aImageMap; 99 100 public: SgaIMapInfo()101 SgaIMapInfo() : SdrObjUserData( SdrInventor::SgaImap, ID_IMAPINFO ) {}; 102 SgaIMapInfo(const ImageMap & rImageMap)103 SgaIMapInfo( const ImageMap& rImageMap) : 104 SdrObjUserData( SdrInventor::SgaImap, ID_IMAPINFO ), 105 aImageMap( rImageMap ) {}; 106 Clone(SdrObject *) const107 virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* ) const override 108 { 109 SgaIMapInfo* pInfo = new SgaIMapInfo; 110 pInfo->aImageMap = aImageMap; 111 return std::unique_ptr<SdrObjUserData>(pInfo); 112 } 113 GetImageMap() const114 const ImageMap& GetImageMap() const { return aImageMap; } 115 }; 116 117 class GraphicFilter; 118 119 class SVX_DLLPUBLIC GalleryProgress 120 { 121 css::uno::Reference< css::awt::XProgressBar > mxProgressBar; 122 123 public: 124 125 GalleryProgress( const GraphicFilter* pFilter = nullptr ); 126 ~GalleryProgress(); 127 128 void Update( sal_Int32 nVal, sal_Int32 nMaxVal ); 129 }; 130 131 class GalleryTheme; 132 class GraphicObject; 133 134 class GalleryTransferable final : public TransferableHelper 135 { 136 friend class GalleryTheme; 137 using TransferableHelper::CopyToClipboard; 138 139 GalleryTheme* mpTheme; 140 SgaObjKind const meObjectKind; 141 sal_uInt32 const mnObjectPos; 142 tools::SvRef<SotStorageStream> mxModelStream; 143 std::unique_ptr<GraphicObject> mpGraphicObject; 144 std::unique_ptr<INetURLObject> mpURL; 145 146 GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy ); 147 virtual ~GalleryTransferable() override; 148 149 void InitData( bool bLazy ); 150 151 // TransferableHelper 152 virtual void AddSupportedFormats() override; 153 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; 154 virtual bool WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override; 155 virtual void DragFinished( sal_Int8 nDropAction ) override; 156 virtual void ObjectReleased() override; 157 158 void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions ); 159 }; 160 161 enum class GalleryHintType 162 { 163 CLOSE_THEME, 164 THEME_REMOVED, 165 THEME_RENAMED, 166 THEME_CREATED, 167 THEME_UPDATEVIEW, 168 CLOSE_OBJECT 169 }; 170 171 class GalleryHint final : public SfxHint 172 { 173 private: 174 175 GalleryHintType const mnType; 176 OUString const maThemeName; 177 OUString const maStringData; 178 void* const mnData1; 179 180 public: 181 GalleryHint(GalleryHintType nType,const OUString & rThemeName,void * nData1=nullptr)182 GalleryHint( GalleryHintType nType, const OUString& rThemeName, void* nData1 = nullptr ) : 183 mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ) {} 184 GalleryHint(GalleryHintType nType,const OUString & rThemeName,const OUString & rStringData)185 GalleryHint( GalleryHintType nType, const OUString& rThemeName, const OUString& rStringData ) : 186 mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nullptr ) {} 187 GetType() const188 GalleryHintType GetType() const { return mnType; } GetThemeName() const189 const OUString& GetThemeName() const { return maThemeName; } GetStringData() const190 const OUString& GetStringData() const { return maStringData; } GetData1() const191 void* GetData1() const { return mnData1; } 192 }; 193 194 #endif 195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 196