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