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>
25 #include <tools/debug.hxx>
26 #include <tools/urlobj.hxx>
27 #include <vcl/salctype.hxx>
28 #include <svl/SfxBroadcaster.hxx>
29 #include <svx/galmisc.hxx>
33 namespace weld
{ class ComboBox
; }
36 class SotStorageStream
;
46 //UI visualization buffering
47 BitmapEx maPreviewBitmapEx
;
54 class GalleryThemeEntry
;
67 class SVX_DLLPUBLIC GalleryTheme
: public SfxBroadcaster
70 friend class GalleryThemeCacheEntry
;
71 friend class ::unogallery::GalleryTheme
;
72 friend class ::unogallery::GalleryItem
;
76 ::std::vector
< std::unique_ptr
<GalleryObject
> > aObjectList
;
78 bool m_bDestDirRelative
;
79 tools::SvRef
<SotStorage
> aSvDrawStorageRef
;
80 Gallery
* const pParent
;
81 GalleryThemeEntry
* pThm
;
82 sal_uInt32 mnThemeLockCount
;
83 sal_uInt32 mnBroadcasterLockCount
;
88 SAL_DLLPRIVATE
void ImplCreateSvDrawStorage();
89 std::unique_ptr
<SgaObject
> ImplReadSgaObject( GalleryObject
const * pEntry
);
90 SAL_DLLPRIVATE
bool ImplWriteSgaObject(const SgaObject
& rObj
, sal_uInt32 nPos
, GalleryObject
* pExistentEntry
);
91 SAL_DLLPRIVATE
void ImplWrite();
92 SAL_DLLPRIVATE
const GalleryObject
* ImplGetGalleryObject(sal_uInt32 nPos
) const
93 { return aObjectList
[ nPos
].get(); }
94 const GalleryObject
* ImplGetGalleryObject( const INetURLObject
& rURL
);
96 SAL_DLLPRIVATE sal_uInt32
ImplGetGalleryObjectPos( const GalleryObject
* pObj
) const
98 for (sal_uInt32 i
= 0, n
= aObjectList
.size(); i
< n
; ++i
)
99 if ( pObj
== aObjectList
[ i
].get() )
101 return SAL_MAX_UINT32
;
103 SAL_DLLPRIVATE
static INetURLObject
ImplGetURL( const GalleryObject
* pObject
);
104 SAL_DLLPRIVATE INetURLObject
ImplCreateUniqueURL( SgaObjKind eObjKind
, ConvertDataFormat nFormat
= ConvertDataFormat::Unknown
);
105 SAL_DLLPRIVATE
void ImplSetModified( bool bModified
);
106 SAL_DLLPRIVATE
void ImplBroadcast(sal_uInt32 nUpdatePos
);
108 SAL_DLLPRIVATE
GalleryTheme( Gallery
* pGallery
, GalleryThemeEntry
* pThemeEntry
);
110 GalleryTheme(GalleryTheme
const &) = delete;
111 void operator =(GalleryTheme
const &) = delete;
115 SAL_DLLPRIVATE
virtual ~GalleryTheme() override
;
117 SAL_DLLPRIVATE
static GalleryThemeEntry
* CreateThemeEntry( const INetURLObject
& rURL
, bool bReadOnly
);
119 SAL_DLLPRIVATE sal_uInt32
GetObjectCount() const { return aObjectList
.size(); }
121 std::unique_ptr
<SgaObject
> AcquireObject(sal_uInt32 nPos
);
123 bool InsertObject(const SgaObject
& rObj
, sal_uInt32 nPos
= SAL_MAX_UINT32
);
124 void RemoveObject(sal_uInt32 nPos
);
125 SAL_DLLPRIVATE
bool ChangeObjectPos(sal_uInt32 nOldPos
, sal_uInt32 nNewPos
);
127 const OUString
& GetName() const;
129 // used for building gallery themes during compilation:
130 SAL_DLLPRIVATE
void SetDestDir(const OUString
& rDestDir
, bool bRelative
)
131 { m_aDestDir
= rDestDir
; m_bDestDirRelative
= bRelative
; }
133 SAL_DLLPRIVATE
const INetURLObject
& GetThmURL() const;
134 const INetURLObject
& GetSdgURL() const;
135 SAL_DLLPRIVATE
const INetURLObject
& GetSdvURL() const;
136 SAL_DLLPRIVATE
const INetURLObject
& GetStrURL() const;
138 sal_uInt32
GetId() const;
139 SAL_DLLPRIVATE
void SetId( sal_uInt32 nNewId
, bool bResetThemeName
);
141 SAL_DLLPRIVATE
void SetDragging( bool bSet
) { bDragging
= bSet
; }
142 SAL_DLLPRIVATE
bool IsDragging() const { return bDragging
; }
144 SAL_DLLPRIVATE
void LockTheme() { ++mnThemeLockCount
; }
145 SAL_DLLPRIVATE
bool UnlockTheme();
147 SAL_DLLPRIVATE
void LockBroadcaster() { mnBroadcasterLockCount
++; }
148 void UnlockBroadcaster();
149 SAL_DLLPRIVATE
bool IsBroadcasterLocked() const { return mnBroadcasterLockCount
> 0; }
151 SAL_DLLPRIVATE
void SetDragPos(sal_uInt32 nPos
) { nDragPos
= nPos
; }
152 SAL_DLLPRIVATE sal_uInt32
GetDragPos() const { return nDragPos
; }
154 SAL_DLLPRIVATE
bool IsThemeNameFromResource() const;
156 bool IsReadOnly() const;
157 bool IsDefault() const;
159 void Actualize( const Link
<const INetURLObject
&, void>& rActualizeLink
, GalleryProgress
* pProgress
= nullptr );
160 SAL_DLLPRIVATE
void AbortActualize() { bAbortActualize
= true; }
162 SAL_DLLPRIVATE Gallery
* GetParent() const { return pParent
; }
163 SAL_DLLPRIVATE
const tools::SvRef
<SotStorage
>& GetSvDrawStorage() const;
167 SAL_DLLPRIVATE SgaObjKind
GetObjectKind(sal_uInt32 nPos
) const
169 DBG_ASSERT( nPos
< GetObjectCount(), "Position out of range" );
170 return ImplGetGalleryObject( nPos
)->eObjKind
;
174 SAL_DLLPRIVATE
const INetURLObject
& GetObjectURL(sal_uInt32 nPos
) const
176 DBG_ASSERT( nPos
< GetObjectCount(), "Position out of range" );
177 return ImplGetGalleryObject( nPos
)->aURL
;
180 SAL_DLLPRIVATE
bool GetThumb(sal_uInt32 nPos
, BitmapEx
& rBmp
);
182 bool GetGraphic(sal_uInt32 nPos
, Graphic
& rGraphic
);
183 bool InsertGraphic(const Graphic
& rGraphic
, sal_uInt32 nInsertPos
);
185 bool GetModel(sal_uInt32 nPos
, SdrModel
& rModel
);
186 bool InsertModel(const FmFormModel
& rModel
, sal_uInt32 nInsertPos
);
188 SAL_DLLPRIVATE
bool GetModelStream(sal_uInt32 nPos
, tools::SvRef
<SotStorageStream
> const & rModelStreamRef
);
189 SAL_DLLPRIVATE
bool InsertModelStream(const tools::SvRef
<SotStorageStream
>& rModelStream
, sal_uInt32 nInsertPos
);
191 SAL_DLLPRIVATE
bool GetURL(sal_uInt32 nPos
, INetURLObject
& rURL
);
192 bool InsertURL(const INetURLObject
& rURL
, sal_uInt32 nInsertPos
= SAL_MAX_UINT32
);
193 SAL_DLLPRIVATE
bool InsertFileOrDirURL(const INetURLObject
& rFileOrDirURL
, sal_uInt32 nInsertPos
);
195 SAL_DLLPRIVATE
bool InsertTransferable(const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
, sal_uInt32 nInsertPos
);
197 SAL_DLLPRIVATE
void CopyToClipboard(vcl::Window
* pWindow
, sal_uInt32 nPos
);
198 SAL_DLLPRIVATE
void StartDrag(vcl::Window
* pWindow
, sal_uInt32 nPos
);
202 SAL_DLLPRIVATE SvStream
& WriteData( SvStream
& rOut
) const;
203 SAL_DLLPRIVATE SvStream
& ReadData( SvStream
& rIn
);
204 static void InsertAllThemes(weld::ComboBox
& rListBox
);
206 // for buffering PreviewBitmaps and strings for object and path
207 SAL_DLLPRIVATE
void GetPreviewBitmapExAndStrings(sal_uInt32 nPos
, BitmapEx
& rBitmapEx
, Size
& rSize
, OUString
& rTitle
, OUString
& rPath
) const;
208 SAL_DLLPRIVATE
void SetPreviewBitmapExAndStrings(sal_uInt32 nPos
, const BitmapEx
& rBitmapEx
, const Size
& rSize
, const OUString
& rTitle
, const OUString
& rPath
);
211 SvStream
& WriteGalleryTheme( SvStream
& rOut
, const GalleryTheme
& rTheme
);
212 SvStream
& ReadGalleryTheme( SvStream
& rIn
, GalleryTheme
& rTheme
);
214 #endif // INCLUDED_SVX_GALTHEME_HXX
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */