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;
82  sal_uInt32 mnThemeLockCount;
84  sal_uInt32 nDragPos;
85  bool bDragging;
87 
88  SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
89  SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject(sal_uInt32 nPos) const
90  {
91  if (nPos < aObjectList.size())
92  return aObjectList[ nPos ].get();
93  return nullptr;
94  }
95  const GalleryObject* ImplGetGalleryObject( const INetURLObject& rURL );
96 
97  SAL_DLLPRIVATE sal_uInt32 ImplGetGalleryObjectPos( const GalleryObject* pObj ) const
98  {
99  for (sal_uInt32 i = 0, n = aObjectList.size(); i < n; ++i)
100  if ( pObj == aObjectList[ i ].get() )
101  return i;
102  return SAL_MAX_UINT32;
103  }
104  SAL_DLLPRIVATE static INetURLObject ImplGetURL( const GalleryObject* pObject );
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  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  bool IsReadOnly() const;
155  bool IsDefault() const;
156 
157  void Actualize( const Link<const INetURLObject&, void>& rActualizeLink, GalleryProgress* pProgress = nullptr );
158  SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
159 
160  SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
161  SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
162 
163 public:
164 
165  SAL_DLLPRIVATE SgaObjKind GetObjectKind(sal_uInt32 nPos) const
166  {
167  if (nPos < GetObjectCount())
168  return ImplGetGalleryObject( nPos )->eObjKind;
169  return SgaObjKind::NONE;
170  }
171 
172  SAL_DLLPRIVATE const INetURLObject& GetObjectURL(sal_uInt32 nPos) const
173  {
174  DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
175  return ImplGetGalleryObject( nPos )->aURL;
176  }
177 
178  SAL_DLLPRIVATE bool GetThumb(sal_uInt32 nPos, BitmapEx& rBmp);
179 
180  bool GetGraphic(sal_uInt32 nPos, Graphic& rGraphic);
181  bool InsertGraphic(const Graphic& rGraphic, sal_uInt32 nInsertPos);
182 
183  bool GetModel(sal_uInt32 nPos, SdrModel& rModel);
184  bool InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos);
185 
186  SAL_DLLPRIVATE bool GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream> const & rModelStreamRef);
187  SAL_DLLPRIVATE bool InsertModelStream(const tools::SvRef<SotStorageStream>& rModelStream, sal_uInt32 nInsertPos);
188 
189  SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject& rURL);
190  bool InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos = SAL_MAX_UINT32);
191  SAL_DLLPRIVATE bool InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos);
192 
193  SAL_DLLPRIVATE bool InsertTransferable(const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, sal_uInt32 nInsertPos);
194 
195  SAL_DLLPRIVATE void CopyToClipboard(sal_uInt32 nPos);
196 
197 public:
198 
199  SAL_DLLPRIVATE SvStream& WriteData( SvStream& rOut ) const;
200  SAL_DLLPRIVATE SvStream& ReadData( SvStream& rIn );
201  static void InsertAllThemes(weld::ComboBox& rListBox);
202 
203  // for buffering PreviewBitmaps and strings for object and path
204  SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const;
205  SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
206 };
207 
208 SvStream& WriteGalleryTheme( SvStream& rOut, const GalleryTheme& rTheme );
210 
211 #endif // INCLUDED_SVX_GALTHEME_HXX
212 
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE bool IsDragging() const
Definition: galtheme.hxx:142
SAL_DLLPRIVATE void LockTheme()
Definition: galtheme.hxx:144
const OUStringLiteral IsReadOnly("IsReadOnly")
sal_uInt32 mnBroadcasterLockCount
Definition: galtheme.hxx:83
SAL_DLLPRIVATE Gallery * GetParent() const
Definition: galtheme.hxx:160
SAL_DLLPRIVATE const INetURLObject & GetObjectURL(sal_uInt32 nPos) const
Definition: galtheme.hxx:172
sal_uInt32 mnThemeLockCount
Definition: galtheme.hxx:82
sal_Int64 n
OUString maPath
Definition: galtheme.hxx:50
SAL_DLLPRIVATE SgaObjKind GetObjectKind(sal_uInt32 nPos) const
Definition: galtheme.hxx:165
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
bool bReadOnly
SvStream & ReadGalleryTheme(SvStream &rIn, GalleryTheme &rTheme)
Definition: galtheme.cxx:1239
#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
Gallery * pParent
Definition: galtheme.hxx:80
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
::std::vector< std::unique_ptr< GalleryObject > > aObjectList
Definition: galtheme.hxx:76
#define DBG_ASSERT(sCon, aError)
int i
OUString m_aDestDir
Definition: galtheme.hxx:77
sal_uInt32 nOffset
Definition: galtheme.hxx:42
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:89
SAL_DLLPRIVATE sal_uInt32 ImplGetGalleryObjectPos(const GalleryObject *pObj) const
Definition: galtheme.hxx:97
#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:158
SvStream & WriteGalleryTheme(SvStream &rOut, const GalleryTheme &rTheme)