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 <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 
40 {
42  OUString aEditedTitle;
45 
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 
69 {
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 SVXCORE_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 
95 class SgaIMapInfo final : public SdrObjUserData, public SfxListener
96 {
98 
99 public:
101 
102  SgaIMapInfo( const ImageMap& rImageMap) :
104  aImageMap( rImageMap ) {};
105 
106  virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* ) const override
107  {
108  SgaIMapInfo* pInfo = new SgaIMapInfo;
109  pInfo->aImageMap = aImageMap;
110  return std::unique_ptr<SdrObjUserData>(pInfo);
111  }
112 
113  const ImageMap& GetImageMap() const { return aImageMap; }
114 };
115 
116 class GraphicFilter;
117 
119 {
120  css::uno::Reference< css::awt::XProgressBar > mxProgressBar;
121 
122  public:
123 
124  GalleryProgress( const GraphicFilter* pFilter = nullptr );
125  ~GalleryProgress();
126 
127  void Update( sal_Int32 nVal, sal_Int32 nMaxVal );
128 };
129 
130 class GalleryTheme;
131 class GraphicObject;
132 
134 {
135 friend class GalleryTheme;
137 
140  sal_uInt32 mnObjectPos;
142  std::unique_ptr<GraphicObject> mpGraphicObject;
143  std::unique_ptr<INetURLObject> mpURL;
144 
145  void InitData( bool bLazy );
146 
147 public:
148  GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy );
149  virtual ~GalleryTransferable() override;
150 
151  void SelectObject(sal_uInt32 nObjectPos);
152 
153  // TransferableHelper
154  virtual void AddSupportedFormats() override;
155  virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
156  virtual bool WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override;
157  virtual void DragFinished( sal_Int8 nDropAction ) override;
158  virtual void ObjectReleased() override;
159 
160  bool StartDrag();
161 };
162 
163 enum class GalleryHintType
164 {
165  CLOSE_THEME,
171 };
172 
173 class GalleryHint final : public SfxHint
174 {
175 private:
176 
178  OUString const maThemeName;
179  OUString const maStringData;
180  void* const mnData1;
181 
182 public:
183 
184  GalleryHint( GalleryHintType nType, const OUString& rThemeName, void* nData1 = nullptr ) :
185  mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ) {}
186 
187  GalleryHint( GalleryHintType nType, const OUString& rThemeName, const OUString& rStringData ) :
188  mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nullptr ) {}
189 
190  GalleryHintType GetType() const { return mnType; }
191  const OUString& GetThemeName() const { return maThemeName; }
192  const OUString& GetStringData() const { return maStringData; }
193  void* GetData1() const { return mnData1; }
194 };
195 
196 #endif
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
User data of a drawing object, e.g.
Definition: svdobj.hxx:204
virtual bool WriteObject(tools::SvRef< SotStorageStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
Definition: galmisc.cxx:513
bool CreateDir(const INetURLObject &rURL)
Definition: galmisc.cxx:234
std::unique_ptr< INetURLObject > mpURL
Definition: galmisc.hxx:143
signed char sal_Int8
virtual void ObjectReleased() override
Definition: galmisc.cxx:542
SdrInventor
Definition: svdobj.hxx:152
SVXCORE_DLLPUBLIC OUString GetReducedString(const INetURLObject &rURL, sal_Int32 nMaxLen)
Definition: galmisc.cxx:159
const ImageMap & GetImageMap() const
Definition: galmisc.hxx:113
GalleryHint(GalleryHintType nType, const OUString &rThemeName, const OUString &rStringData)
Definition: galmisc.hxx:187
SgaObjKind meObjectKind
Definition: galmisc.hxx:139
void *const mnData1
Definition: galmisc.hxx:180
const OUString & GetThemeName() const
Definition: galmisc.hxx:191
GalleryHint(GalleryHintType nType, const OUString &rThemeName, void *nData1=nullptr)
Definition: galmisc.hxx:184
bool GallerySvDrawImport(SvStream &rIStm, SdrModel &rModel)
Definition: galmisc.cxx:83
virtual void AddSupportedFormats() override
Definition: galmisc.cxx:450
void * GetData1() const
Definition: galmisc.hxx:193
tools::SvRef< SotStorageStream > mxModelStream
Definition: galmisc.hxx:141
bool CreateIMapGraphic(const FmFormModel &rModel, Graphic &rGraphic, ImageMap &rImageMap)
Definition: galmisc.cxx:127
GalleryHintType GetType() const
Definition: galmisc.hxx:190
SgaObjKind
Definition: galmisc.hxx:54
GalleryTransferable(GalleryTheme *pTheme, sal_uInt32 nObjectPos, bool bLazy)
Definition: galmisc.cxx:365
OUString const maStringData
Definition: galmisc.hxx:179
GalleryTheme * pTheme
Definition: galmisc.hxx:41
virtual std::unique_ptr< SdrObjUserData > Clone(SdrObject *) const override
Definition: galmisc.hxx:106
GalleryTheme * mpTheme
Definition: galmisc.hxx:138
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
Definition: galmisc.cxx:482
GalleryGraphicImportRet
Definition: galmisc.hxx:68
void CopyToClipboard(const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rClipboard) const
bool CopyFile(const INetURLObject &rSrcURL, const INetURLObject &rDstURL)
Definition: galmisc.cxx:269
GalleryHintType const mnType
Definition: galmisc.hxx:177
Abstract DrawObject.
Definition: svdobj.hxx:312
std::unique_ptr< GraphicObject > mpGraphicObject
Definition: galmisc.hxx:142
tools::Time aThemeChangeTime
Definition: galmisc.hxx:44
OUString const maThemeName
Definition: galmisc.hxx:178
css::uno::Reference< css::awt::XProgressBar > mxProgressBar
Definition: galmisc.hxx:120
bool FileExists(const INetURLObject &rURL)
Definition: galmisc.cxx:206
const OUString & GetStringData() const
Definition: galmisc.hxx:192
Date aThemeChangeDate
Definition: galmisc.hxx:43
SgaIMapInfo(const ImageMap &rImageMap)
Definition: galmisc.hxx:102
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
GalleryHintType
Definition: galmisc.hxx:163
OUString GetSvDrawStreamNameFromURL(const INetURLObject &rSvDrawObjURL)
Definition: galmisc.cxx:193
virtual ~GalleryTransferable() override
Definition: galmisc.cxx:385
void InitData(bool bLazy)
Definition: galmisc.cxx:389
ImageMap aImageMap
Definition: galmisc.hxx:97
#define ID_IMAPINFO
Definition: galmisc.hxx:64
sal_uInt32 mnObjectPos
Definition: galmisc.hxx:140
bool KillFile(const INetURLObject &rURL)
Definition: galmisc.cxx:295
OUString aEditedTitle
Definition: galmisc.hxx:42
void SelectObject(sal_uInt32 nObjectPos)
Definition: galmisc.cxx:374
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: galmisc.cxx:527
GalleryGraphicImportRet GalleryGraphicImport(const INetURLObject &rURL, Graphic &rGraphic, OUString &rFilterName)
Definition: galmisc.cxx:58