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>
26 
27 #include <tools/debug.hxx>
28 #include <tools/urlobj.hxx>
29 #include <tools/datetime.hxx>
30 #include <unotools/datetime.hxx>
31 #include <vcl/bitmapex.hxx>
32 #include <svl/SfxBroadcaster.hxx>
33 #include <svx/galmisc.hxx>
34 #include <memory>
35 #include <vector>
36 
37 namespace weld { class ComboBox; }
38 
39 class SotStorageStream;
40 
41 class GalleryThemeEntry;
42 class SgaObject;
43 class FmFormModel;
44 class Gallery;
45 
46 namespace unogallery
47 {
48  class GalleryTheme;
49  class GalleryItem;
50 }
51 
53 {
54  friend class Gallery;
55  friend class GalleryThemeCacheEntry;
56  friend class ::unogallery::GalleryTheme;
57  friend class ::unogallery::GalleryItem;
58 
59 private:
60 
61  std::unique_ptr<GalleryBinaryEngine> mpGalleryStorageEngine;
65  sal_uInt32 mnThemeLockCount;
67  sal_uInt32 nDragPos;
68  bool bDragging;
70 
71  const std::unique_ptr<GalleryBinaryEngine>& getGalleryStorageEngine() const { return mpGalleryStorageEngine; }
72 
73  SAL_DLLPRIVATE void ImplSetModified( bool bModified );
74  SAL_DLLPRIVATE void ImplBroadcast(sal_uInt32 nUpdatePos);
75 
76  GalleryTheme(GalleryTheme const &) = delete;
77  void operator =(GalleryTheme const &) = delete;
78 
79 public:
80  SAL_DLLPRIVATE GalleryTheme(Gallery* pGallery, GalleryThemeEntry* pThemeEntry);
81 
82  SAL_DLLPRIVATE virtual ~GalleryTheme() override;
83 
84  SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const { return maGalleryObjectCollection.size(); }
85 
86  std::unique_ptr<SgaObject> AcquireObject(sal_uInt32 nPos);
87 
88  bool InsertObject(const SgaObject& rObj, sal_uInt32 nPos = SAL_MAX_UINT32);
89  void RemoveObject(sal_uInt32 nPos);
90  bool ChangeObjectPos(sal_uInt32 nOldPos, sal_uInt32 nNewPos);
91 
92  const OUString& GetName() const;
93 
94  // used for building gallery themes during compilation:
95  void SetDestDir(const OUString& rDestDir, bool bRelative);
96 
97  sal_uInt32 GetId() const;
98  SAL_DLLPRIVATE void SetId( sal_uInt32 nNewId, bool bResetThemeName );
99 
100  SAL_DLLPRIVATE void SetDragging( bool bSet ) { bDragging = bSet; }
101  SAL_DLLPRIVATE bool IsDragging() const { return bDragging; }
102 
103  SAL_DLLPRIVATE void LockTheme() { ++mnThemeLockCount; }
104  SAL_DLLPRIVATE bool UnlockTheme();
105 
106  SAL_DLLPRIVATE void LockBroadcaster() { mnBroadcasterLockCount++; }
107  void UnlockBroadcaster();
108  SAL_DLLPRIVATE bool IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
109 
110  SAL_DLLPRIVATE void SetDragPos(sal_uInt32 nPos) { nDragPos = nPos; }
111  SAL_DLLPRIVATE sal_uInt32 GetDragPos() const { return nDragPos; }
112 
113  bool IsReadOnly() const;
114  bool IsDefault() const;
115 
116  void Actualize( const Link<const INetURLObject&, void>& rActualizeLink, GalleryProgress* pProgress = nullptr );
117  SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
118 
119  SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
120 
121 public:
122 
123  SAL_DLLPRIVATE SgaObjKind GetObjectKind(sal_uInt32 nPos) const
124  {
125  if (nPos < GetObjectCount())
126  return maGalleryObjectCollection.getForPosition( nPos )->eObjKind;
127  return SgaObjKind::NONE;
128  }
129 
130  SAL_DLLPRIVATE const INetURLObject& GetObjectURL(sal_uInt32 nPos) const
131  {
132  DBG_ASSERT(nPos < GetObjectCount(), "Position out of range");
133  return maGalleryObjectCollection.getURLForPosition(nPos);
134  }
135 
136  SAL_DLLPRIVATE bool GetThumb(sal_uInt32 nPos, BitmapEx& rBmp);
137 
138  bool GetGraphic(sal_uInt32 nPos, Graphic& rGraphic);
139  bool InsertGraphic(const Graphic& rGraphic, sal_uInt32 nInsertPos);
140 
141  bool GetModel(sal_uInt32 nPos, SdrModel& rModel);
142  bool InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos);
143 
144  SAL_DLLPRIVATE bool GetModelStream(sal_uInt32 nPos, tools::SvRef<SotTempStream> const & rModelStreamRef);
145  SAL_DLLPRIVATE bool InsertModelStream(const tools::SvRef<SotTempStream>& rModelStream, sal_uInt32 nInsertPos);
146 
147  SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject& rURL);
148  bool InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos = SAL_MAX_UINT32);
149  SAL_DLLPRIVATE bool InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos);
150 
151  SAL_DLLPRIVATE bool InsertTransferable(const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, sal_uInt32 nInsertPos);
152 
153  SAL_DLLPRIVATE void CopyToClipboard(sal_uInt32 nPos);
154 
155  DateTime getModificationDate() const;
156 
157  const INetURLObject& getThemeURL() const { return mpGalleryStorageEngine->getThemeURL(); }
158 
159 public:
160 
161  SAL_DLLPRIVATE SvStream& ReadData( SvStream& rIn );
162  static void InsertAllThemes(weld::ComboBox& rListBox);
163 
164  // for buffering PreviewBitmaps and strings for object and path
165  SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath);
166  SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
167 };
168 
169 #endif // INCLUDED_SVX_GALTHEME_HXX
170 
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE bool IsDragging() const
Definition: galtheme.hxx:101
const INetURLObject & getThemeURL() const
Definition: galtheme.hxx:157
SAL_DLLPRIVATE void LockTheme()
Definition: galtheme.hxx:103
std::unique_ptr< GalleryBinaryEngine > mpGalleryStorageEngine
Definition: galtheme.hxx:61
sal_uInt32 mnBroadcasterLockCount
Definition: galtheme.hxx:66
SAL_DLLPRIVATE Gallery * GetParent() const
Definition: galtheme.hxx:119
SAL_DLLPRIVATE const INetURLObject & GetObjectURL(sal_uInt32 nPos) const
Definition: galtheme.hxx:130
sal_uInt32 mnThemeLockCount
Definition: galtheme.hxx:65
SAL_DLLPRIVATE SgaObjKind GetObjectKind(sal_uInt32 nPos) const
Definition: galtheme.hxx:123
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
const INetURLObject & getURLForPosition(sal_uInt32 nPos) const
SAL_DLLPRIVATE void SetDragging(bool bSet)
Definition: galtheme.hxx:100
SAL_DLLPRIVATE sal_uInt32 GetDragPos() const
Definition: galtheme.hxx:111
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
GalleryThemeEntry * pThm
Definition: galtheme.hxx:64
Gallery * pParent
Definition: galtheme.hxx:63
SAL_DLLPRIVATE void LockBroadcaster()
Definition: galtheme.hxx:106
SAL_DLLPRIVATE void SetDragPos(sal_uInt32 nPos)
Definition: galtheme.hxx:110
SgaObjKind
Definition: galmisc.hxx:56
#define DBG_ASSERT(sCon, aError)
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const
Definition: galtheme.hxx:84
SAL_DLLPRIVATE bool IsBroadcasterLocked() const
Definition: galtheme.hxx:108
GalleryObjectCollection maGalleryObjectCollection
Definition: galtheme.hxx:62
const std::unique_ptr< GalleryBinaryEngine > & getGalleryStorageEngine() const
Definition: galtheme.hxx:71
const GalleryObject * getForPosition(sal_uInt32 nPos) const
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
sal_uInt32 nDragPos
Definition: galtheme.hxx:67
bool bAbortActualize
Definition: galtheme.hxx:69
bool bDragging
Definition: galtheme.hxx:68
SAL_DLLPRIVATE void AbortActualize()
Definition: galtheme.hxx:117