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  { return aObjectList[ nPos ].get(); }
94  const GalleryObject* ImplGetGalleryObject( const INetURLObject& rURL );
95 
96  SAL_DLLPRIVATE sal_uInt32 ImplGetGalleryObjectPos( const GalleryObject* pObj ) const
97  {
98  for (sal_uInt32 i = 0, n = aObjectList.size(); i < n; ++i)
99  if ( pObj == aObjectList[ i ].get() )
100  return i;
101  return SAL_MAX_UINT32;
102  }
103  SAL_DLLPRIVATE static INetURLObject ImplGetURL( const GalleryObject* pObject );
104  SAL_DLLPRIVATE INetURLObject ImplCreateUniqueURL( SgaObjKind eObjKind, ConvertDataFormat nFormat = ConvertDataFormat::Unknown );
105  SAL_DLLPRIVATE void ImplSetModified( bool bModified );
106  SAL_DLLPRIVATE void ImplBroadcast(sal_uInt32 nUpdatePos);
107 
108  SAL_DLLPRIVATE GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry );
109 
110  GalleryTheme(GalleryTheme const &) = delete;
111  void operator =(GalleryTheme const &) = delete;
112 
113 public:
114 
115  SAL_DLLPRIVATE virtual ~GalleryTheme() override;
116 
117  SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry( const INetURLObject& rURL, bool bReadOnly );
118 
119  SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const { return aObjectList.size(); }
120 
121  std::unique_ptr<SgaObject> AcquireObject(sal_uInt32 nPos);
122 
123  bool InsertObject(const SgaObject& rObj, sal_uInt32 nPos = SAL_MAX_UINT32);
124  void RemoveObject(sal_uInt32 nPos);
125  SAL_DLLPRIVATE bool ChangeObjectPos(sal_uInt32 nOldPos, sal_uInt32 nNewPos);
126 
127  const OUString& GetName() const;
128 
129  // used for building gallery themes during compilation:
130  SAL_DLLPRIVATE void SetDestDir(const OUString& rDestDir, bool bRelative)
131  { m_aDestDir = rDestDir; m_bDestDirRelative = bRelative; }
132 
133  SAL_DLLPRIVATE const INetURLObject& GetThmURL() const;
134  const INetURLObject& GetSdgURL() const;
135  SAL_DLLPRIVATE const INetURLObject& GetSdvURL() const;
136  SAL_DLLPRIVATE const INetURLObject& GetStrURL() const;
137 
138  sal_uInt32 GetId() const;
139  SAL_DLLPRIVATE void SetId( sal_uInt32 nNewId, bool bResetThemeName );
140 
141  SAL_DLLPRIVATE void SetDragging( bool bSet ) { bDragging = bSet; }
142  SAL_DLLPRIVATE bool IsDragging() const { return bDragging; }
143 
144  SAL_DLLPRIVATE void LockTheme() { ++mnThemeLockCount; }
145  SAL_DLLPRIVATE bool UnlockTheme();
146 
147  SAL_DLLPRIVATE void LockBroadcaster() { mnBroadcasterLockCount++; }
148  void UnlockBroadcaster();
149  SAL_DLLPRIVATE bool IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
150 
151  SAL_DLLPRIVATE void SetDragPos(sal_uInt32 nPos) { nDragPos = nPos; }
152  SAL_DLLPRIVATE sal_uInt32 GetDragPos() const { return nDragPos; }
153 
154  SAL_DLLPRIVATE bool IsThemeNameFromResource() const;
155 
156  bool IsReadOnly() const;
157  bool IsDefault() const;
158 
159  void Actualize( const Link<const INetURLObject&, void>& rActualizeLink, GalleryProgress* pProgress = nullptr );
160  SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
161 
162  SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
163  SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
164 
165 public:
166 
167  SAL_DLLPRIVATE SgaObjKind GetObjectKind(sal_uInt32 nPos) const
168  {
169  DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
170  return ImplGetGalleryObject( nPos )->eObjKind;
171  }
172 
173 
174  SAL_DLLPRIVATE const INetURLObject& GetObjectURL(sal_uInt32 nPos) const
175  {
176  DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
177  return ImplGetGalleryObject( nPos )->aURL;
178  }
179 
180  SAL_DLLPRIVATE bool GetThumb(sal_uInt32 nPos, BitmapEx& rBmp);
181 
182  bool GetGraphic(sal_uInt32 nPos, Graphic& rGraphic);
183  bool InsertGraphic(const Graphic& rGraphic, sal_uInt32 nInsertPos);
184 
185  bool GetModel(sal_uInt32 nPos, SdrModel& rModel);
186  bool InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos);
187 
188  SAL_DLLPRIVATE bool GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream> const & rModelStreamRef);
189  SAL_DLLPRIVATE bool InsertModelStream(const tools::SvRef<SotStorageStream>& rModelStream, sal_uInt32 nInsertPos);
190 
191  SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject& rURL);
192  bool InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos = SAL_MAX_UINT32);
193  SAL_DLLPRIVATE bool InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos);
194 
195  SAL_DLLPRIVATE bool InsertTransferable(const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, sal_uInt32 nInsertPos);
196 
197  SAL_DLLPRIVATE void CopyToClipboard(vcl::Window* pWindow, sal_uInt32 nPos);
198  SAL_DLLPRIVATE void StartDrag(vcl::Window* pWindow, sal_uInt32 nPos);
199 
200 public:
201 
202  SAL_DLLPRIVATE SvStream& WriteData( SvStream& rOut ) const;
203  SAL_DLLPRIVATE SvStream& ReadData( SvStream& rIn );
204  static void InsertAllThemes(weld::ComboBox& rListBox);
205 
206  // for buffering PreviewBitmaps and strings for object and path
207  SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const;
208  SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
209 };
210 
211 SvStream& WriteGalleryTheme( SvStream& rOut, const GalleryTheme& rTheme );
213 
214 #endif // INCLUDED_SVX_GALTHEME_HXX
215 
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE bool IsDragging() const
Definition: galtheme.hxx:142
SAL_DLLPRIVATE void LockTheme()
Definition: galtheme.hxx:144
sal_uInt32 mnBroadcasterLockCount
Definition: galtheme.hxx:83
SAL_DLLPRIVATE Gallery * GetParent() const
Definition: galtheme.hxx:162
SAL_DLLPRIVATE const INetURLObject & GetObjectURL(sal_uInt32 nPos) const
Definition: galtheme.hxx:174
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:167
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
bool bReadOnly
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
SvStream & ReadGalleryTheme(SvStream &rIn, GalleryTheme &rTheme)
Definition: galtheme.cxx:1453
#define SAL_MAX_UINT32
SAL_DLLPRIVATE void SetDragging(bool bSet)
Definition: galtheme.hxx:141
tools::SvRef< SotStorage > aSvDrawStorageRef
Definition: galtheme.hxx:79
SAL_DLLPRIVATE sal_uInt32 GetDragPos() const
Definition: galtheme.hxx:152
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:147
bool m_bDestDirRelative
Definition: galtheme.hxx:78
SAL_DLLPRIVATE void SetDestDir(const OUString &rDestDir, bool bRelative)
Definition: galtheme.hxx:130
SAL_DLLPRIVATE void SetDragPos(sal_uInt32 nPos)
Definition: galtheme.hxx:151
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:119
SAL_DLLPRIVATE bool IsBroadcasterLocked() const
Definition: galtheme.hxx:149
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:96
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:160
SvStream & WriteGalleryTheme(SvStream &rOut, const GalleryTheme &rTheme)
Definition: galtheme.cxx:1448