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>
26 #include <tools/debug.hxx>
27 #include <tools/urlobj.hxx>
28 #include <tools/datetime.hxx>
29 #include <vcl/bitmapex.hxx>
30 #include <svl/SfxBroadcaster.hxx>
31 #include <svx/galmisc.hxx>
34 class GalleryFileStorage
;
35 class GalleryThemeEntry
;
37 class SotStorageStream
;
51 class SVXCORE_DLLPUBLIC GalleryTheme final
: public SfxBroadcaster
54 friend class GalleryThemeCacheEntry
;
55 friend class ::unogallery::GalleryTheme
;
56 friend class ::unogallery::GalleryItem
;
60 std::unique_ptr
<GalleryFileStorage
> mpGalleryStorageEngine
;
61 GalleryObjectCollection maGalleryObjectCollection
;
63 GalleryThemeEntry
* pThm
;
64 sal_uInt32 mnThemeLockCount
;
65 sal_uInt32 mnBroadcasterLockCount
;
70 const std::unique_ptr
<GalleryFileStorage
>& getGalleryStorageEngine() const { return mpGalleryStorageEngine
; }
72 SAL_DLLPRIVATE
void ImplSetModified( bool bModified
);
73 SAL_DLLPRIVATE
void ImplBroadcast(sal_uInt32 nUpdatePos
);
75 GalleryTheme(GalleryTheme
const &) = delete;
76 void operator =(GalleryTheme
const &) = delete;
79 SAL_DLLPRIVATE
GalleryTheme(Gallery
* pGallery
, GalleryThemeEntry
* pThemeEntry
);
81 SAL_DLLPRIVATE
virtual ~GalleryTheme() override
;
83 SAL_DLLPRIVATE sal_uInt32
GetObjectCount() const { return maGalleryObjectCollection
.size(); }
85 std::unique_ptr
<SgaObject
> AcquireObject(sal_uInt32 nPos
);
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
);
91 const OUString
& GetName() const;
93 // used for building gallery themes during compilation:
94 void SetDestDir(const OUString
& rDestDir
, bool bRelative
);
96 sal_uInt32
GetId() const;
97 SAL_DLLPRIVATE
void SetId( sal_uInt32 nNewId
, bool bResetThemeName
);
99 SAL_DLLPRIVATE
void SetDragging( bool bSet
) { bDragging
= bSet
; }
100 SAL_DLLPRIVATE
bool IsDragging() const { return bDragging
; }
102 SAL_DLLPRIVATE
void LockTheme() { ++mnThemeLockCount
; }
103 SAL_DLLPRIVATE
bool UnlockTheme();
105 SAL_DLLPRIVATE
void LockBroadcaster() { mnBroadcasterLockCount
++; }
106 void UnlockBroadcaster();
107 SAL_DLLPRIVATE
bool IsBroadcasterLocked() const { return mnBroadcasterLockCount
> 0; }
109 SAL_DLLPRIVATE
void SetDragPos(sal_uInt32 nPos
) { nDragPos
= nPos
; }
110 SAL_DLLPRIVATE sal_uInt32
GetDragPos() const { return nDragPos
; }
112 bool IsReadOnly() const;
113 bool IsDefault() const;
115 void Actualize( const Link
<const INetURLObject
&, void>& rActualizeLink
, GalleryProgress
* pProgress
= nullptr );
116 SAL_DLLPRIVATE
void AbortActualize() { bAbortActualize
= true; }
118 SAL_DLLPRIVATE Gallery
* GetParent() const { return pParent
; }
122 SAL_DLLPRIVATE SgaObjKind
GetObjectKind(sal_uInt32 nPos
) const
124 if (nPos
< GetObjectCount())
125 return maGalleryObjectCollection
.getForPosition( nPos
)->eObjKind
;
126 return SgaObjKind::NONE
;
129 SAL_DLLPRIVATE
const INetURLObject
& GetObjectURL(sal_uInt32 nPos
) const
131 DBG_ASSERT(nPos
< GetObjectCount(), "Position out of range");
132 return maGalleryObjectCollection
.getURLForPosition(nPos
);
135 SAL_DLLPRIVATE
bool GetThumb(sal_uInt32 nPos
, BitmapEx
& rBmp
);
137 bool GetGraphic(sal_uInt32 nPos
, Graphic
& rGraphic
);
138 bool InsertGraphic(const Graphic
& rGraphic
, sal_uInt32 nInsertPos
);
140 bool GetModel(sal_uInt32 nPos
, SdrModel
& rModel
);
141 bool InsertModel(const FmFormModel
& rModel
, sal_uInt32 nInsertPos
);
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
);
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
);
150 SAL_DLLPRIVATE
bool InsertTransferable(const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
, sal_uInt32 nInsertPos
);
152 SAL_DLLPRIVATE
void CopyToClipboard(const weld::Widget
& rWidget
, sal_uInt32 nPos
);
154 DateTime
getModificationDate() const;
156 const INetURLObject
& getThemeURL() const;
160 SAL_DLLPRIVATE SvStream
& ReadData( SvStream
& rIn
);
161 static void InsertAllThemes(weld::ComboBox
& rListBox
);
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
);
168 #endif // INCLUDED_SVX_GALTHEME_HXX
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */