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 
41 {
43  OUString aEditedTitle;
46 
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 
70 {
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 {
99 
100 public:
102 
103  SgaIMapInfo( const ImageMap& rImageMap) :
105  aImageMap( rImageMap ) {};
106 
107  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 
114  const ImageMap& GetImageMap() const { return aImageMap; }
115 };
116 
117 class GraphicFilter;
118 
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 
135 {
136 friend class GalleryTheme;
138 
141  sal_uInt32 mnObjectPos;
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<SotStorageStream>& 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,
172 };
173 
174 class GalleryHint final : public SfxHint
175 {
176 private:
177 
179  OUString maThemeName;
180  OUString maStringData;
181  void* mnData1;
182 
183 public:
184 
185  GalleryHint( GalleryHintType nType, const OUString& rThemeName, void* nData1 = nullptr ) :
186  mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ) {}
187 
188  GalleryHint( GalleryHintType nType, const OUString& rThemeName, const OUString& rStringData ) :
189  mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nullptr ) {}
190 
191  GalleryHintType GetType() const { return mnType; }
192  const OUString& GetThemeName() const { return maThemeName; }
193  const OUString& GetStringData() const { return maStringData; }
194  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: */
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:506
bool CreateDir(const INetURLObject &rURL)
Definition: galmisc.cxx:227
std::unique_ptr< INetURLObject > mpURL
Definition: galmisc.hxx:144
signed char sal_Int8
INetURLObject ImplGetURL(const GalleryObject *pObject)
Definition: galmisc.cxx:554
void * mnData1
Definition: galmisc.hxx:181
virtual void ObjectReleased() override
Definition: galmisc.cxx:535
SdrInventor
Definition: svdobj.hxx:152
SVXCORE_DLLPUBLIC OUString GetReducedString(const INetURLObject &rURL, sal_Int32 nMaxLen)
Definition: galmisc.cxx:152
OUString maStringData
Definition: galmisc.hxx:180
const ImageMap & GetImageMap() const
Definition: galmisc.hxx:114
GalleryHint(GalleryHintType nType, const OUString &rThemeName, const OUString &rStringData)
Definition: galmisc.hxx:188
SgaObjKind meObjectKind
Definition: galmisc.hxx:140
const OUString & GetThemeName() const
Definition: galmisc.hxx:192
OUString maThemeName
Definition: galmisc.hxx:179
GalleryHint(GalleryHintType nType, const OUString &rThemeName, void *nData1=nullptr)
Definition: galmisc.hxx:185
bool GallerySvDrawImport(SvStream &rIStm, SdrModel &rModel)
Definition: galmisc.cxx:76
virtual void AddSupportedFormats() override
Definition: galmisc.cxx:443
void * GetData1() const
Definition: galmisc.hxx:194
tools::SvRef< SotStorageStream > mxModelStream
Definition: galmisc.hxx:142
bool CreateIMapGraphic(const FmFormModel &rModel, Graphic &rGraphic, ImageMap &rImageMap)
Definition: galmisc.cxx:120
GalleryHintType GetType() const
Definition: galmisc.hxx:191
SgaObjKind
Definition: galmisc.hxx:55
GalleryTransferable(GalleryTheme *pTheme, sal_uInt32 nObjectPos, bool bLazy)
Definition: galmisc.cxx:358
GalleryTheme * pTheme
Definition: galmisc.hxx:42
virtual std::unique_ptr< SdrObjUserData > Clone(SdrObject *) const override
Definition: galmisc.hxx:107
GalleryTheme * mpTheme
Definition: galmisc.hxx:139
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
Definition: galmisc.cxx:475
GalleryGraphicImportRet
Definition: galmisc.hxx:69
void CopyToClipboard(const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rClipboard) const
bool CopyFile(const INetURLObject &rSrcURL, const INetURLObject &rDstURL)
Definition: galmisc.cxx:262
Abstract DrawObject.
Definition: svdobj.hxx:312
GalleryHintType mnType
Definition: galmisc.hxx:178
std::unique_ptr< GraphicObject > mpGraphicObject
Definition: galmisc.hxx:143
tools::Time aThemeChangeTime
Definition: galmisc.hxx:45
css::uno::Reference< css::awt::XProgressBar > mxProgressBar
Definition: galmisc.hxx:121
bool FileExists(const INetURLObject &rURL)
Definition: galmisc.cxx:199
const OUString & GetStringData() const
Definition: galmisc.hxx:193
Date aThemeChangeDate
Definition: galmisc.hxx:44
SgaIMapInfo(const ImageMap &rImageMap)
Definition: galmisc.hxx:103
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
GalleryHintType
Definition: galmisc.hxx:164
OUString GetSvDrawStreamNameFromURL(const INetURLObject &rSvDrawObjURL)
Definition: galmisc.cxx:186
virtual ~GalleryTransferable() override
Definition: galmisc.cxx:378
void InitData(bool bLazy)
Definition: galmisc.cxx:382
ImageMap aImageMap
Definition: galmisc.hxx:98
#define ID_IMAPINFO
Definition: galmisc.hxx:65
sal_uInt32 mnObjectPos
Definition: galmisc.hxx:141
bool KillFile(const INetURLObject &rURL)
Definition: galmisc.cxx:288
OUString aEditedTitle
Definition: galmisc.hxx:43
void SelectObject(sal_uInt32 nObjectPos)
Definition: galmisc.cxx:367
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: galmisc.cxx:520
GalleryGraphicImportRet GalleryGraphicImport(const INetURLObject &rURL, Graphic &rGraphic, OUString &rFilterName)
Definition: galmisc.cxx:51