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 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 {
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 const mnObjectPos;
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,
169 };
170 
171 class GalleryHint final : public SfxHint
172 {
173 private:
174 
176  OUString const maThemeName;
177  OUString const maStringData;
178  void* const mnData1;
179 
180 public:
181 
182  GalleryHint( GalleryHintType nType, const OUString& rThemeName, void* nData1 = nullptr ) :
183  mnType( nType ), maThemeName( rThemeName ), mnData1( nData1 ) {}
184 
185  GalleryHint( GalleryHintType nType, const OUString& rThemeName, const OUString& rStringData ) :
186  mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nullptr ) {}
187 
188  GalleryHintType GetType() const { return mnType; }
189  const OUString& GetThemeName() const { return maThemeName; }
190  const OUString& GetStringData() const { return maStringData; }
191  void* GetData1() const { return mnData1; }
192 };
193 
194 #endif
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
User data of a drawing object, e.g.
Definition: svdobj.hxx:204
BitmapEx GalleryResGetBitmapEx(const OUString &rId)
Definition: galmisc.cxx:58
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:245
std::unique_ptr< INetURLObject > mpURL
Definition: galmisc.hxx:144
signed char sal_Int8
virtual void ObjectReleased() override
Definition: galmisc.cxx:539
SdrInventor
Definition: svdobj.hxx:152
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
const ImageMap & GetImageMap() const
Definition: galmisc.hxx:114
GalleryHint(GalleryHintType nType, const OUString &rThemeName, const OUString &rStringData)
Definition: galmisc.hxx:185
void *const mnData1
Definition: galmisc.hxx:178
sal_uInt32 const mnObjectPos
Definition: galmisc.hxx:141
const OUString & GetThemeName() const
Definition: galmisc.hxx:189
GalleryHint(GalleryHintType nType, const OUString &rThemeName, void *nData1=nullptr)
Definition: galmisc.hxx:182
bool GallerySvDrawImport(SvStream &rIStm, SdrModel &rModel)
Definition: galmisc.cxx:94
virtual void AddSupportedFormats() override
Definition: galmisc.cxx:450
void * GetData1() const
Definition: galmisc.hxx:191
tools::SvRef< SotStorageStream > mxModelStream
Definition: galmisc.hxx:142
bool CreateIMapGraphic(const FmFormModel &rModel, Graphic &rGraphic, ImageMap &rImageMap)
Definition: galmisc.cxx:138
GalleryHintType GetType() const
Definition: galmisc.hxx:188
SgaObjKind
Definition: galmisc.hxx:54
GalleryTransferable(GalleryTheme *pTheme, sal_uInt32 nObjectPos, bool bLazy)
Definition: galmisc.cxx:376
OUString const maStringData
Definition: galmisc.hxx:177
GalleryTheme * pTheme
Definition: galmisc.hxx:41
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: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:280
GalleryHintType const mnType
Definition: galmisc.hxx:175
Abstract DrawObject.
Definition: svdobj.hxx:312
std::unique_ptr< GraphicObject > mpGraphicObject
Definition: galmisc.hxx:143
tools::Time aThemeChangeTime
Definition: galmisc.hxx:44
OUString const maThemeName
Definition: galmisc.hxx:176
css::uno::Reference< css::awt::XProgressBar > mxProgressBar
Definition: galmisc.hxx:121
bool FileExists(const INetURLObject &rURL)
Definition: galmisc.cxx:217
void StartDrag(vcl::Window *pWindow, sal_Int8 nDragSourceActions)
Definition: galmisc.cxx:546
const OUString & GetStringData() const
Definition: galmisc.hxx:190
Date aThemeChangeDate
Definition: galmisc.hxx:43
SgaIMapInfo(const ImageMap &rImageMap)
Definition: galmisc.hxx:103
GalleryHintType
Definition: galmisc.hxx:161
OUString GetSvDrawStreamNameFromURL(const INetURLObject &rSvDrawObjURL)
Definition: galmisc.cxx:204
virtual ~GalleryTransferable() override
Definition: galmisc.cxx:385
SVX_DLLPUBLIC OUString GetReducedString(const INetURLObject &rURL, sal_Int32 nMaxLen)
Definition: galmisc.cxx:170
void InitData(bool bLazy)
Definition: galmisc.cxx:389
ImageMap aImageMap
Definition: galmisc.hxx:98
SgaObjKind const meObjectKind
Definition: galmisc.hxx:140
#define ID_IMAPINFO
Definition: galmisc.hxx:64
bool KillFile(const INetURLObject &rURL)
Definition: galmisc.cxx:306
OUString aEditedTitle
Definition: galmisc.hxx:42
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: galmisc.cxx:527
GalleryGraphicImportRet GalleryGraphicImport(const INetURLObject &rURL, Graphic &rGraphic, OUString &rFilterName)
Definition: galmisc.cxx:69