LibreOffice Module svx (master)  1
galtheme.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_GALTHEME_HXX
21 #define INCLUDED_SVX_GALTHEME_HXX
22 
23 #include <svx/svxdllapi.h>
24 
25 #include <tools/debug.hxx>
26 #include <tools/urlobj.hxx>
27 #include <vcl/salctype.hxx>
28 #include <svl/SfxBroadcaster.hxx>
29 #include <svx/galmisc.hxx>
30 #include <memory>
31 #include <vector>
32 
33 namespace weld { class ComboBox; }
34 
35 class SotStorage;
36 class SotStorageStream;
37 
38 
40 {
42  sal_uInt32 nOffset;
44  bool mbDelete;
45 
46  //UI visualization buffering
49  OUString maTitle;
50  OUString maPath;
51 };
52 
53 
54 class GalleryThemeEntry;
55 class SgaObject;
56 class FmFormModel;
57 
58 class Gallery;
59 
60 namespace unogallery
61 {
62  class GalleryTheme;
63  class GalleryItem;
64 }
65 
66 
68 {
69  friend class Gallery;
70  friend class GalleryThemeCacheEntry;
71  friend class ::unogallery::GalleryTheme;
72  friend class ::unogallery::GalleryItem;
73 
74 private:
75 
76  ::std::vector< std::unique_ptr<GalleryObject> > aObjectList;
77  OUString m_aDestDir;
80  Gallery* const pParent;
82  sal_uInt32 mnThemeLockCount;
84  sal_uInt32 nDragPos;
85  bool bDragging;
87 
88  SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
89  std::unique_ptr<SgaObject> ImplReadSgaObject( GalleryObject const * pEntry );
90  SAL_DLLPRIVATE bool ImplWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry);
91  SAL_DLLPRIVATE void ImplWrite();
92  SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject(sal_uInt32 nPos) const
93  {
94  if (nPos < aObjectList.size())
95  return aObjectList[ nPos ].get();
96  return nullptr;
97  }
98  const GalleryObject* ImplGetGalleryObject( const INetURLObject& rURL );
99 
100  SAL_DLLPRIVATE sal_uInt32 ImplGetGalleryObjectPos( const GalleryObject* pObj ) const
101  {
102  for (sal_uInt32 i = 0, n = aObjectList.size(); i < n; ++i)
103  if ( pObj == aObjectList[ i ].get() )
104  return i;
105  return SAL_MAX_UINT32;
106  }
107  SAL_DLLPRIVATE static INetURLObject ImplGetURL( const GalleryObject* pObject );
108  SAL_DLLPRIVATE INetURLObject ImplCreateUniqueURL( SgaObjKind eObjKind, ConvertDataFormat nFormat = ConvertDataFormat::Unknown );
109  SAL_DLLPRIVATE void ImplSetModified( bool bModified );
110  SAL_DLLPRIVATE void ImplBroadcast(sal_uInt32 nUpdatePos);
111 
112  SAL_DLLPRIVATE GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry );
113 
114  GalleryTheme(GalleryTheme const &) = delete;
115  void operator =(GalleryTheme const &) = delete;
116 
117 public:
118 
119  SAL_DLLPRIVATE virtual ~GalleryTheme() override;
120 
121  SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry( const INetURLObject& rURL, bool bReadOnly );
122 
123  SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const { return aObjectList.size(); }
124 
125  std::unique_ptr<SgaObject> AcquireObject(sal_uInt32 nPos);
126 
127  bool InsertObject(const SgaObject& rObj, sal_uInt32 nPos = SAL_MAX_UINT32);
128  void RemoveObject(sal_uInt32 nPos);
129  SAL_DLLPRIVATE bool ChangeObjectPos(sal_uInt32 nOldPos, sal_uInt32 nNewPos);
130 
131  const OUString& GetName() const;
132 
133  // used for building gallery themes during compilation:
134  SAL_DLLPRIVATE void SetDestDir(const OUString& rDestDir, bool bRelative)
135  { m_aDestDir = rDestDir; m_bDestDirRelative = bRelative; }
136 
137  SAL_DLLPRIVATE const INetURLObject& GetThmURL() const;
138  const INetURLObject& GetSdgURL() const;
139  SAL_DLLPRIVATE const INetURLObject& GetSdvURL() const;
140  SAL_DLLPRIVATE const INetURLObject& GetStrURL() const;
141 
142  sal_uInt32 GetId() const;
143  SAL_DLLPRIVATE void SetId( sal_uInt32 nNewId, bool bResetThemeName );
144 
145  SAL_DLLPRIVATE void SetDragging( bool bSet ) { bDragging = bSet; }
146  SAL_DLLPRIVATE bool IsDragging() const { return bDragging; }
147 
148  SAL_DLLPRIVATE void LockTheme() { ++mnThemeLockCount; }
149  SAL_DLLPRIVATE bool UnlockTheme();
150 
151  SAL_DLLPRIVATE void LockBroadcaster() { mnBroadcasterLockCount++; }
152  void UnlockBroadcaster();
153  SAL_DLLPRIVATE bool IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
154 
155  SAL_DLLPRIVATE void SetDragPos(sal_uInt32 nPos) { nDragPos = nPos; }
156  SAL_DLLPRIVATE sal_uInt32 GetDragPos() const { return nDragPos; }
157 
158  bool IsReadOnly() const;
159  bool IsDefault() const;
160 
161  void Actualize( const Link<const INetURLObject&, void>& rActualizeLink, GalleryProgress* pProgress = nullptr );
162  SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
163 
164  SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
165  SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
166 
167 public:
168 
169  SAL_DLLPRIVATE SgaObjKind GetObjectKind(sal_uInt32 nPos) const
170  {
171  if (nPos < GetObjectCount())
172  return ImplGetGalleryObject( nPos )->eObjKind;
173  return SgaObjKind::NONE;
174  }
175 
176  SAL_DLLPRIVATE const INetURLObject& GetObjectURL(sal_uInt32 nPos) const
177  {
178  DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
179  return ImplGetGalleryObject( nPos )->aURL;
180  }
181 
182  SAL_DLLPRIVATE bool GetThumb(sal_uInt32 nPos, BitmapEx& rBmp);
183 
184  bool GetGraphic(sal_uInt32 nPos, Graphic& rGraphic);
185  bool InsertGraphic(const Graphic& rGraphic, sal_uInt32 nInsertPos);
186 
187  bool GetModel(sal_uInt32 nPos, SdrModel& rModel);
188  bool InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos);
189 
190  SAL_DLLPRIVATE bool GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream> const & rModelStreamRef);
191  SAL_DLLPRIVATE bool InsertModelStream(const tools::SvRef<SotStorageStream>& rModelStream, sal_uInt32 nInsertPos);
192 
193  SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject& rURL);
194  bool InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos = SAL_MAX_UINT32);
195  SAL_DLLPRIVATE bool InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos);
196 
197  SAL_DLLPRIVATE bool InsertTransferable(const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, sal_uInt32 nInsertPos);
198 
199  SAL_DLLPRIVATE void CopyToClipboard(sal_uInt32 nPos);
200 
201 public:
202 
203  SAL_DLLPRIVATE SvStream& WriteData( SvStream& rOut ) const;
204  SAL_DLLPRIVATE SvStream& ReadData( SvStream& rIn );
205  static void InsertAllThemes(weld::ComboBox& rListBox);
206 
207  // for buffering PreviewBitmaps and strings for object and path
208  SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const;
209  SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
210 };
211 
212 SvStream& WriteGalleryTheme( SvStream& rOut, const GalleryTheme& rTheme );
214 
215 #endif // INCLUDED_SVX_GALTHEME_HXX
216 
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE bool IsDragging() const
Definition: galtheme.hxx:146
SAL_DLLPRIVATE void LockTheme()
Definition: galtheme.hxx:148
sal_uInt32 mnBroadcasterLockCount
Definition: galtheme.hxx:83
SAL_DLLPRIVATE Gallery * GetParent() const
Definition: galtheme.hxx:164
SAL_DLLPRIVATE const INetURLObject & GetObjectURL(sal_uInt32 nPos) const
Definition: galtheme.hxx:176
sal_uInt32 mnThemeLockCount
Definition: galtheme.hxx:82
bool IsReadOnly(const OUString &rURL, bool *pbExist)
sal_Int64 n
OUString maPath
Definition: galtheme.hxx:50
SAL_DLLPRIVATE SgaObjKind GetObjectKind(sal_uInt32 nPos) const
Definition: galtheme.hxx:169
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
bool bReadOnly
SvStream & ReadGalleryTheme(SvStream &rIn, GalleryTheme &rTheme)
Definition: galtheme.cxx:1446
#define SAL_MAX_UINT32
SAL_DLLPRIVATE void SetDragging(bool bSet)
Definition: galtheme.hxx:145
tools::SvRef< SotStorage > aSvDrawStorageRef
Definition: galtheme.hxx:79
SAL_DLLPRIVATE sal_uInt32 GetDragPos() const
Definition: galtheme.hxx:156
SgaObjKind eObjKind
Definition: galtheme.hxx:43
GalleryThemeEntry * pThm
Definition: galtheme.hxx:81
INetURLObject aURL
Definition: galtheme.hxx:41
BitmapEx maPreviewBitmapEx
Definition: galtheme.hxx:47
SAL_DLLPRIVATE void LockBroadcaster()
Definition: galtheme.hxx:151
bool m_bDestDirRelative
Definition: galtheme.hxx:78
SAL_DLLPRIVATE void SetDestDir(const OUString &rDestDir, bool bRelative)
Definition: galtheme.hxx:134
SAL_DLLPRIVATE void SetDragPos(sal_uInt32 nPos)
Definition: galtheme.hxx:155
SgaObjKind
Definition: galmisc.hxx:54
Gallery *const pParent
Definition: galtheme.hxx:80
::std::vector< std::unique_ptr< GalleryObject > > aObjectList
Definition: galtheme.hxx:76
#define DBG_ASSERT(sCon, aError)
OUString m_aDestDir
Definition: galtheme.hxx:77
sal_uInt32 nOffset
Definition: galtheme.hxx:42
ConvertDataFormat
int i
Size maPreparedSize
Definition: galtheme.hxx:48
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const
Definition: galtheme.hxx:123
SAL_DLLPRIVATE bool IsBroadcasterLocked() const
Definition: galtheme.hxx:153
SAL_DLLPRIVATE const GalleryObject * ImplGetGalleryObject(sal_uInt32 nPos) const
Definition: galtheme.hxx:92
SAL_DLLPRIVATE sal_uInt32 ImplGetGalleryObjectPos(const GalleryObject *pObj) const
Definition: galtheme.hxx:100
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
sal_uInt32 nDragPos
Definition: galtheme.hxx:84
bool bAbortActualize
Definition: galtheme.hxx:86
bool bDragging
Definition: galtheme.hxx:85
OUString maTitle
Definition: galtheme.hxx:49
SAL_DLLPRIVATE void AbortActualize()
Definition: galtheme.hxx:162
SvStream & WriteGalleryTheme(SvStream &rOut, const GalleryTheme &rTheme)
Definition: galtheme.cxx:1441