1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_GALTHEME_HXX
21 #define INCLUDED_SVX_GALTHEME_HXX
23 #include <svx/svxdllapi.h>
24 #include <svx/galleryobjectcollection.hxx>
25 #include <svx/gallerybinaryengine.hxx>
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>
37 namespace weld
{ class ComboBox
; }
39 class SotStorageStream
;
41 class GalleryThemeEntry
;
52 class SVXCORE_DLLPUBLIC GalleryTheme
: public SfxBroadcaster
55 friend class GalleryThemeCacheEntry
;
56 friend class ::unogallery::GalleryTheme
;
57 friend class ::unogallery::GalleryItem
;
61 std::unique_ptr
<GalleryBinaryEngine
> mpGalleryStorageEngine
;
62 GalleryObjectCollection maGalleryObjectCollection
;
64 GalleryThemeEntry
* pThm
;
65 sal_uInt32 mnThemeLockCount
;
66 sal_uInt32 mnBroadcasterLockCount
;
71 const std::unique_ptr
<GalleryBinaryEngine
>& getGalleryStorageEngine() const { return mpGalleryStorageEngine
; }
73 SAL_DLLPRIVATE
void ImplSetModified( bool bModified
);
74 SAL_DLLPRIVATE
void ImplBroadcast(sal_uInt32 nUpdatePos
);
76 GalleryTheme(GalleryTheme
const &) = delete;
77 void operator =(GalleryTheme
const &) = delete;
80 SAL_DLLPRIVATE
GalleryTheme(Gallery
* pGallery
, GalleryThemeEntry
* pThemeEntry
);
82 SAL_DLLPRIVATE
virtual ~GalleryTheme() override
;
84 SAL_DLLPRIVATE sal_uInt32
GetObjectCount() const { return maGalleryObjectCollection
.size(); }
86 std::unique_ptr
<SgaObject
> AcquireObject(sal_uInt32 nPos
);
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
);
92 const OUString
& GetName() const;
94 // used for building gallery themes during compilation:
95 void SetDestDir(const OUString
& rDestDir
, bool bRelative
);
97 sal_uInt32
GetId() const;
98 SAL_DLLPRIVATE
void SetId( sal_uInt32 nNewId
, bool bResetThemeName
);
100 SAL_DLLPRIVATE
void SetDragging( bool bSet
) { bDragging
= bSet
; }
101 SAL_DLLPRIVATE
bool IsDragging() const { return bDragging
; }
103 SAL_DLLPRIVATE
void LockTheme() { ++mnThemeLockCount
; }
104 SAL_DLLPRIVATE
bool UnlockTheme();
106 SAL_DLLPRIVATE
void LockBroadcaster() { mnBroadcasterLockCount
++; }
107 void UnlockBroadcaster();
108 SAL_DLLPRIVATE
bool IsBroadcasterLocked() const { return mnBroadcasterLockCount
> 0; }
110 SAL_DLLPRIVATE
void SetDragPos(sal_uInt32 nPos
) { nDragPos
= nPos
; }
111 SAL_DLLPRIVATE sal_uInt32
GetDragPos() const { return nDragPos
; }
113 bool IsReadOnly() const;
114 bool IsDefault() const;
116 void Actualize( const Link
<const INetURLObject
&, void>& rActualizeLink
, GalleryProgress
* pProgress
= nullptr );
117 SAL_DLLPRIVATE
void AbortActualize() { bAbortActualize
= true; }
119 SAL_DLLPRIVATE Gallery
* GetParent() const { return pParent
; }
123 SAL_DLLPRIVATE SgaObjKind
GetObjectKind(sal_uInt32 nPos
) const
125 if (nPos
< GetObjectCount())
126 return maGalleryObjectCollection
.getForPosition( nPos
)->eObjKind
;
127 return SgaObjKind::NONE
;
130 SAL_DLLPRIVATE
const INetURLObject
& GetObjectURL(sal_uInt32 nPos
) const
132 DBG_ASSERT(nPos
< GetObjectCount(), "Position out of range");
133 return maGalleryObjectCollection
.getURLForPosition(nPos
);
136 SAL_DLLPRIVATE
bool GetThumb(sal_uInt32 nPos
, BitmapEx
& rBmp
);
138 bool GetGraphic(sal_uInt32 nPos
, Graphic
& rGraphic
);
139 bool InsertGraphic(const Graphic
& rGraphic
, sal_uInt32 nInsertPos
);
141 bool GetModel(sal_uInt32 nPos
, SdrModel
& rModel
);
142 bool InsertModel(const FmFormModel
& rModel
, sal_uInt32 nInsertPos
);
144 SAL_DLLPRIVATE
bool GetModelStream(sal_uInt32 nPos
, tools::SvRef
<SotStorageStream
> const & rModelStreamRef
);
145 SAL_DLLPRIVATE
bool InsertModelStream(const tools::SvRef
<SotStorageStream
>& rModelStream
, sal_uInt32 nInsertPos
);
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
);
151 SAL_DLLPRIVATE
bool InsertTransferable(const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
, sal_uInt32 nInsertPos
);
153 SAL_DLLPRIVATE
void CopyToClipboard(sal_uInt32 nPos
);
155 DateTime
getModificationDate() const;
157 const INetURLObject
& getThemeURL() const { return mpGalleryStorageEngine
->getThemeURL(); }
161 SAL_DLLPRIVATE SvStream
& ReadData( SvStream
& rIn
);
162 static void InsertAllThemes(weld::ComboBox
& rListBox
);
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
);
169 #endif // INCLUDED_SVX_GALTHEME_HXX
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */