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 class SotTempStream;
39 
40 struct ExchangeData
41 {
42     GalleryTheme*   pTheme;
43     OUString        aEditedTitle;
44     Date            aThemeChangeDate;
45     tools::Time     aThemeChangeTime;
46 
ExchangeDataExchangeData47     ExchangeData()
48         : pTheme(nullptr)
49         , aThemeChangeDate( Date::EMPTY )
50         , aThemeChangeTime( tools::Time::EMPTY )
51         {
52         }
53 };
54 
55 enum class SgaObjKind
56 {
57     NONE = 0,   // abstract object
58     Bitmap = 1,    // bitmap object
59     Sound = 2,  // sound object
60     Animation = 4,   // animation object
61     SvDraw = 5, // Svdraw object
62     Inet = 6    // graphics from the internet
63 };
64 
65 #define ID_IMAPINFO             2
66 
67 #define STREAMBUF_SIZE          16384L
68 
69 enum class GalleryGraphicImportRet
70 {
71     IMPORT_NONE, IMPORT_FILE
72 };
73 
74 #define GALLERY_PROGRESS_RANGE  10000
75 
76 #define GALLERY_FG_COLOR        Application::GetSettings().GetStyleSettings().GetWindowTextColor()
77 #define GALLERY_BG_COLOR        Application::GetSettings().GetStyleSettings().GetWindowColor()
78 #define GALLERY_DLG_COLOR       Application::GetSettings().GetStyleSettings().GetDialogColor()
79 
80 class SvStream;
81 class Graphic;
82 class FmFormModel;
83 
84 GalleryGraphicImportRet  GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, OUString& rFilterName );
85 bool                GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel );
86 bool                CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap );
87 SVXCORE_DLLPUBLIC OUString
88                     GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen );
89 OUString            GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL );
90 
91 bool                FileExists( const INetURLObject& rURL );
92 bool                CreateDir(  const INetURLObject& rURL );
93 bool                CopyFile(  const INetURLObject& rSrcURL, const INetURLObject& rDstURL );
94 bool                KillFile( const INetURLObject& rURL );
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 SVXCORE_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 TransferDataContainer
135 {
136 friend class GalleryTheme;
137 using TransferableHelper::CopyToClipboard;
138 
139     GalleryTheme*                   mpTheme;
140     SgaObjKind                      meObjectKind;
141     sal_uInt32                      mnObjectPos;
142     tools::SvRef<SotTempStream>  mxModelStream;
143     std::unique_ptr<GraphicObject>  mpGraphicObject;
144     std::unique_ptr<INetURLObject>  mpURL;
145 
146     void                            InitData( bool bLazy );
147 
148 public:
149                                     GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy );
150                                     virtual ~GalleryTransferable() override;
151 
152     void                            SelectObject(sal_uInt32 nObjectPos);
153 
154     // TransferableHelper
155     virtual void                    AddSupportedFormats() override;
156     virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
157     virtual bool                    WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override;
158     virtual void                    DragFinished( sal_Int8 nDropAction ) override;
159     virtual void                    ObjectReleased() override;
160 
161     bool                            StartDrag();
162 };
163 
164 enum class GalleryHintType
165 {
166     CLOSE_THEME,
167     THEME_REMOVED,
168     THEME_RENAMED,
169     THEME_CREATED,
170     THEME_UPDATEVIEW,
171     CLOSE_OBJECT
172 };
173 
174 class GalleryHint final : public SfxHint
175 {
176 private:
177 
178     GalleryHintType     mnType;
179     OUString            maThemeName;
180     OUString            maStringData;
181     void*               mnData1;
182 
183 public:
184 
GalleryHint(GalleryHintType nType,const OUString & rThemeName,void * nData1=nullptr)185                      GalleryHint( GalleryHintType nType, const OUString& rThemeName, void* nData1 = nullptr ) :
186                         mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ) {}
187 
GalleryHint(GalleryHintType nType,const OUString & rThemeName,const OUString & rStringData)188                      GalleryHint( GalleryHintType nType, const OUString& rThemeName, const OUString& rStringData ) :
189                         mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nullptr ) {}
190 
GetType() const191     GalleryHintType  GetType() const { return mnType; }
GetThemeName() const192     const OUString&  GetThemeName() const { return maThemeName; }
GetStringData() const193     const OUString&  GetStringData() const { return maStringData; }
GetData1() const194     void*            GetData1() const { return mnData1; }
195 };
196 
197 struct GalleryObject;
198 
199 INetURLObject ImplGetURL(const GalleryObject* pObject);
200 
201 #endif
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
203