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