LibreOffice Module svx (master)  1
galmisc.hxx
Go to the documentation of this file.
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 <vcl/salctype.hxx>
27 #include <svx/svdobj.hxx>
28 #include <com/sun/star/uno/Reference.h>
29 #include <svx/svxdllapi.h>
30 #include <tools/date.hxx>
31 #include <tools/time.hxx>
32 #include <memory>
33 
34 namespace com::sun::star::awt { class XProgressBar; }
35 
36 class INetURLObject;
37 class GalleryTheme;
38 class SotStorageStream;
39 class SotTempStream;
40 
42 {
44  OUString aEditedTitle;
47 
49  : pTheme(nullptr)
50  , aThemeChangeDate( Date::EMPTY )
51  , aThemeChangeTime( tools::Time::EMPTY )
52  {
53  }
54 };
55 
56 enum class SgaObjKind
57 {
58  NONE = 0, // abstract object
59  Bitmap = 1, // bitmap object
60  Sound = 2, // sound object
61  Animation = 4, // animation object
62  SvDraw = 5, // Svdraw object
63  Inet = 6 // graphics from the internet
64 };
65 
66 #define ID_IMAPINFO 2
67 
68 #define STREAMBUF_SIZE 16384L
69 
71 {
73 };
74 
75 #define GALLERY_PROGRESS_RANGE 10000
76 
77 #define GALLERY_FG_COLOR Application::GetSettings().GetStyleSettings().GetWindowTextColor()
78 #define GALLERY_BG_COLOR Application::GetSettings().GetStyleSettings().GetWindowColor()
79 #define GALLERY_DLG_COLOR Application::GetSettings().GetStyleSettings().GetDialogColor()
80 
81 class SvStream;
82 class Graphic;
83 class FmFormModel;
84 
85 GalleryGraphicImportRet GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, OUString& rFilterName );
86 bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel );
87 bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap );
88 SVXCORE_DLLPUBLIC OUString
89  GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen );
90 OUString GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL );
91 
92 bool FileExists( const INetURLObject& rURL );
93 bool CreateDir( const INetURLObject& rURL );
94 bool CopyFile( const INetURLObject& rSrcURL, const INetURLObject& rDstURL );
95 bool KillFile( const INetURLObject& rURL );
96 
97 class SgaIMapInfo final : public SdrObjUserData, public SfxListener
98 {
100 
101 public:
103 
104  SgaIMapInfo( const ImageMap& rImageMap) :
106  aImageMap( rImageMap ) {};
107 
108  virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* ) const override
109  {
110  SgaIMapInfo* pInfo = new SgaIMapInfo;
111  pInfo->aImageMap = aImageMap;
112  return std::unique_ptr<SdrObjUserData>(pInfo);
113  }
114 
115  const ImageMap& GetImageMap() const { return aImageMap; }
116 };
117 
118 class GraphicFilter;
119 
121 {
122  css::uno::Reference< css::awt::XProgressBar > mxProgressBar;
123 
124  public:
125 
126  GalleryProgress( const GraphicFilter* pFilter = nullptr );
127  ~GalleryProgress();
128 
129  void Update( sal_Int32 nVal, sal_Int32 nMaxVal );
130 };
131 
132 class GalleryTheme;
133 class GraphicObject;
134 
136 {
137 friend class GalleryTheme;
139 
142  sal_uInt32 mnObjectPos;
144  std::unique_ptr<GraphicObject> mpGraphicObject;
145  std::unique_ptr<INetURLObject> mpURL;
146 
147  void InitData( bool bLazy );
148 
149 public:
150  GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy );
151  virtual ~GalleryTransferable() override;
152 
153  void SelectObject(sal_uInt32 nObjectPos);
154 
155  // TransferableHelper
156  virtual void AddSupportedFormats() override;
157  virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
158  virtual bool WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override;
159  virtual void DragFinished( sal_Int8 nDropAction ) override;
160  virtual void ObjectReleased() override;
161 
162  bool StartDrag();
163 };
164 
165 enum class GalleryHintType
166 {
167  CLOSE_THEME,
173 };
174 
175 class GalleryHint final : public SfxHint
176 {
177 private:
178 
180  OUString maThemeName;
181  OUString maStringData;
182  void* mnData1;
183 
184 public:
185 
186  GalleryHint( GalleryHintType nType, const OUString& rThemeName, void* nData1 = nullptr ) :
187  mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ) {}
188 
189  GalleryHint( GalleryHintType nType, const OUString& rThemeName, const OUString& rStringData ) :
190  mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nullptr ) {}
191 
192  GalleryHintType GetType() const { return mnType; }
193  const OUString& GetThemeName() const { return maThemeName; }
194  const OUString& GetStringData() const { return maStringData; }
195  void* GetData1() const { return mnData1; }
196 };
197 
198 struct GalleryObject;
199 
200 INetURLObject ImplGetURL(const GalleryObject* pObject);
201 
202 #endif
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
User data of a drawing object, e.g.
Definition: svdobj.hxx:153
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
Definition: galmisc.cxx:505
bool CreateDir(const INetURLObject &rURL)
Definition: galmisc.cxx:226
std::unique_ptr< INetURLObject > mpURL
Definition: galmisc.hxx:145
signed char sal_Int8
INetURLObject ImplGetURL(const GalleryObject *pObject)
Definition: galmisc.cxx:553
void * mnData1
Definition: galmisc.hxx:182
virtual void ObjectReleased() override
Definition: galmisc.cxx:534
SdrInventor
Definition: svdobj.hxx:101
SVXCORE_DLLPUBLIC OUString GetReducedString(const INetURLObject &rURL, sal_Int32 nMaxLen)
Definition: galmisc.cxx:151
OUString maStringData
Definition: galmisc.hxx:181
const ImageMap & GetImageMap() const
Definition: galmisc.hxx:115
GalleryHint(GalleryHintType nType, const OUString &rThemeName, const OUString &rStringData)
Definition: galmisc.hxx:189
SgaObjKind meObjectKind
Definition: galmisc.hxx:141
const OUString & GetThemeName() const
Definition: galmisc.hxx:193
OUString maThemeName
Definition: galmisc.hxx:180
GalleryHint(GalleryHintType nType, const OUString &rThemeName, void *nData1=nullptr)
Definition: galmisc.hxx:186
bool GallerySvDrawImport(SvStream &rIStm, SdrModel &rModel)
Definition: galmisc.cxx:75
virtual void AddSupportedFormats() override
Definition: galmisc.cxx:442
void * GetData1() const
Definition: galmisc.hxx:195
bool CreateIMapGraphic(const FmFormModel &rModel, Graphic &rGraphic, ImageMap &rImageMap)
Definition: galmisc.cxx:119
GalleryHintType GetType() const
Definition: galmisc.hxx:192
SgaObjKind
Definition: galmisc.hxx:56
GalleryTransferable(GalleryTheme *pTheme, sal_uInt32 nObjectPos, bool bLazy)
Definition: galmisc.cxx:357
GalleryTheme * pTheme
Definition: galmisc.hxx:43
virtual std::unique_ptr< SdrObjUserData > Clone(SdrObject *) const override
Definition: galmisc.hxx:108
GalleryTheme * mpTheme
Definition: galmisc.hxx:140
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
Definition: galmisc.cxx:474
GalleryGraphicImportRet
Definition: galmisc.hxx:70
void CopyToClipboard(const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rClipboard) const
bool CopyFile(const INetURLObject &rSrcURL, const INetURLObject &rDstURL)
Definition: galmisc.cxx:261
Abstract DrawObject.
Definition: svdobj.hxx:261
GalleryHintType mnType
Definition: galmisc.hxx:179
std::unique_ptr< GraphicObject > mpGraphicObject
Definition: galmisc.hxx:144
tools::Time aThemeChangeTime
Definition: galmisc.hxx:46
css::uno::Reference< css::awt::XProgressBar > mxProgressBar
Definition: galmisc.hxx:122
bool FileExists(const INetURLObject &rURL)
Definition: galmisc.cxx:198
const OUString & GetStringData() const
Definition: galmisc.hxx:194
Date aThemeChangeDate
Definition: galmisc.hxx:45
SgaIMapInfo(const ImageMap &rImageMap)
Definition: galmisc.hxx:104
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
GalleryHintType
Definition: galmisc.hxx:165
OUString GetSvDrawStreamNameFromURL(const INetURLObject &rSvDrawObjURL)
Definition: galmisc.cxx:185
virtual ~GalleryTransferable() override
Definition: galmisc.cxx:377
void InitData(bool bLazy)
Definition: galmisc.cxx:381
ImageMap aImageMap
Definition: galmisc.hxx:99
#define ID_IMAPINFO
Definition: galmisc.hxx:66
sal_uInt32 mnObjectPos
Definition: galmisc.hxx:142
bool KillFile(const INetURLObject &rURL)
Definition: galmisc.cxx:287
OUString aEditedTitle
Definition: galmisc.hxx:44
void SelectObject(sal_uInt32 nObjectPos)
Definition: galmisc.cxx:366
tools::SvRef< SotTempStream > mxModelStream
Definition: galmisc.hxx:143
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: galmisc.cxx:519
GalleryGraphicImportRet GalleryGraphicImport(const INetURLObject &rURL, Graphic &rGraphic, OUString &rFilterName)
Definition: galmisc.cxx:50